diff --git a/.gitignore b/.gitignore index e2a23af44..b2d69b7c9 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ *.war *.ear /target +ews-api/target/ +ews-client-apache4/target/ +ews-client-java/target/ # Eclipse project files .settings @@ -28,4 +31,9 @@ .idea/dataSources.xml .idea/sqlDataSources.xml .idea/dynamic.xml -.idea/uiDesigner.xml \ No newline at end of file +.idea/uiDesigner.xml + +# Mac OS: +.DS_Store +ews-client-apache5/target +.flattened-pom.xml diff --git a/images/FolderHierarchy.png b/ews-api/images/FolderHierarchy.png similarity index 100% rename from images/FolderHierarchy.png rename to ews-api/images/FolderHierarchy.png diff --git a/images/ItemHierarchy.png b/ews-api/images/ItemHierarchy.png similarity index 100% rename from images/ItemHierarchy.png rename to ews-api/images/ItemHierarchy.png diff --git a/ews-api/pom.xml b/ews-api/pom.xml new file mode 100644 index 000000000..411c01c08 --- /dev/null +++ b/ews-api/pom.xml @@ -0,0 +1,115 @@ + + + + com.eischet + ews-java-api + ${revision} + + + 4.0.0 + + ews-api + + + + + + + + junit + junit + ${junit.version} + test + + + + org.hamcrest + hamcrest-all + ${hamcrest-all.version} + test + + + + org.mockito + mockito-core + ${mockito-core.version} + test + + + + org.slf4j + slf4j-api + ${slf4j.version} + test + + + + ch.qos.logback + logback-classic + ${logback.version} + test + + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + test + + + + + jakarta.xml.bind + jakarta.xml.bind-api + 3.0.1 + + + + com.sun.xml.bind + jaxb-impl + 3.0.1 + runtime + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + true + ${javadoc.doclint.param} + + + + + + org.apache.maven.plugins + maven-jxr-plugin + ${maven-jxr-plugin.version} + + + + org.apache.maven.plugins + maven-surefire-report-plugin + ${maven-surefire-report-plugin.version} + + + + + + + \ No newline at end of file diff --git a/ews-api/src/main/java/com/eischet/ews/api/EWSConstants.java b/ews-api/src/main/java/com/eischet/ews/api/EWSConstants.java new file mode 100644 index 000000000..28eca78ab --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/EWSConstants.java @@ -0,0 +1,36 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api; + +/** + * Class that holds all constants. + */ +public class EWSConstants { + public static final String SRVRECORD = "SRV"; + public static final String DOMAIN = "domain"; + public static final String DNSSERVERADDRESS = "dnsServerAddress"; + public static final String EWS_PROP_FILE = "ews.property"; + public static final String HTTP_SCHEME = "http"; + public static final String HTTPS_SCHEME = "https"; +} diff --git a/src/main/java/microsoft/exchange/webservices/data/ISelfValidate.java b/ews-api/src/main/java/com/eischet/ews/api/ISelfValidate.java similarity index 76% rename from src/main/java/microsoft/exchange/webservices/data/ISelfValidate.java rename to ews-api/src/main/java/com/eischet/ews/api/ISelfValidate.java index 65a80fbec..cd414af72 100644 --- a/src/main/java/microsoft/exchange/webservices/data/ISelfValidate.java +++ b/ews-api/src/main/java/com/eischet/ews/api/ISelfValidate.java @@ -21,20 +21,14 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data; +package com.eischet.ews.api; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; /** * The Interface ISelfValidate. */ public interface ISelfValidate { - /** - * Validate. - * - * @throws ServiceValidationException the service validation exception - * @throws Exception the exception - */ - void validate() throws ServiceValidationException, Exception; + void validate() throws ExchangeXmlException; } diff --git a/src/main/java/microsoft/exchange/webservices/data/attribute/Attachable.java b/ews-api/src/main/java/com/eischet/ews/api/attribute/Attachable.java similarity index 91% rename from src/main/java/microsoft/exchange/webservices/data/attribute/Attachable.java rename to ews-api/src/main/java/com/eischet/ews/api/attribute/Attachable.java index 6c929430e..1b39846d6 100644 --- a/src/main/java/microsoft/exchange/webservices/data/attribute/Attachable.java +++ b/ews-api/src/main/java/com/eischet/ews/api/attribute/Attachable.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.attribute; +package com.eischet.ews.api.attribute; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -32,6 +32,7 @@ * The Interface Attachable. */ @Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) public @interface Attachable { +@Retention(RetentionPolicy.RUNTIME) +public @interface Attachable { } diff --git a/src/main/java/microsoft/exchange/webservices/data/attribute/EditorBrowsable.java b/ews-api/src/main/java/com/eischet/ews/api/attribute/EditorBrowsable.java similarity index 81% rename from src/main/java/microsoft/exchange/webservices/data/attribute/EditorBrowsable.java rename to ews-api/src/main/java/com/eischet/ews/api/attribute/EditorBrowsable.java index 88af067d1..1488de26c 100644 --- a/src/main/java/microsoft/exchange/webservices/data/attribute/EditorBrowsable.java +++ b/ews-api/src/main/java/com/eischet/ews/api/attribute/EditorBrowsable.java @@ -21,9 +21,9 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.attribute; +package com.eischet.ews.api.attribute; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -34,12 +34,13 @@ * The Interface EditorBrowsable. */ @Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) public @interface EditorBrowsable { +@Retention(RetentionPolicy.RUNTIME) +public @interface EditorBrowsable { - /** - * State. - * - * @return the editor browsable state - */ - EditorBrowsableState state(); + /** + * State. + * + * @return the editor browsable state + */ + EditorBrowsableState state(); } diff --git a/src/main/java/microsoft/exchange/webservices/data/attribute/EwsEnum.java b/ews-api/src/main/java/com/eischet/ews/api/attribute/EwsEnum.java similarity index 87% rename from src/main/java/microsoft/exchange/webservices/data/attribute/EwsEnum.java rename to ews-api/src/main/java/com/eischet/ews/api/attribute/EwsEnum.java index 1239b843c..0b0d14832 100644 --- a/src/main/java/microsoft/exchange/webservices/data/attribute/EwsEnum.java +++ b/ews-api/src/main/java/com/eischet/ews/api/attribute/EwsEnum.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.attribute; +package com.eischet.ews.api.attribute; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -32,12 +32,13 @@ * The Interface EwsEnum. */ @Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) public @interface EwsEnum { +@Retention(RetentionPolicy.RUNTIME) +public @interface EwsEnum { - /** - * Schema name. - * - * @return the string - */ - String schemaName(); + /** + * Schema name. + * + * @return the string + */ + String schemaName(); } diff --git a/src/main/java/microsoft/exchange/webservices/data/attribute/Flags.java b/ews-api/src/main/java/com/eischet/ews/api/attribute/Flags.java similarity index 92% rename from src/main/java/microsoft/exchange/webservices/data/attribute/Flags.java rename to ews-api/src/main/java/com/eischet/ews/api/attribute/Flags.java index 81ad2be65..a768a71e1 100644 --- a/src/main/java/microsoft/exchange/webservices/data/attribute/Flags.java +++ b/ews-api/src/main/java/com/eischet/ews/api/attribute/Flags.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.attribute; +package com.eischet.ews.api.attribute; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -32,6 +32,7 @@ * The Interface Flags. */ @Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) public @interface Flags { +@Retention(RetentionPolicy.RUNTIME) +public @interface Flags { } diff --git a/src/main/java/microsoft/exchange/webservices/data/attribute/RequiredServerVersion.java b/ews-api/src/main/java/com/eischet/ews/api/attribute/RequiredServerVersion.java similarity index 82% rename from src/main/java/microsoft/exchange/webservices/data/attribute/RequiredServerVersion.java rename to ews-api/src/main/java/com/eischet/ews/api/attribute/RequiredServerVersion.java index fbde5b038..7dfa08a52 100644 --- a/src/main/java/microsoft/exchange/webservices/data/attribute/RequiredServerVersion.java +++ b/ews-api/src/main/java/com/eischet/ews/api/attribute/RequiredServerVersion.java @@ -21,9 +21,9 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.attribute; +package com.eischet.ews.api.attribute; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -34,12 +34,13 @@ * The Interface RequiredServerVersion. */ @Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) public @interface RequiredServerVersion { +@Retention(RetentionPolicy.RUNTIME) +public @interface RequiredServerVersion { - /** - * Version. - * - * @return the exchange version - */ - ExchangeVersion version(); + /** + * Version. + * + * @return the exchange version + */ + ExchangeVersion version(); } diff --git a/src/main/java/microsoft/exchange/webservices/data/attribute/Schema.java b/ews-api/src/main/java/com/eischet/ews/api/attribute/Schema.java similarity index 92% rename from src/main/java/microsoft/exchange/webservices/data/attribute/Schema.java rename to ews-api/src/main/java/com/eischet/ews/api/attribute/Schema.java index 683d3ff4e..041d8b0a0 100644 --- a/src/main/java/microsoft/exchange/webservices/data/attribute/Schema.java +++ b/ews-api/src/main/java/com/eischet/ews/api/attribute/Schema.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.attribute; +package com.eischet.ews.api.attribute; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -32,6 +32,7 @@ * The Interface Schema. */ @Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) public @interface Schema { +@Retention(RetentionPolicy.RUNTIME) +public @interface Schema { } diff --git a/src/main/java/microsoft/exchange/webservices/data/attribute/ServiceObjectDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/attribute/ServiceObjectDefinition.java similarity index 76% rename from src/main/java/microsoft/exchange/webservices/data/attribute/ServiceObjectDefinition.java rename to ews-api/src/main/java/com/eischet/ews/api/attribute/ServiceObjectDefinition.java index 74eb366bf..1e7b256eb 100644 --- a/src/main/java/microsoft/exchange/webservices/data/attribute/ServiceObjectDefinition.java +++ b/ews-api/src/main/java/com/eischet/ews/api/attribute/ServiceObjectDefinition.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.attribute; +package com.eischet.ews.api.attribute; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; @@ -32,20 +32,21 @@ * The Interface ServiceObjectDefinition. */ @Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) public @interface ServiceObjectDefinition { +@Retention(RetentionPolicy.RUNTIME) +public @interface ServiceObjectDefinition { - /** - * The name of the XML element. - * - * @return the string - */ - String xmlElementName(); + /** + * The name of the XML element. + * + * @return the string + */ + String xmlElementName(); - /** - * True if this ServiceObject can be returned by the server as an object, - * false otherwise. - * - * @return true, if successful - */ - boolean returnedByServer() default true; + /** + * True if this ServiceObject can be returned by the server as an object, + * false otherwise. + * + * @return true, if successful + */ + boolean returnedByServer() default true; } diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AlternateMailbox.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AlternateMailbox.java new file mode 100644 index 000000000..5996dae17 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AlternateMailbox.java @@ -0,0 +1,224 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover; + +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.security.XmlNodeType; + +import javax.xml.stream.XMLStreamException; + +/** + * Defines the AlternateMailbox class. + */ +public final class AlternateMailbox { + + /** + * The type. + */ + private String type; + + /** + * The display name. + */ + private String displayName; + + /** + * The legacy dn. + */ + private String legacyDN; + + /** + * The server. + */ + private String server; + + /** + * The SMTP address of alternate mailbox. It is only set if it is available + * for the given type. E.g. type 'Delegate' has one type 'Archive' not. + */ + private String smtpAddress; + + + /** + * The SMTP address of the owner of this alternate mailbox. + */ + private String ownerSmtpAddress; + + /** + * Initializes a new instance of the AlternateMailbox class. + */ + private AlternateMailbox() { + } + + /** + * PLoads AlternateMailbox instance from XML. + * + * @param reader the reader + * @return AlternateMailbox + * @throws Exception the exception + */ + public static AlternateMailbox loadFromXml(final EwsXmlReader reader) throws Exception { + final AlternateMailbox altMailbox = new AlternateMailbox(); + + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Type)) { + altMailbox.setType(reader.readElementValue(String.class)); + } else if (reader.getLocalName() + .equalsIgnoreCase(XmlElementNames.DisplayName)) { + altMailbox.setDisplayName(reader.readElementValue(String.class)); + } else if (reader.getLocalName() + .equalsIgnoreCase(XmlElementNames.LegacyDN)) { + altMailbox.setLegacyDN(reader.readElementValue(String.class)); + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Server)) { + altMailbox.setServer(reader.readElementValue(String.class)); + } else if (reader.getLocalName() + .equalsIgnoreCase(XmlElementNames.SmtpAddress)) { + altMailbox.setSmtpAddress(reader.readElementValue(String.class)); + } else if (reader.getLocalName() + .equalsIgnoreCase(XmlElementNames.OwnerSmtpAddress)) { + altMailbox.setOwnerSmtpAddress(reader.readElementValue(String.class)); + } + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.AlternateMailbox)); + + return altMailbox; + } + + /** + * Gets the alternate mailbox type. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Sets the type. + * + * @param type the new type + */ + protected void setType(final String type) { + this.type = type; + } + + /** + * Gets the alternate mailbox display name. + * + * @return the display name + */ + public String getDisplayName() { + return displayName; + } + + /** + * Sets the display name. + * + * @param displayName the new display name + */ + protected void setDisplayName(final String displayName) { + this.displayName = displayName; + } + + /** + * Gets the alternate mailbox legacy DN. + * + * @return the legacy dn + */ + public String getLegacyDN() { + return legacyDN; + } + + /** + * Sets the legacy dn. + * + * @param legacyDN the new legacy dn + */ + protected void setLegacyDN(final String legacyDN) { + this.legacyDN = legacyDN; + } + + /** + * Gets the alernate mailbox server. + * + * @return the server + */ + public String getServer() { + return server; + } + + /** + * Sets the server. + * + * @param server the new server. + */ + protected void setServer(final String server) { + this.server = server; + } + + /** + * Gets the SMTP address. + * + * @return the SMTP address if available for the mailbox type otherwise null + * is returned. + */ + public String getSmtpAddress() { + return smtpAddress; + } + + /** + * Sets the SMTP address. + * + * @param smtpAddress the new SMTP address. + */ + protected void setSmtpAddress(final String smtpAddress) { + this.smtpAddress = smtpAddress; + } + + /** + * Gets the owner SMTP address. + * + * @return the SMTP address of the owner of this mailbox. + */ + public String getOwnerSmtpAddress() { + return ownerSmtpAddress; + } + + /** + * Sets the owner SMTP address. + * + * @param ownerSmtpAddress the new owner SMTP address + */ + protected void setOwnerSmtpAddress(final String ownerSmtpAddress) { + this.ownerSmtpAddress = ownerSmtpAddress; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AlternateMailboxCollection.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AlternateMailboxCollection.java new file mode 100644 index 000000000..9b57b5654 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AlternateMailboxCollection.java @@ -0,0 +1,86 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover; + +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a user setting that is a collection of alternate mailboxes. + */ +public final class AlternateMailboxCollection { + + private ArrayList entries; + + /** + * Initializes a new instance of the class + */ + public AlternateMailboxCollection() { + this.setEntries(new ArrayList()); + } + + /** + * Loads instance of AlternateMailboxCollection from XML. + * + * @param reader the reader + * @return AlternateMailboxCollection + * @throws Exception the exception + */ + public static AlternateMailboxCollection loadFromXml(EwsXmlReader reader) + throws Exception { + AlternateMailboxCollection instance = new AlternateMailboxCollection(); + + do { + reader.read(); + + if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && + (reader.getLocalName() + .equals(XmlElementNames.AlternateMailbox))) { + instance.getEntries().add( + AlternateMailbox.loadFromXml(reader)); + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.AlternateMailboxes)); + + return instance; + } + + /** + * Gets the collection of alternate mailboxes. + * + * @return alternate mailboxes + */ + public List getEntries() { + return this.entries; + } + + private void setEntries(ArrayList value) { + this.entries = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AutodiscoverDnsClient.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AutodiscoverDnsClient.java new file mode 100644 index 000000000..9078d051e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AutodiscoverDnsClient.java @@ -0,0 +1,211 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.enumeration.misc.TraceFlags; +import com.eischet.ews.api.core.exception.dns.DnsException; +import com.eischet.ews.api.dns.DnsClient; +import com.eischet.ews.api.dns.DnsSrvRecord; + +import javax.xml.stream.XMLStreamException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +/** + * Class that reads AutoDiscover configuration information from DNS. + */ +class AutodiscoverDnsClient { + + /** + * SRV DNS prefix to lookup. + */ + private static final String AutoDiscoverSrvPrefix = "_autodiscover._tcp."; + + /** + * We are only interested in records that use SSL. + */ + private static final int SslPort = 443; + + /** + * Random selector in the case of ties. + */ + private static final Random RandomTieBreakerSelector = new Random(); + + /** + * AutodiscoverService using this DNS reader. + */ + private final AutodiscoverService service; + + /** + * Initializes a new instance of the class. + * + * @param service the service + */ + protected AutodiscoverDnsClient(AutodiscoverService service) { + this.service = service; + } + + /** + * Extracts a valid autodiscover hostname, if any, from a dns srv response. + * + * @param dnsNameTarget The hostname response returned by DNS + * @return Autodiscover hostname (will be null if dnsNameTarget is invalid). + */ + protected static String extractHostnameFromDnsSrv(String dnsNameTarget) { + if (dnsNameTarget == null || dnsNameTarget.isEmpty()) { + return null; + } else { + if (dnsNameTarget.endsWith(".")) { + dnsNameTarget = dnsNameTarget.substring(0, dnsNameTarget.length() - 1); + } + return dnsNameTarget; + } + } + + /** + * Finds the Autodiscover host from DNS SRV records. + * + * @param domain the domain + * @return Autodiscover hostname (will be null if lookup failed). + * @throws IOException signals that an I/O exception has occurred. + */ + protected String findAutodiscoverHostFromSrv(String domain) + throws XMLStreamException, IOException { + String domainToMatch = AutoDiscoverSrvPrefix + domain; + + DnsSrvRecord dnsSrvRecord = this + .findBestMatchingSrvRecord(domainToMatch); + if (dnsSrvRecord != null) { + String hostName = extractHostnameFromDnsSrv(dnsSrvRecord.getNameTarget()); + if (hostName != null) { + this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, String + .format("DNS query for SRV record for domain %s found %s", domain, hostName)); + return hostName; + } + } + this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, + "No appropriate SRV record was found."); + return null; + } + + /** + * Finds the best matching SRV record. + * + * @param domain the domain + * @return DnsSrvRecord (will be null if lookup failed) + * @throws XMLStreamException the XML stream exception + * @throws IOException signals that an I/O exception has occurred. + */ + private DnsSrvRecord findBestMatchingSrvRecord(String domain) + throws XMLStreamException, IOException { + List dnsSrvRecordList; + try { + // Make DnsQuery call to get collection of SRV records. + dnsSrvRecordList = DnsClient.dnsQuery(DnsSrvRecord.class, domain, this.service.getDnsServerAddress()); + } catch (DnsException ex) { + String dnsExcMessage = String.format("DnsQuery returned error '%s'.", ex.getMessage()); + this.service + .traceMessage( + TraceFlags.AutodiscoverConfiguration, + dnsExcMessage); + return null; + } catch (SecurityException ex) { + // In restricted environments, we may not be allowed to call + // un-managed code. + this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format( + "DnsQuery cannot be called. Security error: %s.", + ex.getMessage())); + return null; + } + + this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, String + .format("%d SRV records were returned.", dnsSrvRecordList + .size())); + + // If multiple records were returned, they will be returned sorted by + // priority + // (and weight) order. Need to find the index of the first record that + // supports SSL. + int priority = Integer.MIN_VALUE; + int weight = Integer.MAX_VALUE; + boolean recordFound = false; + for (DnsSrvRecord dnsSrvRecord : dnsSrvRecordList) { + if (dnsSrvRecord.getPort() == SslPort) { + priority = dnsSrvRecord.getPriority(); + weight = dnsSrvRecord.getWeight(); + recordFound = true; + break; + } + } + + // Records were returned but nothing matched our criteria. + if (!recordFound) { + this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, + "No appropriate SRV records were found."); + + return null; + } + + List bestDnsSrvRecordList = new ArrayList(); + for (DnsSrvRecord dnsSrvRecord : dnsSrvRecordList) { + if (dnsSrvRecord.getPort() == SslPort && + dnsSrvRecord.getPriority() == priority && + dnsSrvRecord.getWeight() == weight) { + bestDnsSrvRecordList.add(dnsSrvRecord); + } + } + + // The list must contain at least one matching record since we found one + // earlier. + EwsUtilities.ewsAssert(dnsSrvRecordList.size() > 0, "AutodiscoverDnsClient.FindBestMatchingSrvRecord", + "At least one DNS SRV record must match the criteria."); + + // If we have multiple records with the same priority and weight, + // randomly pick one. + int recordIndex = (bestDnsSrvRecordList.size() > 1) ? + RandomTieBreakerSelector + .nextInt(bestDnsSrvRecordList.size()) : + 0; + + DnsSrvRecord bestDnsSrvRecord = bestDnsSrvRecordList.get(recordIndex); + + String traceMessage = String.format("Returning SRV record %d " + + "of %d records. " + + "Target: %s, Priority: %d, Weight: %d", + recordIndex, dnsSrvRecordList.size(), + bestDnsSrvRecord.getNameTarget(), + bestDnsSrvRecord.getPriority(), + bestDnsSrvRecord.getWeight()); + this.service.traceMessage(TraceFlags. + AutodiscoverConfiguration, traceMessage); + + + return bestDnsSrvRecord; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AutodiscoverResponseCollection.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AutodiscoverResponseCollection.java new file mode 100644 index 000000000..413f34429 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AutodiscoverResponseCollection.java @@ -0,0 +1,164 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover; + +import com.eischet.ews.api.autodiscover.response.AutodiscoverResponse; +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Represents a collection of response to a call to the Autodiscover service. + * + * @param The type of the response in the collection. + */ +public abstract class AutodiscoverResponseCollection + + extends AutodiscoverResponse implements Iterable { + + /** + * The response. + */ + private final List responses; + + /** + * Initializes a new instance of the AutodiscoverResponseCollection class. + */ + public AutodiscoverResponseCollection() { + super(); + this.responses = new ArrayList(); + } + + /** + * Gets the number of response in the collection. + * + * @return the count + */ + public int getCount() { + return this.responses.size(); + } + + /** + * Gets the response at the specified index. + * + * @param index the index + * @return the t response at index + */ + public TResponse getTResponseAtIndex(int index) { + return this.responses.get(index); + } + + /** + * Gets the response. + * + * @return the response + */ + public List getResponses() { + return responses; + } + + /** + * Loads response from XML. + * + * @param reader the reader + * @param endElementName End element name. + * @throws Exception the exception + */ + public void loadFromXml(EwsXmlReader reader, String endElementName) + throws Exception { + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals( + this.getResponseCollectionXmlElementName())) { + this.loadResponseCollectionFromXml(reader); + } else { + super.loadFromXml(reader, endElementName); + } + } + } while (!reader + .isEndElement(XmlNamespace.Autodiscover, endElementName)); + } + + /** + * Loads response from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + private void loadResponseCollectionFromXml(EwsXmlReader reader) + throws Exception { + if (!reader.isEmptyElement()) { + do { + reader.read(); + if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && + (reader.getLocalName().equals(this + .getResponseInstanceXmlElementName()))) { + TResponse response = this.createResponseInstance(); + response.loadFromXml(reader, this + .getResponseInstanceXmlElementName()); + this.responses.add(response); + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, this + .getResponseCollectionXmlElementName())); + } else { + reader.read(); + } + } + + /** + * Gets the name of the response collection XML element. + * + * @return Response collection XMl element name. + */ + protected abstract String getResponseCollectionXmlElementName(); + + /** + * Gets the name of the response instance XML element. + * + * @return Response collection XMl element name. + */ + protected abstract String getResponseInstanceXmlElementName(); + + /** + * Create a response instance. + * + * @return TResponse. + */ + protected abstract TResponse createResponseInstance(); + + /** + * Gets an Iterator that iterates through the elements of the collection. + * + * @return An Iterator for the collection. + */ + public Iterator iterator() { + return this.responses.iterator(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AutodiscoverService.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AutodiscoverService.java new file mode 100644 index 000000000..a746f3f97 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/AutodiscoverService.java @@ -0,0 +1,1925 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover; + +import com.eischet.ews.api.autodiscover.configuration.ConfigurationSettingsBase; +import com.eischet.ews.api.autodiscover.configuration.outlook.OutlookConfigurationSettings; +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverEndpoints; +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverErrorCode; +import com.eischet.ews.api.autodiscover.enumeration.DomainSettingName; +import com.eischet.ews.api.autodiscover.enumeration.UserSettingName; +import com.eischet.ews.api.autodiscover.exception.AutodiscoverLocalException; +import com.eischet.ews.api.autodiscover.exception.AutodiscoverRemoteException; +import com.eischet.ews.api.autodiscover.exception.MaximumRedirectionHopsExceededException; +import com.eischet.ews.api.autodiscover.request.AutodiscoverRequest; +import com.eischet.ews.api.autodiscover.request.GetDomainSettingsRequest; +import com.eischet.ews.api.autodiscover.request.GetUserSettingsRequest; +import com.eischet.ews.api.autodiscover.response.GetDomainSettingsResponse; +import com.eischet.ews.api.autodiscover.response.GetDomainSettingsResponseCollection; +import com.eischet.ews.api.autodiscover.response.GetUserSettingsResponse; +import com.eischet.ews.api.autodiscover.response.GetUserSettingsResponseCollection; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.ExchangeServiceBase; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.TraceFlags; +import com.eischet.ews.api.core.exception.http.EWSHttpException; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.misc.FormatException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.http.ExchangeHttpClient; +import com.eischet.ews.api.credential.WSSecurityBasedCredentials; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.security.XmlNodeType; + +import javax.xml.stream.XMLStreamException; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.*; + +/** + * Represents a binding to the Exchange Autodiscover Service. + */ +public class AutodiscoverService extends ExchangeServiceBase implements IAutodiscoverRedirectionUrl, IFunctionDelegate { + + private String domain; + private Boolean isExternal = true; + private URI url; + private IAutodiscoverRedirectionUrl redirectionUrlValidationCallback; + private AutodiscoverDnsClient dnsClient; + private String dnsServerAddress; + private boolean enableScpLookup = true; + private static final String AutodiscoverLegacyPath = "/autodiscover/autodiscover.xml"; + private static final String AutodiscoverLegacyHttpsUrl = "https://%s" + AutodiscoverLegacyPath; + private static final String AutodiscoverLegacyHttpUrl = "http://%s" + AutodiscoverLegacyPath; + private static final String AutodiscoverSoapHttpsUrl = "https://%s/autodiscover/autodiscover.svc"; + private static final String AutodiscoverSoapWsSecurityHttpsUrl = AutodiscoverSoapHttpsUrl + "/wssecurity"; + private static final String AutodiscoverSoapWsSecuritySymmetricKeyHttpsUrl = AutodiscoverSoapHttpsUrl + "/wssecurity/symmetrickey"; + private static final String AutodiscoverSoapWsSecurityX509CertHttpsUrl = AutodiscoverSoapHttpsUrl + "/wssecurity/x509cert"; + private static final String AutodiscoverRequestNamespace = "http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006"; + protected static final int AutodiscoverMaxRedirections = 10; + private static final String AutodiscoverSoapEnabledHeaderName = "X-SOAP-Enabled"; + private static final String AutodiscoverWsSecurityEnabledHeaderName = "X-WSSecurity-Enabled"; + private static final String AutodiscoverWsSecuritySymmetricKeyEnabledHeaderName = "X-WSSecurity-SymmetricKey-Enabled"; + private static final String AutodiscoverWsSecurityX509CertEnabledHeaderName = "X-WSSecurity-X509Cert-Enabled"; + private static final ExchangeVersion MinimumRequestVersionForAutoDiscoverSoapService = ExchangeVersion.Exchange2010; + + /** + * Default implementation of AutodiscoverRedirectionUrlValidationCallback. + * Always returns true indicating that the URL can be used. + * + * @param redirectionUrl the redirection url + * @return Returns true. + * @throws AutodiscoverLocalException the autodiscover local exception + */ + private boolean defaultAutodiscoverRedirectionUrlValidationCallback(String redirectionUrl) throws AutodiscoverLocalException { + throw new AutodiscoverLocalException(String.format( + "Autodiscover blocked a potentially insecure redirection to %s. To allow Autodiscover to follow the " + + "redirection, use the AutodiscoverUrl(string, AutodiscoverRedirectionUrlValidationCallback) " + + "overload.", redirectionUrl)); + } + + // Legacy Autodiscover + + /** + * Calls the Autodiscover service to get configuration settings at the + * specified URL. + * + * @param the generic type + * @param cls the cls + * @param emailAddress the email address + * @param url the url + * @return The requested configuration settings. (TSettings The type of the + * settings to retrieve) + * @throws Exception the exception + */ + private + TSettings getLegacyUserSettingsAtUrl( + Class cls, String emailAddress, URI url) + throws Exception { + this + .traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format("Trying to call Autodiscover for %s on %s.", emailAddress, url)); + + TSettings settings = cls.newInstance(); + + ExchangeHttpClient.Request request = null; + try { + request = this.prepareHttpWebRequestForUrl(url); + + this.traceHttpRequestHeaders( + TraceFlags.AutodiscoverRequestHttpHeaders, + request); + // OutputStreamWriter out = new + // OutputStreamWriter(request.getOutputStream()); + OutputStream urlOutStream = request.getOutputStream(); + + // If tracing is enabled, we generate the request in-memory so that we + // can pass it along to the ITraceListener. Then we copy the stream to + // the request stream. + if (this.isTraceEnabledFor(TraceFlags.AutodiscoverRequest)) { + ByteArrayOutputStream memoryStream = new ByteArrayOutputStream(); + + PrintWriter writer = new PrintWriter(memoryStream); + this.writeLegacyAutodiscoverRequest(emailAddress, settings, writer); + writer.flush(); + + this.traceXml(TraceFlags.AutodiscoverRequest, memoryStream); + // out.write(memoryStream.toString()); + // out.close(); + memoryStream.writeTo(urlOutStream); + urlOutStream.flush(); + urlOutStream.close(); + memoryStream.close(); + } else { + PrintWriter writer = new PrintWriter(urlOutStream); + this.writeLegacyAutodiscoverRequest(emailAddress, settings, writer); + + /* Flush Start */ + writer.flush(); + urlOutStream.flush(); + urlOutStream.close(); + /* Flush End */ + } + request.executeRequest(); + request.getResponseCode(); + URI redirectUrl; + OutParam outParam = new OutParam(); + if (this.tryGetRedirectionResponse(request, outParam)) { + redirectUrl = outParam.getParam(); + settings.makeRedirectionResponse(redirectUrl); + return settings; + } + InputStream serviceResponseStream = request.getInputStream(); + // If tracing is enabled, we read the entire response into a + // MemoryStream so that we + // can pass it along to the ITraceListener. Then we parse the response + // from the + // MemoryStream. + if (this.isTraceEnabledFor(TraceFlags.AutodiscoverResponse)) { + ByteArrayOutputStream memoryStream = new ByteArrayOutputStream(); + + while (true) { + int data = serviceResponseStream.read(); + if (-1 == data) { + break; + } else { + memoryStream.write(data); + } + } + memoryStream.flush(); + + this.traceResponse(request, memoryStream); + ByteArrayInputStream memoryStreamIn = new ByteArrayInputStream( + memoryStream.toByteArray()); + EwsXmlReader reader = new EwsXmlReader(memoryStreamIn); + reader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT)); + settings.loadFromXml(reader); + + } else { + EwsXmlReader reader = new EwsXmlReader(serviceResponseStream); + reader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT)); + settings.loadFromXml(reader); + } + + serviceResponseStream.close(); + } finally { + if (request != null) { + try { + request.close(); + } catch (Exception e2) { + // Ignore exception while closing the request. + } + } + } + + return settings; + } + + /** + * Writes the autodiscover request. + * + * @param emailAddress the email address + * @param settings the settings + * @param writer the writer + * @throws java.io.IOException Signals that an I/O exception has occurred. + */ + private void writeLegacyAutodiscoverRequest(String emailAddress, + ConfigurationSettingsBase settings, PrintWriter writer) + throws IOException { + writer.write(String.format("", AutodiscoverRequestNamespace)); + writer.write(""); + writer.write(String.format("%s", + emailAddress)); + writer.write( + String.format("%s", settings.getNamespace())); + writer.write(""); + writer.write(""); + } + + /** + * Gets a redirection URL to an SSL-enabled Autodiscover service from the + * standard non-SSL Autodiscover URL. + * + * @param domainName the domain name + * @return A valid SSL-enabled redirection URL. (May be null) + * @throws EWSHttpException the EWS http exception + * @throws XMLStreamException the XML stream exception + * @throws IOException Signals that an I/O exception has occurred. + * @throws ServiceLocalException the service local exception + * @throws URISyntaxException the uRI syntax exception + */ + private URI getRedirectUrl(String domainName) + throws EWSHttpException, XMLStreamException, IOException, ServiceLocalException, URISyntaxException { + String url = String.format(AutodiscoverLegacyHttpUrl, "autodiscover." + domainName); + + traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format("Trying to get Autodiscover redirection URL from %s.", url)); + + ExchangeHttpClient.Request request = null; + + try { + request = httpClient.createRequest(); + try { + request.setUrl(URI.create(url).toURL()); + } catch (MalformedURLException e) { + String strErr = String.format("Incorrect format : %s", url); + throw new ServiceLocalException(strErr); + } + + request.setRequestMethod("GET"); + request.setAllowAutoRedirect(false); + request.setTimeout(getTimeout()); + + // Do NOT allow authentication as this single request will be made over plain HTTP. + request.setAllowAuthentication(false); + + prepareCredentials(request); + + request.prepareConnection(); + try { + request.executeRequest(); + } catch (IOException e) { + traceMessage(TraceFlags.AutodiscoverConfiguration, "No Autodiscover redirection URL was returned."); + return null; + } + + OutParam outParam = new OutParam(); + if (tryGetRedirectionResponse(request, outParam)) { + return outParam.getParam(); + } + } finally { + if (request != null) { + try { + request.close(); + } catch (Exception e) { + // Ignore exception when closing the request + } + } + } + + traceMessage(TraceFlags.AutodiscoverConfiguration, "No Autodiscover redirection URL was returned."); + return null; + } + + /** + * Tries the get redirection response. + * + * @param request the request + * @param redirectUrl the redirect URL + * @return true if a valid redirection URL was found + * @throws XMLStreamException the XML stream exception + * @throws IOException signals that an I/O exception has occurred. + * @throws EWSHttpException the EWS http exception + */ + private boolean tryGetRedirectionResponse(ExchangeHttpClient.Request request, + OutParam redirectUrl) throws XMLStreamException, IOException, + EWSHttpException { + // redirectUrl = null; + if (AutodiscoverRequest.isRedirectionResponse(request)) { + // Get the redirect location and verify that it's valid. + String location = request.getResponseHeaderField("Location"); + + if (!(location == null || location.isEmpty())) { + try { + redirectUrl.setParam(new URI(location)); + + // Check if URL is SSL and that the path matches. + if ((redirectUrl.getParam().getScheme() + .equalsIgnoreCase("https")) && + (redirectUrl.getParam().getPath() + .equalsIgnoreCase( + AutodiscoverLegacyPath))) { + this.traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format("Redirection URL found: '%s'", + redirectUrl.getParam().toString())); + + return true; + } + } catch (URISyntaxException ex) { + this + .traceMessage( + TraceFlags.AutodiscoverConfiguration, + String + .format( + "Invalid redirection URL " + + "was returned: '%s'", + location)); + return false; + } + } + } + return false; + } + + /** + * Calls the legacy Autodiscover service to retrieve configuration settings. + * + * @param the generic type + * @param cls the cls + * @param emailAddress The email address to retrieve configuration settings for. + * @return The requested configuration settings. + * @throws Exception the exception + */ + protected + TSettings getLegacyUserSettings( + Class cls, String emailAddress) throws Exception { + /*int currentHop = 1; + return this.internalGetConfigurationSettings(cls, emailAddress, + currentHop);*/ + + // If Url is specified, call service directly. + if (this.url != null) { + // this.Uri is intended for Autodiscover SOAP service, convert to Legacy endpoint URL. + URI autodiscoverUrl = new URI(this.url + AutodiscoverLegacyPath); + return this.getLegacyUserSettingsAtUrl(cls, emailAddress, autodiscoverUrl); + } + + // If Domain is specified, figure out the endpoint Url and call service. + else if (!(this.domain == null || this.domain.isEmpty())) { + URI autodiscoverUrl = new URI(String.format(AutodiscoverLegacyHttpsUrl, this.domain)); + return this.getLegacyUserSettingsAtUrl(cls, + emailAddress, autodiscoverUrl); + } else { + // No Url or Domain specified, need to + //figure out which endpoint to use. + int currentHop = 1; + OutParam outParam = new OutParam(); + outParam.setParam(currentHop); + List redirectionEmailAddresses = new ArrayList(); + return this.internalGetLegacyUserSettings( + cls, + emailAddress, + redirectionEmailAddresses, + outParam); + } + } + + /** + * Calls the Autodiscover service to retrieve configuration settings. + * + * @param the generic type + * @param cls the cls + * @param emailAddress The email address to retrieve configuration settings for. + * @param currentHop Current number of redirection urls/addresses attempted so far. + * @return The requested configuration settings. + * @throws Exception the exception + */ + private + TSettings internalGetLegacyUserSettings( + Class cls, + String emailAddress, + List redirectionEmailAddresses, + OutParam currentHop) + throws Exception { + String domainName = EwsUtilities.domainFromEmailAddress(emailAddress); + + int scpUrlCount; + OutParam outParamInt = new OutParam(); + List urls = this.getAutodiscoverServiceUrls(domainName, outParamInt); + scpUrlCount = outParamInt.getParam(); + if (urls.size() == 0) { + throw new ExchangeValidationException( + "This Autodiscover request requires that either the Domain or Url be specified."); + } + + // Assume caller is not inside the Intranet, regardless of whether SCP + // Urls + // were returned or not. SCP Urls are only relevent if one of them + // returns + // valid Autodiscover settings. + this.isExternal = true; + + int currentUrlIndex = 0; + + // Used to save exception for later reporting. + Exception delayedException = null; + TSettings settings; + + do { + URI autodiscoverUrl = urls.get(currentUrlIndex); + boolean isScpUrl = currentUrlIndex < scpUrlCount; + + try { + settings = this.getLegacyUserSettingsAtUrl(cls, + emailAddress, autodiscoverUrl); + + switch (settings.getResponseType()) { + case Success: + // Not external if Autodiscover endpoint found via SCP + // returned the settings. + if (isScpUrl) { + this.isExternal = false; + } + this.url = autodiscoverUrl; + return settings; + case RedirectUrl: + if (currentHop.getParam() < AutodiscoverMaxRedirections) { + currentHop.setParam(currentHop.getParam() + 1); + + this + .traceMessage( + TraceFlags.AutodiscoverResponse, + String + .format( + "Autodiscover " + + "service " + + "returned " + + "redirection URL '%s'.", + settings + .getRedirectTarget())); + + urls.add(currentUrlIndex, new URI( + settings.getRedirectTarget())); + + break; + } else { + throw new MaximumRedirectionHopsExceededException(); + } + case RedirectAddress: + if (currentHop.getParam() < AutodiscoverMaxRedirections) { + currentHop.setParam(currentHop.getParam() + 1); + + this + .traceMessage( + TraceFlags.AutodiscoverResponse, + String + .format( + "Autodiscover " + + "service " + + "returned " + + "redirection email " + + "address '%s'.", + settings + .getRedirectTarget())); + // Bug E14:255576 If this email address was already tried, we may have a loop + // in SCP lookups. Disable consideration of SCP records. + this.disableScpLookupIfDuplicateRedirection( + settings.getRedirectTarget(), + redirectionEmailAddresses); + + return this.internalGetLegacyUserSettings(cls, + settings.getRedirectTarget(), + redirectionEmailAddresses, + currentHop); + } else { + throw new MaximumRedirectionHopsExceededException(); + } + case Error: + // Don't treat errors from an SCP-based Autodiscover service + // to be conclusive. + // We'll try the next one and record the error for later. + if (isScpUrl) { + this + .traceMessage( + TraceFlags.AutodiscoverConfiguration, + "Error returned by " + + "Autodiscover service " + + "found via SCP, treating " + + "as inconclusive."); + + delayedException = new AutodiscoverRemoteException( + "The Autodiscover service returned an error.", settings.getError()); + currentUrlIndex++; + } else { + throw new AutodiscoverRemoteException("The Autodiscover service returned an error.", settings.getError()); + } + break; + default: + EwsUtilities + .ewsAssert(false, "Autodiscover.GetConfigurationSettings", + "An unexpected error has occured. This code path should never be reached."); + break; + } + } catch (XMLStreamException ex) { + this.traceMessage(TraceFlags.AutodiscoverConfiguration, String + .format("%s failed: XML parsing error: %s", url, ex + .getMessage())); + + // The content at the URL wasn't a valid response, let's try the + // next. + currentUrlIndex++; + } catch (IOException ex) { + this.traceMessage( + TraceFlags.AutodiscoverConfiguration, + String.format("%s failed: I/O error: %s", + url, ex.getMessage())); + + // The content at the URL wasn't a valid response, let's try the next. + currentUrlIndex++; + } catch (Exception ex) { + ExchangeHttpClient.Request response = null; + URI redirectUrl; + OutParam outParam1 = new OutParam(); + if ((response != null) && + this.tryGetRedirectionResponse(response, outParam1)) { + redirectUrl = outParam1.getParam(); + this.traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format( + "Host returned a redirection to url %s", + redirectUrl.toString())); + + currentHop.setParam(currentHop.getParam() + 1); + urls.add(currentUrlIndex, redirectUrl); + } else { + if (response != null) { + this.processHttpErrorResponse(response, ex); + + } + + this.traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format("%s failed: %s (%s)", url, ex + .getClass().getName(), ex.getMessage())); + + // The url did not work, let's try the next. + currentUrlIndex++; + } + } + } while (currentUrlIndex < urls.size()); + + // If we got this far it's because none of the URLs we tried have + // worked. As a next-to-last chance, use GetRedirectUrl to + // try to get a redirection URL using an HTTP GET on a non-SSL + // Autodiscover endpoint. If successful, use this + // redirection URL to get the configuration settings for this email + // address. (This will be a common scenario for + // DataCenter deployments). + URI redirectionUrl = this.getRedirectUrl(domainName); + OutParam outParam = new OutParam(); + if ((redirectionUrl != null) + && this.tryLastChanceHostRedirection(cls, emailAddress, + redirectionUrl, outParam)) { + settings = outParam.getParam(); + return settings; + } else { + // Getting a redirection URL from an HTTP GET failed too. As a last + // chance, try to get an appropriate SRV Record + // using DnsQuery. If successful, use this redirection URL to get + // the configuration settings for this email address. + redirectionUrl = this.getRedirectionUrlFromDnsSrvRecord(domainName); + if ((redirectionUrl != null) + && this.tryLastChanceHostRedirection(cls, emailAddress, + redirectionUrl, outParam)) { + return outParam.getParam(); + } + + // If there was an earlier exception, throw it. + if (delayedException != null) { + throw delayedException; + } + + throw new AutodiscoverLocalException("The Autodiscover service couldn't be located."); + } + } + + /** + * Get an autodiscover SRV record in DNS and construct autodiscover URL. + * + * @param domainName Name of the domain. + * @return Autodiscover URL (may be null if lookup failed) + * @throws Exception the exception + */ + protected URI getRedirectionUrlFromDnsSrvRecord(String domainName) + throws Exception { + + this + .traceMessage( + TraceFlags.AutodiscoverConfiguration, + String + .format( + "Trying to get Autodiscover host " + + "from DNS SRV record for %s.", + domainName)); + + String hostname = this.dnsClient + .findAutodiscoverHostFromSrv(domainName); + if (!(hostname == null || hostname.isEmpty())) { + this + .traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format( + "Autodiscover host %s was returned.", + hostname)); + + return new URI(String.format(AutodiscoverLegacyHttpsUrl, + hostname)); + } else { + this.traceMessage(TraceFlags.AutodiscoverConfiguration, + "No matching Autodiscover DNS SRV records were found."); + + return null; + } + } + + /** + * Tries to get Autodiscover settings using redirection Url. + * + * @param the generic type + * @param cls the cls + * @param emailAddress The email address. + * @param redirectionUrl Redirection Url. + * @param settings The settings. + * @return boolean The boolean. + * @throws AutodiscoverLocalException the autodiscover local exception + * @throws AutodiscoverRemoteException the autodiscover remote exception + * @throws Exception the exception + */ + private boolean + tryLastChanceHostRedirection( + Class cls, String emailAddress, URI redirectionUrl, + OutParam settings) throws AutodiscoverLocalException, + AutodiscoverRemoteException, Exception { + List redirectionEmailAddresses = new ArrayList(); + + // Bug 60274: Performing a non-SSL HTTP GET to retrieve a redirection + // URL is potentially unsafe. We allow the caller + // to specify delegate to be called to determine whether we are allowed + // to use the redirection URL. + if (this + .callRedirectionUrlValidationCallback(redirectionUrl.toString())) { + for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) { + try { + settings.setParam(this.getLegacyUserSettingsAtUrl(cls, + emailAddress, redirectionUrl)); + + switch (settings.getParam().getResponseType()) { + case Success: + return true; + case Error: + throw new AutodiscoverRemoteException("The Autodiscover service returned an error.", settings.getParam() + .getError()); + case RedirectAddress: + // If this email address was already tried, + //we may have a loop + // in SCP lookups. Disable consideration of SCP records. + this.disableScpLookupIfDuplicateRedirection(settings.getParam().getRedirectTarget(), + redirectionEmailAddresses); + OutParam outParam = new OutParam(); + outParam.setParam(currentHop); + settings.setParam( + this.internalGetLegacyUserSettings(cls, + emailAddress, + redirectionEmailAddresses, + outParam)); + currentHop = outParam.getParam(); + return true; + case RedirectUrl: + try { + redirectionUrl = new URI(settings.getParam() + .getRedirectTarget()); + } catch (URISyntaxException ex) { + this + .traceMessage( + TraceFlags. + AutodiscoverConfiguration, + String + .format( + "Service " + + "returned " + + "invalid " + + "redirection " + + "URL %s", + settings + .getParam() + .getRedirectTarget())); + return false; + } + break; + default: + String failureMessage = String.format( + "Autodiscover call at %s failed with error %s, target %s", + redirectionUrl, + settings.getParam().getResponseType(), + settings.getParam().getRedirectTarget()); + this.traceMessage( + TraceFlags.AutodiscoverConfiguration, failureMessage); + + return false; + } + } catch (XMLStreamException ex) { + // If the response is malformed, it wasn't a valid + // Autodiscover endpoint. + this + .traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format( + "%s failed: XML parsing error: %s", + redirectionUrl, ex + .getMessage())); + return false; + } catch (IOException ex) { + this.traceMessage( + TraceFlags.AutodiscoverConfiguration, + String.format("%s failed: I/O error: %s", + redirectionUrl, ex.getMessage())); + return false; + } catch (Exception ex) { + // TODO: BUG response is always null + ExchangeHttpClient.Request response = null; + OutParam outParam = new OutParam(); + if ((response != null) + && this.tryGetRedirectionResponse(response, + outParam)) { + redirectionUrl = outParam.getParam(); + this + .traceMessage( + TraceFlags.AutodiscoverConfiguration, + String + .format( + "Host returned a " + + "redirection" + + " to url %s", + redirectionUrl)); + + } else { + if (response != null) { + this.processHttpErrorResponse(response, ex); + } + + this + .traceMessage( + TraceFlags.AutodiscoverConfiguration, + String.format("%s failed: %s (%s)", + url, ex.getClass().getName(), + ex.getMessage())); + return false; + } + } + } + } + + return false; + } + + /** + * Disables SCP lookup if duplicate email address redirection. + * + * @param emailAddress The email address to use. + * @param redirectionEmailAddresses The list of prior redirection email addresses. + */ + private void disableScpLookupIfDuplicateRedirection( + String emailAddress, + List redirectionEmailAddresses) { + // SMTP addresses are case-insensitive so entries are converted to lower-case. + emailAddress = emailAddress.toLowerCase(); + + if (redirectionEmailAddresses.contains(emailAddress)) { + this.enableScpLookup = false; + } else { + redirectionEmailAddresses.add(emailAddress); + } + } + + /** + * Gets user settings from Autodiscover legacy endpoint. + * + * @param emailAddress The email address to use. + * @param requestedSettings The requested settings. + * @return GetUserSettingsResponse + * @throws Exception on error + */ + protected GetUserSettingsResponse internalGetLegacyUserSettings( + String emailAddress, + List requestedSettings) throws Exception { + // Cannot call legacy Autodiscover service with WindowsLive and other WSSecurity-based credential + if ((this.getCredentials() != null) && (this.getCredentials() instanceof WSSecurityBasedCredentials)) { + throw new AutodiscoverLocalException( + "WindowsLiveCredentials can't be used with this Autodiscover endpoint."); + } + + OutlookConfigurationSettings settings = this.getLegacyUserSettings( + OutlookConfigurationSettings.class, + emailAddress); + + + return settings.convertSettings(emailAddress, requestedSettings); + } + + /** + * Calls the SOAP Autodiscover service + * for user settings for a single SMTP address. + * + * @param smtpAddress SMTP address. + * @param requestedSettings The requested settings. + * @return GetUserSettingsResponse + * @throws Exception on error + */ + protected GetUserSettingsResponse internalGetSoapUserSettings( + String smtpAddress, + List requestedSettings) throws Exception { + List smtpAddresses = new ArrayList(); + smtpAddresses.add(smtpAddress); + + List redirectionEmailAddresses = new ArrayList(); + redirectionEmailAddresses.add(smtpAddress.toLowerCase()); + + for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) { + GetUserSettingsResponse response = this.getUserSettings(smtpAddresses, + requestedSettings).getTResponseAtIndex(0); + + switch (response.getErrorCode()) { + case RedirectAddress: + this.traceMessage( + TraceFlags.AutodiscoverResponse, + String.format("Autodiscover service returned redirection email address '%s'.", + response.getRedirectTarget())); + + smtpAddresses.clear(); + smtpAddresses.add(response.getRedirectTarget(). + toLowerCase()); + this.url = null; + this.domain = null; + + // If this email address was already tried, + //we may have a loop + // in SCP lookups. Disable consideration of SCP records. + this.disableScpLookupIfDuplicateRedirection(response.getRedirectTarget(), + redirectionEmailAddresses); + break; + + case RedirectUrl: + this.traceMessage( + TraceFlags.AutodiscoverResponse, + String.format("Autodiscover service returned redirection URL '%s'.", + response.getRedirectTarget())); + + //this.url = new URI(response.getRedirectTarget()); + this.url = this.getCredentials().adjustUrl(new URI(response.getRedirectTarget())); + break; + + case NoError: + default: + return response; + } + } + + throw new AutodiscoverLocalException("The Autodiscover service couldn't be located."); + } + + /** + * Gets the user settings using Autodiscover SOAP service. + * + * @param smtpAddresses The SMTP addresses of the users. + * @param settings The settings. + * @return GetUserSettingsResponseCollection Object. + * @throws Exception the exception + */ + protected GetUserSettingsResponseCollection getUserSettings( + final List smtpAddresses, List settings) + throws Exception { + EwsUtilities.validateParam(smtpAddresses, "smtpAddresses"); + EwsUtilities.validateParam(settings, "settings"); + + return this.getSettings( + GetUserSettingsResponseCollection.class, UserSettingName.class, + smtpAddresses, settings, null, this, + new IFuncDelegate() { + public String func() throws FormatException { + return EwsUtilities + .domainFromEmailAddress(smtpAddresses.get(0)); + } + }); + } + + /** + * Gets user or domain settings using Autodiscover SOAP service. + * + * @param the generic type + * @param the generic type + * @param cls the cls + * @param cls1 the cls1 + * @param identities Either the domains or the SMTP addresses of the users. + * @param settings The settings. + * @param requestedVersion Requested version of the Exchange service. + * @param getSettingsMethod The method to use. + * @param getDomainMethod The method to calculate the domain value. + * @return TGetSettingsResponse Collection. + * @throws Exception the exception + */ + private + TGetSettingsResponseCollection getSettings( + Class cls, + Class cls1, + List identities, + List settings, + ExchangeVersion requestedVersion, + IFunctionDelegate, List, + TGetSettingsResponseCollection> getSettingsMethod, + IFuncDelegate getDomainMethod) throws Exception { + TGetSettingsResponseCollection response; + + // Autodiscover service only exists in E14 or later. + if (this.getRequestedServerVersion().compareTo( + MinimumRequestVersionForAutoDiscoverSoapService) < 0) { + throw new ServiceVersionException(String.format( + "The Autodiscover service only supports %s or a later version.", + MinimumRequestVersionForAutoDiscoverSoapService)); + } + + // If Url is specified, call service directly. + if (this.url != null) { + URI autodiscoverUrl = this.url; + response = getSettingsMethod.func(identities, settings, + requestedVersion, this.url); + this.url = autodiscoverUrl; + return response; + } + // If Domain is specified, determine endpoint Url and call service. + else if (!(this.domain == null || this.domain.isEmpty())) { + URI autodiscoverUrl = this.getAutodiscoverEndpointUrl(this.domain); + response = getSettingsMethod.func(identities, settings, + requestedVersion, + autodiscoverUrl); + + // If we got this far, response was successful, set Url. + this.url = autodiscoverUrl; + return response; + } + // No Url or Domain specified, need to figure out which endpoint(s) to + // try. + else { + // Assume caller is not inside the Intranet, regardless of whether + // SCP Urls + // were returned or not. SCP Urls are only relevent if one of them + // returns + // valid Autodiscover settings. + this.isExternal = true; + + URI autodiscoverUrl; + + String domainName = getDomainMethod.func(); + int scpHostCount; + OutParam outParam = new OutParam(); + List hosts = this.getAutodiscoverServiceHosts(domainName, + outParam); + scpHostCount = outParam.getParam(); + if (hosts.size() == 0) { + throw new ExchangeValidationException( + "This Autodiscover request requires that either the Domain or Url be specified."); + } + + for (int currentHostIndex = 0; currentHostIndex < hosts.size(); currentHostIndex++) { + String host = hosts.get(currentHostIndex); + boolean isScpHost = currentHostIndex < scpHostCount; + OutParam outParams = new OutParam(); + if (this.tryGetAutodiscoverEndpointUrl(host, outParams)) { + autodiscoverUrl = outParams.getParam(); + response = getSettingsMethod.func(identities, settings, + requestedVersion, + autodiscoverUrl); + + // If we got this far, the response was successful, set Url. + this.url = autodiscoverUrl; + + // Not external if Autodiscover endpoint found via SCP + // returned the settings. + if (isScpHost) { + this.isExternal = false; + } + + return response; + } + } + + // Next-to-last chance: try unauthenticated GET over HTTP to be + // redirected to appropriate service endpoint. + autodiscoverUrl = this.getRedirectUrl(domainName); + OutParam outParamUrl = new OutParam(); + if ((autodiscoverUrl != null) && + this + .callRedirectionUrlValidationCallback( + autodiscoverUrl.toString()) && + this.tryGetAutodiscoverEndpointUrl(autodiscoverUrl + .getHost(), outParamUrl)) { + autodiscoverUrl = outParamUrl.getParam(); + response = getSettingsMethod.func(identities, settings, + requestedVersion, + autodiscoverUrl); + + // If we got this far, the response was successful, set Url. + this.url = autodiscoverUrl; + + return response; + } + + // Last Chance: try to read autodiscover SRV Record from DNS. If we + // find one, use + // the hostname returned to construct an Autodiscover endpoint URL. + autodiscoverUrl = this + .getRedirectionUrlFromDnsSrvRecord(domainName); + if ((autodiscoverUrl != null) && + this + .callRedirectionUrlValidationCallback( + autodiscoverUrl.toString()) && + this.tryGetAutodiscoverEndpointUrl(autodiscoverUrl + .getHost(), outParamUrl)) { + autodiscoverUrl = outParamUrl.getParam(); + response = getSettingsMethod.func(identities, settings, + requestedVersion, + autodiscoverUrl); + + // If we got this far, the response was successful, set Url. + this.url = autodiscoverUrl; + + return response; + } else { + throw new AutodiscoverLocalException("The Autodiscover service couldn't be located."); + } + } + } + + /** + * Gets settings for one or more users. + * + * @param smtpAddresses The SMTP addresses of the users. + * @param settings The settings. + * @param requestedVersion Requested version of the Exchange service. + * @param autodiscoverUrl The autodiscover URL. + * @return GetUserSettingsResponse collection. + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + private GetUserSettingsResponseCollection internalGetUserSettings( + List smtpAddresses, List settings, + ExchangeVersion requestedVersion, + URI autodiscoverUrl) throws ServiceLocalException, Exception { + // The response to GetUserSettings can be a redirection. Execute + // GetUserSettings until we get back + // a valid response or we've followed too many redirections. + for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) { + GetUserSettingsRequest request = new GetUserSettingsRequest(this, + autodiscoverUrl); + request.setSmtpAddresses(smtpAddresses); + request.setSettings(settings); + GetUserSettingsResponseCollection response = request.execute(); + + // Did we get redirected? + if (response.getErrorCode() == AutodiscoverErrorCode.RedirectUrl + && response.getRedirectionUrl() != null) { + this.traceMessage( + TraceFlags.AutodiscoverConfiguration, + String.format("Request to %s returned redirection to %s", + autodiscoverUrl.toString(), response.getRedirectionUrl())); + + autodiscoverUrl = response.getRedirectionUrl(); + } else { + return response; + } + } + + this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format( + "Maximum number of redirection hops %d exceeded", + AutodiscoverMaxRedirections)); + + throw new MaximumRedirectionHopsExceededException(); + } + + /** + * Gets the domain settings using Autodiscover SOAP service. + * + * @param domains The domains. + * @param settings The settings. + * @param requestedVersion Requested version of the Exchange service. + * @return GetDomainSettingsResponse collection. + * @throws Exception the exception + */ + protected GetDomainSettingsResponseCollection getDomainSettings( + final List domains, List settings, + ExchangeVersion requestedVersion) + throws Exception { + EwsUtilities.validateParam(domains, "domains"); + EwsUtilities.validateParam(settings, "settings"); + + return this.getSettings( + GetDomainSettingsResponseCollection.class, + DomainSettingName.class, domains, settings, + requestedVersion, this, + new IFuncDelegate() { + public String func() { + return domains.get(0); + } + }); + } + + /** + * Gets settings for one or more domains. + * + * @param domains The domains. + * @param settings The settings. + * @param requestedVersion Requested version of the Exchange service. + * @param autodiscoverUrl The autodiscover URL. + * @return GetDomainSettingsResponse Collection. + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + private GetDomainSettingsResponseCollection internalGetDomainSettings( + List domains, List settings, + ExchangeVersion requestedVersion, + URI autodiscoverUrl) throws ServiceLocalException, Exception { + // The response to GetDomainSettings can be a redirection. Execute + // GetDomainSettings until we get back + // a valid response or we've followed too many redirections. + for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) { + GetDomainSettingsRequest request = new GetDomainSettingsRequest( + this, autodiscoverUrl); + request.setDomains(domains); + request.setSettings(settings); + request.setRequestedVersion(requestedVersion); + GetDomainSettingsResponseCollection response = request.execute(); + + // Did we get redirected? + if (response.getErrorCode() == AutodiscoverErrorCode.RedirectUrl + && response.getRedirectionUrl() != null) { + autodiscoverUrl = response.getRedirectionUrl(); + } else { + return response; + } + } + + this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format( + "Maximum number of redirection hops %d exceeded", + AutodiscoverMaxRedirections)); + + throw new MaximumRedirectionHopsExceededException(); + } + + /** + * Gets the autodiscover endpoint URL. + * + * @param host The host. + * @return URI The URI. + * @throws Exception the exception + */ + private URI getAutodiscoverEndpointUrl(String host) throws Exception { + URI autodiscoverUrl = null; + OutParam outParam = new OutParam(); + if (this.tryGetAutodiscoverEndpointUrl(host, outParam)) { + return autodiscoverUrl; + } else { + throw new AutodiscoverLocalException( + "No appropriate Autodiscover SOAP or WS-Security endpoint is available."); + } + } + + /** + * Tries the get Autodiscover Service endpoint URL. + * + * @param host The host. + * @param url the url + * @return boolean The boolean. + * @throws Exception the exception + */ + private boolean tryGetAutodiscoverEndpointUrl(String host, + OutParam url) + throws Exception { + EnumSet endpoints; + OutParam> outParam = + new OutParam>(); + if (this.tryGetEnabledEndpointsForHost(host, outParam)) { + endpoints = outParam.getParam(); + url + .setParam(new URI(String.format(AutodiscoverSoapHttpsUrl, + host))); + + // Make sure that at least one of the non-legacy endpoints is + // available. + if ((!endpoints.contains(AutodiscoverEndpoints.Soap)) && + (!endpoints.contains( + AutodiscoverEndpoints.WsSecurity)) + // (endpoints .contains( AutodiscoverEndpoints.WSSecuritySymmetricKey) ) && + //(endpoints .contains( AutodiscoverEndpoints.WSSecurityX509Cert)) + ) { + this + .traceMessage( + TraceFlags.AutodiscoverConfiguration, + String + .format( + "No Autodiscover endpoints " + + "are available for host %s", + host)); + + return false; + } + + // If we have WLID credential, make sure that we have a WS-Security + // endpoint + /* + if (this.getCredentials() instanceof WindowsLiveCredentials) { + if (endpoints.contains(AutodiscoverEndpoints.WsSecurity)) { + this + .traceMessage( + TraceFlags.AutodiscoverConfiguration, + String + .format( + "No Autodiscover " + + "WS-Security " + + "endpoint is available" + + " for host %s", + host)); + + return false; + } else { + url.setParam(new URI(String.format( + AutodiscoverSoapWsSecurityHttpsUrl, host))); + } + } + else if (this.getCredentials() instanceof PartnerTokenCredentials) + { + if (endpoints.contains( AutodiscoverEndpoints.WSSecuritySymmetricKey)) + { + this.traceMessage( + TraceFlags.AutodiscoverConfiguration, + String.format("No Autodiscover WS-Security/SymmetricKey endpoint is available for host {0}", host)); + + return false; + } + else + { + url.setParam( new URI(String.format(AutodiscoverSoapWsSecuritySymmetricKeyHttpsUrl, host))); + } + } + else if (this.getCredentials()instanceof X509CertificateCredentials) + { + if ((endpoints.contains(AutodiscoverEndpoints.WSSecurityX509Cert)) + { + this.traceMessage( + TraceFlags.AutodiscoverConfiguration, + String.format("No Autodiscover WS-Security/X509Cert endpoint is available for host {0}", host)); + + return false; + } + else + { + url.setParam( new URI(String.format(AutodiscoverSoapWsSecurityX509CertHttpsUrl, host))); + } + } + */ + return true; + + + } else { + this + .traceMessage( + TraceFlags.AutodiscoverConfiguration, + String + .format( + "No Autodiscover endpoints " + + "are available for host %s", + host)); + + return false; + } + } + + /** + * Gets the list of autodiscover service URLs. + * + * @param domainName Domain name. + * @param scpHostCount Count of hosts found via SCP lookup. + * @return List of Autodiscover URLs. + * @throws java.net.URISyntaxException the URI Syntax exception + */ + protected List getAutodiscoverServiceUrls(String domainName, + OutParam scpHostCount) throws URISyntaxException { + List urls; + + urls = new ArrayList(); + + scpHostCount.setParam(urls.size()); + + // As a fallback, add autodiscover URLs base on the domain name. + urls.add(new URI(String.format(AutodiscoverLegacyHttpsUrl, + domainName))); + urls.add(new URI(String.format(AutodiscoverLegacyHttpsUrl, + "autodiscover." + domainName))); + + return urls; + } + + /** + * Gets the list of autodiscover service hosts. + * + * @param domainName Domain name. + * @param outParam the out param + * @return List of hosts. + * @throws java.net.URISyntaxException the uRI syntax exception + * @throws ClassNotFoundException the class not found exception + */ + protected List getAutodiscoverServiceHosts(String domainName, + OutParam outParam) throws URISyntaxException, + ClassNotFoundException { + + List urls = this.getAutodiscoverServiceUrls(domainName, outParam); + List lst = new ArrayList(); + for (URI url : urls) { + lst.add(url.getHost()); + } + return lst; + } + + /** + * Gets the enabled autodiscover endpoints on a specific host. + * + * @param host The host. + * @param endpoints Endpoints found for host. + * @return Flags indicating which endpoints are enabled. + * @throws Exception the exception + */ + private boolean tryGetEnabledEndpointsForHost(String host, + OutParam> endpoints) throws Exception { + this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format( + "Determining which endpoints are enabled for host %s", host)); + + // We may get redirected to another host. And therefore need to limit the number of redirections we'll + // tolerate. + for (int currentHop = 0; currentHop < AutodiscoverMaxRedirections; currentHop++) { + URI autoDiscoverUrl = new URI(String.format(AutodiscoverLegacyHttpsUrl, host)); + + endpoints.setParam(EnumSet.of(AutodiscoverEndpoints.None)); + + ExchangeHttpClient.Request request = null; + try { + request = httpClient.createRequest(); // new HttpClientWebRequest(httpClient, httpContext); + + try { + request.setUrl(autoDiscoverUrl.toURL()); + } catch (MalformedURLException e) { + String strErr = String.format("Incorrect format : %s", url); + throw new ServiceLocalException(strErr); + } + + request.setRequestMethod("GET"); + request.setAllowAutoRedirect(false); + request.setPreAuthenticate(false); + request.setUseDefaultCredentials(this.getUseDefaultCredentials()); + request.setTimeout(getTimeout()); + + prepareCredentials(request); + + request.prepareConnection(); + try { + request.executeRequest(); + } catch (IOException e) { + return false; + } + + OutParam outParam = new OutParam(); + if (this.tryGetRedirectionResponse(request, outParam)) { + URI redirectUrl = outParam.getParam(); + this.traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format("Host returned redirection to host '%s'", redirectUrl.getHost())); + + host = redirectUrl.getHost(); + } else { + endpoints.setParam(this.getEndpointsFromHttpWebResponse(request)); + + this.traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format("Host returned enabled endpoint flags: %s", endpoints.getParam().toString())); + + return true; + } + } finally { + if (request != null) { + request.close(); + } + } + } + + this.traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format("Maximum number of redirection hops %d exceeded", AutodiscoverMaxRedirections)); + + throw new MaximumRedirectionHopsExceededException(); + } + + /** + * Gets the endpoints from HTTP web response. + * + * @param request the request + * @return Endpoints enabled. + * @throws EWSHttpException the EWS http exception + */ + private EnumSet getEndpointsFromHttpWebResponse( + ExchangeHttpClient.Request request) throws EWSHttpException { + EnumSet endpoints = EnumSet + .noneOf(AutodiscoverEndpoints.class); + endpoints.add(AutodiscoverEndpoints.Legacy); + + final String soapEnabled = request.getResponseHeaderField(AutodiscoverSoapEnabledHeaderName); + if (soapEnabled != null && !soapEnabled.isEmpty()) { + endpoints.add(AutodiscoverEndpoints.Soap); + } + final String wsSecEnabled = request.getResponseHeaderField(AutodiscoverWsSecurityEnabledHeaderName); + if (wsSecEnabled != null && !wsSecEnabled.isEmpty()) { + endpoints.add(AutodiscoverEndpoints.WsSecurity); + } + + /* if (! (request.getResponseHeaders().get( + AutodiscoverWsSecuritySymmetricKeyEnabledHeaderName) !=null || request + .getResponseHeaders().get( + AutodiscoverWsSecuritySymmetricKeyEnabledHeaderName).isEmpty())) + { + endpoints .add( AutodiscoverEndpoints.WSSecuritySymmetricKey); + } + if (!(request.getResponseHeaders().get( + AutodiscoverWsSecurityX509CertEnabledHeaderName)!=null || + request.getResponseHeaders().get( + AutodiscoverWsSecurityX509CertEnabledHeaderName).isEmpty())) + + { + endpoints .add(AutodiscoverEndpoints.WSSecurityX509Cert); + }*/ + + return endpoints; + } + + /** + * Traces the response. + * + * @param request the request + * @param memoryStream the memory stream + * @throws XMLStreamException the XML stream exception + * @throws IOException signals that an I/O exception has occurred. + * @throws EWSHttpException the EWS http exception + */ + public void traceResponse(ExchangeHttpClient.Request request, ByteArrayOutputStream memoryStream) throws XMLStreamException, + IOException, EWSHttpException { + this.processHttpResponseHeaders( + TraceFlags.AutodiscoverResponseHttpHeaders, request); + String contentType = request.getResponseContentType(); + if (!(contentType == null || contentType.isEmpty())) { + contentType = contentType.toLowerCase(); + if (contentType.toLowerCase().startsWith("text/") || + contentType.toLowerCase(). + startsWith("application/soap")) { + this.traceXml(TraceFlags.AutodiscoverResponse, memoryStream); + } else { + this.traceMessage(TraceFlags.AutodiscoverResponse, + "Non-textual response"); + } + } + } + + /** + * Creates an HttpWebRequest instance and initializes it with the + * appropriate parameters, based on the configuration of this service + * object. + * + * @param url The URL that the HttpWebRequest should target + * @return HttpWebRequest The HttpWebRequest + * @throws ServiceLocalException the service local exception + * @throws java.net.URISyntaxException the uRI syntax exception + */ + public ExchangeHttpClient.Request prepareHttpWebRequestForUrl(URI url) throws ServiceLocalException, URISyntaxException { + return this.prepareHttpWebRequestForUrl(url, false, + // acceptGzipEncoding + false); // allowAutoRedirect + } + + /** + * Calls the redirection URL validation callback. If the redirection URL + * validation callback is null, use the default callback which does not + * allow following any redirections. + * + * @param redirectionUrl The redirection URL. + * @return True if redirection should be followed. + * @throws AutodiscoverLocalException the autodiscover local exception + */ + private boolean callRedirectionUrlValidationCallback(String redirectionUrl) + throws AutodiscoverLocalException { + IAutodiscoverRedirectionUrl callback = + (this.redirectionUrlValidationCallback == null) ? this + : this.redirectionUrlValidationCallback; + return callback + .autodiscoverRedirectionUrlValidationCallback(redirectionUrl); + } + + /** + * Processes an HTTP error response. + * + * @param httpWebResponse The HTTP web response. + * @throws Exception the exception + */ + @Override + public void processHttpErrorResponse(ExchangeHttpClient.Request httpWebResponse, Exception webException) throws Exception { + this.internalProcessHttpErrorResponse( + httpWebResponse, + webException, + TraceFlags.AutodiscoverResponseHttpHeaders, + TraceFlags.AutodiscoverResponse); + } + + /* + * (non-Javadoc) + * + * @see microsoft.exchange.webservices.AutodiscoverRedirectionUrlInterface# + * autodiscoverRedirectionUrlValidationCallback(java.lang.String) + */ + public boolean autodiscoverRedirectionUrlValidationCallback( + String redirectionUrl) throws AutodiscoverLocalException { + return defaultAutodiscoverRedirectionUrlValidationCallback( + redirectionUrl); + } + + /** + * Initializes a new instance of the "AutodiscoverService" class. + * + * @throws ArgumentException on validation error + */ + public AutodiscoverService(final ExchangeHttpClient client) throws ArgumentException { + this(client, ExchangeVersion.Exchange2010); + } + + /** + * Initializes a new instance of the "AutodiscoverService" class. + * + * @param requestedServerVersion The requested server version + * @throws ArgumentException on validation error + */ + public AutodiscoverService(final ExchangeHttpClient client, ExchangeVersion requestedServerVersion) throws ArgumentException { + this(client, null, null, requestedServerVersion); + } + + /** + * Initializes a new instance of the "AutodiscoverService" class. + * + * @param domain The domain that will be used to determine the URL of the service + * @throws ArgumentException on validation error + */ + public AutodiscoverService(final ExchangeHttpClient client, String domain) throws ArgumentException { + this(client, null, domain); + } + + /** + * Initializes a new instance of the "AutodiscoverService" class. + * + * @param domain The domain that will be used to determine the URL of the service + * @param requestedServerVersion The requested server version + * @throws ArgumentException on validation error + */ + public AutodiscoverService(final ExchangeHttpClient client, + String domain, + ExchangeVersion requestedServerVersion) throws ArgumentException { + this(client, null, domain, requestedServerVersion); + } + + /** + * Initializes a new instance of the "AutodiscoverService" class. + * + * @param url The URL of the service + * @throws ArgumentException on validation error + */ + public AutodiscoverService(final ExchangeHttpClient client, URI url) throws ArgumentException { + this(client, url, url.getHost()); + } + + /** + * Initializes a new instance of the "AutodiscoverService" class. + * + * @param url The URL of the service + * @param requestedServerVersion The requested server version + * @throws ArgumentException on validation error + */ + public AutodiscoverService(final ExchangeHttpClient client, URI url, + ExchangeVersion requestedServerVersion) throws ArgumentException { + this(client, url, url.getHost(), requestedServerVersion); + } + + /** + * Initializes a new instance of the "AutodiscoverService" class. + * + * @param url The URL of the service + * @param domain The domain that will be used to determine the URL of the service + * @throws ArgumentException on validation error + */ + public AutodiscoverService(final ExchangeHttpClient client, URI url, String domain) throws ArgumentException { + super(client); + EwsUtilities.validateDomainNameAllowNull(domain, "domain"); + this.url = url; + this.domain = domain; + this.dnsClient = new AutodiscoverDnsClient(this); + } + + /** + * Initializes a new instance of the "AutodiscoverService" class. + * + * @param url The URL of the service. + * @param domain The domain that will be used to determine the URL of the + * service. + * @param requestedServerVersion The requested server version. + * @throws ArgumentException on validation error + */ + public AutodiscoverService(final ExchangeHttpClient client, URI url, String domain, ExchangeVersion requestedServerVersion) throws ArgumentException { + super(requestedServerVersion, client); + EwsUtilities.validateDomainNameAllowNull(domain, "domain"); + + this.url = url; + this.domain = domain; + this.dnsClient = new AutodiscoverDnsClient(this); + } + + /** + * Initializes a new instance of the AutodiscoverService class. + * + * @param service The other service. + * @param requestedServerVersion The requested server version. + */ + public AutodiscoverService(ExchangeServiceBase service, + ExchangeVersion requestedServerVersion) { + super(service, requestedServerVersion); + this.dnsClient = new AutodiscoverDnsClient(this); + } + + /** + * Initializes a new instance of the "AutodiscoverService" class. + * + * @param service The service. + */ + public AutodiscoverService(ExchangeServiceBase service) { + super(service, service.getRequestedServerVersion()); + } + + /** + * Retrieves the specified settings for single SMTP address. + *

This method will run the entire Autodiscover "discovery" + * algorithm and will follow address and URL redirections.

+ * + * @param userSmtpAddress The SMTP addresses of the user. + * @param userSettingNames The user setting names. + * @return A UserResponse object containing the requested settings for the + * specified user. + * @throws Exception on error + */ + public GetUserSettingsResponse getUserSettings(String userSmtpAddress, + UserSettingName... userSettingNames) throws Exception { + List requestedSettings = new ArrayList(); + requestedSettings.addAll(Arrays.asList(userSettingNames)); + + if (userSmtpAddress == null || userSmtpAddress.isEmpty()) { + throw new ExchangeValidationException("A valid SMTP address must be specified."); + } + + if (requestedSettings.size() == 0) { + throw new ExchangeValidationException("At least one setting must be requested."); + } + + if (this.getRequestedServerVersion().compareTo(MinimumRequestVersionForAutoDiscoverSoapService) < 0) { + return this.internalGetLegacyUserSettings(userSmtpAddress, + requestedSettings); + } else { + return this.internalGetSoapUserSettings(userSmtpAddress, + requestedSettings); + } + + } + + /** + * Retrieves the specified settings for a set of users. + * + * @param userSmtpAddresses the user smtp addresses + * @param userSettingNames The user setting names. + * @return A GetUserSettingsResponseCollection object containing the + * response for each individual user. + * @throws Exception the exception + */ + public GetUserSettingsResponseCollection getUsersSettings( + Iterable userSmtpAddresses, + UserSettingName... userSettingNames) throws Exception { + if (this.getRequestedServerVersion().compareTo(MinimumRequestVersionForAutoDiscoverSoapService) < 0) { + throw new ServiceVersionException( + String.format("The Autodiscover service only supports %s or a later version.", + MinimumRequestVersionForAutoDiscoverSoapService)); + } + List smtpAddresses = new ArrayList(); + smtpAddresses.addAll((Collection) userSmtpAddresses); + List settings = new ArrayList(); + settings.addAll(Arrays.asList(userSettingNames)); + return this.getUserSettings(smtpAddresses, settings); + } + + /** + * Retrieves the specified settings for a domain. + * + * @param domain The domain. + * @param requestedVersion Requested version of the Exchange service. + * @param domainSettingNames The domain setting names. + * @return A DomainResponse object containing the requested settings for the + * specified domain. + * @throws Exception the exception + */ + public GetDomainSettingsResponse getDomainSettings(String domain, + ExchangeVersion requestedVersion, + DomainSettingName... domainSettingNames) throws Exception { + List domains = new ArrayList(1); + domains.add(domain); + + List settings = new ArrayList(); + settings.addAll(Arrays.asList(domainSettingNames)); + + return this.getDomainSettings(domains, settings, requestedVersion). + getTResponseAtIndex(0); + } + + /** + * Retrieves the specified settings for a set of domains. + * + * @param domains the domains + * @param requestedVersion Requested version of the Exchange service. + * @param domainSettingNames The domain setting names. + * @return A GetDomainSettingsResponseCollection object containing the + * response for each individual domain. + * @throws Exception the exception + */ + public GetDomainSettingsResponseCollection getDomainSettings( + Iterable domains, ExchangeVersion requestedVersion, + DomainSettingName... domainSettingNames) + throws Exception { + List settings = new ArrayList(); + settings.addAll(Arrays.asList(domainSettingNames)); + + List domainslst = new ArrayList(); + domainslst.addAll((Collection) domains); + + return this.getDomainSettings(domainslst, settings, requestedVersion); + } + + /** + * Gets the domain this service is bound to. When this property is + * set, the domain name is used to automatically determine the Autodiscover service URL. + * + * @return the domain + */ + public String getDomain() { + return this.domain; + } + + /** + * Sets the domain this service is bound to. When this property is + * set, the domain + * name is used to automatically determine the Autodiscover service URL. + * + * @param value the new domain + * @throws ArgumentException on validation error + */ + public void setDomain(String value) throws ArgumentException { + EwsUtilities.validateDomainNameAllowNull(value, "Domain"); + + // If Domain property is set to non-null value, Url property is nulled. + if (value != null) { + this.url = null; + } + this.domain = value; + } + + /** + * Gets the url this service is bound to. + * + * @return the url + */ + public URI getUrl() { + return this.url; + } + + /** + * Sets the url this service is bound to. + * + * @param value the new url + */ + public void setUrl(URI value) { + // If Url property is set to non-null value, Domain property is set to + // host portion of Url. + if (value != null) { + this.domain = value.getHost(); + } + this.url = value; + } + + public Boolean isExternal() { + return this.isExternal; + } + + protected void setIsExternal(Boolean value) { + this.isExternal = value; + } + + + /** + * Gets the redirection url validation callback. + * + * @return the redirection url validation callback + */ + public IAutodiscoverRedirectionUrl + getRedirectionUrlValidationCallback() { + return this.redirectionUrlValidationCallback; + } + + /** + * Sets the redirection url validation callback. + * + * @param value the new redirection url validation callback + */ + public void setRedirectionUrlValidationCallback( + IAutodiscoverRedirectionUrl value) { + this.redirectionUrlValidationCallback = value; + } + + /** + * Gets the dns server address. + * + * @return the dns server address + */ + protected String getDnsServerAddress() { + return this.dnsServerAddress; + } + + /** + * Sets the dns server address. + * + * @param value the new dns server address + */ + protected void setDnsServerAddress(String value) { + this.dnsServerAddress = value; + } + + /** + * Gets a value indicating whether the AutodiscoverService should + * perform SCP (ServiceConnectionPoint) record lookup when determining + * the Autodiscover service URL. + * + * @return the enable scp lookup + */ + public boolean getEnableScpLookup() { + return this.enableScpLookup; + } + + /** + * Sets the enable scp lookup. + * + * @param value the new enable scp lookup + */ + public void setEnableScpLookup(boolean value) { + this.enableScpLookup = value; + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.FuncDelegateInterface#func(java.util.List, + * java.util.List, java.net.URI) + */ + @Override + public Object func(List arg1, List arg2, ExchangeVersion arg3, URI arg4) + throws Exception { + if (arg2.get(0).getClass().equals(DomainSettingName.class)) { + return internalGetDomainSettings(arg1, arg2, arg3, arg4); + } else if (arg2.get(0).getClass().equals(UserSettingName.class)) { + return internalGetUserSettings(arg1, arg2, arg3, arg4); + } else { + return null; + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/IAutodiscoverRedirectionUrl.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/IAutodiscoverRedirectionUrl.java new file mode 100644 index 000000000..a76b0edd3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/IAutodiscoverRedirectionUrl.java @@ -0,0 +1,43 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover; + +import com.eischet.ews.api.autodiscover.exception.AutodiscoverLocalException; + +/** + * Defines a delegate that is used by the AutodiscoverService to ask whether a + * redirectionUrl can be used. + */ +public interface IAutodiscoverRedirectionUrl { + + /** + * Autodiscover redirection url validation callback. + * + * @param redirectionUrl the redirection url + * @return true, if successful + * @throws AutodiscoverLocalException the autodiscover local exception + */ + boolean autodiscoverRedirectionUrlValidationCallback( + String redirectionUrl) throws AutodiscoverLocalException; +} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/IFunc.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/IFunc.java similarity index 89% rename from src/main/java/microsoft/exchange/webservices/data/autodiscover/IFunc.java rename to ews-api/src/main/java/com/eischet/ews/api/autodiscover/IFunc.java index 3dc6429a6..a001c207e 100644 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/IFunc.java +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/IFunc.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.autodiscover; +package com.eischet.ews.api.autodiscover; /** * The Interface Func. @@ -31,11 +31,11 @@ */ public interface IFunc { - /** - * Func. - * - * @param arg the arg - * @return the t result - */ - TResult func(T arg); + /** + * Func. + * + * @param arg the arg + * @return the t result + */ + TResult func(T arg); } diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/IFuncDelegate.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/IFuncDelegate.java similarity index 81% rename from src/main/java/microsoft/exchange/webservices/data/autodiscover/IFuncDelegate.java rename to ews-api/src/main/java/com/eischet/ews/api/autodiscover/IFuncDelegate.java index 386e3e4aa..326fe1243 100644 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/IFuncDelegate.java +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/IFuncDelegate.java @@ -21,9 +21,9 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.autodiscover; +package com.eischet.ews.api.autodiscover; -import microsoft.exchange.webservices.data.core.exception.misc.FormatException; +import com.eischet.ews.api.core.exception.misc.FormatException; /** * The Interface FuncDelegate. @@ -32,11 +32,11 @@ */ public interface IFuncDelegate { - /** - * Func. - * - * @return the t result - * @throws FormatException the format exception - */ - TResult func() throws FormatException; + /** + * Func. + * + * @return the t result + * @throws FormatException the format exception + */ + TResult func() throws FormatException; } diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/IFunctionDelegate.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/IFunctionDelegate.java similarity index 77% rename from src/main/java/microsoft/exchange/webservices/data/autodiscover/IFunctionDelegate.java rename to ews-api/src/main/java/com/eischet/ews/api/autodiscover/IFunctionDelegate.java index 0588754d0..220f701c5 100644 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/IFunctionDelegate.java +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/IFunctionDelegate.java @@ -21,9 +21,9 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.autodiscover; +package com.eischet.ews.api.autodiscover; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; import java.net.URI; import java.util.List; @@ -37,16 +37,16 @@ */ public interface IFunctionDelegate, T2 extends List, TResult> { - /** - * Func. - * - * @param arg1 the arg1 - * @param arg2 the arg2 - * @param arg3 the arg3 - * @param arg4 the arg4 - * @return the t result - * @throws Exception the exception - */ - TResult func(T1 arg1, T2 arg2, ExchangeVersion arg3, URI arg4) throws Exception; + /** + * Func. + * + * @param arg1 the arg1 + * @param arg2 the arg2 + * @param arg3 the arg3 + * @param arg4 the arg4 + * @return the t result + * @throws Exception the exception + */ + TResult func(T1 arg1, T2 arg2, ExchangeVersion arg3, URI arg4) throws Exception; } diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/ProtocolConnection.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/ProtocolConnection.java new file mode 100644 index 000000000..86e5e32ca --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/ProtocolConnection.java @@ -0,0 +1,160 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover; + +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +/** + * Represents the email Protocol connection settings for pop/imap/smtp + * protocols. + */ +public final class ProtocolConnection { + + /** + * The encryption method. + */ + private String encryptionMethod; + + /** + * The hostname. + */ + private String hostname; + + /** + * The port. + */ + private int port; + + /** + * Initializes a new instance of the {@link ProtocolConnection} class. + */ + + protected ProtocolConnection() { + } + + /** + * Read user setting with ProtocolConnection value. + * + * @param reader EwsServiceXmlReader + * @return the protocol connection + * @throws Exception the exception + */ + protected static ProtocolConnection loadFromXml(EwsXmlReader reader) + throws Exception { + ProtocolConnection connection = new ProtocolConnection(); + + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals( + XmlElementNames.EncryptionMethod)) { + connection.setEncryptionMethod(reader + .readElementValue(String.class)); + } else if (reader.getLocalName().equals( + XmlElementNames.Hostname)) { + connection.setHostname(reader + .readElementValue(String.class)); + } else if (reader.getLocalName().equals(XmlElementNames.Port)) { + connection.setPort(reader.readElementValue(int.class)); + } + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.ProtocolConnection)); + + return connection; + } + + /** + * Initializes a new instance of the ProtocolConnection class. + * + * @param encryptionMethod The encryption method. + * @param hostname The hostname. + * @param port The port number to use for the portocol. + */ + protected ProtocolConnection(String encryptionMethod, String hostname, + int port) { + this.encryptionMethod = encryptionMethod; + this.hostname = hostname; + this.port = port; + } + + /** + * Gets the encryption method. + * + * @return The encryption method. + */ + public String getEncryptionMethod() { + return this.encryptionMethod; + } + + /** + * Sets the encryption method. + * + * @param value the new encryption method + */ + public void setEncryptionMethod(String value) { + this.encryptionMethod = value; + } + + /** + * Gets the hostname. + * + * @return The hostname. + */ + public String getHostname() { + return this.hostname; + + } + + /** + * Sets the hostname. + * + * @param value the new hostname + */ + public void setHostname(String value) { + this.hostname = value; + } + + /** + * Gets the port number. + * + * @return The port number. + */ + public int getPort() { + return this.port; + } + + /** + * Sets the port. + * + * @param value the new port + */ + public void setPort(int value) { + this.port = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/ProtocolConnectionCollection.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/ProtocolConnectionCollection.java new file mode 100644 index 000000000..a0c4525af --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/ProtocolConnectionCollection.java @@ -0,0 +1,96 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover; + +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.ArrayList; + +/** + * Represents a user setting that is a collection of protocol connection. + */ +public final class ProtocolConnectionCollection { + + /** + * The connections. + */ + private ArrayList connections; + + /** + * Initializes a new instance of the class. + */ + ProtocolConnectionCollection() { + this.connections = new ArrayList(); + } + + /** + * Read user setting with ProtocolConnectionCollection value. + * + * @param reader EwsServiceXmlReader + * @return the protocol connection collection + * @throws Exception the exception + */ + public static ProtocolConnectionCollection loadFromXml(final EwsXmlReader reader) + throws Exception { + final ProtocolConnectionCollection value = new ProtocolConnectionCollection(); + + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals(XmlElementNames.ProtocolConnection)) { + final ProtocolConnection connection = ProtocolConnection.loadFromXml(reader); + if (connection != null) { + value.getConnections().add(connection); + } + } + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.ProtocolConnections)); + + return value; + } + + /** + * Gets the Connections. + * + * @return the connections + */ + public ArrayList getConnections() { + return this.connections; + } + + /** + * Sets the connections. + * + * @param value the new connections + */ + void setConnections(ArrayList value) { + this.connections = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/WebClientUrl.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/WebClientUrl.java new file mode 100644 index 000000000..a592495d4 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/WebClientUrl.java @@ -0,0 +1,129 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover; + +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +/** + * Represents the URL of the Exchange web client. + */ +public final class WebClientUrl { + + /** + * The authentication methods. + */ + private String authenticationMethods; + + /** + * The url. + */ + private String url; + + /** + * Initializes a new instance of the class. + */ + private WebClientUrl() { + } + + /** + * Initializes a new instance of the WebClientUrl class. + * + * @param authenticationMethods The authentication methods. + * @param url The URL. + */ + public WebClientUrl(String authenticationMethods, String url) { + this.authenticationMethods = authenticationMethods; + this.url = url; + } + + + /** + * Loads WebClientUrl instance from XML. + * + * @param reader The reader. + * @return WebClientUrl. + * @throws Exception the exception + */ + protected static WebClientUrl loadFromXml(EwsXmlReader reader) + throws Exception { + WebClientUrl webClientUrl = new WebClientUrl(); + + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals( + XmlElementNames.AuthenticationMethods)) { + webClientUrl.setAuthenticationMethods(reader + .readElementValue(String.class)); + } else if (reader.getLocalName().equals(XmlElementNames.Url)) { + webClientUrl.setUrl(reader.readElementValue(String.class)); + } + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.WebClientUrl)); + + return webClientUrl; + } + + /** + * Gets the authentication methods. + * + * @return the authentication methods + */ + public String getAuthenticationMethods() { + return this.authenticationMethods; + } + + /** + * Sets the authentication methods. + * + * @param value the new authentication methods + */ + protected void setAuthenticationMethods(String value) { + this.authenticationMethods = value; + } + + /** + * Gets the URL. + * + * @return the url + */ + public String getUrl() { + return this.url; + } + + /** + * Sets the url. + * + * @param value the new url + */ + protected void setUrl(String value) { + this.url = value; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/WebClientUrlCollection.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/WebClientUrlCollection.java new file mode 100644 index 000000000..40d1f6104 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/WebClientUrlCollection.java @@ -0,0 +1,84 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover; + +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.ArrayList; + +/** + * Represents a user setting that is a collection of Exchange web client URLs. + */ +public final class WebClientUrlCollection { + + /** + * The urls. + */ + private final ArrayList urls; + + /** + * Initializes a new instance of the {@link WebClientUrlCollection} class. + */ + public WebClientUrlCollection() { + this.urls = new ArrayList(); + } + + /** + * Loads instance of WebClientUrlCollection from XML. + * + * @param reader The reader. + * @return the web client url collection + * @throws Exception the exception + */ + public static WebClientUrlCollection loadFromXml(EwsXmlReader reader) + throws Exception { + WebClientUrlCollection instance = new WebClientUrlCollection(); + + do { + reader.read(); + + if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && + (reader.getLocalName() + .equals(XmlElementNames.WebClientUrl))) { + instance.getUrls().add(WebClientUrl.loadFromXml(reader)); + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.WebClientUrls)); + + return instance; + } + + /** + * Gets the URLs. + * + * @return the urls + */ + public ArrayList getUrls() { + return this.urls; + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/ConfigurationSettingsBase.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/ConfigurationSettingsBase.java new file mode 100644 index 000000000..e2bb641dc --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/ConfigurationSettingsBase.java @@ -0,0 +1,149 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.configuration; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverResponseType; +import com.eischet.ews.api.autodiscover.enumeration.UserSettingName; +import com.eischet.ews.api.autodiscover.exception.error.AutodiscoverError; +import com.eischet.ews.api.autodiscover.response.GetUserSettingsResponse; +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; + +import java.net.URI; +import java.util.List; + +/** + * Represents the base class for configuration settings. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class ConfigurationSettingsBase { + + /** + * The error. + */ + private AutodiscoverError error; + + /** + * Initializes a new instance of the ConfigurationSettingsBase class. + */ + public ConfigurationSettingsBase() { + } + + /** + * Tries to read the current XML element. + * + * @param reader the reader + * @return True is the current element was read, false otherwise. + * @throws Exception the exception + */ + public boolean tryReadCurrentXmlElement(EwsXmlReader reader) + throws Exception { + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Error)) { + this.error = AutodiscoverError.parse(reader); + + return true; + } else { + return false; + } + } + + /** + * Loads the settings from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + public void loadFromXml(EwsXmlReader reader) throws Exception { + reader.readStartElement(XmlNamespace.NotSpecified, + XmlElementNames.Autodiscover); + reader.readStartElement(XmlNamespace.NotSpecified, + XmlElementNames.Response); + + do { + reader.read(); + + if (reader.isStartElement()) { + if (!this.tryReadCurrentXmlElement(reader)) { + reader.skipCurrentElement(); + } + } + } while (!reader.isEndElement(XmlNamespace.NotSpecified, + XmlElementNames.Response)); + + reader.readEndElement(XmlNamespace.NotSpecified, + XmlElementNames.Autodiscover); + } + + /** + * Gets the namespace that defines the settings. + * + * @return The namespace that defines the settings + */ + public abstract String getNamespace(); + + /** + * Makes this instance a redirection response. + * + * @param redirectUrl the redirect url + */ + public abstract void makeRedirectionResponse(URI redirectUrl); + + /** + * Gets the type of the response. + * + * @return The type of the response. + */ + public abstract AutodiscoverResponseType getResponseType(); + + /** + * Gets the redirect target. + * + * @return The redirect target. + */ + public abstract String getRedirectTarget(); + + /** + * Convert ConfigurationSettings to GetUserSettings response. + * + * @param smtpAddress SMTP address. + * @param requestedSettings The requested settings. + * @return GetUserSettingsResponse. + */ + public abstract GetUserSettingsResponse convertSettings( + String smtpAddress, + List requestedSettings); + + + /** + * Gets the error. + * + * @return The error. + */ + public AutodiscoverError getError() { + return this.error; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/outlook/OutlookAccount.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/outlook/OutlookAccount.java new file mode 100644 index 000000000..8f476dbb3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/outlook/OutlookAccount.java @@ -0,0 +1,208 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.configuration.outlook; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.autodiscover.AlternateMailbox; +import com.eischet.ews.api.autodiscover.AlternateMailboxCollection; +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverResponseType; +import com.eischet.ews.api.autodiscover.enumeration.OutlookProtocolType; +import com.eischet.ews.api.autodiscover.enumeration.UserSettingName; +import com.eischet.ews.api.autodiscover.response.GetUserSettingsResponse; +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.HashMap; +import java.util.List; + +/** + * Represents an Outlook configuration settings account. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +final class OutlookAccount { + + //region Private constants + /** + * The Constant Settings. + */ + private final static String Settings = "settings"; + + /** + * The Constant RedirectAddr. + */ + private final static String RedirectAddr = "redirectAddr"; + + /** + * The Constant RedirectUrl. + */ + private final static String RedirectUrl = "redirectUrl"; + //endRegion + + private String accountType; + private AutodiscoverResponseType responseType; + + //region Private fields + /** + * The protocols. + */ + private final HashMap protocols; + private final AlternateMailboxCollection alternateMailboxes; + private String redirectTarget; + //endRegion + + /** + * Initializes a new instance of the OutlookAccount class. + */ + protected OutlookAccount() { + this.protocols = new HashMap(); + this.alternateMailboxes = new AlternateMailboxCollection(); + } + + /** + * Parses the specified reader. + * + * @param reader The reader. + * @throws Exception the exception + */ + protected void loadFromXml(EwsXmlReader reader) + throws Exception { + + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals(XmlElementNames.AccountType)) { + this.setAccountType(reader.readElementValue()); + } else if (reader.getLocalName().equals(XmlElementNames.Action)) { + String xmlResponseType = reader.readElementValue(); + if (xmlResponseType.equals(OutlookAccount.Settings)) { + this.setResponseType(AutodiscoverResponseType.Success); + } else if (xmlResponseType + .equals(OutlookAccount.RedirectUrl)) { + this.setResponseType(AutodiscoverResponseType. + RedirectUrl); + } else if (xmlResponseType + .equals(OutlookAccount.RedirectAddr)) { + this.setResponseType( + AutodiscoverResponseType.RedirectAddress); + } else { + this.setResponseType(AutodiscoverResponseType.Error); + } + + } else if (reader.getLocalName().equals( + XmlElementNames.Protocol)) { + OutlookProtocol protocol = new OutlookProtocol(); + protocol.loadFromXml(reader); + this.protocols.put( + protocol.getProtocolType(), protocol); + } else if (reader.getLocalName().equals( + XmlElementNames.RedirectAddr)) { + this.setRedirectTarget(reader.readElementValue()); + } else if (reader.getLocalName().equals( + XmlElementNames.RedirectUrl)) { + this.setRedirectTarget(reader.readElementValue()); + } else if (reader.getLocalName().equals( + XmlElementNames.AlternateMailboxes)) { + AlternateMailbox alternateMailbox = AlternateMailbox. + loadFromXml(reader); + this.alternateMailboxes.getEntries().add(alternateMailbox); + } else { + reader.skipCurrentElement(); + } + } + } while (!reader.isEndElement(XmlNamespace.NotSpecified, + XmlElementNames.Account)); + } + + /** + * Gets the type of the account. + */ + protected void convertToUserSettings(List requestedSettings, + GetUserSettingsResponse response) { + for (OutlookProtocol protocol : this.protocols.values()) { + protocol.convertToUserSettings(requestedSettings, response); + } + + if (requestedSettings.contains(UserSettingName.AlternateMailboxes)) { + response.getSettings().put(UserSettingName. + AlternateMailboxes, this.alternateMailboxes); + } + } + + /** + * Gets the type of the account. + * + * @return the account type + */ + protected String getAccountType() { + return accountType; + } + + /** + * Gets the type of the account. + */ + protected void setAccountType(String value) { + this.accountType = value; + } + + /** + * Gets the type of the response. + * + * @return the response type + */ + protected AutodiscoverResponseType getResponseType() { + return responseType; + } + + /** + * Sets the response type. + * + * @param value the new response type + */ + protected void setResponseType(AutodiscoverResponseType value) { + this.responseType = value; + } + + /** + * Gets the redirect target. + * + * @return the redirect target + */ + protected String getRedirectTarget() { + return redirectTarget; + + } + + /** + * Sets the redirect target. + * + * @param value the new redirect target + */ + protected void setRedirectTarget(String value) { + this.redirectTarget = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/outlook/OutlookConfigurationSettings.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/outlook/OutlookConfigurationSettings.java new file mode 100644 index 000000000..889ecef87 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/outlook/OutlookConfigurationSettings.java @@ -0,0 +1,249 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.configuration.outlook; + +import com.eischet.ews.api.autodiscover.configuration.ConfigurationSettingsBase; +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverErrorCode; +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverResponseType; +import com.eischet.ews.api.autodiscover.enumeration.UserSettingName; +import com.eischet.ews.api.autodiscover.exception.error.UserSettingError; +import com.eischet.ews.api.autodiscover.response.GetUserSettingsResponse; +import com.eischet.ews.api.core.*; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +/** + * Represents Outlook configuration settings. + */ +public final class OutlookConfigurationSettings extends ConfigurationSettingsBase { + + /** + * All user settings that are available from the Outlook provider. + */ + private static final LazyMember> + allOutlookProviderSettings = new LazyMember>( + new ILazyMember>() { + public List createInstance() { + + List results = + new ArrayList(); + for (UserSettingName userSettingName : OutlookUser.getAvailableUserSettings()) { + results.add(userSettingName); + } + results.addAll(OutlookProtocol.getAvailableUserSettings()); + results.add(UserSettingName.AlternateMailboxes); + return results; + } + }); + + + /** + * The user. + */ + private final OutlookUser user; + + /** + * The account. + */ + private OutlookAccount account; + + /** + * Initializes a new instance of the OutlookConfigurationSettings class. + */ + public OutlookConfigurationSettings() { + this.user = new OutlookUser(); + this.account = new OutlookAccount(); + } + + /** + * Determines whether user setting is available in the + * OutlookConfiguration or not. + * + * @param setting The setting. + * @return True if user setting is available, otherwise, false. + */ + protected static boolean isAvailableUserSetting(UserSettingName setting) { + return allOutlookProviderSettings.getMember().contains(setting); + } + + /** + * Gets the namespace that defines the settings. + * + * @return The namespace that defines the settings. + */ + @Override + public String getNamespace() { + return "http://schemas.microsoft.com/exchange/" + + "autodiscover/outlook/responseschema/2006a"; + } + + /** + * Makes this instance a redirection response. + * + * @param redirectUrl The redirect URL. + */ + @Override + public void makeRedirectionResponse(URI redirectUrl) { + this.account = new OutlookAccount(); + this.account.setRedirectTarget(redirectUrl.toString()); + this.account.setResponseType(AutodiscoverResponseType.RedirectUrl); + } + + /** + * Tries to read the current XML element. + * + * @param reader the reader + * @return true is the current element was read, false otherwise + * @throws Exception the exception + */ + @Override + public boolean tryReadCurrentXmlElement(EwsXmlReader reader) throws Exception { + if (!super.tryReadCurrentXmlElement(reader)) { + if (reader.getLocalName().equals(XmlElementNames.User)) { + this.user.loadFromXml(reader); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Account)) { + this.account.loadFromXml(reader); + return true; + } else { + reader.skipCurrentElement(); + return false; + } + } else { + return true; + } + } + + /** + * Convert OutlookConfigurationSettings to GetUserSettings response. + * + * @param smtpAddress SMTP address requested. + * @param requestedSettings The requested settings. + * @return GetUserSettingsResponse + */ + @Override + public GetUserSettingsResponse convertSettings(String smtpAddress, + List requestedSettings) { + GetUserSettingsResponse response = new GetUserSettingsResponse(); + response.setSmtpAddress(smtpAddress); + + if (this.getError() != null) { + response.setErrorCode(AutodiscoverErrorCode.InternalServerError); + response.setErrorMessage(this.getError().getMessage()); + } else { + switch (this.getResponseType()) { + case Success: + response.setErrorCode(AutodiscoverErrorCode.NoError); + response.setErrorMessage(""); + this.user.convertToUserSettings(requestedSettings, response); + this.account.convertToUserSettings(requestedSettings, response); + this.reportUnsupportedSettings(requestedSettings, response); + break; + case Error: + response.setErrorCode(AutodiscoverErrorCode.InternalServerError); + response.setErrorMessage("The Autodiscover service response was invalid."); + break; + case RedirectAddress: + response.setErrorCode(AutodiscoverErrorCode.RedirectAddress); + response.setErrorMessage(""); + response.setRedirectTarget(this.getRedirectTarget()); + break; + case RedirectUrl: + response.setErrorCode(AutodiscoverErrorCode.RedirectUrl); + response.setErrorMessage(""); + response.setRedirectTarget(this.getRedirectTarget()); + break; + default: + EwsUtilities.ewsAssert(false, "OutlookConfigurationSettings.ConvertSettings", + "An unexpected error has occured. " + + "This code path should never be reached."); + break; + } + } + return response; + } + + /** + * Reports any requested user settings that aren't + * supported by the Outlook provider. + * + * @param requestedSettings The requested settings. + * @param response The response. + */ + private void reportUnsupportedSettings(List requestedSettings, + GetUserSettingsResponse response) { + // In English: find settings listed in requestedSettings that are not supported by the Legacy provider. + + //TODO need to check Iterable + List invalidSettingQuery = + new ArrayList(); + for (UserSettingName userSettingName : requestedSettings) { + if (!OutlookConfigurationSettings.isAvailableUserSetting(userSettingName)) { + invalidSettingQuery.add(userSettingName); + } + } + /* from setting in requestedSettings + where !OutlookConfigurationSettings.IsAvailableUserSetting(setting) + select setting;*/ + + // Add any unsupported settings to the UserSettingsError collection. + for (UserSettingName invalidSetting : invalidSettingQuery) { + UserSettingError settingError = new UserSettingError(); + settingError.setErrorCode(AutodiscoverErrorCode.InvalidSetting); + settingError.setSettingName(invalidSetting.toString()); + settingError.setErrorMessage(String.format( + "The requested setting, '%s', isn't supported by this Autodiscover endpoint.", + invalidSetting)); + response.getUserSettingErrors().add(settingError); + } + } + + /** + * Gets the type of the response. + * + * @return The type of the response. + */ + @Override + public AutodiscoverResponseType getResponseType() { + if (this.account != null) { + return this.account.getResponseType(); + } else { + return AutodiscoverResponseType.Error; + } + } + + /** + * Gets the redirect target. + * + * @return String + * the redirect target. + */ + @Override + public String getRedirectTarget() { + return this.account.getRedirectTarget(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/outlook/OutlookProtocol.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/outlook/OutlookProtocol.java new file mode 100644 index 000000000..2c7c02037 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/outlook/OutlookProtocol.java @@ -0,0 +1,808 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.configuration.outlook; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.autodiscover.IFunc; +import com.eischet.ews.api.autodiscover.WebClientUrl; +import com.eischet.ews.api.autodiscover.WebClientUrlCollection; +import com.eischet.ews.api.autodiscover.enumeration.OutlookProtocolType; +import com.eischet.ews.api.autodiscover.enumeration.UserSettingName; +import com.eischet.ews.api.autodiscover.response.GetUserSettingsResponse; +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +/** + * Represents a supported Outlook protocol in an Outlook configurations settings + * account. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +final class OutlookProtocol { + + /** + * The Constant EXCH. + */ + private final static String EXCH = "EXCH"; + + /** + * The Constant EXPR. + */ + private final static String EXPR = "EXPR"; + + /** + * The Constant WEB. + */ + private final static String WEB = "WEB"; + + /** + * Converters to translate common Outlook protocol settings. + * Each entry maps to a lambda expression used to + * get the matching property from the OutlookProtocol instance. + */ + private static final LazyMember>> + commonProtocolSettings = + new LazyMember>>( + new ILazyMember>>() { + public Map> createInstance() { + + Map> results = + new HashMap>(); + + results.put(UserSettingName.EcpDeliveryReportUrlFragment, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.ecpUrlMt; + } + }); + results.put(UserSettingName.EcpEmailSubscriptionsUrlFragment, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.ecpUrlAggr; + } + }); + results.put(UserSettingName.EcpPublishingUrlFragment, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.ecpUrlPublish; + } + }); + results.put(UserSettingName.EcpRetentionPolicyTagsUrlFragment, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.ecpUrlRet; + } + }); + results.put(UserSettingName.EcpTextMessagingUrlFragment, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.ecpUrlSms; + } + }); + results.put(UserSettingName.EcpVoicemailUrlFragment, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.ecpUrlUm; + } + }); + return results; + } + }); + + + /** + * Converters to translate internal (EXCH) Outlook protocol settings. + * Each entry maps to a lambda expression used to + * get the matching property from the OutlookProtocol instance. + */ + private static final LazyMember>> + internalProtocolSettings = + new LazyMember>>( + new ILazyMember>>() { + public Map> createInstance() { + + Map> results = + new HashMap>(); + + results.put(UserSettingName.ActiveDirectoryServer, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.activeDirectoryServer; + } + }); + results.put(UserSettingName.CrossOrganizationSharingEnabled, + new IFunc() { + public Object func(OutlookProtocol arg) { + return String.valueOf(arg.sharingEnabled); + } + }); + results.put(UserSettingName.InternalEcpUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.ecpUrl; + } + }); + results.put(UserSettingName.InternalEcpDeliveryReportUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.convertEcpFragmentToUrl(arg.ecpUrlMt); + } + }); + results.put(UserSettingName.InternalEcpEmailSubscriptionsUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.convertEcpFragmentToUrl(arg.ecpUrlAggr); + } + }); + results.put(UserSettingName.InternalEcpPublishingUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.convertEcpFragmentToUrl(arg.ecpUrlPublish); + } + }); + results.put(UserSettingName.InternalEcpRetentionPolicyTagsUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.convertEcpFragmentToUrl(arg.ecpUrlRet); + } + }); + results.put(UserSettingName.InternalEcpTextMessagingUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.convertEcpFragmentToUrl(arg.ecpUrlSms); + } + }); + results.put(UserSettingName.InternalEcpVoicemailUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.convertEcpFragmentToUrl(arg.ecpUrlUm); + } + }); + results.put(UserSettingName.InternalEwsUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.exchangeWebServicesUrl == null ? + arg.availabilityServiceUrl : arg.exchangeWebServicesUrl; + } + }); + results.put(UserSettingName.InternalMailboxServerDN, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.serverDN; + } + }); + results.put(UserSettingName.InternalRpcClientServer, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.server; + } + }); + results.put(UserSettingName.InternalOABUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.offlineAddressBookUrl; + } + }); + results.put(UserSettingName.InternalUMUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.unifiedMessagingUrl; + } + }); + results.put(UserSettingName.MailboxDN, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.mailboxDN; + } + }); + results.put(UserSettingName.PublicFolderServer, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.publicFolderServer; + } + }); + results.put(UserSettingName.GroupingInformation, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.groupingInformation; + } + }); + + return results; + } + }); + + /** + * Converters to translate external (EXPR) Outlook protocol settings. + * Each entry maps to a lambda expression used to + * get the matching property from the OutlookProtocol instance. + */ + private static final LazyMember>> + externalProtocolSettings = + new LazyMember>>( + new ILazyMember>>() { + public Map> createInstance() { + + Map> results = + new HashMap>(); + + results.put(UserSettingName.ExternalEcpDeliveryReportUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.convertEcpFragmentToUrl(arg.ecpUrlRet); + } + }); + results.put(UserSettingName.ExternalEcpEmailSubscriptionsUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.convertEcpFragmentToUrl(arg.ecpUrlAggr); + } + }); + results.put(UserSettingName.ExternalEcpPublishingUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.convertEcpFragmentToUrl(arg.ecpUrlPublish); + } + }); + results.put(UserSettingName.ExternalEcpRetentionPolicyTagsUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.convertEcpFragmentToUrl(arg.ecpUrlRet); + } + }); + results.put(UserSettingName.ExternalEcpTextMessagingUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.convertEcpFragmentToUrl(arg.ecpUrlSms); + } + }); + results.put(UserSettingName.ExternalEcpUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.ecpUrl; + } + }); + results.put(UserSettingName.ExternalEcpVoicemailUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.convertEcpFragmentToUrl(arg.ecpUrlUm); + } + }); + results.put(UserSettingName.ExternalEwsUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.exchangeWebServicesUrl == null ? + arg.availabilityServiceUrl : arg.exchangeWebServicesUrl; + } + }); + results.put(UserSettingName.ExternalMailboxServer, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.server; + } + }); + results.put( + UserSettingName.ExternalMailboxServerAuthenticationMethods, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.authPackage; + } + }); + results.put( + UserSettingName.ExternalMailboxServerRequiresSSL, + new IFunc() { + public Object func(OutlookProtocol arg) { + return String.valueOf(arg.sslEnabled); + } + }); + results.put(UserSettingName.ExternalOABUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.offlineAddressBookUrl; + } + }); + results.put(UserSettingName.ExternalUMUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.unifiedMessagingUrl; + } + }); + results.put(UserSettingName.ExchangeRpcUrl, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.exchangeRpcUrl; + } + }); + return results; + } + }); + + + /** + * Merged converter dictionary for translating + * internal (EXCH) Outlook protocol settings. + * Each entry maps to a lambda expression used to + * get the matching property from the OutlookProtocol instance. + */ + private static final LazyMember>> + internalProtocolConverterDictionary = + new LazyMember>>( + new ILazyMember>>() { + public Map> createInstance() { + + Map> results = + new HashMap>(); + for (Entry> kv : commonProtocolSettings + .getMember().entrySet()) { + results.put(kv.getKey(), kv.getValue()); + } + for (Entry> kv : internalProtocolSettings + .getMember().entrySet()) { + results.put(kv.getKey(), kv.getValue()); + } + return results; + } + }); + + + /** + * Merged converter dictionary for translating + * external (EXPR) Outlook protocol settings. + * Each entry maps to a lambda expression used to + * get the matching property from the OutlookProtocol instance. + */ + private static final LazyMember>> + externalProtocolConverterDictionary = + new LazyMember>>( + new ILazyMember>>() { + public Map> createInstance() { + + Map> results = + new HashMap>(); + for (Entry> kv : commonProtocolSettings + .getMember().entrySet()) { + results.put(kv.getKey(), kv.getValue()); + } + for (Entry> kv : externalProtocolSettings + .getMember().entrySet()) { + results.put(kv.getKey(), kv.getValue()); + } + return results; + } + }); + + + /** + * Converters to translate Web (WEB) Outlook protocol settings. + * Each entry maps to a lambda expression used to + * get the matching property from the OutlookProtocol instance. + */ + private static final LazyMember>> + webProtocolConverterDictionary = + new LazyMember>>( + new ILazyMember>>() { + public Map> createInstance() { + + Map> results = + new HashMap>(); + + results.put(UserSettingName.InternalWebClientUrls, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.internalOutlookWebAccessUrls; + } + }); + results.put(UserSettingName.ExternalWebClientUrls, + new IFunc() { + public Object func(OutlookProtocol arg) { + return arg.externalOutlookWebAccessUrls; + } + }); + return results; + } + }); + + /** + * Each entry maps to a lambda expression used to + * get the matching property from the OutlookProtocol instance. + */ + private static final LazyMember> + availableUserSettings = + new LazyMember>( + new ILazyMember>() { + public List createInstance() { + + List results = + new ArrayList(); + + results.addAll(commonProtocolSettings. + getMember().keySet()); + results.addAll(internalProtocolSettings. + getMember().keySet()); + results.addAll(externalProtocolSettings. + getMember().keySet()); + results.addAll(webProtocolConverterDictionary. + getMember().keySet()); + return results; + } + }); + + + /** + * Map Outlook protocol name to type. + */ + private static final LazyMember> + protocolNameToTypeMap = + new LazyMember>( + new ILazyMember>() { + @Override + public Map createInstance() { + Map results = + new HashMap(); + results.put(OutlookProtocol.EXCH, OutlookProtocolType.Rpc); + results.put(OutlookProtocol.EXPR, OutlookProtocolType.RpcOverHttp); + results.put(OutlookProtocol.WEB, OutlookProtocolType.Web); + return results; + + } + }); + + + /** + * The constant activeDirectoryServer. + */ + private String activeDirectoryServer; + /** + * The constant authPackage. + */ + private String authPackage; + /** + * The constant availabilityServiceUrl. + */ + private String availabilityServiceUrl; + /** + * The constant ecpUrl. + */ + private String ecpUrl; + /** + * The constant ecpUrlAggr. + */ + private String ecpUrlAggr; + /** + * The constant ecpUrlMt. + */ + private String ecpUrlMt; + /** + * The constant ecpUrlPublish. + */ + private String ecpUrlPublish; + /** + * The constant ecpUrlRet. + */ + private String ecpUrlRet; + /** + * The constant ecpUrlSms. + */ + private String ecpUrlSms; + /** + * The constant ecpUrlUm. + */ + private String ecpUrlUm; + /** + * The constant exchangeWebServicesUrl. + */ + private String exchangeWebServicesUrl; + /** + * The constant mailboxDN. + */ + private String mailboxDN; + /** + * The constant offlineAddressBookUrl. + */ + private String offlineAddressBookUrl; + /** + * The constant exchangeRpcUrl. + */ + private String exchangeRpcUrl; + /** + * The constant publicFolderServer. + */ + private String publicFolderServer; + /** + * The constant server. + */ + private String server; + /** + * The constant serverDN. + */ + private String serverDN; + /** + * The constant unifiedMessagingUrl. + */ + private String unifiedMessagingUrl; + /** + * The constant sharingEnabled. + */ + private boolean sharingEnabled; + /** + * The constant sslEnabled. + */ + private boolean sslEnabled; + /** + * The constant externalOutlookWebAccessUrls. + */ + private final WebClientUrlCollection externalOutlookWebAccessUrls; + /** + * The constant internalOutlookWebAccessUrls. + */ + private final WebClientUrlCollection internalOutlookWebAccessUrls; + /** + * The constant groupingInformation. + */ + private String groupingInformation; + + + /** + * Initializes a new instance of the OutlookProtocol class. + */ + protected OutlookProtocol() { + this.internalOutlookWebAccessUrls = new WebClientUrlCollection(); + this.externalOutlookWebAccessUrls = new WebClientUrlCollection(); + } + + + /** + * Parses the XML using the specified reader and creates an Outlook + * protocol. + * + * @param reader The reader. + * @throws Exception the exception + */ + protected void loadFromXml(EwsXmlReader reader) + throws Exception { + do { + reader.read(); + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals(XmlElementNames.Type)) { + this.setProtocolType(OutlookProtocol. + protocolNameToType(reader.readElementValue())); + } else if (reader.getLocalName().equals(XmlElementNames.AuthPackage)) { + this.authPackage = reader.readElementValue(); + } else if (reader.getLocalName().equals(XmlElementNames.Server)) { + this.server = reader.readElementValue(); + } else if (reader.getLocalName().equals(XmlElementNames.ServerDN)) { + this.serverDN = reader.readElementValue(); + } else if (reader.getLocalName().equals(XmlElementNames.ServerVersion)) { + reader.readElementValue(); + } else if (reader.getLocalName().equals(XmlElementNames.AD)) { + this.activeDirectoryServer = reader.readElementValue(); + } else if (reader.getLocalName().equals(XmlElementNames.MdbDN)) { + this.mailboxDN = reader.readElementValue(); + } else if (reader.getLocalName().equals(XmlElementNames.EWSUrl)) { + this.exchangeWebServicesUrl = reader.readElementValue(); + } else if (reader.getLocalName().equals(XmlElementNames.ASUrl)) { + this.availabilityServiceUrl = reader.readElementValue(); + } else if (reader.getLocalName().equals(XmlElementNames.OOFUrl)) { + reader.readElementValue(); + } else if (reader.getLocalName().equals(XmlElementNames.UMUrl)) { + this.unifiedMessagingUrl = reader.readElementValue(); + } else if (reader.getLocalName().equals(XmlElementNames.OABUrl)) { + this.offlineAddressBookUrl = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.PublicFolderServer)) { + this.publicFolderServer = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.Internal)) { + OutlookProtocol.loadWebClientUrlsFromXml(reader, + this.internalOutlookWebAccessUrls, reader.getLocalName()); + } else if (reader.getLocalName().equals( + XmlElementNames.External)) { + OutlookProtocol.loadWebClientUrlsFromXml(reader, + this.externalOutlookWebAccessUrls, reader.getLocalName()); + } else if (reader.getLocalName().equals( + XmlElementNames.Ssl)) { + String sslStr = reader.readElementValue(); + this.sslEnabled = sslStr.equalsIgnoreCase("On"); + } else if (reader.getLocalName().equals( + XmlElementNames.SharingUrl)) { + this.sharingEnabled = reader. + readElementValue().length() > 0; + } else if (reader.getLocalName().equals( + XmlElementNames.EcpUrl)) { + this.ecpUrl = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.EcpUrl_um)) { + this.ecpUrlUm = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.EcpUrl_aggr)) { + this.ecpUrlAggr = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.EcpUrl_sms)) { + this.ecpUrlSms = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.EcpUrl_mt)) { + this.ecpUrlMt = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.EcpUrl_ret)) { + this.ecpUrlRet = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.EcpUrl_publish)) { + this.ecpUrlPublish = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.ExchangeRpcUrl)) { + this.exchangeRpcUrl = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.GroupingInformation)) { + this.groupingInformation = reader.readElementValue(); + } else { + reader.skipCurrentElement(); + } + } + } while (!reader.isEndElement(XmlNamespace.NotSpecified, + XmlElementNames.Protocol)); + } + + /** + * Convert protocol name to protocol type. + * + * @param protocolName Name of the protocol. + * @return OutlookProtocolType + */ + private static OutlookProtocolType protocolNameToType(String + protocolName) { + OutlookProtocolType protocolType = null; + if (!(protocolNameToTypeMap.getMember().containsKey(protocolName))) { + protocolType = OutlookProtocolType.Unknown; + } else { + protocolType = protocolNameToTypeMap.getMember().get(protocolName); + } + return protocolType; + + } + + /** + * Loads web client urls from XML. + * + * @param reader The reader. + * @param webClientUrls The web client urls. + * @param elementName Name of the element. + * @throws Exception + */ + private static void loadWebClientUrlsFromXml(EwsXmlReader reader, + WebClientUrlCollection webClientUrls, String elementName) throws Exception { + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals(XmlElementNames.OWAUrl)) { + String authMethod = reader.readAttributeValue(XmlAttributeNames.AuthenticationMethod); + String owaUrl = reader.readElementValue(); + WebClientUrl webClientUrl = + new WebClientUrl(authMethod, owaUrl); + webClientUrls.getUrls().add(webClientUrl); + } else { + reader.skipCurrentElement(); + } + } + } + while (!reader.isEndElement(XmlNamespace.NotSpecified, elementName)); + } + + + /** + * Convert ECP fragment to full ECP URL. + * + * @param fragment The fragment. + * @return Full URL string (or null if either portion is empty. + */ + private String convertEcpFragmentToUrl(String fragment) { + return ((this.ecpUrl == null || this.ecpUrl.isEmpty()) || + (fragment == null || fragment.isEmpty())) ? null : (this.ecpUrl + fragment); + } + + /** + * Convert OutlookProtocol to GetUserSettings response. + * + * @param requestedSettings The requested settings. + * @param response The response. + */ + protected void convertToUserSettings( + List requestedSettings, + GetUserSettingsResponse response) { + if (this.getConverterDictionary() != null) { + // In English: collect converters that are contained in the requested settings. + Map> converterQuery = + new HashMap>(); + Map> t = + this.getConverterDictionary(); + for (Entry> map : t.entrySet()) { + if (requestedSettings.contains(map.getKey())) { + converterQuery.put(map.getKey(), map.getValue()); + } + } + + for (Entry> kv : converterQuery.entrySet()) { + Object value = kv.getValue().func(this); + if (value != null) { + response.getSettings().put(kv.getKey(), value); + } + } + } + } + + private OutlookProtocolType protocolType; + + /** + * Gets the type of the protocol. + * + * @return The type of the protocol. + */ + protected OutlookProtocolType getProtocolType() { + return this.protocolType; + } + + /** + * Sets the type of the protocol. + */ + protected void setProtocolType(OutlookProtocolType protocolType) { + this.protocolType = protocolType; + } + + /** + * Gets the converter dictionary for protocol type. + * + * @return The converter dictionary. + */ + private Map> + getConverterDictionary() { + switch (this.getProtocolType()) { + case Rpc: + return internalProtocolConverterDictionary.getMember(); + case RpcOverHttp: + return externalProtocolConverterDictionary.getMember(); + case Web: + return webProtocolConverterDictionary.getMember(); + default: + return null; + } + } + + + /** + * Gets the available user settings. + * + * @return availableUserSettings + */ + protected static List getAvailableUserSettings() { + return availableUserSettings.getMember(); + } +} + diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/outlook/OutlookUser.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/outlook/OutlookUser.java new file mode 100644 index 000000000..da79ade92 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/configuration/outlook/OutlookUser.java @@ -0,0 +1,170 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.configuration.outlook; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.autodiscover.IFunc; +import com.eischet.ews.api.autodiscover.enumeration.UserSettingName; +import com.eischet.ews.api.autodiscover.response.GetUserSettingsResponse; +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.ILazyMember; +import com.eischet.ews.api.core.LazyMember; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +/** + * Represents the user Outlook configuration settings apply to. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +final class OutlookUser { + + /** + * Converters to translate Outlook user settings. + * Each entry maps to a lambda expression used to + * get the matching property from the OutlookUser instance. + */ + private static final LazyMember>> + converterDictionary = + new LazyMember>>( + new ILazyMember>>() { + public Map> createInstance() { + Map> results = + new HashMap>(); + results.put(UserSettingName.UserDisplayName, + new IFunc() { + public String func(OutlookUser arg) { + return arg.displayName; + } + }); + results.put(UserSettingName.UserDN, + new IFunc() { + public String func(OutlookUser arg) { + return arg.legacyDN; + } + }); + results.put(UserSettingName.UserDeploymentId, + new IFunc() { + public String func(OutlookUser arg) { + return arg.deploymentId; + } + }); + return results; + } + }); + + /** + * The display name. + */ + private String displayName; + + /** + * The legacy dn. + */ + private String legacyDN; + + /** + * The deployment id. + */ + private String deploymentId; + + /** + * Initializes a new instance of the OutlookUser class. + */ + protected OutlookUser() { + } + + /** + * Load from XML. + * + * @param reader The reader. + * @throws Exception the exception + */ + protected void loadFromXml(EwsXmlReader reader) throws Exception { + + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals(XmlElementNames.DisplayName)) { + this.displayName = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.LegacyDN)) { + this.legacyDN = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.DeploymentId)) { + this.deploymentId = reader.readElementValue(); + } else { + reader.skipCurrentElement(); + + } + } + } while (!reader.isEndElement(XmlNamespace.NotSpecified, + XmlElementNames.User)); + } + + /** + * Convert OutlookUser to GetUserSettings response. + * + * @param requestedSettings The requested settings. + * @param response The response. + */ + protected void convertToUserSettings( + List requestedSettings, + GetUserSettingsResponse response) { + // In English: collect converters that are + //contained in the requested settings. + Map> + converterQuery = new HashMap>(); + for (Entry> map : converterDictionary.getMember() + .entrySet()) { + if (requestedSettings.contains(map.getKey())) { + converterQuery.put(map.getKey(), map.getValue()); + } + } + + for (Entry> kv : converterQuery.entrySet()) { + String value = kv.getValue().func(this); + if (!(value == null || value.isEmpty())) { + response.getSettings().put(kv.getKey(), value); + } + } + } + + /** + * Gets the available user settings. + * + * @return The available user settings. + */ + protected static Iterable getAvailableUserSettings() { + return converterDictionary.getMember().keySet(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/AutodiscoverEndpoints.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/AutodiscoverEndpoints.java new file mode 100644 index 000000000..7c70906f3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/AutodiscoverEndpoints.java @@ -0,0 +1,74 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.enumeration; + +/** + * Defines the types of Autodiscover endpoints that are available. + */ +public enum AutodiscoverEndpoints { + + /** + * No endpoints available. + */ + None(0), + + /** + * The "legacy" Autodiscover endpoint. + */ + Legacy(1), + + /** + * The SOAP endpoint. + */ + Soap(2), + + /** + * The WS-Security endpoint. + */ + WsSecurity(4), + + /** + * The WS-Security/SymmetricKey endpoint. + */ + WSSecuritySymmetricKey(8), + + /** + * The WS-Security/X509Cert endpoint. + */ + WSSecurityX509Cert(16); + + /** + * The autodiscover end points. + */ + private final int autodiscoverEndPoints; + + /** + * Instantiates a new autodiscover endpoints. + * + * @param autodiscoverEndPoints the autodiscover end points + */ + AutodiscoverEndpoints(int autodiscoverEndPoints) { + this.autodiscoverEndPoints = autodiscoverEndPoints; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/AutodiscoverErrorCode.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/AutodiscoverErrorCode.java new file mode 100644 index 000000000..3cf3aae6f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/AutodiscoverErrorCode.java @@ -0,0 +1,98 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.enumeration; + +/** + * Defines the error codes that can be returned by the Autodiscover service. + */ +public enum AutodiscoverErrorCode { + + // There was no Error. + /** + * The No error. + */ + NoError, + + // The caller must follow the e-mail address redirection that was returned + // by Autodiscover. + /** + * The Redirect address. + */ + RedirectAddress, + + // The caller must follow the URL redirection that was returned by + // Autodiscover. + /** + * The Redirect url. + */ + RedirectUrl, + + // The user that was passed in the request is invalid. + /** + * The Invalid user. + */ + InvalidUser, + + // The request is invalid. + /** + * The Invalid request. + */ + InvalidRequest, + + // A specified setting is invalid. + /** + * The Invalid setting. + */ + InvalidSetting, + + // A specified setting is not available. + /** + * The Setting is not available. + */ + SettingIsNotAvailable, + + // The server is too busy to process the request. + /** + * The Server busy. + */ + ServerBusy, + + // The requested domain is not valid. + /** + * The Invalid domain. + */ + InvalidDomain, + + // The organization is not federated. + /** + * The Not federated. + */ + NotFederated, + + // Internal server error. + /** + * The Internal server error. + */ + InternalServerError, +} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/AutodiscoverResponseType.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/AutodiscoverResponseType.java similarity index 75% rename from src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/AutodiscoverResponseType.java rename to ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/AutodiscoverResponseType.java index bee8d1258..dddffdfb7 100644 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/AutodiscoverResponseType.java +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/AutodiscoverResponseType.java @@ -21,31 +21,31 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.autodiscover.enumeration; +package com.eischet.ews.api.autodiscover.enumeration; /** * Defines the types of response the Autodiscover service can return. */ public enum AutodiscoverResponseType { - // The request returned an error. - /** - * The Error. - */ - Error, - // A URL redirection is necessary. - /** - * The Redirect url. - */ - RedirectUrl, - // An address redirection is necessary. - /** - * The Redirect address. - */ - RedirectAddress, - // The request succeeded. - /** - * The Success. - */ - Success + // The request returned an error. + /** + * The Error. + */ + Error, + // A URL redirection is necessary. + /** + * The Redirect url. + */ + RedirectUrl, + // An address redirection is necessary. + /** + * The Redirect address. + */ + RedirectAddress, + // The request succeeded. + /** + * The Success. + */ + Success } diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/DomainSettingName.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/DomainSettingName.java similarity index 78% rename from src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/DomainSettingName.java rename to ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/DomainSettingName.java index 797580e29..daa944301 100644 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/DomainSettingName.java +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/DomainSettingName.java @@ -21,25 +21,25 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.autodiscover.enumeration; +package com.eischet.ews.api.autodiscover.enumeration; /** * Domain setting names. */ public enum DomainSettingName { - // The external URL of the Exchange Web Services. - /** - * The External ews url. - */ - ExternalEwsUrl, + // The external URL of the Exchange Web Services. + /** + * The External ews url. + */ + ExternalEwsUrl, - /// The version of the Exchange server hosting - /// the URL of the Exchange Web Services. - /** - * The External ews version. - */ - ExternalEwsVersion, + /// The version of the Exchange server hosting + /// the URL of the Exchange Web Services. + /** + * The External ews version. + */ + ExternalEwsVersion, } diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/OutlookProtocolType.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/OutlookProtocolType.java similarity index 75% rename from src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/OutlookProtocolType.java rename to ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/OutlookProtocolType.java index ebcfacd10..3f39f08ea 100644 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/OutlookProtocolType.java +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/OutlookProtocolType.java @@ -21,35 +21,35 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.autodiscover.enumeration; +package com.eischet.ews.api.autodiscover.enumeration; /** * Defines supported Outlook protocls. */ public enum OutlookProtocolType { - // The Remote Procedure Call (RPC) protocol. - /** - * The Rpc. - */ - Rpc, + // The Remote Procedure Call (RPC) protocol. + /** + * The Rpc. + */ + Rpc, - // The Remote Procedure Call (RPC) over HTTP protocol. - /** - * The Rpc over http. - */ - RpcOverHttp, + // The Remote Procedure Call (RPC) over HTTP protocol. + /** + * The Rpc over http. + */ + RpcOverHttp, - // The Web protocol. - /** - * The Web. - */ - Web, + // The Web protocol. + /** + * The Web. + */ + Web, - // The protocol is unknown. - /** - * The Unknown. - */ - Unknown + // The protocol is unknown. + /** + * The Unknown. + */ + Unknown } diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/UserSettingName.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/UserSettingName.java new file mode 100644 index 000000000..5f493d7d8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/enumeration/UserSettingName.java @@ -0,0 +1,360 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.enumeration; + +/** + * The Enum UserSettingName. + */ +public enum UserSettingName { + + // The display name of the user. + /** + * The User display name. + */ + UserDisplayName, + + // The legacy distinguished name of the user. + /** + * The User dn. + */ + UserDN, + + // The deployment Id of the user. + /** + * The User deployment id. + */ + UserDeploymentId, + + // The fully qualified domain name of the mailbox server. + /** + * The Internal mailbox server. + */ + InternalMailboxServer, + + // The fully qualified domain name of the RPC client server. + /** + * The Internal rpc client server. + */ + InternalRpcClientServer, + + // The legacy distinguished name of the mailbox server. + /** + * The Internal mailbox server dn. + */ + InternalMailboxServerDN, + + // The internal URL of the Exchange Control Panel. + /** + * The Internal ecp url. + */ + InternalEcpUrl, + + // The internal URL of the Exchange Control Panel for VoiceMail + // Customization. + /** + * The Internal ecp voicemail url. + */ + InternalEcpVoicemailUrl, + + // The internal URL of the Exchange Control Panel for Email Subscriptions. + /** + * The Internal ecp email subscriptions url. + */ + InternalEcpEmailSubscriptionsUrl, + + // The internal URL of the Exchange Control Panel for Text Messaging. + /** + * The Internal ecp text messaging url. + */ + InternalEcpTextMessagingUrl, + + // The internal URL of the Exchange Control Panel for Delivery Reports. + /** + * The Internal ecp delivery report url. + */ + InternalEcpDeliveryReportUrl, + + /// The internal URL of the Exchange Control Panel for RetentionPolicy Tags. + /** + * The Internal ecp retention policy tags url. + */ + InternalEcpRetentionPolicyTagsUrl, + + /// The internal URL of the Exchange Control Panel for Publishing. + /** + * The Internal ecp publishing url. + */ + InternalEcpPublishingUrl, + + // The internal URL of the Exchange Web Services. + /** + * The Internal ews url. + */ + InternalEwsUrl, + + // The internal URL of the Offline Address Book. + /** + * The Internal oab url. + */ + InternalOABUrl, + + // The internal URL of the Unified Messaging services. + /** + * The Internal um url. + */ + InternalUMUrl, + + // The internal URLs of the Exchange web client. + /** + * The Internal web client urls. + */ + InternalWebClientUrls, + + // The distinguished name of the mailbox database of the user's mailbox. + /** + * The Mailbox dn. + */ + MailboxDN, + + // The name of the Public Folders server. + /** + * The Public folder server. + */ + PublicFolderServer, + + // The name of the Active Directory server. + /** + * The Active directory server. + */ + ActiveDirectoryServer, + + // The name of the RPC over HTTP server. + /** + * The External mailbox server. + */ + ExternalMailboxServer, + + // Indicates whether the RPC over HTTP server requires SSL. + /** + * The External mailbox server requires ssl. + */ + ExternalMailboxServerRequiresSSL, + + // The authentication methods supported by the RPC over HTTP server. + /** + * The External mailbox server authentication methods. + */ + ExternalMailboxServerAuthenticationMethods, + + // The URL fragment of the Exchange Control Panel for VoiceMail + // Customization. + /** + * The Ecp voicemail url fragment. + */ + EcpVoicemailUrlFragment, + + // The URL fragment of the Exchange Control Panel for Email Subscriptions. + /** + * The Ecp email subscriptions url fragment. + */ + EcpEmailSubscriptionsUrlFragment, + + // The URL fragment of the Exchange Control Panel for Text Messaging. + /** + * The Ecp text messaging url fragment. + */ + EcpTextMessagingUrlFragment, + + // The URL fragment of the Exchange Control Panel for Delivery Reports. + /** + * The Ecp delivery report url fragment. + */ + EcpDeliveryReportUrlFragment, + + /// The URL fragment of the Exchange Control Panel for RetentionPolicy Tags. + /** + * The Ecp retention policy tags url fragment. + */ + EcpRetentionPolicyTagsUrlFragment, + + /// The URL fragment of the Exchange Control Panel for Publishing. + /** + * The Ecp publishing url fragment. + */ + EcpPublishingUrlFragment, + + // The external URL of the Exchange Control Panel. + /** + * The External ecp url. + */ + ExternalEcpUrl, + + // The external URL of the Exchange Control Panel for VoiceMail + // Customization. + /** + * The External ecp voicemail url. + */ + ExternalEcpVoicemailUrl, + + // The external URL of the Exchange Control Panel for Email Subscriptions. + /** + * The External ecp email subscriptions url. + */ + ExternalEcpEmailSubscriptionsUrl, + + // The external URL of the Exchange Control Panel for Text Messaging. + /** + * The External ecp text messaging url. + */ + ExternalEcpTextMessagingUrl, + + // The external URL of the Exchange Control Panel for Delivery Reports. + /** + * The External ecp delivery report url. + */ + ExternalEcpDeliveryReportUrl, + + /// The external URL of the Exchange Control Panel for RetentionPolicy Tags. + /** + * The External ecp retention policy tags url. + */ + ExternalEcpRetentionPolicyTagsUrl, + + /// The external URL of the Exchange Control Panel for Publishing. + /** + * The External ecp publishing url. + */ + ExternalEcpPublishingUrl, + + // The external URL of the Exchange Web Services. + /** + * The External ews url. + */ + ExternalEwsUrl, + + // The external URL of the Offline Address Book. + /** + * The External oab url. + */ + ExternalOABUrl, + + // The external URL of the Unified Messaging services. + /** + * The External um url. + */ + ExternalUMUrl, + + // The external URLs of the Exchange web client. + /** + * The External web client urls. + */ + ExternalWebClientUrls, + + // Indicates that cross-organization sharing is enabled. + /** + * The Cross organization sharing enabled. + */ + CrossOrganizationSharingEnabled, + + // Collection of alternate mailboxes. + /** + * The Alternate mailboxes. + */ + AlternateMailboxes, + + // The version of the Client Access Server serving the request (e.g. + // 14.XX.YYY.ZZZ) + /** + * The Cas version. + */ + CasVersion, + + // Comma-separated list of schema versions supported by Exchange Web + // Services. The schema version values + // will be the same as the values of the ExchangeServerVersion enumeration. + /** + * The Ews supported schema. + */ + EwsSupportedSchemas, + + // The internal connection settings list for pop protocol + /** + * The Internal pop3 connections. + */ + InternalPop3Connections, + + // The external connection settings list for pop protocol + /** + * The External pop3 connections. + */ + ExternalPop3Connections, + + // The internal connection settings list for imap4 protocol + /** + * The Internal imap4 connections. + */ + InternalImap4Connections, + + // The external connection settings list for imap4 protocol + /** + * The External imap4 connections. + */ + ExternalImap4Connections, + + // The internal connection settings list for smtp protocol + /** + * The Internal smtp connections. + */ + InternalSmtpConnections, + + // The external connection settings list for smtp protocol + /** + * The External smtp connections. + */ + ExternalSmtpConnections, + + /// If set, then clients can call the server via XTC + /** + * The Exchange Rpc Url. + */ + ExchangeRpcUrl, + + /// The version of the Exchange Web Services + ///server ExternalEwsUrl is pointing to. + /** + * The External Ews Version. + */ + ExternalEwsVersion, + + /** + * Mobile Mailbox policy settings. + */ + + MobileMailboxPolicy, + + /** + * The grouping hint for certain clients. + */ + GroupingInformation, +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/AutodiscoverLocalException.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/AutodiscoverLocalException.java new file mode 100644 index 000000000..ae29e0e67 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/AutodiscoverLocalException.java @@ -0,0 +1,65 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.exception; + +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; + +/** + * Represents an exception that is thrown when the Autodiscover service could + * not be contacted. + */ +public class AutodiscoverLocalException extends ServiceLocalException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * Initializes a new instance of the class. + */ + public AutodiscoverLocalException() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param message the message + */ + public AutodiscoverLocalException(String message) { + super(message); + } + + /** + * Initializes a new instance of the class. + * + * @param message the message + * @param innerException the inner exception + */ + public AutodiscoverLocalException(String message, + Exception innerException) { + super(message, innerException); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/AutodiscoverRemoteException.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/AutodiscoverRemoteException.java new file mode 100644 index 000000000..a0c808f69 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/AutodiscoverRemoteException.java @@ -0,0 +1,87 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.exception; + +import com.eischet.ews.api.autodiscover.exception.error.AutodiscoverError; +import com.eischet.ews.api.core.exception.service.remote.ServiceRemoteException; + +/** + * Represents an exception that is thrown when the Autodiscover service returns + * an error. + */ +public class AutodiscoverRemoteException extends ServiceRemoteException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * The error. + */ + private final AutodiscoverError error; + + /** + * Initializes a new instance of the class. + * + * @param error the error + */ + public AutodiscoverRemoteException(AutodiscoverError error) { + super(); + this.error = error; + } + + /** + * Initializes a new instance of the class. + * + * @param message the message + * @param error the error + */ + public AutodiscoverRemoteException(String message, AutodiscoverError error) { + super(message); + this.error = error; + } + + /** + * Initializes a new instance of the class. + * + * @param message the message + * @param error the error + * @param innerException the inner exception + */ + public AutodiscoverRemoteException(String message, AutodiscoverError error, + Exception innerException) { + super(message, innerException); + this.error = error; + } + + /** + * Gets the error. + * + * @return the error + */ + public AutodiscoverError getError() { + return this.error; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/AutodiscoverResponseException.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/AutodiscoverResponseException.java new file mode 100644 index 000000000..6dde74e14 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/AutodiscoverResponseException.java @@ -0,0 +1,63 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.exception; + +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverErrorCode; +import com.eischet.ews.api.core.exception.service.remote.ServiceRemoteException; + +/** + * Represents an exception from an autodiscover error response. + */ +public class AutodiscoverResponseException extends ServiceRemoteException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * Error code when Autodiscover service operation failed remotely. + */ + private final AutodiscoverErrorCode errorCode; + + /** + * Initializes a new instance of the class. + * + * @param errorCode the error code + * @param message the message + */ + public AutodiscoverResponseException(AutodiscoverErrorCode errorCode, String message) { + super(message); + this.errorCode = errorCode; + } + + /** + * Gets the ErrorCode for the exception. + * + * @return the error code + */ + public AutodiscoverErrorCode getErrorCode() { + return this.errorCode; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/MaximumRedirectionHopsExceededException.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/MaximumRedirectionHopsExceededException.java new file mode 100644 index 000000000..fd9857424 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/MaximumRedirectionHopsExceededException.java @@ -0,0 +1,63 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.exception; + +/** + * The Class MaximumRedirectionHopsExceededException. + * + * @see com.eischet.ews.api.autodiscover.AutodiscoverService + */ +public class MaximumRedirectionHopsExceededException extends AutodiscoverLocalException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * Initializes a new instance of the class. + */ + public MaximumRedirectionHopsExceededException() { + } + + /** + * Initializes a new instance of the class. + * + * @param message the message + */ + public MaximumRedirectionHopsExceededException(String message) { + super(message); + } + + /** + * Initializes a new instance of the class. + * + * @param message the message + * @param innerException the inner exception + */ + public MaximumRedirectionHopsExceededException(String message, Exception innerException) { + super(message, innerException); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/error/AutodiscoverError.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/error/AutodiscoverError.java new file mode 100644 index 000000000..fb6231872 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/error/AutodiscoverError.java @@ -0,0 +1,154 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.exception.error; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +/** + * Defines the AutodiscoverError class. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class AutodiscoverError { + + /** + * The time. + */ + private String time; + + /** + * The id. + */ + private String id; + + /** + * The error code. + */ + private int errorCode; + + /** + * The message. + */ + private String message; + + /** + * The debug data. + */ + private String debugData; + + /** + * Initializes a new instance of the AutodiscoverError class. + */ + private AutodiscoverError() { + } + + /** + * Parses the XML through the specified reader and creates an Autodiscover + * error. + * + * @param reader the reader + * @return AutodiscoverError + * @throws Exception the exception + */ + public static AutodiscoverError parse(EwsXmlReader reader) + throws Exception { + AutodiscoverError error = new AutodiscoverError(); + error.time = reader.readAttributeValue(XmlAttributeNames.Time); + error.id = reader.readAttributeValue(XmlAttributeNames.Id); + + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.ErrorCode)) { + error.errorCode = reader.readElementValue(Integer.class); + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.Message)) { + error.message = reader.readElementValue(); + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.DebugData)) { + error.debugData = reader.readElementValue(); + } else { + reader.skipCurrentElement(); + } + } + } while (!reader.isEndElement(XmlNamespace.NotSpecified, + XmlElementNames.Error)); + + return error; + } + + /** + * Gets the time when the error was returned. + * + * @return the time + */ + public String getTime() { + return time; + } + + /** + * Gets a hash of the name of the computer that is running Microsoft + * Exchange Server that has the Client Access server role installed. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Gets the error code. + * + * @return the error code + */ + public int getErrorCode() { + return errorCode; + } + + /** + * Gets the error message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Gets the debug data. + * + * @return the debug data + */ + public String getDebugData() { + return debugData; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/error/DomainSettingError.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/error/DomainSettingError.java new file mode 100644 index 000000000..db0082a80 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/error/DomainSettingError.java @@ -0,0 +1,113 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.exception.error; + +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverErrorCode; +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +/** + * Represents an error from a GetDomainSettings request. + */ +public final class DomainSettingError { + + /** + * The error code. + */ + private AutodiscoverErrorCode errorCode; + + /** + * The error message. + */ + private String errorMessage; + + /** + * The setting name. + */ + private String settingName; + + /** + * Initializes a new instance of the {@link DomainSettingError} class. + */ + public DomainSettingError() { + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @throws Exception the exception + */ + public void loadFromXml(EwsXmlReader reader) throws Exception { + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals(XmlElementNames.ErrorCode)) { + this.errorCode = reader + .readElementValue(AutodiscoverErrorCode.class); + } else if (reader.getLocalName().equals( + XmlElementNames.ErrorMessage)) { + this.errorMessage = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.SettingName)) { + this.settingName = reader.readElementValue(); + } + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.DomainSettingError)); + } + + /** + * Gets the error code. + * + * @return The error code. + */ + + public AutodiscoverErrorCode getErrorCode() { + return this.errorCode; + } + + /** + * Gets the error message. + * + * @return The error message. + */ + + public String getErrorMessage() { + return this.errorMessage; + } + + /** + * Gets the name of the setting. + * + * @return The name of the setting. + */ + public String getSettingName() { + return this.settingName; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/error/UserSettingError.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/error/UserSettingError.java new file mode 100644 index 000000000..4429aab8a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/exception/error/UserSettingError.java @@ -0,0 +1,139 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.exception.error; + +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverErrorCode; +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +/** + * Represents an error from a GetUserSettings request. + */ +public final class UserSettingError { + + /** + * The error code. + */ + private AutodiscoverErrorCode errorCode; + + /** + * The error message. + */ + private String errorMessage; + + /** + * The setting name. + */ + private String settingName; + + /** + * Initializes a new instance of the "UserSettingError" class. + */ + public UserSettingError() { + } + + /** + * Initializes a new instance of the "UserSettingError" class. + * + * @param errorCode The error code + * @param errorMessage The error message + * @param settingName Name of the setting + */ + protected UserSettingError(AutodiscoverErrorCode errorCode, + String errorMessage, String settingName) { + this.errorCode = errorCode; + this.errorMessage = errorMessage; + this.settingName = settingName; + } + + + /** + * Loads from XML. + * + * @param reader The reader. + * @throws Exception the exception + */ + public void loadFromXml(EwsXmlReader reader) throws Exception { + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals(XmlElementNames.ErrorCode)) { + this.setErrorCode(reader + .readElementValue(AutodiscoverErrorCode.class)); + } else if (reader.getLocalName().equals( + XmlElementNames.ErrorMessage)) { + this.setErrorMessage(reader.readElementValue()); + } else if (reader.getLocalName().equals( + XmlElementNames.SettingName)) { + this.setSettingName(reader.readElementValue()); + } + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.UserSettingError)); + } + + /** + * Gets the error code. + * + * @return The error code. + */ + public AutodiscoverErrorCode getErrorCode() { + return errorCode; + } + + public void setErrorCode(AutodiscoverErrorCode errorCode) { + this.errorCode = errorCode; + } + + /** + * Gets the error message. + * + * @return The error message. + */ + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + + /** + * Gets the name of the setting. + * + * @return The name of the setting. + */ + public String getSettingName() { + return settingName; + } + + public void setSettingName(String settingName) { + this.settingName = settingName; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/request/ApplyConversationActionRequest.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/request/ApplyConversationActionRequest.java new file mode 100644 index 000000000..5fba044fd --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/request/ApplyConversationActionRequest.java @@ -0,0 +1,162 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.request.MultiResponseServiceRequest; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.misc.ConversationAction; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a request to a Apply Conversation Action operation + */ +public final class ApplyConversationActionRequest extends MultiResponseServiceRequest { + + private final List conversationActions = + new ArrayList(); + + public List getConversationActions() { + return this.conversationActions; + } + + /** + * Initializes a new instance of the ApplyConversationActionRequest class + * + * @param service The service + * @param errorHandlingMode Indicates how errors should be handled + * @throws Exception on error + */ + public ApplyConversationActionRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) throws Exception { + super(service, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param service The service. + * @param responseIndex Index of the response. + * @return Service response. + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new ServiceResponse(); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.conversationActions.size(); + } + + /** + * Validate request. + * + * @throws Exception on validation error + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParamCollection( + conversationActions.iterator(), "conversationActions" + ); + + for (int iAction = 0; iAction < this.getConversationActions().size(); iAction++) { + this.getConversationActions().get(iAction).validate(); + } + } + + + /** + * Writes XML elements. + * + * @param writer The writer. + * @throws Exception on validation error + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) throws Exception { + writer.writeStartElement( + XmlNamespace.Messages, + XmlElementNames.ConversationActions); + for (int iAction = 0; iAction < this.getConversationActions().size(); iAction++) { + this.getConversationActions().get(iAction). + writeElementsToXml(writer); + } + writer.writeEndElement(); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.ApplyConversationAction; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.ApplyConversationActionResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.ApplyConversationActionResponseMessage; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010_SP1; + } +} + diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/request/AutodiscoverRequest.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/request/AutodiscoverRequest.java new file mode 100644 index 000000000..595d7f328 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/request/AutodiscoverRequest.java @@ -0,0 +1,737 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.request; + +import com.eischet.ews.api.EWSConstants; +import com.eischet.ews.api.autodiscover.AutodiscoverService; +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverErrorCode; +import com.eischet.ews.api.autodiscover.exception.AutodiscoverResponseException; +import com.eischet.ews.api.autodiscover.response.AutodiscoverResponse; +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.TraceFlags; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.http.EWSHttpException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.service.remote.ServiceRemoteException; +import com.eischet.ews.api.core.exception.service.remote.ServiceRequestException; +import com.eischet.ews.api.core.exception.service.remote.ServiceResponseException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.http.ExchangeHttpClient; +import com.eischet.ews.api.misc.SoapFaultDetails; +import com.eischet.ews.api.security.XmlNodeType; + +import javax.xml.stream.XMLStreamException; +import java.io.*; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.zip.GZIPInputStream; +import java.util.zip.InflaterInputStream; + +/** + * Represents the base class for all requested made to the Autodiscover service. + */ +public abstract class AutodiscoverRequest { + + private static final Logger LOG = Logger.getLogger(AutodiscoverRequest.class.getCanonicalName()); + + /** + * The service. + */ + private final AutodiscoverService service; + + /** + * The url. + */ + private final URI url; + + /** + * Initializes a new instance of the AutodiscoverResponse class. + * + * @param service Autodiscover service associated with this request. + * @param url URL of Autodiscover service. + */ + protected AutodiscoverRequest(AutodiscoverService service, URI url) { + this.service = service; + this.url = url; + } + + /** + * Determines whether response is a redirection. + * + * @param request the request + * @return True if redirection response. + * @throws EWSHttpException the EWS http exception + */ + public static boolean isRedirectionResponse(ExchangeHttpClient.Request request) + throws EWSHttpException { + return ((request.getResponseCode() == 301) + || (request.getResponseCode() == 302) + || (request.getResponseCode() == 307) || (request + .getResponseCode() == 303)); + } + + /** + * Validates the request. + * + * @throws Exception the exception + */ + protected void validate() throws Exception { + this.getService().validate(); + } + + /** + * Executes this instance. + * + * @return the autodiscover response + * @throws Exception the exception + */ + protected AutodiscoverResponse internalExecute() throws Exception { + this.validate(); + ExchangeHttpClient.Request request = null; + try { + request = this.service.prepareHttpWebRequestForUrl(this.url); + this.service.traceHttpRequestHeaders( + TraceFlags.AutodiscoverRequestHttpHeaders, request); + + boolean needSignature = this.getService().getCredentials() != null + && this.getService().getCredentials().isNeedSignature(); + boolean needTrace = this.getService().isTraceEnabledFor( + TraceFlags.AutodiscoverRequest); + + OutputStream urlOutStream = request.getOutputStream(); + + ByteArrayOutputStream memoryStream = new ByteArrayOutputStream(); + EwsServiceXmlWriter writer = new EwsServiceXmlWriter(this + .getService(), memoryStream); + writer.setRequireWSSecurityUtilityNamespace(needSignature); + this.writeSoapRequest(this.url, writer); + + if (needSignature) { + this.service.getCredentials().sign(memoryStream); + } + + if (needTrace) { + memoryStream.flush(); + this.service.traceXml(TraceFlags.AutodiscoverRequest, + memoryStream); + } + memoryStream.writeTo(urlOutStream); + urlOutStream.flush(); + urlOutStream.close(); + memoryStream.close(); + // out.write(memoryStream.toString()); + // out.close(); + request.executeRequest(); + request.getResponseCode(); + if (AutodiscoverRequest.isRedirectionResponse(request)) { + AutodiscoverResponse response = this + .createRedirectionResponse(request); + if (response != null) { + return response; + } else { + throw new ServiceRemoteException("The service returned an invalid redirection response."); + } + } + + memoryStream = new ByteArrayOutputStream(); + InputStream serviceResponseStream = request.getInputStream(); + + while (true) { + int data = serviceResponseStream.read(); + if (-1 == data) { + break; + } else { + memoryStream.write(data); + } + } + memoryStream.flush(); + serviceResponseStream.close(); + + if (this.service.isTraceEnabled()) { + this.service.traceResponse(request, memoryStream); + } + ByteArrayInputStream memoryStreamIn = new ByteArrayInputStream( + memoryStream.toByteArray()); + EwsXmlReader ewsXmlReader = new EwsXmlReader(memoryStreamIn); + + // WCF may not generate an XML declaration. + ewsXmlReader.read(); + if (ewsXmlReader.getNodeType().getNodeType() == XmlNodeType.START_DOCUMENT) { + ewsXmlReader.readStartElement(XmlNamespace.Soap, + XmlElementNames.SOAPEnvelopeElementName); + } else if ((ewsXmlReader.getNodeType().getNodeType() != XmlNodeType.START_ELEMENT) + || (!ewsXmlReader.getLocalName().equals( + XmlElementNames.SOAPEnvelopeElementName)) + || (!ewsXmlReader.getNamespaceUri().equals( + EwsUtilities.getNamespaceUri(XmlNamespace.Soap)))) { + throw new ServiceXmlDeserializationException("The Autodiscover service response was invalid."); + } + + this.readSoapHeaders(ewsXmlReader); + + AutodiscoverResponse response = this.readSoapBody(ewsXmlReader); + + ewsXmlReader.readEndElement(XmlNamespace.Soap, + XmlElementNames.SOAPEnvelopeElementName); + + if (response.getErrorCode() == AutodiscoverErrorCode.NoError) { + return response; + } else { + throw new AutodiscoverResponseException( + response.getErrorCode(), response.getErrorMessage()); + } + + } catch (XMLStreamException ex) { + this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format("XML parsing error: %s", ex.getMessage())); + + // Wrap exception + throw new ServiceRequestException(String.format("The request failed. %s", ex.getMessage()), ex); + } catch (IOException ex) { + this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, + String.format("I/O error: %s", ex.getMessage())); + + // Wrap exception + throw new ServiceRequestException(String.format("The request failed. %s", ex.getMessage()), ex); + } catch (Exception ex) { + // HttpWebRequest httpWebResponse = (HttpWebRequest)ex; + + if (null != request && request.getResponseCode() == 7) { + if (AutodiscoverRequest.isRedirectionResponse(request)) { + this.service + .processHttpResponseHeaders( + TraceFlags.AutodiscoverResponseHttpHeaders, + request); + + AutodiscoverResponse response = this + .createRedirectionResponse(request); + if (response != null) { + return response; + } + } else { + this.processWebException(ex, request); + } + } + + // Wrap exception if the above code block didn't throw + throw new ServiceRequestException(String.format("The request failed. %s", ex.getMessage()), ex); + } finally { + try { + if (request != null) { + request.close(); + } + } catch (Exception e) { + // do nothing + } + } + } + + /** + * Processes the web exception. + * @param exception WebException + * @param req HttpWebRequest + */ + private void processWebException(Exception exception, ExchangeHttpClient.Request req) { + if (null != req) { + try { + if (500 == req.getResponseCode()) { + if (this.service + .isTraceEnabledFor( + TraceFlags.AutodiscoverRequest)) { + ByteArrayOutputStream memoryStream = + new ByteArrayOutputStream(); + InputStream serviceResponseStream = AutodiscoverRequest + .getResponseStream(req); + while (true) { + int data = serviceResponseStream.read(); + if (-1 == data) { + break; + } else { + memoryStream.write(data); + } + } + memoryStream.flush(); + serviceResponseStream.close(); + this.service.traceResponse(req, memoryStream); + ByteArrayInputStream memoryStreamIn = + new ByteArrayInputStream( + memoryStream.toByteArray()); + EwsXmlReader reader = new EwsXmlReader(memoryStreamIn); + this.readSoapFault(reader); + memoryStream.close(); + } else { + InputStream serviceResponseStream = AutodiscoverRequest + .getResponseStream(req); + EwsXmlReader reader = new EwsXmlReader( + serviceResponseStream); + SoapFaultDetails soapFaultDetails = this.readSoapFault(reader); + serviceResponseStream.close(); + + if (soapFaultDetails != null) { + throw new ServiceResponseException( + new ServiceResponse(soapFaultDetails)); + } + } + } else { + this.service.processHttpErrorResponse(req, exception); + } + } catch (Exception e) { + LOG.log(Level.SEVERE, "error processing web exception", e); + } + } + } + + /** + * Create a redirection response. + * + * @param httpWebResponse the HTTP web response + * @return AutodiscoverResponse autodiscoverResponse object + * @throws XMLStreamException the XML stream exception + * @throws IOException signals that an I/O exception has occurred + * @throws EWSHttpException the EWS http exception + */ + private AutodiscoverResponse createRedirectionResponse( + ExchangeHttpClient.Request httpWebResponse) throws XMLStreamException, + IOException, EWSHttpException { + String location = httpWebResponse.getResponseHeaderField("Location"); + if (!(location == null || location.isEmpty())) { + try { + URI redirectionUri = new URI(location); + String scheme = redirectionUri.getScheme(); + + if (scheme.equalsIgnoreCase(EWSConstants.HTTP_SCHEME) + || scheme.equalsIgnoreCase(EWSConstants.HTTPS_SCHEME)) { + AutodiscoverResponse response = this.createServiceResponse(); + response.setErrorCode(AutodiscoverErrorCode.RedirectUrl); + response.setRedirectionUrl(redirectionUri); + return response; + } + + this.service + .traceMessage( + TraceFlags.AutodiscoverConfiguration, + String + .format( + "Invalid redirection" + + " URL '%s' " + + "returned by Autodiscover " + + "service.", + redirectionUri)); + + } catch (URISyntaxException ex) { + this.service + .traceMessage( + TraceFlags.AutodiscoverConfiguration, + String + .format( + "Invalid redirection " + + "location '%s' " + + "returned by Autodiscover " + + "service.", + location)); + } + } else { + this.service + .traceMessage( + TraceFlags.AutodiscoverConfiguration, + "Redirection response returned by Autodiscover " + + "service without redirection location."); + } + + return null; + } + + /** + * Reads the SOAP fault. + * + * @param reader The reader. + * @return SOAP fault details. + */ + private SoapFaultDetails readSoapFault(EwsXmlReader reader) { + SoapFaultDetails soapFaultDetails = null; + + try { + + reader.read(); + if (reader.getNodeType().getNodeType() == XmlNodeType.START_DOCUMENT) { + reader.read(); + } + if (!reader.isStartElement() + || (!reader.getLocalName().equals( + XmlElementNames.SOAPEnvelopeElementName))) { + return null; + } + + // Get the namespace URI from the envelope element and use it for + // the rest of the parsing. + // If it's not 1.1 or 1.2, we can't continue. + XmlNamespace soapNamespace = EwsUtilities.getNamespaceFromUri(reader.getNamespaceUri()); + if (soapNamespace == XmlNamespace.NotSpecified) { + return null; + } + + reader.read(); + + // Skip SOAP header. + if (reader.isStartElement(soapNamespace, + XmlElementNames.SOAPHeaderElementName)) { + do { + reader.read(); + } while (!reader.isEndElement(soapNamespace, + XmlElementNames.SOAPHeaderElementName)); + + // Queue up the next read + reader.read(); + } + + // Parse the fault element contained within the SOAP body. + if (reader.isStartElement(soapNamespace, + XmlElementNames.SOAPBodyElementName)) { + do { + reader.read(); + + // Parse Fault element + if (reader.isStartElement(soapNamespace, + XmlElementNames.SOAPFaultElementName)) { + soapFaultDetails = SoapFaultDetails.parse(reader, + soapNamespace); + } + } while (!reader.isEndElement(soapNamespace, + XmlElementNames.SOAPBodyElementName)); + } + + reader.readEndElement(soapNamespace, + XmlElementNames.SOAPEnvelopeElementName); + } catch (Exception e) { + // If response doesn't contain a valid SOAP fault, just ignore + // exception and + // return null for SOAP fault details. + LOG.log(Level.SEVERE, "error reading SOAP fault", e); + } + + return soapFaultDetails; + } + + /** + * Writes the autodiscover SOAP request. + * + * @param requestUrl request URL + * @param writer writer object + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + protected void writeSoapRequest(URI requestUrl, EwsServiceXmlWriter writer) throws XMLStreamException, ServiceXmlSerializationException, ExchangeXmlException { + + if (writer.isRequireWSSecurityUtilityNamespace()) { + writer.writeAttributeValue("xmlns", + EwsUtilities.WSSecurityUtilityNamespacePrefix, + EwsUtilities.WSSecurityUtilityNamespace); + } + writer.writeStartDocument(); + writer.writeStartElement(XmlNamespace.Soap, + XmlElementNames.SOAPEnvelopeElementName); + writer.writeAttributeValue("xmlns", EwsUtilities + .getNamespacePrefix(XmlNamespace.Soap), EwsUtilities + .getNamespaceUri(XmlNamespace.Soap)); + writer.writeAttributeValue("xmlns", + EwsUtilities.AutodiscoverSoapNamespacePrefix, + EwsUtilities.AutodiscoverSoapNamespace); + writer.writeAttributeValue("xmlns", + EwsUtilities.WSAddressingNamespacePrefix, + EwsUtilities.WSAddressingNamespace); + writer.writeAttributeValue("xmlns", + EwsUtilities.EwsXmlSchemaInstanceNamespacePrefix, + EwsUtilities.EwsXmlSchemaInstanceNamespace); + + writer.writeStartElement(XmlNamespace.Soap, + XmlElementNames.SOAPHeaderElementName); + + if (this.service.getCredentials() != null) { + this.service.getCredentials().emitExtraSoapHeaderNamespaceAliases( + writer.getInternalWriter()); + } + + writer.writeElementValue(XmlNamespace.Autodiscover, + XmlElementNames.RequestedServerVersion, this.service + .getRequestedServerVersion().toString()); + + writer.writeElementValue(XmlNamespace.WSAddressing, + XmlElementNames.Action, this.getWsAddressingActionName()); + + writer.writeElementValue(XmlNamespace.WSAddressing, XmlElementNames.To, + requestUrl.toString()); + + this.writeExtraCustomSoapHeadersToXml(writer); + + if (this.service.getCredentials() != null) { + this.service.getCredentials().serializeWSSecurityHeaders( + writer.getInternalWriter()); + } + + this.service.doOnSerializeCustomSoapHeaders(writer.getInternalWriter()); + + writer.writeEndElement(); // soap:Header + + writer.writeStartElement(XmlNamespace.Soap, + XmlElementNames.SOAPBodyElementName); + + this.writeBodyToXml(writer); + + writer.writeEndElement(); // soap:Body + writer.writeEndElement(); // soap:Envelope + writer.flush(); + writer.dispose(); + } + + /** + * Write extra headers. + * + * @param writer the writer + * @throws ServiceXmlSerializationException the service xml serialization exception + * @throws XMLStreamException the XML stream exception + */ + protected void writeExtraCustomSoapHeadersToXml(EwsServiceXmlWriter writer) + throws XMLStreamException, ServiceXmlSerializationException, ExchangeXmlException { + // do nothing here. + // currently used only by GetUserSettingRequest to emit the BinarySecret header. + } + + + /** + * Writes XML body. + * + * @param writer the writer + * @throws ServiceXmlSerializationException the service xml serialization exception + * @throws XMLStreamException the XML stream exception + */ + protected void writeBodyToXml(EwsServiceXmlWriter writer) + throws ServiceXmlSerializationException, XMLStreamException, ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Autodiscover, this + .getRequestXmlElementName()); + + this.writeAttributesToXml(writer); + this.writeElementsToXml(writer); + + writer.writeEndElement(); // m:this.GetXmlElementName() + } + + /** + * Gets the response stream (may be wrapped with GZip/Deflate stream to + * decompress content). + * + * @param request the request + * @return ResponseStream + * @throws EWSHttpException the EWS http exception + * @throws IOException signals that an I/O exception has occurred. + */ + protected static InputStream getResponseStream(ExchangeHttpClient.Request request) + throws EWSHttpException, IOException { + String contentEncoding = ""; + + if (null != request.getContentEncoding()) { + contentEncoding = request.getContentEncoding().toLowerCase(); + } + + InputStream responseStream; + + if (contentEncoding.contains("gzip")) { + responseStream = new GZIPInputStream(request.getInputStream()); + } else if (contentEncoding.contains("deflate")) { + responseStream = new InflaterInputStream(request.getInputStream()); + } else { + responseStream = request.getInputStream(); + } + return responseStream; + } + + /** + * Read SOAP header. + * + * @param reader EwsXmlReader. + * @throws Exception the exception + */ + protected void readSoapHeaders(EwsXmlReader reader) throws Exception { + reader.readStartElement(XmlNamespace.Soap, + XmlElementNames.SOAPHeaderElementName); + do { + reader.read(); + + this.readSoapHeader(reader); + } while (!reader.isEndElement(XmlNamespace.Soap, + XmlElementNames.SOAPHeaderElementName)); + } + + /** + * Reads a single SOAP header. + * + * @param reader EwsXmlReader + * @throws Exception on error + */ + protected void readSoapHeader(EwsXmlReader reader) throws Exception { + // Is this the ServerVersionInfo? + if (reader.isStartElement(XmlNamespace.Autodiscover, + XmlElementNames.ServerVersionInfo)) { + this.service.setServerInfo(this.readServerVersionInfo(reader)); + } + } + + /** + * Read ServerVersionInfo SOAP header. + * + * @param reader EwsXmlReader. + * @return ExchangeServerInfo ExchangeServerInfo object + * @throws Exception the exception + */ + private ExchangeServerInfo readServerVersionInfo(EwsXmlReader reader) throws Exception { + ExchangeServerInfo serverInfo = new ExchangeServerInfo(); + do { + reader.read(); + + if (reader.isStartElement()) { + if (reader.getLocalName().equals(XmlElementNames.MajorVersion)) { + serverInfo.setMajorVersion(reader + .readElementValue(Integer.class)); + } else if (reader.getLocalName().equals( + XmlElementNames.MinorVersion)) { + serverInfo.setMinorVersion(reader + .readElementValue(Integer.class)); + } else if (reader.getLocalName().equals( + XmlElementNames.MajorBuildNumber)) { + serverInfo.setMajorBuildNumber(reader + .readElementValue(Integer.class)); + } else if (reader.getLocalName().equals( + XmlElementNames.MinorBuildNumber)) { + serverInfo.setMinorBuildNumber(reader + .readElementValue(Integer.class)); + } else if (reader.getLocalName() + .equals(XmlElementNames.Version)) { + serverInfo.setVersionString(reader.readElementValue()); + } + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.ServerVersionInfo)); + + return serverInfo; + } + + /** + * Read SOAP body. + * + * @param reader EwsXmlReader. + * @return AutodiscoverResponse AutodiscoverResponse object + * @throws Exception the exception + */ + protected AutodiscoverResponse readSoapBody(EwsXmlReader reader) throws Exception { + reader.readStartElement(XmlNamespace.Soap, + XmlElementNames.SOAPBodyElementName); + AutodiscoverResponse responses = this.loadFromXml(reader); + reader.readEndElement(XmlNamespace.Soap, + XmlElementNames.SOAPBodyElementName); + return responses; + } + + /** + * Loads response from XML. + * + * @param reader The reader. + * @return AutodiscoverResponse object + * @throws Exception the exception + */ + protected AutodiscoverResponse loadFromXml(EwsXmlReader reader) throws Exception { + String elementName = this.getResponseXmlElementName(); + reader.readStartElement(XmlNamespace.Autodiscover, elementName); + AutodiscoverResponse response = this.createServiceResponse(); + response.loadFromXml(reader, elementName); + return response; + } + + /** + * Gets the name of the request XML element. + * + * @return RequestXmlElementName gets XmlElementName. + */ + protected abstract String getRequestXmlElementName(); + + /** + * Gets the name of the response XML element. + * + * @return ResponseXmlElementName gets XmlElementName. + */ + protected abstract String getResponseXmlElementName(); + + /** + * Gets the WS-Addressing action name. + * + * @return WsAddressingActionName gets WsAddressingActionName. + */ + protected abstract String getWsAddressingActionName(); + + /** + * Creates the service response. + * + * @return AutodiscoverResponse AutodiscoverResponse object. + */ + protected abstract AutodiscoverResponse createServiceResponse(); + + /** + * Writes attribute to request XML. + * + * @param writer The writer. + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + protected abstract void writeAttributesToXml(EwsServiceXmlWriter writer) + throws ServiceXmlSerializationException, ExchangeXmlException; + + /** + * Writes elements to request XML. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + protected abstract void writeElementsToXml(EwsServiceXmlWriter writer) + throws XMLStreamException, ServiceXmlSerializationException, ExchangeXmlException; + + /** + * Gets the Service. + * + * @return AutodiscoverService AutodiscoverService object. + */ + protected AutodiscoverService getService() { + return this.service; + } + + /** + * Gets the URL. + * + * @return url URL Object. + */ + protected URI getUrl() { + return this.url; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/request/GetDomainSettingsRequest.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/request/GetDomainSettingsRequest.java new file mode 100644 index 000000000..3ab6f82fc --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/request/GetDomainSettingsRequest.java @@ -0,0 +1,269 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.request; + +import com.eischet.ews.api.autodiscover.AutodiscoverService; +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverErrorCode; +import com.eischet.ews.api.autodiscover.enumeration.DomainSettingName; +import com.eischet.ews.api.autodiscover.response.AutodiscoverResponse; +import com.eischet.ews.api.autodiscover.response.GetDomainSettingsResponseCollection; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import javax.xml.stream.XMLStreamException; +import java.net.URI; +import java.util.List; + +/** + * Represents a GetDomainSettings request. + */ +public class GetDomainSettingsRequest extends AutodiscoverRequest { + + /** + * Action Uri of Autodiscover.GetDomainSettings method. + */ + private static final String GetDomainSettingsActionUri = EwsUtilities.AutodiscoverSoapNamespace + "/Autodiscover/GetDomainSettings"; + + /** + * The domains. + */ + private List domains; + + /** + * The settings. + */ + private List settings; + + private ExchangeVersion requestedVersion; + + /** + * Initializes a new instance of the {@link GetDomainSettingsRequest} class. + * + * @param service the service + * @param url the url + */ + public GetDomainSettingsRequest(AutodiscoverService service, URI url) { + super(service, url); + } + + /** + * Validates the request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + + EwsUtilities.validateParam(this.getDomains(), "domains"); + EwsUtilities.validateParam(this.getSettings(), "settings"); + + if (this.getSettings().size() == 0) { + throw new ExchangeValidationException("At least one setting must be requested."); + } + + if (domains.size() == 0) { + throw new ExchangeValidationException("At least one domain name must be requested."); + } + + for (String domain : this.getDomains()) { + if (domain == null || domain.isEmpty()) { + throw new ExchangeValidationException("The domain name must be specified."); + } + } + } + + /** + * Executes this instance. + * + * @return the gets the domain settings response collection + * @throws Exception the exception + */ + public GetDomainSettingsResponseCollection execute() throws Exception { + GetDomainSettingsResponseCollection responses = (GetDomainSettingsResponseCollection) this.internalExecute(); + if (responses.getErrorCode() == AutodiscoverErrorCode.NoError) { + this.PostProcessResponses(responses); + } + return responses; + } + + /** + * Post-process response to GetDomainSettings. + * + * @param responses The GetDomainSettings response. + */ + private void PostProcessResponses(GetDomainSettingsResponseCollection responses) { + // Note:The response collection may not include all of the requested + // domains if the request has been throttled. + for (int index = 0; index < responses.getCount(); index++) { + responses.getResponses().get(index).setDomain(this.getDomains().get(index)); + } + } + + /** + * Gets the name of the request XML element. + * + * @return Request XML element name. + */ + @Override + protected String getRequestXmlElementName() { + return XmlElementNames.GetDomainSettingsRequestMessage; + } + + /** + * Gets the name of the response XML element. + * + * @return Response XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetDomainSettingsResponseMessage; + } + + /** + * Gets the WS-Addressing action name. + * + * @return WS-Addressing action name. + */ + @Override + protected String getWsAddressingActionName() { + return GetDomainSettingsActionUri; + } + + /** + * Creates the service response. + * + * @return AutodiscoverResponse + */ + @Override + protected AutodiscoverResponse createServiceResponse() { + return new GetDomainSettingsResponseCollection(); + } + + /** + * Writes the attribute to XML. + * + * @param writer The writer. + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue("xmlns", EwsUtilities.AutodiscoverSoapNamespacePrefix, EwsUtilities.AutodiscoverSoapNamespace); + } + + /** + * Writes request to XML. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Autodiscover, XmlElementNames.Request); + + writer.writeStartElement(XmlNamespace.Autodiscover, XmlElementNames.Domains); + + for (String domain : this.getDomains()) { + if (!(domain == null || domain.isEmpty())) { + writer.writeElementValue(XmlNamespace.Autodiscover, XmlElementNames.Domain, domain); + } + } + writer.writeEndElement(); // Domains + + writer.writeStartElement(XmlNamespace.Autodiscover, XmlElementNames.RequestedSettings); + for (DomainSettingName setting : settings) { + writer.writeElementValue(XmlNamespace.Autodiscover, XmlElementNames.Setting, setting); + } + + writer.writeEndElement(); // RequestedSettings + + if (this.requestedVersion != null) { + writer.writeElementValue(XmlNamespace.Autodiscover, XmlElementNames.RequestedVersion, this.requestedVersion); + } + + writer.writeEndElement(); // Request + } + + /** + * Gets the domains. + * + * @return the domains + */ + protected List getDomains() { + return domains; + } + + /** + * Sets the domains. + * + * @param value the new domains + */ + public void setDomains(List value) { + domains = value; + } + + /** + * Gets or sets the settings. + * + * @return the settings + */ + protected List getSettings() { + return settings; + } + + /** + * Sets the settings. + * + * @param value the new settings + */ + public void setSettings(List value) { + settings = value; + } + + /** + * Gets or sets the requestedVersion. + * + * @return the requestedVersion + */ + protected ExchangeVersion getRequestedVersion() { + return requestedVersion; + } + + /** + * Sets the requestedVersion. + * + * @param value the new requestedVersion + */ + public void setRequestedVersion(ExchangeVersion value) { + requestedVersion = value; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/request/GetUserSettingsRequest.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/request/GetUserSettingsRequest.java new file mode 100644 index 000000000..d43ff5932 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/request/GetUserSettingsRequest.java @@ -0,0 +1,340 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.request; + +import com.eischet.ews.api.autodiscover.AutodiscoverService; +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverErrorCode; +import com.eischet.ews.api.autodiscover.enumeration.UserSettingName; +import com.eischet.ews.api.autodiscover.response.AutodiscoverResponse; +import com.eischet.ews.api.autodiscover.response.GetUserSettingsResponseCollection; +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import javax.xml.stream.XMLStreamException; +import java.net.URI; +import java.util.Base64; +import java.util.List; + +/** + * Represents a GetUserSettings request. + */ +public class GetUserSettingsRequest extends AutodiscoverRequest { + + /** + * Action Uri of Autodiscover.GetUserSettings method. + */ + private static final String GetUserSettingsActionUri = EwsUtilities. + AutodiscoverSoapNamespace + + "/Autodiscover/GetUserSettings"; + + private List smtpAddresses; + private List settings; + + + // Expect this request to return the partner token. + + private boolean expectPartnerToken = false; + private String partnerTokenReference; + private String partnerToken; + + /** + * Initializes a new instance of the {@link GetUserSettingsRequest} class. + * + * @param service the service + * @param url the url + * @throws ExchangeValidationException on validation error + */ + public GetUserSettingsRequest(AutodiscoverService service, URI url) throws ExchangeValidationException { + this(service, url, false); + } + + /** + * Initializes a new instance of the {@link GetUserSettingsRequest} class. + * + * @param service autodiscover service associated with this request + * @param url URL of Autodiscover service + * @param expectPartnerToken expect partner token or not + * @throws ExchangeValidationException on validation error + */ + public GetUserSettingsRequest(AutodiscoverService service, URI url, boolean expectPartnerToken) + throws ExchangeValidationException { + super(service, url); + this.expectPartnerToken = expectPartnerToken; + + // make an explicit https check. + if (expectPartnerToken && !url.getScheme().equalsIgnoreCase("https")) { + throw new ExchangeValidationException("Https is required."); + } + } + + /** + * Validates the request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + + EwsUtilities.validateParam(this.getSmtpAddresses(), "smtpAddresses"); + EwsUtilities.validateParam(this.getSettings(), "settings"); + + if (this.getSettings().isEmpty()) { + throw new ExchangeValidationException("At least one setting must be requested."); + } + + if (this.getSmtpAddresses().isEmpty()) { + throw new ExchangeValidationException("At least one SMTP address must be requested."); + } + + for (String smtpAddress : this.getSmtpAddresses()) { + if (smtpAddress == null || smtpAddress.isEmpty()) { + throw new ExchangeValidationException("A valid SMTP address must be specified."); + } + } + } + + /** + * Executes this instance. + * + * @return the gets the user settings response collection + * @throws Exception the exception + */ + public GetUserSettingsResponseCollection execute() throws Exception { + GetUserSettingsResponseCollection responses = + (GetUserSettingsResponseCollection) this + .internalExecute(); + if (responses.getErrorCode() == AutodiscoverErrorCode.NoError) { + this.postProcessResponses(responses); + } + return responses; + } + + /** + * Post-process response to GetUserSettings. + * + * @param responses The GetUserSettings response. + */ + private void postProcessResponses( + GetUserSettingsResponseCollection responses) { + // Note:The response collection may not include all of the requested + // users if the request has been throttled. + for (int index = 0; index < responses.getCount(); index++) { + responses.getResponses().get(index).setSmtpAddress( + this.getSmtpAddresses().get(index)); + } + } + + /** + * Gets the name of the request XML element. + * + * @return Request XML element name. + */ + @Override + protected String getRequestXmlElementName() { + return XmlElementNames.GetUserSettingsRequestMessage; + } + + /** + * Gets the name of the response XML element. + * + * @return Response XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetUserSettingsResponseMessage; + } + + /** + * Gets the WS-Addressing action name. + * + * @return WS-Addressing action name. + */ + @Override + protected String getWsAddressingActionName() { + return GetUserSettingsActionUri; + } + + /** + * Creates the service response. + * + * @return AutodiscoverResponse + */ + @Override + protected AutodiscoverResponse createServiceResponse() { + return new GetUserSettingsResponseCollection(); + } + + /** + * Writes the attribute to XML. + * + * @param writer The writer. + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue("xmlns", EwsUtilities.AutodiscoverSoapNamespacePrefix, EwsUtilities.AutodiscoverSoapNamespace); + } + + /** + * @param writer XML writer + */ + @Override + public void writeExtraCustomSoapHeadersToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (this.expectPartnerToken) { + writer.writeElementValue(XmlNamespace.Autodiscover, + XmlElementNames.BinarySecret, + Base64.getMimeEncoder().encodeToString(ExchangeServiceBase.getSessionKey())); + } + } + + /** + * Writes request to XML. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Autodiscover, + XmlElementNames.Request); + + writer.writeStartElement(XmlNamespace.Autodiscover, + XmlElementNames.Users); + + for (String smtpAddress : this.getSmtpAddresses()) { + writer.writeStartElement(XmlNamespace.Autodiscover, + XmlElementNames.User); + + if (!(smtpAddress == null || smtpAddress.isEmpty())) { + writer.writeElementValue(XmlNamespace.Autodiscover, + XmlElementNames.Mailbox, smtpAddress); + } + writer.writeEndElement(); // User + } + writer.writeEndElement(); // Users + + writer.writeStartElement(XmlNamespace.Autodiscover, + XmlElementNames.RequestedSettings); + for (UserSettingName setting : this.getSettings()) { + writer.writeElementValue(XmlNamespace.Autodiscover, + XmlElementNames.Setting, setting); + } + + writer.writeEndElement(); // RequestedSettings + + writer.writeEndElement(); // Request + } + + /** + * Read the partner token soap header. + * + * @param reader EWS XML reader + * @throws Exception on error + */ + @Override + protected void readSoapHeader(EwsXmlReader reader) throws Exception { + super.readSoapHeader(reader); + + if (this.expectPartnerToken) { + if (reader.isStartElement(XmlNamespace.Autodiscover, + XmlElementNames.PartnerToken)) { + this.partnerToken = reader.readInnerXml(); + } + + if (reader.isStartElement(XmlNamespace.Autodiscover, + XmlElementNames.PartnerTokenReference)) { + partnerTokenReference = reader.readInnerXml(); + } + } + } + + /** + * Gets the SMTP addresses. + * + * @return the SMTP addresses + */ + protected List getSmtpAddresses() { + return smtpAddresses; + } + + /** + * Sets the smtp addresses. + * + * @param value the new smtp addresses + */ + public void setSmtpAddresses(List value) { + this.smtpAddresses = value; + } + + /** + * Gets the settings. + * + * @return the settings + */ + protected List getSettings() { + return settings; + } + + /** + * Sets the settings. + * + * @param value the new settings + */ + public void setSettings(List value) { + this.settings = value; + + } + + /** + * Gets the partner token. + * + * @return partner token + */ + protected String getPartnerToken() { + return partnerToken; + } + + private void setPartnerToken(String value) { + partnerToken = value; + } + + /** + * Gets the partner token reference. + * + * @return partner token reference + */ + protected String getPartnerTokenReference() { + return partnerTokenReference; + + } + + private void setPartnerTokenReference(String tokenReference) { + partnerTokenReference = tokenReference; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/AutodiscoverResponse.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/AutodiscoverResponse.java new file mode 100644 index 000000000..24dc06029 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/AutodiscoverResponse.java @@ -0,0 +1,131 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.response; + +import com.eischet.ews.api.autodiscover.enumeration.AutodiscoverErrorCode; +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlElementNames; + +import java.net.URI; + +/** + * Represents the base class for all response returned by the Autodiscover + * service. + */ +public abstract class AutodiscoverResponse { + + /** + * The error code. + */ + private AutodiscoverErrorCode errorCode; + + /** + * The error message. + */ + private String errorMessage; + + /** + * The redirection url. + */ + private URI redirectionUrl; + + /** + * Initializes a new instance of the AutodiscoverResponse class. + */ + public AutodiscoverResponse() { + this.errorCode = AutodiscoverErrorCode.NoError; + } + + /** + * Initializes a new instance of the AutodiscoverResponse class. + * + * @param reader the reader + * @param endElementName the end element name + * @throws Exception the exception + */ + public void loadFromXml(EwsXmlReader reader, String endElementName) + throws Exception { + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ErrorCode)) { + this.errorCode = reader + .readElementValue(AutodiscoverErrorCode.class); + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.ErrorMessage)) { + this.errorMessage = reader.readElementValue(); + } + } + + /** + * Gets the error code that was returned by the service. + * + * @return the error code + */ + public AutodiscoverErrorCode getErrorCode() { + return errorCode; + } + + /** + * Sets the error code. + * + * @param errorCode the new error code + */ + public void setErrorCode(AutodiscoverErrorCode errorCode) { + this.errorCode = errorCode; + } + + /** + * Gets the error message that was returned by the service. + * + * @return the error message + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Sets the error message. + * + * @param errorMessage the new error message + */ + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * Gets the redirection URL. + * + * @return the redirection url + */ + public URI getRedirectionUrl() { + return redirectionUrl; + } + + /** + * Sets the redirection url. + * + * @param redirectionUrl the new redirection url + */ + public void setRedirectionUrl(URI redirectionUrl) { + this.redirectionUrl = redirectionUrl; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/GetDomainSettingsResponse.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/GetDomainSettingsResponse.java new file mode 100644 index 000000000..0ae6692c5 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/GetDomainSettingsResponse.java @@ -0,0 +1,252 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.response; + +import com.eischet.ews.api.autodiscover.enumeration.DomainSettingName; +import com.eischet.ews.api.autodiscover.exception.error.DomainSettingError; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents the response to a GetDomainSettings call for an individual domain. + */ +public final class GetDomainSettingsResponse extends AutodiscoverResponse { + + private static final Logger LOG = Logger.getLogger(GetDomainSettingsResponse.class.getCanonicalName()); + + /** + * The domain. + */ + private String domain; + + /** + * The redirect target. + */ + private String redirectTarget; + + /** + * The settings. + */ + private final Map settings; + + /** + * The domain setting errors. + */ + private final Collection domainSettingErrors; + + /** + * Initializes a new instance of the {@link GetDomainSettingsResponse} class. + */ + public GetDomainSettingsResponse() { + super(); + this.domain = ""; + this.settings = new HashMap(); + this.domainSettingErrors = new ArrayList(); + } + + /** + * Gets the domain this response applies to. + * + * @return the domain + */ + public String getDomain() { + return this.domain; + } + + /** + * Sets the domain. + * + * @param value the new domain + */ + public void setDomain(String value) { + this.domain = value; + } + + /** + * Gets the redirectionTarget (URL or email address). + * + * @return the redirect target + */ + public String getRedirectTarget() { + return this.redirectTarget; + } + + /** + * Gets the requested settings for the domain. + * + * @return the settings + */ + public Map getSettings() { + return this.settings; + } + + /** + * Gets error information for settings that could not be returned. + * + * @return the domain setting errors + */ + public Collection getDomainSettingErrors() { + return this.domainSettingErrors; + } + + /** + * Loads response from XML. + * + * @param reader The reader. + * @param endElementName End element name. + * @throws Exception the exception + */ + @Override + public void loadFromXml(EwsXmlReader reader, String endElementName) + throws Exception { + do { + reader.read(); + + if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName() + .equals(XmlElementNames.RedirectTarget)) { + this.redirectTarget = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.DomainSettingErrors)) { + this.loadDomainSettingErrorsFromXml(reader); + } else if (reader.getLocalName().equals( + XmlElementNames.DomainSettings)) { + try { + this.loadDomainSettingsFromXml(reader); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error loading domain settings from XML", e); + } + } else { + super.loadFromXml(reader, endElementName); + break; + } + } + } while (!reader + .isEndElement(XmlNamespace.Autodiscover, endElementName)); + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @throws Exception the exception + */ + protected void loadDomainSettingsFromXml(EwsXmlReader reader) + throws Exception { + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if ((reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) && + (reader.getLocalName() + .equals(XmlElementNames.DomainSetting))) { + String settingClass = reader.readAttributeValue( + XmlNamespace.XmlSchemaInstance, + XmlAttributeNames.Type); + + if (settingClass + .equals(XmlElementNames.DomainStringSetting)) { + + this.readSettingFromXml(reader); + } else { + EwsUtilities + .ewsAssert(false, "GetDomainSettingsResponse." + "LoadDomainSettingsFromXml", + String.format("%s,%s", "Invalid setting " + "class '%s' returned", settingClass)); + break; + } + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.DomainSettings)); + } else { + reader.read(); + } + } + + /** + * Reads domain setting from XML. + * + * @param reader The reader. + * @throws Exception the exception + */ + private void readSettingFromXml(EwsXmlReader reader) throws Exception { + DomainSettingName name = null; + Object value = null; + + do { + reader.read(); + + if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals( + XmlElementNames.DomainStringSetting)) { + name = reader.readElementValue(DomainSettingName.class); + } else if (reader.getLocalName().equals(XmlElementNames.Value)) { + value = reader.readElementValue(); + } + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.DomainSetting)); + + EwsUtilities.ewsAssert(name != null, "GetDomainSettingsResponse.ReadSettingFromXml", + "Missing name element in domain setting"); + + this.settings.put(name, value); + } + + /** + * Loads the domain setting errors. + * + * @param reader The reader. + * @throws Exception the exception + */ + private void loadDomainSettingErrorsFromXml(EwsXmlReader reader) + throws Exception { + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if ((reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) && + (reader.getLocalName() + .equals(XmlElementNames.DomainSettingError))) { + DomainSettingError error = new DomainSettingError(); + error.loadFromXml(reader); + domainSettingErrors.add(error); + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.DomainSettingErrors)); + } else { + reader.read(); + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/GetDomainSettingsResponseCollection.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/GetDomainSettingsResponseCollection.java new file mode 100644 index 000000000..bd658d5b5 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/GetDomainSettingsResponseCollection.java @@ -0,0 +1,71 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.response; + +import com.eischet.ews.api.autodiscover.AutodiscoverResponseCollection; +import com.eischet.ews.api.core.XmlElementNames; + +/** + * Represents a collection of response to GetDomainSettings. + */ +public final class GetDomainSettingsResponseCollection extends + AutodiscoverResponseCollection { + + /** + * Initializes a new instance of the AutodiscoverResponseCollection class. + */ + public GetDomainSettingsResponseCollection() { + } + + /** + * Create a response instance. + * + * @return GetDomainSettingsResponse. + */ + @Override + protected GetDomainSettingsResponse createResponseInstance() { + return new GetDomainSettingsResponse(); + } + + /** + * Gets the name of the response collection XML element. + * + * @return Response collection XMl element name. + */ + @Override + protected String getResponseCollectionXmlElementName() { + return XmlElementNames.DomainResponses; + } + + /** + * Gets the name of the response instance XML element. + * + * @return Response instance XMl element name. + */ + @Override + protected String getResponseInstanceXmlElementName() { + return XmlElementNames.DomainResponse; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/GetUserSettingsResponse.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/GetUserSettingsResponse.java new file mode 100644 index 000000000..84085b90c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/GetUserSettingsResponse.java @@ -0,0 +1,308 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.response; + +import com.eischet.ews.api.autodiscover.AlternateMailboxCollection; +import com.eischet.ews.api.autodiscover.ProtocolConnectionCollection; +import com.eischet.ews.api.autodiscover.WebClientUrlCollection; +import com.eischet.ews.api.autodiscover.enumeration.UserSettingName; +import com.eischet.ews.api.autodiscover.exception.error.UserSettingError; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +/** + * Represents the response to a GetUsersSettings call for an individual user. + */ +public final class GetUserSettingsResponse extends AutodiscoverResponse { + + /** + * The smtp address. + */ + private String smtpAddress; + + /** + * The redirect target. + */ + private String redirectTarget; + + /** + * The settings. + */ + private Map settings; + + /** + * The user setting errors. + */ + private Collection userSettingErrors; + + /** + * Initializes a new instance of the {@link GetUserSettingsResponse} class. + */ + public GetUserSettingsResponse() { + super(); + this.setSmtpAddress(null); + this.setSettings(new HashMap()); + this.setUserSettingErrors(new ArrayList()); + } + + /** + * Tries the get the user setting value. + * + * @param cls Type of user setting. + * @param setting The setting. + * @param value The setting value. + * @return True if setting was available. + */ + public boolean tryGetSettingValue(Class cls, + UserSettingName setting, OutParam value) { + Object objValue; + if (this.getSettings().containsKey(setting)) { + objValue = this.getSettings().get(setting); + value.setParam((T) objValue); + return true; + } else { + value.setParam(null); + return false; + } + } + + /** + * Gets the SMTP address this response applies to. + * + * @return the smtp address + */ + public String getSmtpAddress() { + return this.smtpAddress; + } + + /** + * Sets the smtp address. + * + * @param value the new smtp address + */ + public void setSmtpAddress(String value) { + this.smtpAddress = value; + } + + /** + * Gets the redirectionTarget (URL or email address). + * + * @return the redirect target + */ + public String getRedirectTarget() { + return this.redirectTarget; + } + + /** + * Sets the redirectionTarget (URL or email address). + * + * @param value redirect target value + */ + public void setRedirectTarget(String value) { + this.redirectTarget = value; + } + + /** + * Gets the requested settings for the user. + * + * @return the settings + */ + public Map getSettings() { + return this.settings; + } + + /** + * Sets the requested settings for the user. + * + * @param settings settings map + */ + public void setSettings(Map settings) { + this.settings = settings; + } + + /** + * Gets error information for settings that could not be returned. + * + * @return the user setting errors + */ + public Collection getUserSettingErrors() { + return this.userSettingErrors; + } + + /** + * Sets the requested settings for the user. + * + * @param value user setting errors + */ + protected void setUserSettingErrors(Collection value) { + this.userSettingErrors = value; + } + + /** + * Loads response from XML. + * + * @param reader The reader. + * @param endElementName End element name. + * @throws Exception the exception + */ + @Override + public void loadFromXml(EwsXmlReader reader, String endElementName) + throws Exception { + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName() + .equals(XmlElementNames.RedirectTarget)) { + + this.setRedirectTarget(reader.readElementValue()); + } else if (reader.getLocalName().equals( + XmlElementNames.UserSettingErrors)) { + this.loadUserSettingErrorsFromXml(reader); + } else if (reader.getLocalName().equals( + XmlElementNames.UserSettings)) { + this.loadUserSettingsFromXml(reader); + } else { + super.loadFromXml(reader, endElementName); + } + } + } while (!reader + .isEndElement(XmlNamespace.Autodiscover, endElementName)); + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @throws Exception the exception + */ + protected void loadUserSettingsFromXml(EwsXmlReader reader) + throws Exception { + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && + (reader.getLocalName() + .equals(XmlElementNames.UserSetting))) { + String settingClass = reader.readAttributeValue( + XmlNamespace.XmlSchemaInstance, + XmlAttributeNames.Type); + + if (settingClass.equals(XmlElementNames.StringSetting)) { + this.readSettingFromXml(reader); + } else if (settingClass.equals(XmlElementNames.WebClientUrlCollectionSetting)) { + this.readSettingFromXml(reader); + } else if (settingClass.equals(XmlElementNames.AlternateMailboxCollectionSetting)) { + this.readSettingFromXml(reader); + } else if (settingClass.equals(XmlElementNames.ProtocolConnectionCollectionSetting)) { + this.readSettingFromXml(reader); + } else { + EwsUtilities.ewsAssert(false, "GetUserSettingsResponse." + "LoadUserSettingsFromXml", String + .format("%s,%s", "Invalid setting class '%s' returned", settingClass)); + break; + } + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.UserSettings)); + } else { + reader.read(); + } + } + + /** + * Reads user setting from XML. + * + * @param reader The reader. + * @throws Exception the exception + */ + private void readSettingFromXml(EwsXmlReader reader) throws Exception { + UserSettingName name = null; + Object value = null; + + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals(XmlElementNames.Name)) { + name = reader.readElementValue(UserSettingName.class); + } else if (reader.getLocalName().equals(XmlElementNames.Value)) { + value = reader.readElementValue(); + } else if (reader.getLocalName().equals( + XmlElementNames.WebClientUrls)) { + + value = WebClientUrlCollection.loadFromXml(reader); + } else if (reader.getLocalName().equals( + XmlElementNames.ProtocolConnections)) { + value = ProtocolConnectionCollection.loadFromXml(reader); + } else if (reader.getLocalName().equals( + XmlElementNames.AlternateMailboxes)) { + value = AlternateMailboxCollection.loadFromXml(reader); + } + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.UserSetting)); + + EwsUtilities.ewsAssert(name != null, "GetUserSettingsResponse.ReadSettingFromXml", + "Missing name element in user setting"); + + this.getSettings().put(name, value); + } + + /** + * Loads the user setting errors. + * + * @param reader The reader. + * @throws Exception the exception + */ + private void loadUserSettingErrorsFromXml(EwsXmlReader reader) + throws Exception { + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && + (reader.getLocalName() + .equals(XmlElementNames.UserSettingError))) { + UserSettingError error = new UserSettingError(); + error.loadFromXml(reader); + this.getUserSettingErrors().add(error); + } + } while (!reader.isEndElement(XmlNamespace.Autodiscover, + XmlElementNames.UserSettingErrors)); + } else { + reader.read(); + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/GetUserSettingsResponseCollection.java b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/GetUserSettingsResponseCollection.java new file mode 100644 index 000000000..f95044f9b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/autodiscover/response/GetUserSettingsResponseCollection.java @@ -0,0 +1,71 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.response; + +import com.eischet.ews.api.autodiscover.AutodiscoverResponseCollection; +import com.eischet.ews.api.core.XmlElementNames; + +/** + * Represents a collection of response to GetUserSettings. + */ +public final class GetUserSettingsResponseCollection extends + AutodiscoverResponseCollection { + + /** + * Initializes a new instance of the AutodiscoverResponseCollection class. + */ + public GetUserSettingsResponseCollection() { + } + + /** + * Create a response instance. + * + * @return GetUserSettingsResponse. + */ + @Override + protected GetUserSettingsResponse createResponseInstance() { + return new GetUserSettingsResponse(); + } + + /** + * Gets the name of the response collection XML element. + * + * @return Response collection XMl element name. + */ + @Override + protected String getResponseCollectionXmlElementName() { + return XmlElementNames.UserResponses; + } + + /** + * Gets the name of the response instance XML element. + * + * @return Response instance XMl element name. + */ + @Override + protected String getResponseInstanceXmlElementName() { + return XmlElementNames.UserResponse; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/EwsServiceMultiResponseXmlReader.java b/ews-api/src/main/java/com/eischet/ews/api/core/EwsServiceMultiResponseXmlReader.java new file mode 100644 index 000000000..6090f86d9 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/EwsServiceMultiResponseXmlReader.java @@ -0,0 +1,106 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; + +/** + * Represents an xml reader used by the ExchangeService to parse multi-response streams, + * such as GetStreamingEvents. + *

+ * Necessary because the basic EwsServiceXmlReader does not + * use normalization (see E14:60369), and in order to turn normalization off, it is + * necessary to use an XmlTextReader, which does not allow the ConformanceLevel.Auto that + * a multi-response stream requires. + * If ever there comes a time we need to deal with multi-response streams with user-generated + * content, we will need to tackle that parsing problem separately. + *

+ */ +public class EwsServiceMultiResponseXmlReader extends EwsServiceXmlReader { + + /** + * Initializes a new instance of the + * EwsServiceMultiResponseXmlReader class. + * + * @param stream The stream. + * @param service The service. + */ + private EwsServiceMultiResponseXmlReader(InputStream stream, + ExchangeService service) throws ExchangeXmlException { + super(stream, service); + } + + /** + * Creates a new instance of the EwsServiceMultiResponseXmlReader class. + * + * @param stream the stream + * @param service the service + * @return an instance of EwsServiceMultiResponseXmlReader wrapped around the input stream + * @throws Exception on error + */ + public static EwsServiceMultiResponseXmlReader create(InputStream stream, ExchangeService service) throws Exception { + return new EwsServiceMultiResponseXmlReader(stream, service); + } + + /** + * Creates the XML reader. + * + * @param stream The stream + * @return an XML reader to use + */ + private static XMLEventReader createXmlReader(InputStream stream) throws ExchangeXmlException { + + // E14:240522 The ProhibitDtd property is used to indicate whether XmlReader should process DTDs or not. By default, + // it will do so. EWS doesn't use DTD references so we want to turn this off. Also, the XmlResolver property is + // set to an instance of XmlUrlResolver by default. We don't want XmlTextReader to try to resolve this DTD reference + // so we disable the XmlResolver as well. + XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + InputStreamReader isr = new InputStreamReader(stream); + BufferedReader in = new BufferedReader(isr); + try { + return inputFactory.createXMLEventReader(in); + } catch (XMLStreamException e) { + throw new ExchangeXmlException("error creating an xml event reader", e); + } + } + + + /** + * Initializes the XML reader. + * + * @param stream The stream. An XML reader to use. + */ + @Override + protected XMLEventReader initializeXmlReader(InputStream stream) throws ExchangeXmlException { + return createXmlReader(stream); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/EwsServiceXmlReader.java b/ews-api/src/main/java/com/eischet/ews/api/core/EwsServiceXmlReader.java new file mode 100644 index 000000000..ace90a75b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/EwsServiceXmlReader.java @@ -0,0 +1,182 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.IGetObjectInstanceDelegate; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.util.DateTimeUtils; + +import java.io.InputStream; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +/** + * XML reader. + */ +public class EwsServiceXmlReader extends EwsXmlReader { + + /** + * The service. + */ + private ExchangeService service; + + /** + * Initializes a new instance of the EwsXmlReader class. + * + * @param stream the stream + * @param service the service + */ + public EwsServiceXmlReader(InputStream stream, ExchangeService service) throws ExchangeXmlException { + super(stream); + this.service = service; + } + + /** + * Reads the element value as date time. + * + * @return Element value + * @throws Exception the exception + */ + public LocalDateTime readElementValueAsDateTime() throws ExchangeXmlException { + return DateTimeUtils.parseDateTime(readElementValue()); + } + + /** + * Reads the element value as unspecified date. + * + * @return element value + */ + public LocalDate readElementValueAsUnspecifiedDate() throws ExchangeXmlException { + return DateTimeUtils.parseDateOnly(readElementValue()); + } + + /** + * Reads the element value as date time, assuming it is unbiased (e.g. + * 2009/01/01T08:00) and scoped to service's time zone. + * + * @return Date + * @throws Exception the exception + */ + public LocalDateTime readElementValueAsUnbiasedDateTimeScopedToServiceTimeZone() throws ExchangeXmlException { + return DateTimeUtils.parseDateTime(this.readElementValue()); + } + + /** + * Reads the element value as date time. + * + * @param xmlNamespace the xml namespace + * @param localName the local name + * @return the date + * @throws Exception the exception + */ + public LocalDateTime readElementValueAsDateTime(XmlNamespace xmlNamespace, String localName) throws ExchangeXmlException { + return DateTimeUtils.parseDateTime(readElementValue(xmlNamespace, localName)); + } + + /** + * Reads the service objects collection from XML. + * + * @param the generic type + * @param collectionXmlElementName the collection xml element name + * @param getObjectInstanceDelegate the get object instance delegate + * @param clearPropertyBag the clear property bag + * @param requestedPropertySet the requested property set + * @param summaryPropertiesOnly the summary property only + * @return the list + */ + public List + readServiceObjectsCollectionFromXml( + String collectionXmlElementName, + IGetObjectInstanceDelegate + getObjectInstanceDelegate, + boolean clearPropertyBag, PropertySet requestedPropertySet, + boolean summaryPropertiesOnly) throws ExchangeXmlException { + + List serviceObjects = new ArrayList<>(); + TServiceObject serviceObject; + + this.readStartElement(XmlNamespace.Messages, collectionXmlElementName); + + if (!this.isEmptyElement()) { + do { + this.read(); + + if (this.isStartElement()) { + serviceObject = (TServiceObject) getObjectInstanceDelegate.getObjectInstanceDelegate(this.getService(), this.getLocalName()); + if (serviceObject == null) { + this.skipCurrentElement(); + } else { + if (!(this.getLocalName()).equals(serviceObject + .getXmlElementName())) { + + throw new ExchangeXmlException(String.format( + "The type of the " + "object in " + + "the store (%s)" + + " does not match that" + + " of the " + + "local object (%s).", + this.getLocalName(), serviceObject + .getXmlElementName())); + } + serviceObject.loadFromXml(this, clearPropertyBag, + requestedPropertySet, summaryPropertiesOnly); + + serviceObjects.add(serviceObject); + } + } + } while (!this.isEndElement(XmlNamespace.Messages, + collectionXmlElementName)); + } else { + // For empty elements read End Element tag + // i.e. position cursor on End Element + this.read(); + } + + return serviceObjects; + + } + + /** + * Gets the service. + * + * @return the service + */ + public ExchangeService getService() { + return service; + } + + /** + * Sets the service. + * + * @param service the new service + */ + public void setService(ExchangeService service) { + this.service = service; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/EwsServiceXmlWriter.java b/ews-api/src/main/java/com/eischet/ews/api/core/EwsServiceXmlWriter.java new file mode 100644 index 000000000..aba1bdf87 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/EwsServiceXmlWriter.java @@ -0,0 +1,579 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.complex.ISearchStringProvider; +import org.w3c.dom.*; + +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Base64; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Stax based XML Writer implementation. + */ +public class EwsServiceXmlWriter implements IDisposable { + + private static final Logger LOG = Logger.getLogger(EwsServiceXmlWriter.class.getCanonicalName()); + + /** + * The is disposed. + */ + private boolean isDisposed; + + /** + * The service. + */ + private final ExchangeServiceBase service; + + /** + * The xml writer. + */ + private final XMLStreamWriter xmlWriter; + + /** + * The is time zone header emitted. + */ + private boolean isTimeZoneHeaderEmitted; + + /** + * The Buffer size. + */ + private static final int BufferSize = 4096; + + /** + * The requireWSSecurityUtilityNamespace * + */ + + protected boolean requireWSSecurityUtilityNamespace; + + /** + * Initializes a new instance. + * + * @param service the service + * @param stream the stream + * @throws XMLStreamException the XML stream exception + */ + public EwsServiceXmlWriter(ExchangeServiceBase service, OutputStream stream) throws XMLStreamException { + this.service = service; + XMLOutputFactory xmlof = XMLOutputFactory.newInstance(); + xmlWriter = xmlof.createXMLStreamWriter(stream, "utf-8"); + + } + + /** + * Try to convert object to a string. + * + * @param value The value. + * @param str the str + * @return True if object was converted, false otherwise. A null object will + * be "successfully" converted to a null string. + */ + protected boolean tryConvertObjectToString(Object value, + OutParam str) { + boolean converted = true; + str.setParam(null); + if (value != null) { + if (value.getClass().isEnum()) { + str.setParam(EwsUtilities.serializeEnum(value)); + } else if (value.getClass().equals(Boolean.class)) { + str.setParam(EwsUtilities.boolToXSBool((Boolean) value)); + } else if (value instanceof LocalDateTime) { + str + .setParam(this.service + .convertDateTimeToUniversalDateTimeString( + (LocalDateTime) value)); + } else if (value instanceof LocalDate) { + str + .setParam(this.service + .convertDateTimeToUniversalDateTimeString( + (LocalDate) value)); + } else if (value.getClass().isPrimitive()) { + str.setParam(value.toString()); + } else if (value instanceof String) { + str.setParam(value.toString()); + } else if (value instanceof ISearchStringProvider) { + ISearchStringProvider searchStringProvider = + (ISearchStringProvider) value; + str.setParam(searchStringProvider.getSearchString()); + } else if (value instanceof Number) { + str.setParam(value.toString()); + } else { + converted = false; + } + } + return converted; + } + + /** + * Performs application-defined tasks associated with freeing, releasing, or + * resetting unmanaged resources. + */ + @Override + public void dispose() { + if (!this.isDisposed) { + try { + this.xmlWriter.close(); + } catch (XMLStreamException e) { + LOG.log(Level.WARNING, "error closing xmlWriter", e); + } + this.isDisposed = true; + } + } + + /** + * Flushes this instance. + * + * @throws XMLStreamException the XML stream exception + */ + public void flush() throws XMLStreamException { + this.xmlWriter.flush(); + } + + /** + * Writes the start element. + * + * @param xmlNamespace the XML namespace + * @param localName the local name of the element + */ + public void writeStartElement(XmlNamespace xmlNamespace, String localName) throws ExchangeXmlException { + String strPrefix = EwsUtilities.getNamespacePrefix(xmlNamespace); + String strNameSpace = EwsUtilities.getNamespaceUri(xmlNamespace); + try { + this.xmlWriter.writeStartElement(strPrefix, localName, strNameSpace); + } catch (XMLStreamException e) { + throw new ExchangeXmlException("error writing start element", e); + } + } + + /** + * Writes the end element. + */ + public void writeEndElement() throws ExchangeXmlException { + try { + this.xmlWriter.writeEndElement(); + } catch (XMLStreamException e) { + throw new ExchangeXmlException("error writing end element", e); + } + } + + /** + * Writes the attribute value. + * + * @param localName the local name of the attribute + * @param value the value + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + public void writeAttributeValue(String localName, Object value) throws ExchangeXmlException { + this.writeAttributeValue(localName, false /* alwaysWriteEmptyString */, value); + } + + /** + * Writes the attribute value. Optionally emits empty string values. + * + * @param localName the local name of the attribute. + * @param alwaysWriteEmptyString always emit the empty string as the value. + * @param value the value + */ + public void writeAttributeValue(String localName, + boolean alwaysWriteEmptyString, + Object value) throws ExchangeXmlException { + OutParam stringOut = new OutParam<>(); + String stringValue; + if (this.tryConvertObjectToString(value, stringOut)) { + stringValue = stringOut.getParam(); + if ((null != stringValue) && (alwaysWriteEmptyString || (!stringValue.isEmpty()))) { + this.writeAttributeString(localName, stringValue); + } + } else { + throw new ExchangeXmlException(String.format("Values of type '%s' can't be used for the '%s' attribute.", value.getClass().getName(), localName)); + } + } + + /** + * Writes the attribute value. + * + * @param namespacePrefix the namespace prefix + * @param localName the local name of the attribute + * @param value the value + */ + public void writeAttributeValue(String namespacePrefix, String localName, Object value) throws ExchangeXmlException { + OutParam stringOut = new OutParam(); + String stringValue; + if (this.tryConvertObjectToString(value, stringOut)) { + stringValue = stringOut.getParam(); + if (null != stringValue && !stringValue.isEmpty()) { + this.writeAttributeString(namespacePrefix, localName, + stringValue); + } + } else { + throw new ExchangeXmlException(String.format("Values of type '%s' can't be used for the '%s' attribute.", value.getClass().getName(), localName)); + } + } + + /** + * Writes the attribute value. + * + * @param localName The local name of the attribute. + * @param stringValue The string value. + */ + protected void writeAttributeString(String localName, String stringValue) throws ExchangeXmlException { + try { + this.xmlWriter.writeAttribute(localName, stringValue); + } catch (XMLStreamException e) { + // Bug E14:65046: XmlTextWriter will throw ArgumentException + //if string includes invalid characters. + throw new ExchangeXmlException(String.format("The invalid value '%s' was specified for the '%s' attribute.", stringValue, localName), e); + } + } + + /** + * Writes the attribute value. + * + * @param namespacePrefix The namespace prefix. + * @param localName The local name of the attribute. + * @param stringValue The string value. + */ + protected void writeAttributeString(String namespacePrefix, + String localName, String stringValue) + throws ExchangeXmlException { + try { + this.xmlWriter.writeAttribute(namespacePrefix, "", localName, + stringValue); + } catch (XMLStreamException e) { + // Bug E14:65046: XmlTextWriter will throw ArgumentException + //if string includes invalid characters. + throw new ExchangeXmlException(String.format("The invalid value '%s' was specified for the '%s' attribute.", stringValue, localName), e); + } + } + + /** + * Writes string value. + * + * @param value The value. + * @param name Element name (used for error handling) + */ + public void writeValue(String value, String name) throws ExchangeXmlException { + try { + this.xmlWriter.writeCharacters(value); + } catch (XMLStreamException e) { + // Bug E14:65046: XmlTextWriter will throw ArgumentException + //if string includes invalid characters. + throw new ExchangeXmlException(String.format("The invalid value '%s' was specified for the '%s' element.", value, name), e); + } + } + + /** + * Writes the element value. + * + * @param xmlNamespace the XML namespace + * @param localName the local name of the element + * @param displayName the name that should appear in the exception message when the value can not be serialized + * @param value the value + */ + public void writeElementValue(XmlNamespace xmlNamespace, String localName, String displayName, Object value) throws ExchangeXmlException { + String stringValue; + OutParam strOut = new OutParam(); + + if (this.tryConvertObjectToString(value, strOut)) { + stringValue = strOut.getParam(); + if (null != stringValue) { + // allow an empty string to create an empty element (like ). + this.writeStartElement(xmlNamespace, localName); + this.writeValue(stringValue, displayName); + this.writeEndElement(); + } + } else { + throw new ExchangeXmlException(String.format("Values of type '%s' can't be used for the '%s' element.", value.getClass().getName(), localName)); + } + } + + public void writeNode(Node xmlNode) throws ExchangeXmlException { + if (xmlNode != null) { + writeNode(xmlNode, this.xmlWriter); + } + } + + /** + * @param xmlNode XML node + * @param xmlStreamWriter XML stream writer + * @throws XMLStreamException the XML stream exception + */ + public static void writeNode(Node xmlNode, XMLStreamWriter xmlStreamWriter) throws ExchangeXmlException { + try { + if (xmlNode instanceof Element) { + addElement((Element) xmlNode, xmlStreamWriter); + } else if (xmlNode instanceof Text) { + xmlStreamWriter.writeCharacters(xmlNode.getNodeValue()); + } else if (xmlNode instanceof CDATASection) { + // TODO: check if writeCData every actually worked, because it could never have been called (CDATASection extends Text!) + xmlStreamWriter.writeCData(((CDATASection) xmlNode).getData()); + } else if (xmlNode instanceof Comment) { + xmlStreamWriter.writeComment(((Comment) xmlNode).getData()); + } else if (xmlNode instanceof EntityReference) { + xmlStreamWriter.writeEntityRef(xmlNode.getNodeValue()); + } else if (xmlNode instanceof ProcessingInstruction) { + ProcessingInstruction procInst = (ProcessingInstruction) xmlNode; + xmlStreamWriter.writeProcessingInstruction(procInst.getTarget(), + procInst.getData()); + } else if (xmlNode instanceof Document) { + writeToDocument((Document) xmlNode, xmlStreamWriter); + } + } catch (XMLStreamException e) { + throw new ExchangeXmlException("error writing note " + xmlNode, e); + } + } + + /** + * @param document XML document + * @param xmlStreamWriter XML stream writer + * @throws XMLStreamException the XML stream exception + */ + public static void writeToDocument(Document document, + XMLStreamWriter xmlStreamWriter) throws ExchangeXmlException { + + try { + xmlStreamWriter.writeStartDocument(); + Element rootElement = document.getDocumentElement(); + addElement(rootElement, xmlStreamWriter); + xmlStreamWriter.writeEndDocument(); + } catch (XMLStreamException e) { + throw new ExchangeXmlException("error writing document " + document, e); + } + } + + /** + * @param element DOM element + * @param writer XML stream writer + * @throws XMLStreamException the XML stream exception + */ + public static void addElement(Element element, XMLStreamWriter writer) throws ExchangeXmlException { + + try { + + String nameSpace = element.getNamespaceURI(); + String prefix = element.getPrefix(); + String localName = element.getLocalName(); + if (prefix == null) { + prefix = ""; + } + if (localName == null) { + localName = element.getNodeName(); + + if (localName == null) { + throw new IllegalStateException( + "Element's local name cannot be null!"); + } + } + + String decUri = writer.getNamespaceContext().getNamespaceURI(prefix); + boolean declareNamespace = decUri == null || !decUri.equals(nameSpace); + + if (nameSpace == null || nameSpace.length() == 0) { + writer.writeStartElement(localName); + } else { + writer.writeStartElement(prefix, localName, nameSpace); + } + + NamedNodeMap attrs = element.getAttributes(); + for (int i = 0; i < attrs.getLength(); i++) { + Node attr = attrs.item(i); + + String name = attr.getNodeName(); + String attrPrefix = ""; + int prefixIndex = name.indexOf(':'); + if (prefixIndex != -1) { + attrPrefix = name.substring(0, prefixIndex); + name = name.substring(prefixIndex + 1); + } + + if ("xmlns".equals(attrPrefix)) { + writer.writeNamespace(name, attr.getNodeValue()); + if (name.equals(prefix) + && attr.getNodeValue().equals(nameSpace)) { + declareNamespace = false; + } + } else { + if ("xmlns".equals(name) && "".equals(attrPrefix)) { + writer.writeNamespace("", attr.getNodeValue()); + if (attr.getNodeValue().equals(nameSpace)) { + declareNamespace = false; + } + } else { + writer.writeAttribute(attrPrefix, attr.getNamespaceURI(), + name, attr.getNodeValue()); + } + } + } + + if (declareNamespace) { + if (nameSpace == null) { + writer.writeNamespace(prefix, ""); + } else { + writer.writeNamespace(prefix, nameSpace); + } + } + + NodeList nodes = element.getChildNodes(); + for (int i = 0; i < nodes.getLength(); i++) { + Node n = nodes.item(i); + writeNode(n, writer); + } + + + writer.writeEndElement(); + } catch (XMLStreamException e) { + throw new ExchangeXmlException("error writing element " + element, e); + } + } + + + /** + * Writes the element value. + * + * @param xmlNamespace the XML namespace + * @param localName the local name of the element + * @param value the value + */ + public void writeElementValue(XmlNamespace xmlNamespace, String localName, Object value) throws ExchangeXmlException { + this.writeElementValue(xmlNamespace, localName, localName, value); + } + + /** + * Writes the base64-encoded element value. + * + * @param buffer the buffer + * @throws XMLStreamException the XML stream exception + */ + public void writeBase64ElementValue(byte[] buffer) throws ExchangeXmlException { + String strValue = Base64.getMimeEncoder().encodeToString(buffer); + try { + this.xmlWriter.writeCharacters(strValue);//Base64.encode(buffer)); + } catch (XMLStreamException e) { + throw new ExchangeXmlException("error writing base64 encoded element value", e); + } + } + + /** + * Writes the base64-encoded element value. + * + * @param stream the stream + * @throws XMLStreamException the XML stream exception + */ + public void writeBase64ElementValue(InputStream stream) throws ExchangeXmlException { + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + try (bos) { + byte[] buf = new byte[BufferSize]; + for (int readNum; (readNum = stream.read(buf)) != -1; ) { + bos.write(buf, 0, readNum); + } + } catch (IOException ex) { + throw new ExchangeXmlException("error writing binary data", ex); + } + byte[] bytes = bos.toByteArray(); + String strValue = Base64.getMimeEncoder().encodeToString(bytes); + try { + this.xmlWriter.writeCharacters(strValue); + } catch (XMLStreamException e) { + throw new ExchangeXmlException("error writing binary data as mime encoded characters", e); + } + + } + + /** + * Gets the internal XML writer. + * + * @return the internal writer + */ + public XMLStreamWriter getInternalWriter() { + return xmlWriter; + } + + /** + * Gets the service. + * + * @return The service. + */ + public ExchangeServiceBase getService() { + return service; + } + + /** + * Gets a value indicating whether the SOAP message need WSSecurity Utility namespace. + */ + public boolean isRequireWSSecurityUtilityNamespace() { + return requireWSSecurityUtilityNamespace; + } + + /** + * Sets a value indicating whether the SOAP message need WSSecurity Utility namespace. + */ + public void setRequireWSSecurityUtilityNamespace(boolean requireWSSecurityUtilityNamespace) { + this.requireWSSecurityUtilityNamespace = requireWSSecurityUtilityNamespace; + } + + /** + * Gets a value indicating whether the time zone SOAP header was emitted + * through this writer. + * + * @return true if the time zone SOAP header was emitted; otherwise false. + */ + public boolean isTimeZoneHeaderEmitted() { + return isTimeZoneHeaderEmitted; + } + + /** + * Sets a value indicating whether the time zone SOAP header was emitted + * through this writer. + * + * @param isTimeZoneHeaderEmitted true if the time zone SOAP header was emitted; otherwise + * false. + */ + public void setTimeZoneHeaderEmitted(boolean isTimeZoneHeaderEmitted) { + this.isTimeZoneHeaderEmitted = isTimeZoneHeaderEmitted; + } + + /** + * Write start document. + * + * @throws XMLStreamException the XML stream exception + */ + public void writeStartDocument() throws XMLStreamException { + this.xmlWriter.writeStartDocument("utf-8", "1.0"); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/EwsUtilities.java b/ews-api/src/main/java/com/eischet/ews/api/core/EwsUtilities.java new file mode 100644 index 000000000..bf9ed0d8c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/EwsUtilities.java @@ -0,0 +1,1327 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.ISelfValidate; +import com.eischet.ews.api.attribute.EwsEnum; +import com.eischet.ews.api.attribute.RequiredServerVersion; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.notification.EventType; +import com.eischet.ews.api.core.enumeration.property.MailboxType; +import com.eischet.ews.api.core.enumeration.property.RuleProperty; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.enumeration.search.ItemTraversal; +import com.eischet.ews.api.core.enumeration.service.FileAsMapping; +import com.eischet.ews.api.core.enumeration.service.MeetingRequestsDeliveryScope; +import com.eischet.ews.api.core.exception.http.EWSHttpException; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.misc.ArgumentNullException; +import com.eischet.ews.api.core.exception.misc.FormatException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ICreateServiceObjectWithAttachmentParam; +import com.eischet.ews.api.core.service.ICreateServiceObjectWithServiceParam; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.ServiceObjectInfo; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.http.ExchangeHttpClient; +import com.eischet.ews.api.misc.TimeSpan; +import com.eischet.ews.api.property.complex.ItemAttachment; + +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.net.URISyntaxException; +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.Duration; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * EWS utilities. + */ +public final class EwsUtilities { + + /** + * The Constant XSFalse. + */ + public static final String XSFalse = "false"; + + /** + * The Constant XSTrue. + */ + public static final String XSTrue = "true"; + + /** + * The Constant EwsTypesNamespacePrefix. + */ + public static final String EwsTypesNamespacePrefix = "t"; + + /** + * The Constant EwsMessagesNamespacePrefix. + */ + public static final String EwsMessagesNamespacePrefix = "m"; + + /** + * The Constant EwsErrorsNamespacePrefix. + */ + public static final String EwsErrorsNamespacePrefix = "e"; + + /** + * The Constant EwsSoapNamespacePrefix. + */ + public static final String EwsSoapNamespacePrefix = "soap"; + + /** + * The Constant EwsXmlSchemaInstanceNamespacePrefix. + */ + public static final String EwsXmlSchemaInstanceNamespacePrefix = "xsi"; + + /** + * The Constant PassportSoapFaultNamespacePrefix. + */ + public static final String PassportSoapFaultNamespacePrefix = "psf"; + + /** + * The Constant WSTrustFebruary2005NamespacePrefix. + */ + public static final String WSTrustFebruary2005NamespacePrefix = "wst"; + + /** + * The Constant WSAddressingNamespacePrefix. + */ + public static final String WSAddressingNamespacePrefix = "wsa"; + + /** + * The Constant AutodiscoverSoapNamespacePrefix. + */ + public static final String AutodiscoverSoapNamespacePrefix = "a"; + + /** + * The Constant WSSecurityUtilityNamespacePrefix. + */ + public static final String WSSecurityUtilityNamespacePrefix = "wsu"; + + /** + * The Constant WSSecuritySecExtNamespacePrefix. + */ + public static final String WSSecuritySecExtNamespacePrefix = "wsse"; + + /** + * The Constant EwsTypesNamespace. + */ + public static final String EwsTypesNamespace = + "http://schemas.microsoft.com/exchange/services/2006/types"; + + /** + * The Constant EwsMessagesNamespace. + */ + public static final String EwsMessagesNamespace = + "http://schemas.microsoft.com/exchange/services/2006/messages"; + + /** + * The Constant EwsErrorsNamespace. + */ + public static final String EwsErrorsNamespace = + "http://schemas.microsoft.com/exchange/services/2006/errors"; + + /** + * The Constant EwsSoapNamespace. + */ + public static final String EwsSoapNamespace = + "http://schemas.xmlsoap.org/soap/envelope/"; + + /** + * The Constant EwsSoap12Namespace. + */ + public static final String EwsSoap12Namespace = + "http://www.w3.org/2003/05/soap-envelope"; + + /** + * The Constant EwsXmlSchemaInstanceNamespace. + */ + public static final String EwsXmlSchemaInstanceNamespace = + "http://www.w3.org/2001/XMLSchema-instance"; + + /** + * The Constant PassportSoapFaultNamespace. + */ + public static final String PassportSoapFaultNamespace = + "http://schemas.microsoft.com/Passport/SoapServices/SOAPFault"; + + /** + * The Constant WSTrustFebruary2005Namespace. + */ + public static final String WSTrustFebruary2005Namespace = + "http://schemas.xmlsoap.org/ws/2005/02/trust"; + + /** + * The Constant WSAddressingNamespace. + */ + public static final String WSAddressingNamespace = + "http://www.w3.org/2005/08/addressing"; + // "http://schemas.xmlsoap.org/ws/2004/08/addressing"; + + /** + * The Constant AutodiscoverSoapNamespace. + */ + public static final String AutodiscoverSoapNamespace = + "http://schemas.microsoft.com/exchange/2010/Autodiscover"; + + public static final String WSSecurityUtilityNamespace = + "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"; + public static final String WSSecuritySecExtNamespace = + "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; + + /** + * The service object info. + */ + private static final LazyMember SERVICE_OBJECT_INFO = + new LazyMember( + new ILazyMember() { + public ServiceObjectInfo createInstance() { + return new ServiceObjectInfo(); + } + } + ); + + private static final String XML_SCHEMA_DATE_FORMAT = "yyyy-MM-dd'Z'"; + private static final String XML_SCHEMA_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + + private static final Pattern PATTERN_TIME_SPAN = Pattern.compile("-P"); + private static final Pattern PATTERN_YEAR = Pattern.compile("(\\d+)Y"); + private static final Pattern PATTERN_MONTH = Pattern.compile("(\\d+)M"); + private static final Pattern PATTERN_DAY = Pattern.compile("(\\d+)D"); + private static final Pattern PATTERN_HOUR = Pattern.compile("(\\d+)H"); + private static final Pattern PATTERN_MINUTES = Pattern.compile("(\\d+)M"); + private static final Pattern PATTERN_SECONDS = Pattern.compile("(\\d+)\\."); // Need to escape dot, otherwise it matches any char + private static final Pattern PATTERN_MILLISECONDS = Pattern.compile("(\\d+)S"); + + + private EwsUtilities() { + throw new UnsupportedOperationException(); + } + + + /** + * Gets the builds the version. + * + * @return the builds the version + */ + public static String getBuildVersion() { + return "0.0.0.0"; + } + + /** + * The enum version dictionaries. + */ + private static final LazyMember, Map>> + ENUM_VERSION_DICTIONARIES = + new LazyMember, Map>>( + new ILazyMember, Map>>() { + @Override + public Map, Map> + createInstance() { + Map, Map> enumDicts = + new HashMap, Map>(); + enumDicts.put(WellKnownFolderName.class, + buildEnumDict(WellKnownFolderName.class)); + enumDicts.put(ItemTraversal.class, + buildEnumDict(ItemTraversal.class)); + enumDicts.put(FileAsMapping.class, + buildEnumDict(FileAsMapping.class)); + enumDicts.put(EventType.class, + buildEnumDict(EventType.class)); + enumDicts.put(MeetingRequestsDeliveryScope.class, + buildEnumDict(MeetingRequestsDeliveryScope. + class)); + return enumDicts; + } + }); + /** + * Dictionary of enum type to schema-name-to-enum-value maps. + */ + private static final LazyMember, Map>> + SCHEMA_TO_ENUM_DICTIONARIES = + new LazyMember, Map>>( + new ILazyMember, Map>>() { + @Override + public Map, Map> createInstance() { + Map, Map> enumDicts = + new HashMap, Map>(); + enumDicts.put(EventType.class, + buildSchemaToEnumDict(EventType.class)); + enumDicts.put(MailboxType.class, + buildSchemaToEnumDict(MailboxType.class)); + enumDicts.put(FileAsMapping.class, + buildSchemaToEnumDict(FileAsMapping.class)); + enumDicts.put(RuleProperty.class, + buildSchemaToEnumDict(RuleProperty.class)); + return enumDicts; + + } + }); + + /** + * Dictionary of enum type to enum-value-to-schema-name maps. + */ + public static final LazyMember, Map>> + ENUM_TO_SCHEMA_DICTIONARIES = + new LazyMember, Map>>( + new ILazyMember, Map>>() { + @Override + public Map, Map> createInstance() { + Map, Map> enumDicts = + new HashMap, Map>(); + enumDicts.put(EventType.class, + buildEnumToSchemaDict(EventType.class)); + enumDicts.put(MailboxType.class, + buildEnumToSchemaDict(MailboxType.class)); + enumDicts.put(FileAsMapping.class, + buildEnumToSchemaDict(FileAsMapping.class)); + enumDicts.put(RuleProperty.class, + buildEnumToSchemaDict(RuleProperty.class)); + return enumDicts; + } + }); + + /** + * Regular expression for legal domain names. + */ + public static final String DomainRegex = "^[-a-zA-Z0-9_.]+$"; + + /** + * Asserts that the specified condition if true. + * + * @param condition Assertion. + * @param caller The caller. + * @param message The message to use if assertion fails. + */ + public static void ewsAssert(final boolean condition, final String caller, final String message) { + if (!condition) { + throw new RuntimeException(String.format("[%s] %s", caller, message)); + } + } + + /** + * Gets the namespace prefix from an XmlNamespace enum value. + * + * @param xmlNamespace The XML namespace + * @return Namespace prefix string. + */ + public static String getNamespacePrefix(XmlNamespace xmlNamespace) { + return xmlNamespace.getNameSpacePrefix(); + } + + /** + * Gets the namespace URI from an XmlNamespace enum value. + * + * @param xmlNamespace The XML namespace. + * @return Uri as string + */ + public static String getNamespaceUri(XmlNamespace xmlNamespace) { + return xmlNamespace.getNameSpaceUri(); + } + + /** + * Gets the namespace from uri. + * + * @param namespaceUri the namespace uri + * @return the namespace from uri + */ + public static XmlNamespace getNamespaceFromUri(String namespaceUri) { + if (EwsErrorsNamespace.equals(namespaceUri)) { + return XmlNamespace.Errors; + } else if (EwsTypesNamespace.equals(namespaceUri)) { + return XmlNamespace.Types; + } else if (EwsMessagesNamespace.equals(namespaceUri)) { + return XmlNamespace.Messages; + } else if (EwsSoapNamespace.equals(namespaceUri)) { + return XmlNamespace.Soap; + } else if (EwsSoap12Namespace.equals(namespaceUri)) { + return XmlNamespace.Soap12; + } else if (EwsXmlSchemaInstanceNamespace.equals(namespaceUri)) { + return XmlNamespace.XmlSchemaInstance; + } else if (PassportSoapFaultNamespace.equals(namespaceUri)) { + return XmlNamespace.PassportSoapFault; + } else if (WSTrustFebruary2005Namespace.equals(namespaceUri)) { + return XmlNamespace.WSTrustFebruary2005; + } else if (WSAddressingNamespace.equals(namespaceUri)) { + return XmlNamespace.WSAddressing; + } else { + return XmlNamespace.NotSpecified; + } + } + + /** + * Creates the ews object from xml element name. + * + * @param the generic type + * @param itemClass the item class + * @param service the service + * @param xmlElementName the xml element name + * @return the t service object + * @throws Exception the exception + */ + @SuppressWarnings("unchecked") + public static TServiceObject createEwsObjectFromXmlElementName(Class itemClass, ExchangeService service, String xmlElementName) throws ExchangeXmlException { + final ServiceObjectInfo member = EwsUtilities.SERVICE_OBJECT_INFO.getMember(); + final Map> map = member.getXmlElementNameToServiceObjectClassMap(); + + final Class ic = map.get(xmlElementName); + if (ic != null) { + final Map, ICreateServiceObjectWithServiceParam> + serviceParam = member.getServiceObjectConstructorsWithServiceParam(); + final ICreateServiceObjectWithServiceParam creationDelegate = + serviceParam.get(ic); + + if (creationDelegate != null) { + return (TServiceObject) creationDelegate.createServiceObjectWithServiceParam(service); + } else { + throw new IllegalArgumentException("No appropriate constructor could be found for this item class."); + } + } + try { + return (TServiceObject) itemClass.getDeclaredConstructor().newInstance(); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + throw new ExchangeXmlException("cannot create an instance of class " + itemClass.getCanonicalName()); + } + } + + /** + * Creates the item from item class. + * + * @param itemAttachment the item attachment + * @param itemClass the item class + * @param isNew the is new + * @return the item + * @throws Exception the exception + */ + public static Item createItemFromItemClass(ItemAttachment itemAttachment, Class itemClass, boolean isNew) throws ExchangeXmlException { + final ServiceObjectInfo member = EwsUtilities.SERVICE_OBJECT_INFO.getMember(); + final Map, ICreateServiceObjectWithAttachmentParam> + dataMap = member.getServiceObjectConstructorsWithAttachmentParam(); + final ICreateServiceObjectWithAttachmentParam creationDelegate = + dataMap.get(itemClass); + + if (creationDelegate != null) { + return (Item) creationDelegate.createServiceObjectWithAttachmentParam(itemAttachment, isNew); + } + throw new IllegalArgumentException("No appropriate constructor could be found for this item class."); + } + + /** + * Creates the item from xml element name. + * + * @param itemAttachment the item attachment + * @param xmlElementName the xml element name + * @return the item + * @throws Exception the exception + */ + public static Item createItemFromXmlElementName(ItemAttachment itemAttachment, String xmlElementName) throws ExchangeXmlException { + final ServiceObjectInfo member = EwsUtilities.SERVICE_OBJECT_INFO.getMember(); + final Map> map = + member.getXmlElementNameToServiceObjectClassMap(); + + final Class itemClass = map.get(xmlElementName); + if (itemClass != null) { + return createItemFromItemClass(itemAttachment, itemClass, false); + } + return null; + } + + public static Class getItemTypeFromXmlElementName(String xmlElementName) { + final ServiceObjectInfo member = EwsUtilities.SERVICE_OBJECT_INFO.getMember(); + final Map> map = member.getXmlElementNameToServiceObjectClassMap(); + return map.get(xmlElementName); + } + + /** + * Finds the first item of type TItem (not a descendant type) in the + * specified collection. + * + * @param TItem is the type of the item to find. + * @param cls the cls + * @param items the item + * @return A TItem instance or null if no instance of TItem could be found. + */ + @SuppressWarnings("unchecked") + public static TItem findFirstItemOfType( + Class cls, Iterable items + ) { + for (Item item : items) { + // We're looking for an exact class match here. + final Class itemClass = item.getClass(); + if (itemClass.equals(cls)) { + return (TItem) item; + } + } + + return null; + } + + /** + * Write trace start element. + * + * @param writer the writer to write the start element to + * @param traceTag the trace tag + * @param includeVersion if true, include build version attribute + * @throws XMLStreamException the XML stream exception + */ + private static void writeTraceStartElement( + XMLStreamWriter writer, + String traceTag, + boolean includeVersion) throws XMLStreamException { + writer.writeStartElement("Trace"); + writer.writeAttribute("Tag", traceTag); + writer.writeAttribute("Tid", Thread.currentThread().getId() + ""); + Date d = new Date(); + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'Z'"); + df.setTimeZone(TimeZone.getTimeZone("UTC")); + String formattedString = df.format(d); + writer.writeAttribute("Time", formattedString); + + if (includeVersion) { + writer.writeAttribute("Version", EwsUtilities.getBuildVersion()); + } + } + + /** + * . + * + * @param entryKind the entry kind + * @param logEntry the log entry + * @return the string + * @throws XMLStreamException the XML stream exception + * @throws IOException signals that an I/O exception has occurred. + */ + public static String formatLogMessage(String entryKind, String logEntry) + throws XMLStreamException, IOException { + String lineSeparator = System.getProperty("line.separator"); + ByteArrayOutputStream outStream = new ByteArrayOutputStream(); + XMLOutputFactory factory = XMLOutputFactory.newInstance(); + XMLStreamWriter writer = factory.createXMLStreamWriter(outStream); + EwsUtilities.writeTraceStartElement(writer, entryKind, false); + writer.writeCharacters(lineSeparator); + writer.writeCharacters(logEntry); + writer.writeCharacters(lineSeparator); + writer.writeEndElement(); + writer.writeCharacters(lineSeparator); + writer.flush(); + writer.close(); + outStream.flush(); + String formattedLogMessage = outStream.toString(); + formattedLogMessage = formattedLogMessage.replaceAll("'", "'"); + formattedLogMessage = formattedLogMessage.replaceAll(""", "\""); + formattedLogMessage = formattedLogMessage.replaceAll(">", ">"); + formattedLogMessage = formattedLogMessage.replaceAll("<", "<"); + formattedLogMessage = formattedLogMessage.replaceAll("&", "&"); + outStream.close(); + return formattedLogMessage; + } + + /** + * Format http response headers. + * + * @param response the response + * @return the string + * @throws EWSHttpException the EWS http exception + */ + public static String formatHttpResponseHeaders(ExchangeHttpClient.Request response) + throws EWSHttpException { + final int code = response.getResponseCode(); + final String contentType = response.getResponseContentType(); + final Map headers = response.getResponseHeaders(); + + return code + " " + contentType + "\n" + + EwsUtilities.formatHttpHeaders(headers) + "\n"; + } + + /** + * Format request HTTP headers. + * + * @param request The HTTP request. + */ + public static String formatHttpRequestHeaders(ExchangeHttpClient.Request request) + throws URISyntaxException, EWSHttpException { + final String method = request.getRequestMethod().toUpperCase(); + final String path = request.getUrl().toURI().getPath(); + final Map property = request.getRequestProperty(); + final String headers = EwsUtilities.formatHttpHeaders(property); + + return String.format("%s %s HTTP/%s\n", method, path, "1.1") + headers + "\n"; + } + + /** + * Formats HTTP headers. + * + * @param headers The headers. + * @return Headers as a string + */ + private static String formatHttpHeaders(Map headers) { + StringBuilder sb = new StringBuilder(); + for (Map.Entry header : headers.entrySet()) { + sb.append(String.format("%s : %s\n", header.getKey(), header.getValue())); + } + return sb.toString(); + } + + /** + * Format XML content in a MemoryStream for message. + * + * @param traceTypeStr Kind of the entry. + * @param stream The memory stream. + * @return XML log entry as a string. + */ + public static String formatLogMessageWithXmlContent(String traceTypeStr, + ByteArrayOutputStream stream) { + try { + return formatLogMessage(traceTypeStr, stream.toString()); + } catch (Exception e) { + return stream.toString(); + } + } + + /** + * Convert bool to XML Schema bool. + * + * @param value Bool value. + * @return String representing bool value in XML Schema. + */ + public static String boolToXSBool(Boolean value) { + return value ? EwsUtilities.XSTrue : EwsUtilities.XSFalse; + } + + /** + * Parses an enum value list. + * + * @param the generic type + * @param c the c + * @param list the list + * @param value the value + * @param separators the separators + */ + public static > void parseEnumValueList(Class c, + List list, String value, char... separators) { + EwsUtilities.ewsAssert(c.isEnum(), "EwsUtilities.ParseEnumValueList", "T is not an enum type."); + + StringBuilder regexp = new StringBuilder(); + regexp.append("["); + for (char s : separators) { + regexp.append("["); + regexp.append(Pattern.quote(s + "")); + regexp.append("]"); + } + regexp.append("]"); + + String[] enumValues = value.split(regexp.toString()); + + for (String enumValue : enumValues) { + for (T o : c.getEnumConstants()) { + if (o.toString().equals(enumValue)) { + list.add(o); + } + } + } + } + + /** + * Converts an enum to a string, using the mapping dictionaries if + * appropriate. + * + * @param value The enum value to be serialized + * @return String representation of enum to be used in the protocol + */ + public static String serializeEnum(Object value) { + String strValue = value.toString(); + final Map, Map> member = + ENUM_TO_SCHEMA_DICTIONARIES.getMember(); + + final Map enumToStringDict = member.get(value.getClass()); + if (enumToStringDict != null) { + final Enum e = (Enum) value; + final String enumStr = enumToStringDict.get(e.name()); + if (enumStr != null) { + strValue = enumStr; + } + } + return strValue; + } + + /** + * Parses the. + * + * @param the generic type + * @param cls the cls + * @param value the value + * @return the t + * @throws java.text.ParseException the parse exception + */ + @SuppressWarnings("unchecked") + public static T parse(Class cls, String value) throws ExchangeXmlException { + if (cls.isEnum()) { + final Map, Map> member = SCHEMA_TO_ENUM_DICTIONARIES.getMember(); + + String val = value; + final Map stringToEnumDict = member.get(cls); + if (stringToEnumDict != null) { + final String strEnumName = stringToEnumDict.get(value); + if (strEnumName != null) { + val = strEnumName; + } + } + for (T o : cls.getEnumConstants()) { + if (o.toString().equals(val)) { + return o; + } + } + return null; + } else if (Number.class.isAssignableFrom(cls)) { + if (Double.class.isAssignableFrom(cls)) { + return (T) ((Double) Double.parseDouble(value)); + } else if (Integer.class.isAssignableFrom(cls)) { + return (T) ((Integer) Integer.parseInt(value)); + } else if (Long.class.isAssignableFrom(cls)) { + return (T) ((Long) Long.parseLong(value)); + } else if (Float.class.isAssignableFrom(cls)) { + return (T) ((Float) Float.parseFloat(value)); + } else if (Byte.class.isAssignableFrom(cls)) { + return (T) ((Byte) Byte.parseByte(value)); + } else if (Short.class.isAssignableFrom(cls)) { + return (T) ((Short) Short.parseShort(value)); + } else if (BigInteger.class.isAssignableFrom(cls)) { + return (T) (new BigInteger(value)); + } else if (BigDecimal.class.isAssignableFrom(cls)) { + return (T) (new BigDecimal(value)); + } + } else if (Date.class.isAssignableFrom(cls)) { + DateFormat df = createDateFormat(XML_SCHEMA_DATE_TIME_FORMAT); + try { + return (T) df.parse(value); + } catch (ParseException e) { + throw new ExchangeXmlException("error parsing as date: {}", e); + } + } else if (Boolean.class.isAssignableFrom(cls)) { + return (T) ((Boolean) Boolean.parseBoolean(value)); + } else if (String.class.isAssignableFrom(cls)) { + return (T) value; + } + return null; + } + + + /** + * Builds the schema to enum mapping dictionary. + * + * @param Type of the enum. + * @param c Class + * @return The mapping from enum to schema name + */ + private static > Map + buildSchemaToEnumDict(Class c) { + Map dict = new HashMap<>(); + + Field[] fields = c.getDeclaredFields(); + for (Field f : fields) { + if (f.isEnumConstant() && f.isAnnotationPresent(EwsEnum.class)) { + EwsEnum ewsEnum = f.getAnnotation(EwsEnum.class); + String fieldName = f.getName(); + String schemaName = ewsEnum.schemaName(); + if (!schemaName.isEmpty()) { + dict.put(schemaName, fieldName); + } + } + } + return dict; + } + + /** + * Validate param collection. + * + * @param eventTypes the event types + * @param paramName the param name + * @throws Exception the exception + */ + public static void validateParamCollection(EventType[] eventTypes, + String paramName) throws Exception { + validateParam(eventTypes, paramName); + int count = 0; + + for (EventType event : eventTypes) { + try { + validateParam(event, String.format("collection[%d] , ", count)); + } catch (Exception e) { + throw new IllegalArgumentException(String.format( + "The element at position %d is invalid", count), e); + } + count++; + } + + if (count == 0) { + throw new IllegalArgumentException( + String.format("The collection \"%s\" is empty.", paramName) + ); + } + } + + /** + * Convert DateTime to XML Schema date. + * + * @param date the date + * @return String representation of DateTime. + */ + public static String dateTimeToXSDate(LocalDateTime date) { + return formatDate(date, XML_SCHEMA_DATE_FORMAT); + } + + public static String dateToXSDate(LocalDate date) { + return formatDate(date, XML_SCHEMA_DATE_FORMAT); + } + + /** + * Dates the DateTime into an XML schema date time. + * + * @param date the date + * @return String representation of DateTime. + */ + public static String dateTimeToXSDateTime(LocalDateTime date) { + return formatDate(date, XML_SCHEMA_DATE_TIME_FORMAT); + } + + /** + * 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 + * + * @param timeOffset structure to convert + * @return xs:duration formatted string + */ + public static String getTimeSpanToXSDuration(TimeSpan timeOffset) { + // Optional '-' offset + String offsetStr = (timeOffset.getTotalSeconds() < 0) ? "-" : ""; + long days = Math.abs(timeOffset.getDays()); + long hours = Math.abs(timeOffset.getHours()); + long minutes = Math.abs(timeOffset.getMinutes()); + long seconds = Math.abs(timeOffset.getSeconds()); + long milliseconds = Math.abs(timeOffset.getMilliseconds()); + + // The TimeSpan structure does not have a Year or Month + // property, therefore we wouldn't be able to return an xs:duration + // string from a TimeSpan that included the nY or nM components. + return offsetStr + "P" + days + "DT" + hours + "H" + minutes + "M" + + seconds + "." + milliseconds + "S"; + } + + /** + * 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. + * + * @param xsDuration xs:duration string to convert + * @return System.TimeSpan structure + */ + public static TimeSpan getXSDurationToTimeSpan(String xsDuration) { + try { + // TODO: Need to check whether this should be the equivalent or not + Matcher m = PATTERN_TIME_SPAN.matcher(xsDuration); + boolean negative = m.find(); + + // Removing leading '-' + if (negative) { + xsDuration = xsDuration.replace("-P", "P"); + } + + Duration duration = Duration.parse(xsDuration); + long retval = duration.toMillis(); + + // Joda Time: + // Period period = Period.parse(xsDuration, ISOPeriodFormat.standard()); + // long retval = period.toStandardDuration().getMillis(); + + if (negative) { + retval = -retval; + } + + return new TimeSpan(retval); + } catch (DateTimeParseException e) { + throw new IllegalArgumentException("illegal duration: " + xsDuration, e); + } + } + + /** + * Time span to xs time. + * + * @param timeSpan the time span + * @return the string + */ + public static String timeSpanToXSTime(TimeSpan timeSpan) { + DecimalFormat myFormatter = new DecimalFormat("00"); + return String.format("%s:%s:%s", myFormatter.format(timeSpan.getHours()), myFormatter.format(timeSpan + .getMinutes()), myFormatter.format(timeSpan.getSeconds())); + } + + /** + * Gets the domain name from an email address. + * + * @param emailAddress The email address. + * @return Domain name. + * @throws FormatException the format exception + */ + public static String domainFromEmailAddress(String emailAddress) + throws FormatException { + String[] emailAddressParts = emailAddress.split("@"); + + if (emailAddressParts.length != 2 + || (emailAddressParts[1] == null || emailAddressParts[1] + .isEmpty())) { + throw new FormatException("The e-mail address is formed incorrectly."); + } + + return emailAddressParts[1]; + } + + public static int getDim(Object array) { + int dim = 0; + Class c = array.getClass(); + while (c.isArray()) { + c = c.getComponentType(); + dim++; + } + return (dim); + } + + /** + * Validates parameter (and allows null value). + * + * @param param The param. + * @param paramName Name of the param. + */ + public static void validateParamAllowNull(Object param, String paramName) throws ExchangeValidationException { + if (param instanceof ISelfValidate) { + ISelfValidate selfValidate = (ISelfValidate) param; + try { + selfValidate.validate(); + } catch (ExchangeXmlException e) { + throw new ExchangeValidationException(String.format("%s %s", "Validation failed.", paramName), e); + } + } + + if (param instanceof ServiceObject) { + ServiceObject ewsObject = (ServiceObject) param; + try { + if (ewsObject.isNew()) { + throw new ExchangeValidationException(String.format("%s %s", "This service object doesn't have an ID.", paramName)); + } + } catch (ExchangeXmlException e) { + throw new ExchangeValidationException("error checking if object " + ewsObject + " is new", e); + } + } + } + + /** + * Validates parameter (null value not allowed). + * + * @param param The param. + * @param paramName Name of the param. + * @throws Exception the exception + */ + public static void validateParam(Object param, String paramName) throws ExchangeValidationException { + boolean isValid; + + if (param instanceof String) { + String strParam = (String) param; + isValid = !strParam.isEmpty(); + } else { + isValid = param != null; + } + + if (!isValid) { + throw new ArgumentException(String.format("Argument %s = %s is not valid", paramName, param)); + } + validateParamAllowNull(param, paramName); + } + + /** + * Validates parameter collection. + * + * @param the generic type + * @param collection The collection. + * @param paramName Name of the param. + * @throws Exception the exception + */ + public static void validateParamCollection(Iterator collection, String paramName) throws Exception { + validateParam(collection, paramName); + int count = 0; + + while (collection.hasNext()) { + T obj = collection.next(); + try { + validateParam(obj, String.format("collection[%d],", count)); + } catch (Exception e) { + throw new IllegalArgumentException(String.format( + "The element at position %d is invalid", count), e); + } + count++; + } + + if (count == 0) { + throw new IllegalArgumentException( + String.format("The collection \"%s\" is empty.", paramName) + ); + } + } + + /** + * Validates string parameter to be non-empty string (null value allowed). + * + * @param param The string parameter. + * @param paramName Name of the parameter. + */ + public static void validateNonBlankStringParamAllowNull(String param, String paramName) throws ExchangeValidationException { + if (param != null) { + // Non-empty string has at least one character which is *not* a whitespace character + try { + if (param.length() == countMatchingChars(param, Character::isWhitespace)) { + throw new ArgumentException("The string argument contains only white space characters.", paramName); + } + } catch (ExchangeXmlException e) { + throw new ExchangeValidationException("error validating param " + paramName + " = " + param, e); + } + } + } + + + /** + * Validates string parameter to be + * non-empty string (null value not allowed). + * + * @param param The string parameter. + * @param paramName Name of the parameter. + */ + public static void validateNonBlankStringParam(String param, String paramName) throws ExchangeValidationException { + if (param == null) { + throw new ArgumentNullException(paramName); + } + + validateNonBlankStringParamAllowNull(param, paramName); + } + + /** + * Validate enum version value. + * + * @param enumValue the enum value + * @param requestVersion the request version + * @throws ServiceVersionException the service version exception + */ + public static void validateEnumVersionValue(Enum enumValue, + ExchangeVersion requestVersion) throws ServiceVersionException { + final Map, Map> member = + ENUM_VERSION_DICTIONARIES.getMember(); + final Map enumVersionDict = + member.get(enumValue.getClass()); + + final ExchangeVersion enumVersion = enumVersionDict.get(enumValue.toString()); + if (enumVersion != null) { + final int i = requestVersion.compareTo(enumVersion); + if (i < 0) { + throw new ServiceVersionException( + String.format( + "Enumeration value %s in enumeration type %s is only valid for Exchange version %s or later.", + enumValue, + enumValue.getClass().getName(), + enumVersion + ) + ); + } + } + } + + /** + * Validates service object version against the request version. + * + * @param serviceObject The service object. + * @param requestVersion The request version. + * @throws ServiceVersionException Raised if this service object type requires a later version + * of Exchange. + */ + public static void validateServiceObjectVersion(ServiceObject serviceObject, ExchangeVersion requestVersion) throws ServiceVersionException { + ExchangeVersion minimumRequiredServerVersion = serviceObject.getMinimumRequiredServerVersion(); + if (requestVersion.ordinal() < minimumRequiredServerVersion.ordinal()) { + String msg = String.format("The object type %s is only valid for Exchange Server version %s or later versions.", serviceObject.getClass().getName(), minimumRequiredServerVersion); + throw new ServiceVersionException(msg); + } + } + + /** + * Validates property version against the request version. + * + * @param service The Exchange service. + * @param minimumServerVersion The minimum server version + * @param propertyName The property name + * @throws ServiceVersionException The service version exception + */ + public static void validatePropertyVersion( + ExchangeService service, + ExchangeVersion minimumServerVersion, + String propertyName) throws ExchangeXmlException { + if (service.getRequestedServerVersion().ordinal() < + minimumServerVersion.ordinal()) { + throw new ServiceVersionException( + String.format("The property %s is valid only for Exchange %s or later versions.", + propertyName, + minimumServerVersion)); + } + } + + /** + * Validate method version. + * + * @param service the service + * @param minimumServerVersion the minimum server version + * @param methodName the method name + * @throws ServiceVersionException the service version exception + */ + public static void validateMethodVersion(ExchangeService service, + ExchangeVersion minimumServerVersion, String methodName) + throws ServiceVersionException { + if (service.getRequestedServerVersion().ordinal() < + minimumServerVersion.ordinal()) { + throw new ServiceVersionException(String.format( + "Method %s is only valid for Exchange Server version %s or later.", methodName, + minimumServerVersion)); + } + } + + /** + * Validates class version against the request version. + * + * @param service the service + * @param minimumServerVersion The minimum server version that supports the method. + * @param className Name of the class. + */ + public static void validateClassVersion( + ExchangeService service, + ExchangeVersion minimumServerVersion, + String className) throws ServiceVersionException { + if (service.getRequestedServerVersion().ordinal() < + minimumServerVersion.ordinal()) { + throw new ServiceVersionException( + String.format("Class %s is only valid for Exchange version %s or later.", + className, + minimumServerVersion)); + } + } + + /** + * Validates domain name (null value allowed) + * + * @param domainName Domain name. + * @param paramName Parameter name. + */ + public static void validateDomainNameAllowNull(String domainName, String paramName) throws ArgumentException { + if (domainName != null) { + Pattern domainNamePattern = Pattern.compile(DomainRegex); + Matcher domainNameMatcher = domainNamePattern.matcher(domainName); + if (!domainNameMatcher.find()) { + throw new ArgumentException(String.format("'%s' is not a valid domain name.", domainName), paramName); + } + } + } + + /** + * Builds the enum dict. + * + * @param the element type + * @param c the c + * @return the map + */ + private static > Map + buildEnumDict(Class c) { + Map dict = + new HashMap<>(); + Field[] fields = c.getDeclaredFields(); + for (Field f : fields) { + if (f.isEnumConstant() + && f.isAnnotationPresent(RequiredServerVersion.class)) { + RequiredServerVersion ewsEnum = f + .getAnnotation(RequiredServerVersion.class); + String fieldName = f.getName(); + ExchangeVersion exchangeVersion = ewsEnum.version(); + dict.put(fieldName, exchangeVersion); + } + } + return dict; + } + + /** + * Builds the enum to schema mapping dictionary. + * + * @param c class type + * @return The mapping from enum to schema name + */ + private static Map buildEnumToSchemaDict(Class c) { + Map dict = new HashMap<>(); + Field[] fields = c.getFields(); + for (Field f : fields) { + if (f.isEnumConstant() && f.isAnnotationPresent(EwsEnum.class)) { + EwsEnum ewsEnum = f.getAnnotation(EwsEnum.class); + String fieldName = f.getName(); + String schemaName = ewsEnum.schemaName(); + if (!schemaName.isEmpty()) { + dict.put(fieldName, schemaName); + } + } + } + return dict; + } + + /** + * Gets the enumerated object count. + * + * @param the generic type + * @param objects The objects. + * @return Count of objects in iterator. + */ + public static int getEnumeratedObjectCount(Iterator objects) { + int count = 0; + while (objects != null && objects.hasNext()) { + objects.next(); + count++; + } + return count; + } + + /** + * Gets the enumerated object at. + * + * @param the generic type + * @param objects the objects + * @param index the index + * @return the enumerated object at + */ + public static Object getEnumeratedObjectAt(Iterable objects, int index) { + int count = 0; + for (Object obj : objects) { + if (count == index) { + return obj; + } + count++; + } + throw new IndexOutOfBoundsException("The IEnumerable doesn't contain that many objects."); + } + + + /** + * Count characters in string that match a condition. + * + * @param str The string. + * @param charPredicate Predicate to evaluate for each character in the string. + * @return Count of characters that match condition expressed by predicate. + */ + public static int countMatchingChars(String str, IPredicate charPredicate) throws ExchangeXmlException { + int count = 0; + for (int i = 0; i < str.length(); i++) { + if (charPredicate.predicate(str.charAt(i))) { + count++; + } + } + return count; + } + + /** + * Determines whether every element in the collection + * matches the conditions defined by the specified predicate. + * + * @param Entry type. + * @param collection The collection. + * @param predicate Predicate that defines the conditions to check against the elements. + * @return True if every element in the collection matches + * the conditions defined by the specified predicate; otherwise, false. + */ + public static boolean trueForAll(Iterable collection, + IPredicate predicate) throws ExchangeXmlException { + for (T entry : collection) { + if (!predicate.predicate(entry)) { + return false; + } + } + + return true; + } + + /** + * Call an action for each member of a collection. + * + * @param Collection element type. + * @param collection The collection. + * @param action The action to apply. + */ + public static void forEach(Iterable collection, IAction action) { + for (T entry : collection) { + action.action(entry); + } + } + + private static String formatDate(LocalDateTime date, String format) { + final DateTimeFormatter utcFormatter = DateTimeFormatter.ofPattern(format); + // final DateFormat utcFormatter = createDateFormat(format); + return utcFormatter.format(date); + } + + + private static String formatDate(LocalDate date, String format) { + final DateTimeFormatter utcFormatter = DateTimeFormatter.ofPattern(format); + // final DateFormat utcFormatter = createDateFormat(format); + return utcFormatter.format(date); + } + + private static DateFormat createDateFormat(String format) { + final DateFormat utcFormatter = new SimpleDateFormat(format); + utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); + return utcFormatter; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/EwsXmlReader.java b/ews-api/src/main/java/com/eischet/ews/api/core/EwsXmlReader.java new file mode 100644 index 000000000..01722a100 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/EwsXmlReader.java @@ -0,0 +1,1034 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.security.XmlNodeType; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.*; +import java.io.*; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.Objects; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Defines the EwsXmlReader class. + */ +public class EwsXmlReader { + + private static final Logger LOG = Logger.getLogger(EwsXmlReader.class.getCanonicalName()); + + /** + * The xml reader. + */ + private XMLEventReader xmlReader; + + /** + * The present event. + */ + private XMLEvent presentEvent; + + /** + * The prev event. + */ + private XMLEvent prevEvent; + + /** + * Initializes a new instance of the EwsXmlReader class. + * + * @param stream the stream + */ + public EwsXmlReader(InputStream stream) throws ExchangeXmlException { + this.xmlReader = initializeXmlReader(stream); + } + + /** + * Initializes the XML reader. + * + * @param stream the stream + * @return An XML reader to use. + */ + protected XMLEventReader initializeXmlReader(InputStream stream) throws ExchangeXmlException { + XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false); + try { + return inputFactory.createXMLEventReader(stream); + } catch (XMLStreamException e) { + throw new ExchangeXmlException("error initializing XMLInputFactory", e); + } + } + + + /** + * Formats the name of the element. + * + * @param namespacePrefix The namespace prefix + * @param localElementName Element name + * @return the string + */ + private static String formatElementName(String namespacePrefix, + String localElementName) { + + return isNullOrEmpty(namespacePrefix) ? localElementName : + namespacePrefix + ":" + localElementName; + } + + /** + * Read XML element. + * + * @param xmlNamespace The XML namespace + * @param localName Name of the local + * @param nodeType Type of the node + */ + private void internalReadElement(XmlNamespace xmlNamespace, String localName, XmlNodeType nodeType) throws ExchangeXmlException { + + if (xmlNamespace == XmlNamespace.NotSpecified) { + this.internalReadElement("", localName, nodeType); + } else { + this.read(nodeType); + + if ((!this.getLocalName().equals(localName)) || + (!this.getNamespaceUri().equals(EwsUtilities + .getNamespaceUri(xmlNamespace)))) { + throw new ExchangeXmlException( + String + .format( + "An element node '%s:%s' of the type %s was expected, but node '%s' of type %s was found.", + EwsUtilities + .getNamespacePrefix( + xmlNamespace), + localName, nodeType.toString(), this + .getName(), this.getNodeType() + .toString())); + } + } + } + + /** + * Read XML element. + * + * @param namespacePrefix The namespace prefix + * @param localName Name of the local + * @param nodeType Type of the node + */ + private void internalReadElement(String namespacePrefix, String localName, XmlNodeType nodeType) throws ExchangeXmlException { + read(nodeType); + + if ((!this.getLocalName().equals(localName)) || + (!this.getNamespacePrefix().equals(namespacePrefix))) { + throw new ExchangeXmlException(String.format( + "An element node '%s:%s' of the type %s was expected, but node '%s' of type %s was found.", namespacePrefix, localName, + nodeType.toString(), this.getName(), this.getNodeType() + .toString())); + } + } + + /** + * Reads the specified node type. + */ + public void read() throws ExchangeXmlException { + read(false); + } + + /** + * Reads the specified node type. + * + * @param keepWhiteSpace Do not remove whitespace characters if true + */ + private void read(boolean keepWhiteSpace) throws ExchangeXmlException { + // The caller to EwsXmlReader.Read expects + // that there's another node to + // read. Throw an exception if not true. + while (true) { + if (!xmlReader.hasNext()) { + throw new ExchangeXmlException("Unexpected end of XML document."); + } else { + try { + XMLEvent event = xmlReader.nextEvent(); + if (event.getEventType() == XMLStreamConstants.CHARACTERS) { + Characters characters = (Characters) event; + if (!keepWhiteSpace) + if (characters.isIgnorableWhiteSpace() + || characters.isWhiteSpace()) { + continue; + } + } + this.prevEvent = this.presentEvent; + this.presentEvent = event; + break; + } catch (XMLStreamException e) { + throw new ExchangeXmlException("error reading next XML event", e); + } + } + } + } + + /** + * Reads the specified node type. + * + * @param nodeType Type of the node. + */ + public void read(XmlNodeType nodeType) throws ExchangeXmlException { + this.read(); + if (!Objects.equals(this.getNodeType(), nodeType)) { + throw new ExchangeXmlException(String.format("The expected XML node type was %s, but the actual type is %s.", nodeType, this.getNodeType())); + } + } + + /** + * Read attribute value from QName. + * + * @param qName QName of the attribute + * @return Attribute Value + * @throws com.eischet.ews.api.core.exception.ExchangeException thrown if attribute value can not be read + */ + private String readAttributeValue(QName qName) throws ExchangeXmlException { + if (this.presentEvent.isStartElement()) { + StartElement startElement = this.presentEvent.asStartElement(); + Attribute attr = startElement.getAttributeByName(qName); + if (null != attr) { + return attr.getValue(); + } else { + return null; + } + } else { + String errMsg = String.format("Could not fetch attribute %s", qName.toString()); + throw new ExchangeXmlException(errMsg); + } + } + + /** + * Reads the attribute value. + * + * @param xmlNamespace The XML namespace. + * @param attributeName Name of the attribute + * @return Attribute Value + */ + public String readAttributeValue(XmlNamespace xmlNamespace, String attributeName) throws ExchangeXmlException { + if (xmlNamespace == XmlNamespace.NotSpecified) { + return this.readAttributeValue(attributeName); + } else { + QName qName = new QName(EwsUtilities.getNamespaceUri(xmlNamespace), + attributeName); + return readAttributeValue(qName); + } + } + + /** + * Reads the attribute value. + * + * @param attributeName Name of the attribute + * @return Attribute value. + */ + public String readAttributeValue(String attributeName) throws ExchangeXmlException { + QName qName = new QName(attributeName); + return readAttributeValue(qName); + } + + /** + * Reads the attribute value. + * + * @param the generic type + * @param cls the cls + * @param attributeName the attribute name + * @return T + */ + public T readAttributeValue(Class cls, String attributeName) throws ExchangeXmlException { + return EwsUtilities.parse(cls, this.readAttributeValue(attributeName)); + } + + /** + * Reads a nullable attribute value. + * + * @param the generic type + * @param cls the cls + * @param attributeName the attribute name + * @return T + */ + public T readNullableAttributeValue(Class cls, String attributeName) throws ExchangeXmlException { + String attributeValue = this.readAttributeValue(attributeName); + if (attributeValue == null) { + return null; + } else { + return EwsUtilities.parse(cls, attributeValue); + } + } + + /** + * Reads the element value. + * + * @param namespacePrefix the namespace prefix + * @param localName the local name + * @return String + */ + public String readElementValue(String namespacePrefix, String localName) throws ExchangeXmlException { + if (!this.isStartElement(namespacePrefix, localName)) { + this.readStartElement(namespacePrefix, localName); + } + + String value = null; + + if (!this.isEmptyElement()) { + value = this.readValue(); + } + return value; + } + + /** + * Reads the element value. + * + * @param xmlNamespace the xml namespace + * @param localName the local name + * @return String + */ + public String readElementValue(XmlNamespace xmlNamespace, String localName) throws ExchangeXmlException { + + if (!this.isStartElement(xmlNamespace, localName)) { + this.readStartElement(xmlNamespace, localName); + } + + String value = null; + + if (!this.isEmptyElement()) { + value = this.readValue(); + } else { + this.read(); + } + + return value; + } + + /** + * Read element value. + * + * @return String + */ + public String readElementValue() throws ExchangeXmlException { + this.ensureCurrentNodeIsStartElement(); + + return this.readElementValue(this.getNamespacePrefix(), this + .getLocalName()); + } + + /** + * Reads the element value. + * + * @param the generic type + * @param cls the cls + * @param xmlNamespace the xml namespace + * @param localName the local name + * @return T + */ + public T readElementValue(Class cls, XmlNamespace xmlNamespace, String localName) throws ExchangeXmlException { + if (!this.isStartElement(xmlNamespace, localName)) { + this.readStartElement(xmlNamespace, localName); + } + + T value = null; + + if (!this.isEmptyElement()) { + value = this.readValue(cls); + } + + return value; + } + + /** + * Read element value. + * + * @param the generic type + * @param cls the cls + * @return T + */ + public T readElementValue(Class cls) throws ExchangeXmlException { + this.ensureCurrentNodeIsStartElement(); + + T value = null; + + if (!this.isEmptyElement()) { + value = this.readValue(cls); + } + + return value; + } + + /** + * Reads the value. Should return content element or text node as string + * Present event must be START ELEMENT. After executing this function + * Present event will be set on END ELEMENT + * + * @return String + */ + public String readValue() throws ExchangeXmlException { + return readValue(false); + } + + /** + * Reads the value. Should return content element or text node as string + * Present event must be START ELEMENT. After executing this function + * Present event will be set on END ELEMENT + * + * @param keepWhiteSpace Do not remove whitespace characters if true + * @return String + */ + public String readValue(boolean keepWhiteSpace) throws ExchangeXmlException { + if (this.presentEvent.isStartElement()) { + // Go to next event and check for Characters event + this.read(keepWhiteSpace); + if (this.presentEvent.isCharacters()) { + final StringBuilder elementValue = new StringBuilder(); + do { + if (this.getNodeType().nodeType == XmlNodeType.CHARACTERS) { + Characters characters = (Characters) this.presentEvent; + if (keepWhiteSpace || (!characters.isIgnorableWhiteSpace() + && !characters.isWhiteSpace())) { + final String charactersData = characters.getData(); + if (charactersData != null && !charactersData.isEmpty()) { + elementValue.append(charactersData); + } + } + } + this.read(); + } while (!this.presentEvent.isEndElement()); + // Characters chars = this.presentEvent.asCharacters(); + // String elementValue = chars.getData(); + // Advance to next event post Characters (ideally it will be End + // Element) + // this.read(); + return elementValue.toString(); + } else if (this.presentEvent.isEndElement()) { + return ""; + } else { + throw new ExchangeXmlException(getReadValueErrMsg("Could not find " + XmlNodeType.getString(XmlNodeType.CHARACTERS))); + } + } else if (this.presentEvent.getEventType() == XmlNodeType.CHARACTERS + && this.presentEvent.isCharacters()) { + /* + * if(this.presentEvent.asCharacters().getData().equals("<")) { + */ + final String charData = this.presentEvent.asCharacters().getData(); + final StringBuilder data = new StringBuilder(charData == null ? "" : charData); + do { + this.read(keepWhiteSpace); + if (this.getNodeType().nodeType == XmlNodeType.CHARACTERS) { + Characters characters = (Characters) this.presentEvent; + if (keepWhiteSpace || (!characters.isIgnorableWhiteSpace() + && !characters.isWhiteSpace())) { + final String charactersData = characters.getData(); + if (charactersData != null && !charactersData.isEmpty()) { + data.append(charactersData); + } + } + } + } while (!this.presentEvent.isEndElement()); + return data.toString();// this.presentEvent. = new XMLEvent(); + /* + * } else { Characters chars = this.presentEvent.asCharacters(); + * String elementValue = chars.getData(); // Advance to next event + * post Characters (ideally it will be End // Element) this.read(); + * return elementValue; } + */ + } else { + throw new ExchangeXmlException(getReadValueErrMsg("Expected is " + XmlNodeType.getString(XmlNodeType.START_ELEMENT)) + ); + } + + } + + /** + * Tries to read value. + * + * @param value the value + * @return boolean + */ + public boolean tryReadValue(OutParam value) throws ExchangeXmlException { + if (!this.isEmptyElement()) { + this.read(); + + if (this.presentEvent.isCharacters()) { + value.setParam(this.readValue()); + return true; + } else { + return false; + } + } else { + return false; + } + } + + /** + * Reads the value. + * + * @param the generic type + * @param cls the cls + * @return T + */ + public T readValue(Class cls) throws ExchangeXmlException { + return EwsUtilities.parse(cls, this.readValue()); + } + + public byte[] writeBase64ElementValue() throws ExchangeXmlException { + this.ensureCurrentNodeIsStartElement(); + try { + ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream(); + byte[] buffer = Base64.getMimeDecoder().decode(this.xmlReader.getElementText()); + byteArrayStream.write(buffer); + return byteArrayStream.toByteArray(); + } catch (XMLStreamException | IOException e) { + throw new ExchangeXmlException("error reading base64 element value", e); + } + + } + + public void writeBase64ElementValue(OutputStream outputStream) throws ExchangeXmlException { + this.ensureCurrentNodeIsStartElement(); + try { + byte[] buffer = Base64.getMimeDecoder().decode(this.xmlReader.getElementText()); + outputStream.write(buffer); + outputStream.flush(); + } catch (XMLStreamException | IOException e) { + throw new ExchangeXmlException("error reading base64 element value", e); + } + } + + /** + * Reads the start element. + * + * @param namespacePrefix the namespace prefix + * @param localName the local name + */ + public void readStartElement(String namespacePrefix, String localName) throws ExchangeXmlException { + this.internalReadElement(namespacePrefix, localName, new XmlNodeType(XmlNodeType.START_ELEMENT)); + } + + /** + * Reads the start element. + * + * @param xmlNamespace the xml namespace + * @param localName the local name + */ + public void readStartElement(XmlNamespace xmlNamespace, String localName) throws ExchangeXmlException { + this.internalReadElement(xmlNamespace, localName, new XmlNodeType( + XmlNodeType.START_ELEMENT)); + } + + /** + * Reads the end element. + * + * @param namespacePrefix the namespace prefix + * @param elementName the element name + */ + public void readEndElement(String namespacePrefix, String elementName) throws ExchangeXmlException { + this.internalReadElement(namespacePrefix, elementName, new XmlNodeType( + XmlNodeType.END_ELEMENT)); + } + + /** + * Reads the end element. + * + * @param xmlNamespace the xml namespace + * @param localName the local name + */ + public void readEndElement(XmlNamespace xmlNamespace, String localName) throws ExchangeXmlException { + this.internalReadElement(xmlNamespace, localName, new XmlNodeType(XmlNodeType.END_ELEMENT)); + } + + /** + * Reads the end element if necessary. + * + * @param xmlNamespace the xml namespace + * @param localName the local name + */ + public void readEndElementIfNecessary(XmlNamespace xmlNamespace, String localName) throws ExchangeXmlException { + + if (!(this.isStartElement(xmlNamespace, localName) && this + .isEmptyElement())) { + if (!this.isEndElement(xmlNamespace, localName)) { + this.readEndElement(xmlNamespace, localName); + } + } + } + + /** + * Determines whether current element is a start element. + * + * @return boolean + */ + public boolean isStartElement() { + return this.presentEvent.isStartElement(); + } + + /** + * Determines whether current element is a start element. + * + * @param namespacePrefix the namespace prefix + * @param localName the local name + * @return boolean + */ + public boolean isStartElement(String namespacePrefix, String localName) { + boolean isStart = false; + if (this.presentEvent.isStartElement()) { + StartElement startElement = this.presentEvent.asStartElement(); + QName qName = startElement.getName(); + isStart = qName.getLocalPart().equals(localName) + && qName.getPrefix().equals(namespacePrefix); + } + return isStart; + } + + /** + * Determines whether current element is a start element. + * + * @param xmlNamespace the xml namespace + * @param localName the local name + * @return true for matching start element; false otherwise. + */ + public boolean isStartElement(XmlNamespace xmlNamespace, String localName) { + return this.isStartElement() + && Objects.equals(getLocalName(), localName) + && ( + Objects.equals(getNamespacePrefix(), EwsUtilities.getNamespacePrefix(xmlNamespace)) || + Objects.equals(getNamespaceUri(), EwsUtilities.getNamespaceUri(xmlNamespace))); + } + + /** + * Determines whether current element is a end element. + * + * @param namespacePrefix the namespace prefix + * @param localName the local name + * @return boolean + */ + public boolean isEndElement(String namespacePrefix, String localName) { + boolean isEndElement = false; + if (this.presentEvent.isEndElement()) { + EndElement endElement = this.presentEvent.asEndElement(); + QName qName = endElement.getName(); + isEndElement = qName.getLocalPart().equals(localName) + && qName.getPrefix().equals(namespacePrefix); + + } + return isEndElement; + } + + /** + * Determines whether current element is a end element. + * + * @param xmlNamespace the xml namespace + * @param localName the local name + * @return boolean + */ + public boolean isEndElement(XmlNamespace xmlNamespace, String localName) { + + boolean isEndElement = false; + /* + * if(localName.equals("Body")) { return true; } else + */ + if (this.presentEvent.isEndElement()) { + EndElement endElement = this.presentEvent.asEndElement(); + QName qName = endElement.getName(); + isEndElement = qName.getLocalPart().equals(localName) + && (qName.getPrefix().equals( + EwsUtilities.getNamespacePrefix(xmlNamespace)) || + qName.getNamespaceURI().equals( + EwsUtilities.getNamespaceUri( + xmlNamespace))); + + } + return isEndElement; + } + + /** + * Skips the element. + * + * @param namespacePrefix the namespace prefix + * @param localName the local name + */ + public void skipElement(String namespacePrefix, String localName) throws ExchangeXmlException { + if (!this.isEndElement(namespacePrefix, localName)) { + if (!this.isStartElement(namespacePrefix, localName)) { + this.readStartElement(namespacePrefix, localName); + } + + if (!this.isEmptyElement()) { + do { + this.read(); + } while (!this.isEndElement(namespacePrefix, localName)); + } + } + } + + /** + * Skips the element. + * + * @param xmlNamespace the xml namespace + * @param localName the local name + */ + public void skipElement(XmlNamespace xmlNamespace, String localName) throws ExchangeXmlException { + if (!this.isEndElement(xmlNamespace, localName)) { + if (!this.isStartElement(xmlNamespace, localName)) { + this.readStartElement(xmlNamespace, localName); + } + + if (!this.isEmptyElement()) { + do { + this.read(); + } while (!this.isEndElement(xmlNamespace, localName)); + } + } + } + + /** + * Skips the current element. + */ + public void skipCurrentElement() throws ExchangeXmlException { + this.skipElement(this.getNamespacePrefix(), this.getLocalName()); + } + + /** + * Ensures the current node is start element. + * + * @param xmlNamespace the xml namespace + * @param localName the local name + */ + public void ensureCurrentNodeIsStartElement(XmlNamespace xmlNamespace, String localName) throws ExchangeXmlException { + if (!this.isStartElement(xmlNamespace, localName)) { + throw new ExchangeXmlException(String.format("The element '%s' in namespace '%s' wasn't found at the current position.", localName, xmlNamespace)); + } + } + + /** + * Ensures the current node is start element. + */ + public void ensureCurrentNodeIsStartElement() throws ExchangeXmlException { + XmlNodeType presentNodeType = new XmlNodeType(this.presentEvent.getEventType()); + if (!this.presentEvent.isStartElement()) { + throw new ExchangeXmlException(String.format("The start element was expected, but node '%s' of type %s was found.", this.presentEvent.toString(), presentNodeType)); + } + } + + /** + * Ensures the current node is start element. + * + * @param xmlNamespace the xml namespace + * @param localName the local name + */ + public void ensureCurrentNodeIsEndElement(XmlNamespace xmlNamespace, + String localName) throws ExchangeXmlException { + if (!this.isEndElement(xmlNamespace, localName)) { + if (!(this.isStartElement(xmlNamespace, localName) && this.isEmptyElement())) { + throw new ExchangeXmlException(String.format("The element '%s' in namespace '%s' wasn't found at the current position.", xmlNamespace, localName)); + } + } + } + + /** + * Outer XML as string. + * + * @return String + * @throws ServiceXmlDeserializationException the service xml deserialization exception + * @throws XMLStreamException the XML stream exception + */ + public String readOuterXml() throws ServiceXmlDeserializationException, XMLStreamException { + if (!this.isStartElement()) { + throw new ServiceXmlDeserializationException("The current position is not the start of an element."); + } + XMLEvent startEvent = this.presentEvent; + XMLEvent event; + StringBuilder str = new StringBuilder(); + str.append(startEvent); + do { + event = this.xmlReader.nextEvent(); + str.append(event); + } while (!checkEndElement(startEvent, event)); + + return str.toString(); + } + + /** + * Reads the Inner XML at the given location. + * + * @return String + * @throws ServiceXmlDeserializationException the service xml deserialization exception + * @throws XMLStreamException the XML stream exception + */ + public String readInnerXml() throws ServiceXmlDeserializationException, + XMLStreamException { + if (!this.isStartElement()) { + throw new ServiceXmlDeserializationException("The current position is not the start of an element."); + } + + XMLEvent startEvent = this.presentEvent; + StringBuilder str = new StringBuilder(); + do { + XMLEvent event = this.xmlReader.nextEvent(); + if (checkEndElement(startEvent, event)) { + break; + } + str.append(event); + } while (true); + + return str.toString(); + } + + /** + * Check end element. + * + * @param startEvent the start event + * @param endEvent the end event + * @return true, if successful + */ + public static boolean checkEndElement(XMLEvent startEvent, XMLEvent endEvent) { + boolean isEndElement = false; + if (endEvent.isEndElement()) { + QName qEName = endEvent.asEndElement().getName(); + QName qSName = startEvent.asStartElement().getName(); + isEndElement = qEName.getLocalPart().equals(qSName.getLocalPart()) + && (qEName.getPrefix().equals(qSName.getPrefix()) || qEName + .getNamespaceURI().equals(qSName. + getNamespaceURI())); + + } + return isEndElement; + } + + /** + * Gets the XML reader for node. + * + * @return null + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlDeserializationException the service xml deserialization exception + * @throws FileNotFoundException the file not found exception + */ + public XMLEventReader getXmlReaderForNode() + throws FileNotFoundException, ServiceXmlDeserializationException, XMLStreamException { + return readSubtree(); + } + + public XMLEventReader readSubtree() throws XMLStreamException, ServiceXmlDeserializationException { + + if (!this.isStartElement()) { + throw new ServiceXmlDeserializationException("The current position is not the start of an element."); + } + + XMLEventReader eventReader = null; + InputStream in = null; + XMLEvent startEvent = this.presentEvent; + XMLEvent event = startEvent; + StringBuilder str = new StringBuilder(); + str.append(startEvent); + do { + event = this.xmlReader.nextEvent(); + str.append(event); + } while (!checkEndElement(startEvent, event)); + + try { + + XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + + in = new ByteArrayInputStream(str.toString().getBytes(StandardCharsets.UTF_8)); + eventReader = inputFactory.createXMLEventReader(in); + + } catch (Exception e) { + LOG.log(Level.SEVERE, "error reading subtree", e); + } + return eventReader; + } + + /** + * Reads to the next descendant element with the specified local name and + * namespace. + * + * @param xmlNamespace The namespace of the element you with to move to. + * @param localName The local name of the element you wish to move to. + * @throws XMLStreamException the XML stream exception + */ + public void readToDescendant(XmlNamespace xmlNamespace, String localName) throws XMLStreamException { + readToDescendant(localName, EwsUtilities.getNamespaceUri(xmlNamespace)); + } + + public boolean readToDescendant(String localName, String namespaceURI) throws XMLStreamException { + + if (!this.isStartElement()) { + return false; + } + XMLEvent startEvent = this.presentEvent; + XMLEvent event = this.presentEvent; + do { + if (event.isStartElement()) { + QName qEName = event.asStartElement().getName(); + if (qEName.getLocalPart().equals(localName) && + qEName.getNamespaceURI().equals(namespaceURI)) { + return true; + } + } + event = this.xmlReader.nextEvent(); + } while (!checkEndElement(startEvent, event)); + + return false; + } + + + /** + * Gets a value indicating whether this instance has attribute. + * + * @return boolean + */ + public boolean hasAttributes() { + + if (this.presentEvent.isStartElement()) { + StartElement startElement = this.presentEvent.asStartElement(); + return startElement.getAttributes().hasNext(); + } else { + return false; + } + } + + /** + * Gets a value indicating whether current element is empty. + * + * @return boolean + * @throws XMLStreamException the XML stream exception + */ + public boolean isEmptyElement() throws ExchangeXmlException { + try { + boolean isPresentStartElement = this.presentEvent.isStartElement(); + boolean isNextEndElement = this.xmlReader.peek().isEndElement(); + return isPresentStartElement && isNextEndElement; + } catch (XMLStreamException e) { + throw new ExchangeXmlException("error peeking next XML event", e); + } + } + + /** + * Gets the local name of the current element. + * + * @return String + */ + public String getLocalName() { + + String localName = null; + + if (this.presentEvent.isStartElement()) { + localName = this.presentEvent.asStartElement().getName() + .getLocalPart(); + } else { + + localName = this.presentEvent.asEndElement().getName() + .getLocalPart(); + } + return localName; + } + + /** + * Gets the namespace prefix. + * + * @return String + */ + protected String getNamespacePrefix() { + if (this.presentEvent.isStartElement()) { + return this.presentEvent.asStartElement().getName().getPrefix(); + } + if (this.presentEvent.isEndElement()) { + return this.presentEvent.asEndElement().getName().getPrefix(); + } + return null; + } + + /** + * Gets the namespace URI. + * + * @return String + */ + public String getNamespaceUri() { + + String nameSpaceUri; + if (this.presentEvent.isStartElement()) { + nameSpaceUri = this.presentEvent.asStartElement().getName() + .getNamespaceURI(); + } else { + + nameSpaceUri = this.presentEvent.asEndElement().getName() + .getNamespaceURI(); + } + return nameSpaceUri; + } + + /** + * Gets the type of the node. + * @return XmlNodeType + */ + public XmlNodeType getNodeType() { + XMLEvent event = this.presentEvent; + return new XmlNodeType(event.getEventType()); + } + + /** + * Gets the name of the current element. + * + * @return Object + */ + protected Object getName() { + String name; + if (this.presentEvent.isStartElement()) { + name = this.presentEvent.asStartElement().getName().toString(); + } else { + + name = this.presentEvent.asEndElement().getName().toString(); + } + return name; + } + + /** + * Checks is the string is null or empty. + * + * @param namespacePrefix the namespace prefix + * @return true, if is null or empty + */ + private static boolean isNullOrEmpty(String namespacePrefix) { + return (namespacePrefix == null || namespacePrefix.isEmpty()); + + } + + /** + * Gets the error message which happened during {@link #readValue()}. + * + * @param details details message + * @return error message with details + */ + private String getReadValueErrMsg(final String details) { + final int eventType = this.presentEvent.getEventType(); + return "Could not read value from " + XmlNodeType.getString(eventType) + "." + details; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/ExchangeServerInfo.java b/ews-api/src/main/java/com/eischet/ews/api/core/ExchangeServerInfo.java new file mode 100644 index 000000000..3150a3879 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/ExchangeServerInfo.java @@ -0,0 +1,197 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +/** + * Represents Exchange server information. + */ +public final class ExchangeServerInfo { + + /** + * The major version. + */ + private int majorVersion; + + /** + * The minor version. + */ + private int minorVersion; + + /** + * The major build number. + */ + private int majorBuildNumber; + + /** + * The minor build number. + */ + private int minorBuildNumber; + + /** + * The version string. + */ + private String versionString; + + /* + * Default constructor + */ + + /** + * Instantiates a new exchange server info. + */ + public ExchangeServerInfo() { + + } + + /** + * Parse current element to extract server information. + * + * @param reader EwsServiceXmlReader + * @return ExchangeServerInfo + * @throws Exception the exception + */ + public static ExchangeServerInfo parse(EwsServiceXmlReader reader) + throws Exception { + EwsUtilities.ewsAssert(reader.hasAttributes(), "ExchangeServerVersion.Parse", + "Current element doesn't have attribute"); + + ExchangeServerInfo info = new ExchangeServerInfo(); + info.majorVersion = reader.readAttributeValue(Integer.class, + "MajorVersion"); + info.minorVersion = reader.readAttributeValue(Integer.class, + "MinorVersion"); + info.majorBuildNumber = reader.readAttributeValue(Integer.class, + "MajorBuildNumber"); + info.minorBuildNumber = reader.readAttributeValue(Integer.class, + "MinorBuildNumber"); + info.versionString = reader.readAttributeValue("Version"); + return info; + } + + /** + * Gets the Major Exchange server version number. + * + * @return the major version + */ + public int getMajorVersion() { + return this.majorVersion; + } + + /** + * Sets the major version. + * + * @param majorVersion the new major version + */ + public void setMajorVersion(int majorVersion) { + this.majorVersion = majorVersion; + } + + /** + * Gets the Minor Exchange server version number. + * + * @return the minor version + */ + public int getMinorVersion() { + return minorVersion; + } + + /** + * Sets the minor version. + * + * @param minorVersion the new minor version + */ + public void setMinorVersion(int minorVersion) { + this.minorVersion = minorVersion; + } + + /** + * Gets the Major Exchange server build number. + * + * @return the major build number + */ + public int getMajorBuildNumber() { + return majorBuildNumber; + } + + /** + * Sets the major build number. + * + * @param majorBuildNumber the new major build number + */ + public void setMajorBuildNumber(int majorBuildNumber) { + this.majorBuildNumber = majorBuildNumber; + } + + /** + * Gets the Minor Exchange server build number. + * + * @return the minor build number + */ + public int getMinorBuildNumber() { + return minorBuildNumber; + } + + /** + * Sets the minor build number. + * + * @param minorBuildNumber the new minor build number + */ + public void setMinorBuildNumber(int minorBuildNumber) { + this.minorBuildNumber = minorBuildNumber; + } + + /** + * Gets the Exchange server version string (e.g. "Exchange2010") + * + * @return the version string + */ + // / The version is a string rather than an enum since its possible for the + // client to + // / be connected to a later server for which there would be no appropriate + // enum value. + public String getVersionString() { + return versionString; + } + + /** + * Sets the version string. + * + * @param versionString the new version string + */ + public void setVersionString(String versionString) { + this.versionString = versionString; + } + + /** + * Override ToString method. + * + * @return the string + */ + @Override + public String toString() { + return String + .format("%d,%2d,%4d,%3d", this.majorVersion, this.minorVersion, + this.majorBuildNumber, this.minorBuildNumber); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/ExchangeService.java b/ews-api/src/main/java/com/eischet/ews/api/core/ExchangeService.java new file mode 100644 index 000000000..df30e2bea --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/ExchangeService.java @@ -0,0 +1,3869 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.autodiscover.AutodiscoverService; +import com.eischet.ews.api.autodiscover.IAutodiscoverRedirectionUrl; +import com.eischet.ews.api.autodiscover.enumeration.UserSettingName; +import com.eischet.ews.api.autodiscover.exception.AutodiscoverLocalException; +import com.eischet.ews.api.autodiscover.request.ApplyConversationActionRequest; +import com.eischet.ews.api.autodiscover.response.GetUserSettingsResponse; +import com.eischet.ews.api.core.enumeration.availability.AvailabilityData; +import com.eischet.ews.api.core.enumeration.misc.*; +import com.eischet.ews.api.core.enumeration.notification.EventType; +import com.eischet.ews.api.core.enumeration.property.BodyType; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.enumeration.search.ResolveNameSearchLocation; +import com.eischet.ews.api.core.enumeration.service.*; +import com.eischet.ews.api.core.enumeration.service.calendar.AffectedTaskOccurrence; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.misc.ArgumentOutOfRangeException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.remote.AccountIsLockedException; +import com.eischet.ews.api.core.exception.service.remote.ServiceRemoteException; +import com.eischet.ews.api.core.exception.service.remote.ServiceResponseException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.request.*; +import com.eischet.ews.api.core.response.*; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.folder.Folder; +import com.eischet.ews.api.core.service.item.Appointment; +import com.eischet.ews.api.core.service.item.Conversation; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.http.ExchangeHttpClient; +import com.eischet.ews.api.messaging.UnifiedMessaging; +import com.eischet.ews.api.misc.*; +import com.eischet.ews.api.misc.availability.AttendeeInfo; +import com.eischet.ews.api.misc.availability.AvailabilityOptions; +import com.eischet.ews.api.misc.availability.GetUserAvailabilityResults; +import com.eischet.ews.api.misc.availability.TimeWindow; +import com.eischet.ews.api.misc.id.AlternateIdBase; +import com.eischet.ews.api.notification.GetEventsResults; +import com.eischet.ews.api.notification.PullSubscription; +import com.eischet.ews.api.notification.PushSubscription; +import com.eischet.ews.api.notification.StreamingSubscription; +import com.eischet.ews.api.property.complex.*; +import com.eischet.ews.api.property.complex.availability.OofSettings; +import com.eischet.ews.api.property.complex.time.TimeZoneDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinitionBase; +import com.eischet.ews.api.search.*; +import com.eischet.ews.api.search.filter.SearchFilter; +import com.eischet.ews.api.sync.ChangeCollection; +import com.eischet.ews.api.sync.FolderChange; +import com.eischet.ews.api.sync.ItemChange; +import org.w3c.dom.Document; +import org.w3c.dom.Node; + +import java.net.URI; +import java.net.URISyntaxException; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents a binding to the Exchange Web Services. + */ +public class ExchangeService extends ExchangeServiceBase implements IAutodiscoverRedirectionUrl { + + private static final Logger LOG = Logger.getLogger(ExchangeService.class.getCanonicalName()); + + /** + * The url. + */ + private URI url; + + /** + * The preferred culture. + */ + private Locale preferredCulture; + + /** + * The DateTimePrecision + */ + private DateTimePrecision dateTimePrecision = DateTimePrecision.Default; + + /** + * The impersonated user id. + */ + private ImpersonatedUserId impersonatedUserId; + // private Iterator Iterator; + /** + * The file attachment content handler. + */ + private IFileAttachmentContentHandler fileAttachmentContentHandler; + + /** + * The unified messaging. + */ + private UnifiedMessaging unifiedMessaging; + + private boolean enableScpLookup = true; + + /** + * When false, used to indicate that we should use "Exchange2007" as the server version String rather than + * Exchange2007_SP1 (@see #getExchange2007CompatibilityMode). + */ + private boolean exchange2007CompatibilityMode = false; + + /** + * Create response object. + * + * @param responseObject the response object + * @param parentFolderId the parent folder id + * @param messageDisposition the message disposition + * @return The list of item created or modified as a result of the + * "creation" of the response object. + * @throws Exception the exception + */ + public List internalCreateResponseObject(ServiceObject responseObject, FolderId parentFolderId, + MessageDisposition messageDisposition) throws Exception { + CreateResponseObjectRequest request = new CreateResponseObjectRequest( + this, ServiceErrorHandling.ThrowOnError); + Collection serviceList = new ArrayList<>(); + serviceList.add(responseObject); + request.setParentFolderId(parentFolderId); + request.setItems(serviceList); + request.setMessageDisposition(messageDisposition); + + ServiceResponseCollection responses = request + .execute(); + + return responses.getResponseAtIndex(0).getItems(); + } + + /** + * Creates a folder. Calling this method results in a call to EWS. + * + * @param folder The folder. + * @param parentFolderId The parent folder Id + * @throws Exception the exception + */ + public void createFolder(Folder folder, FolderId parentFolderId) + throws Exception { + CreateFolderRequest request = new CreateFolderRequest(this, + ServiceErrorHandling.ThrowOnError); + List folArry = new ArrayList(); + folArry.add(folder); + request.setFolders(folArry); + request.setParentFolderId(parentFolderId); + + request.execute(); + } + + /** + * Updates a folder. + * + * @param folder The folder. + * @throws Exception the exception + */ + public void updateFolder(Folder folder) throws Exception { + UpdateFolderRequest request = new UpdateFolderRequest(this, + ServiceErrorHandling.ThrowOnError); + + request.getFolders().add(folder); + + request.execute(); + } + + /** + * Copies a folder. Calling this method results in a call to EWS. + * + * @param folderId The folderId. + * @param destinationFolderId The destination folder id. + * @return the folder + * @throws Exception the exception + */ + public Folder copyFolder(FolderId folderId, FolderId destinationFolderId) + throws Exception { + CopyFolderRequest request = new CopyFolderRequest(this, + ServiceErrorHandling.ThrowOnError); + + request.setDestinationFolderId(destinationFolderId); + request.getFolderIds().add(folderId); + + ServiceResponseCollection responses = request + .execute(); + + return responses.getResponseAtIndex(0).getFolder(); + } + + /** + * Move a folder. + * + * @param folderId The folderId. + * @param destinationFolderId The destination folder id. + * @return the folder + * @throws Exception the exception + */ + public Folder moveFolder(FolderId folderId, FolderId destinationFolderId) + throws Exception { + MoveFolderRequest request = new MoveFolderRequest(this, + ServiceErrorHandling.ThrowOnError); + + request.setDestinationFolderId(destinationFolderId); + request.getFolderIds().add(folderId); + + ServiceResponseCollection responses = request + .execute(); + + return responses.getResponseAtIndex(0).getFolder(); + } + + /** + * Finds folder. + * + * @param parentFolderIds The parent folder ids. + * @param searchFilter The search filter. Available search filter classes include + * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection + * @param view The view controlling the number of folder returned. + * @param errorHandlingMode Indicates the type of error handling should be done. + * @return Collection of service response. + * @throws Exception the exception + */ + private ServiceResponseCollection internalFindFolders( + Iterable parentFolderIds, SearchFilter searchFilter, + FolderView view, ServiceErrorHandling errorHandlingMode) + throws Exception { + FindFolderRequest request = new FindFolderRequest(this, + errorHandlingMode); + + request.getParentFolderIds().addRangeFolderId(parentFolderIds); + request.setSearchFilter(searchFilter); + request.setView(view); + + return request.execute(); + + } + + /** + * Obtains a list of folder by searching the sub-folder of the specified + * folder. + * + * @param parentFolderId The Id of the folder in which to search for folder. + * @param searchFilter The search filter. Available search filter classes include + * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection + * @param view The view controlling the number of folder returned. + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindFoldersResults findFolders(FolderId parentFolderId, + SearchFilter searchFilter, FolderView view) throws Exception { + EwsUtilities.validateParam(parentFolderId, "parentFolderId"); + EwsUtilities.validateParam(view, "view"); + EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); + + List folderIdArray = new ArrayList(); + folderIdArray.add(parentFolderId); + ServiceResponseCollection responses = this + .internalFindFolders(folderIdArray, searchFilter, view, + ServiceErrorHandling.ThrowOnError); + + return responses.getResponseAtIndex(0).getResults(); + } + + /** + * Obtains a list of folder by searching the sub-folder of the specified + * folder. + * + * @param parentFolderId The Id of the folder in which to search for folder. + * @param view The view controlling the number of folder returned. + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindFoldersResults findFolders(FolderId parentFolderId, + FolderView view) throws Exception { + EwsUtilities.validateParam(parentFolderId, "parentFolderId"); + EwsUtilities.validateParam(view, "view"); + + List folderIdArray = new ArrayList(); + folderIdArray.add(parentFolderId); + + ServiceResponseCollection responses = this + .internalFindFolders(folderIdArray, null, /* searchFilter */ + view, ServiceErrorHandling.ThrowOnError); + + return responses.getResponseAtIndex(0).getResults(); + } + + /** + * Obtains a list of folder by searching the sub-folder of the specified + * folder. + * + * @param parentFolderName The name of the folder in which to search for folder. + * @param searchFilter The search filter. Available search filter classes include + * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection + * @param view The view controlling the number of folder returned. + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindFoldersResults findFolders(WellKnownFolderName parentFolderName, + SearchFilter searchFilter, FolderView view) throws Exception { + return this.findFolders(new FolderId(parentFolderName), searchFilter, + view); + } + + /** + * Obtains a list of folder by searching the sub-folder of the specified + * folder. + * + * @param parentFolderName the parent folder name + * @param view the view + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindFoldersResults findFolders(WellKnownFolderName parentFolderName, + FolderView view) throws Exception { + return this.findFolders(new FolderId(parentFolderName), view); + } + + /** + * Load specified property for a folder. + * + * @param folder The folder + * @param propertySet The property set + * @throws Exception the exception + */ + public void loadPropertiesForFolder(Folder folder, PropertySet propertySet) throws Exception { + EwsUtilities.validateParam(folder, "folder"); + EwsUtilities.validateParam(propertySet, "propertySet"); + + GetFolderRequestForLoad request = new GetFolderRequestForLoad(this, + ServiceErrorHandling.ThrowOnError); + + request.getFolderIds().add(folder); + request.setPropertySet(propertySet); + + request.execute(); + } + + /** + * Binds to a folder. + * + * @param folderId the folder id + * @param propertySet the property set + * @return Folder + * @throws Exception the exception + */ + public Folder bindToFolder(FolderId folderId, PropertySet propertySet) + throws Exception { + EwsUtilities.validateParam(folderId, "folderId"); + EwsUtilities.validateParam(propertySet, "propertySet"); + + GetFolderRequest request = new GetFolderRequest(this, + ServiceErrorHandling.ThrowOnError); + + request.getFolderIds().add(folderId); + request.setPropertySet(propertySet); + + ServiceResponseCollection responses = request + .execute(); + + return responses.getResponseAtIndex(0).getFolder(); + + } + + /** + * Binds to folder. + * + * @param The type of the folder. + * @param cls Folder class + * @param folderId The folder id. + * @param propertySet The property set. + * @return Folder + * @throws Exception the exception + */ + public TFolder bindToFolder(Class cls, FolderId folderId, + PropertySet propertySet) throws Exception { + Folder result = this.bindToFolder(folderId, propertySet); + + if (cls.isAssignableFrom(result.getClass())) { + return (TFolder) result; + } else { + throw new ServiceLocalException(String.format( + "The folder type returned by the service (%s) isn't compatible with the requested folder type (%s).", + result.getClass().getName(), cls.getName())); + } + } + + /** + * Deletes a folder. Calling this method results in a call to EWS. + * + * @param folderId The folder id + * @param deleteMode The delete mode + * @throws Exception the exception + */ + public void deleteFolder(FolderId folderId, DeleteMode deleteMode) + throws Exception { + EwsUtilities.validateParam(folderId, "folderId"); + + DeleteFolderRequest request = new DeleteFolderRequest(this, + ServiceErrorHandling.ThrowOnError); + + request.getFolderIds().add(folderId); + request.setDeleteMode(deleteMode); + + request.execute(); + } + + /** + * Empties a folder. Calling this method results in a call to EWS. + * + * @param folderId The folder id + * @param deleteMode The delete mode + * @param deleteSubFolders if set to "true" empty folder should also delete sub folder. + * @throws Exception the exception + */ + public void emptyFolder(FolderId folderId, DeleteMode deleteMode, boolean deleteSubFolders) throws Exception { + EwsUtilities.validateParam(folderId, "folderId"); + + EmptyFolderRequest request = new EmptyFolderRequest(this, + ServiceErrorHandling.ThrowOnError); + + request.getFolderIds().add(folderId); + request.setDeleteMode(deleteMode); + request.setDeleteSubFolders(deleteSubFolders); + request.execute(); + } + + /** + * Creates multiple item in a single EWS call. Supported item classes are + * EmailMessage, Appointment, Contact, PostItem, Task and Item. CreateItems + * does not support item that have unsaved attachments. + * + * @param items the item + * @param parentFolderId the parent folder id + * @param messageDisposition the message disposition + * @param sendInvitationsMode the send invitations mode + * @param errorHandling the error handling + * @return A ServiceResponseCollection providing creation results for each + * of the specified item. + * @throws Exception the exception + */ + private ServiceResponseCollection internalCreateItems( + Collection items, FolderId parentFolderId, + MessageDisposition messageDisposition, + SendInvitationsMode sendInvitationsMode, + ServiceErrorHandling errorHandling) throws Exception { + CreateItemRequest request = new CreateItemRequest(this, errorHandling); + request.setParentFolderId(parentFolderId); + request.setItems(items); + request.setMessageDisposition(messageDisposition); + request.setSendInvitationsMode(sendInvitationsMode); + return request.execute(); + } + + /** + * Creates multiple item in a single EWS call. Supported item classes are + * EmailMessage, Appointment, Contact, PostItem, Task and Item. CreateItems + * does not support item that have unsaved attachments. + * + * @param items the item + * @param parentFolderId the parent folder id + * @param messageDisposition the message disposition + * @param sendInvitationsMode the send invitations mode + * @return A ServiceResponseCollection providing creation results for each + * of the specified item. + * @throws Exception the exception + */ + public ServiceResponseCollection createItems( + Collection items, FolderId parentFolderId, + MessageDisposition messageDisposition, + SendInvitationsMode sendInvitationsMode) throws Exception { + // All item have to be new. + if (!EwsUtilities.trueForAll(items, ServiceObject::isNew)) { + throw new ExchangeValidationException( + "This operation can't be performed because at least one item already has an ID."); + } + + // E14:298274 Make sure that all item do *not* have unprocessed + // attachments. + if (!EwsUtilities.trueForAll(items, new IPredicate() { + @Override + public boolean predicate(Item obj) throws ExchangeXmlException { + return !obj.hasUnprocessedAttachmentChanges(); + } + })) { + throw new ExchangeValidationException("This operation doesn't support item that have attachments."); + } + return this.internalCreateItems(items, parentFolderId, + messageDisposition, sendInvitationsMode, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Creates an item. Calling this method results in a call to EWS. + * + * @param item the item + * @param parentFolderId the parent folder id + * @param messageDisposition the message disposition + * @param sendInvitationsMode the send invitations mode + * @throws Exception the exception + */ + public void createItem(Item item, FolderId parentFolderId, MessageDisposition messageDisposition, + SendInvitationsMode sendInvitationsMode) throws Exception { + ArrayList items = new ArrayList(); + items.add(item); + internalCreateItems(items, parentFolderId, messageDisposition, sendInvitationsMode, + ServiceErrorHandling.ThrowOnError); + } + + /** + * Updates multiple item in a single EWS call. UpdateItems does not + * support item that have unsaved attachments. + * + * @param items the item + * @param savedItemsDestinationFolderId the saved item destination folder id + * @param conflictResolution the conflict resolution + * @param messageDisposition the message disposition + * @param sendInvitationsOrCancellationsMode the send invitations or cancellations mode + * @param errorHandling the error handling + * @return A ServiceResponseCollection providing update results for each of + * the specified item. + * @throws Exception the exception + */ + private ServiceResponseCollection internalUpdateItems( + Iterable items, + FolderId savedItemsDestinationFolderId, + ConflictResolutionMode conflictResolution, + MessageDisposition messageDisposition, + SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode, + ServiceErrorHandling errorHandling) throws Exception { + UpdateItemRequest request = new UpdateItemRequest(this, errorHandling); + + request.getItems().addAll((Collection) items); + request.setSavedItemsDestinationFolder(savedItemsDestinationFolderId); + request.setMessageDisposition(messageDisposition); + request.setConflictResolutionMode(conflictResolution); + request + .setSendInvitationsOrCancellationsMode(sendInvitationsOrCancellationsMode); + + return request.execute(); + } + + /** + * Updates multiple item in a single EWS call. UpdateItems does not + * support item that have unsaved attachments. + * + * @param items the item + * @param savedItemsDestinationFolderId the saved item destination folder id + * @param conflictResolution the conflict resolution + * @param messageDisposition the message disposition + * @param sendInvitationsOrCancellationsMode the send invitations or cancellations mode + * @return A ServiceResponseCollection providing update results for each of + * the specified item. + * @throws Exception the exception + */ + public ServiceResponseCollection updateItems( + Iterable items, + FolderId savedItemsDestinationFolderId, + ConflictResolutionMode conflictResolution, + MessageDisposition messageDisposition, + SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode) + throws Exception { + + // All item have to exist on the server (!new) and modified (dirty) + if (!EwsUtilities.trueForAll(items, new IPredicate() { + @Override + public boolean predicate(Item obj) throws ExchangeXmlException { + return (!obj.isNew() && obj.isDirty()); + } + })) { + throw new ExchangeValidationException( + "This operation can't be performed because one or more item are new or unmodified."); + } + + // E14:298274 Make sure that all item do *not* have unprocessed + // attachments. + if (!EwsUtilities.trueForAll(items, new IPredicate() { + @Override + public boolean predicate(Item obj) throws ExchangeXmlException { + return !obj.hasUnprocessedAttachmentChanges(); + } + })) { + throw new ExchangeValidationException( + "This operation can't be performed because attachments have been added or deleted for one or more item."); + } + + return this.internalUpdateItems(items, savedItemsDestinationFolderId, conflictResolution, + messageDisposition, sendInvitationsOrCancellationsMode, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Updates an item. + * + * @param item the item + * @param savedItemsDestinationFolderId the saved item destination folder id + * @param conflictResolution the conflict resolution + * @param messageDisposition the message disposition + * @param sendInvitationsOrCancellationsMode the send invitations or cancellations mode + * @return A ServiceResponseCollection providing deletion results for each + * of the specified item Ids. + * @throws Exception the exception + */ + public Item updateItem(Item item, FolderId savedItemsDestinationFolderId, + ConflictResolutionMode conflictResolution, MessageDisposition messageDisposition, + SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode) + throws Exception { + List itemIdArray = new ArrayList<>(); + itemIdArray.add(item); + + ServiceResponseCollection responses = this + .internalUpdateItems(itemIdArray, + savedItemsDestinationFolderId, conflictResolution, + messageDisposition, sendInvitationsOrCancellationsMode, + ServiceErrorHandling.ThrowOnError); + + return responses.getResponseAtIndex(0).getReturnedItem(); + } + + /** + * Send item. + * + * @param item the item + * @param savedCopyDestinationFolderId the saved copy destination folder id + * @throws Exception the exception + */ + public void sendItem(Item item, FolderId savedCopyDestinationFolderId) + throws Exception { + SendItemRequest request = new SendItemRequest(this, + ServiceErrorHandling.ThrowOnError); + + List itemIdArray = new ArrayList<>(); + itemIdArray.add(item); + + request.setItems(itemIdArray); + request.setSavedCopyDestinationFolderId(savedCopyDestinationFolderId); + + request.execute(); + } + + /** + * Copies multiple item in a single call to EWS. + * + * @param itemIds the item ids + * @param destinationFolderId the destination folder id + * @param returnNewItemIds Flag indicating whether service should return new ItemIds or + * not. + * @param errorHandling the error handling + * @return A ServiceResponseCollection providing copy results for each of + * the specified item Ids. + * @throws Exception the exception + */ + private ServiceResponseCollection internalCopyItems( + Iterable itemIds, FolderId destinationFolderId, + Boolean returnNewItemIds, ServiceErrorHandling errorHandling) + throws Exception { + CopyItemRequest request = new CopyItemRequest(this, errorHandling); + request.getItemIds().addRange(itemIds); + request.setDestinationFolderId(destinationFolderId); + request.setReturnNewItemIds(returnNewItemIds); + return request.execute(); + + } + + /** + * Copies multiple item in a single call to EWS. + * + * @param itemIds the item ids + * @param destinationFolderId the destination folder id + * @return A ServiceResponseCollection providing copy results for each of + * the specified item Ids. + * @throws Exception the exception + */ + public ServiceResponseCollection copyItems( + Iterable itemIds, FolderId destinationFolderId) + throws Exception { + return this.internalCopyItems(itemIds, destinationFolderId, null, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Copies multiple item in a single call to EWS. + * + * @param itemIds The Ids of the item to copy. + * @param destinationFolderId The Id of the folder to copy the item to. + * @param returnNewItemIds Flag indicating whether service should return new ItemIds or + * not. + * @return A ServiceResponseCollection providing copy results for each of + * the specified item Ids. + * @throws Exception on error + */ + public ServiceResponseCollection copyItems( + Iterable itemIds, FolderId destinationFolderId, + boolean returnNewItemIds) throws Exception { + EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010_SP1, "CopyItems"); + + return this.internalCopyItems(itemIds, destinationFolderId, returnNewItemIds, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Copies an item. Calling this method results in a call to EWS. + * + * @param itemId The Id of the item to copy. + * @param destinationFolderId The folder in which to save sent messages, meeting invitations + * or cancellations. If null, the message, meeting invitation or + * cancellation is saved in the Sent Items folder + * @return The copy of the item. + * @throws Exception the exception + */ + public Item copyItem(ItemId itemId, FolderId destinationFolderId) + throws Exception { + List itemIdArray = new ArrayList(); + itemIdArray.add(itemId); + + return this.internalCopyItems(itemIdArray, destinationFolderId, null, + ServiceErrorHandling.ThrowOnError).getResponseAtIndex(0) + .getItem(); + } + + /** + * Moves multiple item in a single call to EWS. + * + * @param itemIds the item ids + * @param destinationFolderId the destination folder id + * @param returnNewItemIds Flag indicating whether service should return new ItemIds or + * not. + * @param errorHandling the error handling + * @return A ServiceResponseCollection providing copy results for each of + * the specified item Ids. + * @throws Exception the exception + */ + private ServiceResponseCollection internalMoveItems( + Iterable itemIds, FolderId destinationFolderId, + Boolean returnNewItemIds, ServiceErrorHandling errorHandling) + throws Exception { + MoveItemRequest request = new MoveItemRequest(this, errorHandling); + + request.getItemIds().addRange(itemIds); + request.setDestinationFolderId(destinationFolderId); + request.setReturnNewItemIds(returnNewItemIds); + return request.execute(); + } + + /** + * Moves multiple item in a single call to EWS. + * + * @param itemIds the item ids + * @param destinationFolderId the destination folder id + * @return A ServiceResponseCollection providing copy results for each of + * the specified item Ids. + * @throws Exception the exception + */ + public ServiceResponseCollection moveItems( + Iterable itemIds, FolderId destinationFolderId) + throws Exception { + return this.internalMoveItems(itemIds, destinationFolderId, null, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Moves multiple item in a single call to EWS. + * + * @param itemIds The Ids of the item to move. + * @param destinationFolderId The Id of the folder to move the item to. + * @param returnNewItemIds Flag indicating whether service should return new ItemIds or + * not. + * @return A ServiceResponseCollection providing copy results for each of + * the specified item Ids. + * @throws Exception on error + */ + public ServiceResponseCollection moveItems( + Iterable itemIds, FolderId destinationFolderId, + boolean returnNewItemIds) throws Exception { + EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010_SP1, "MoveItems"); + + return this.internalMoveItems(itemIds, destinationFolderId, returnNewItemIds, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Copies multiple item in a single call to EWS. + * + * @param itemId the item id + * @param destinationFolderId the destination folder id + * @return A ServiceResponseCollection providing copy results for each of + * the specified item Ids. + * @throws Exception the exception + */ + public Item moveItem(ItemId itemId, FolderId destinationFolderId) + throws Exception { + List itemIdArray = new ArrayList(); + itemIdArray.add(itemId); + + return this.internalMoveItems(itemIdArray, destinationFolderId, null, + ServiceErrorHandling.ThrowOnError).getResponseAtIndex(0) + .getItem(); + } + + /** + * Finds item. + * + * @param The type of item + * @param parentFolderIds The parent folder ids. + * @param searchFilter The search filter. Available search filter classes include + * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection + * @param queryString the query string + * @param view The view controlling the number of folder returned. + * @param groupBy The group by. + * @param errorHandlingMode Indicates the type of error handling should be done. + * @return Service response collection. + * @throws Exception the exception + */ + public ServiceResponseCollection> findItems( + Iterable parentFolderIds, SearchFilter searchFilter, String queryString, ViewBase view, + Grouping groupBy, ServiceErrorHandling errorHandlingMode) throws Exception { + EwsUtilities.validateParamCollection(parentFolderIds.iterator(), + "parentFolderIds"); + EwsUtilities.validateParam(view, "view"); + EwsUtilities.validateParamAllowNull(groupBy, "groupBy"); + EwsUtilities.validateParamAllowNull(queryString, "queryString"); + EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); + + FindItemRequest request = new FindItemRequest(this, + errorHandlingMode); + + request.getParentFolderIds().addRangeFolderId(parentFolderIds); + request.setSearchFilter(searchFilter); + request.setQueryString(queryString); + request.setView(view); + request.setGroupBy(groupBy); + + return request.execute(); + } + + /** + * Obtains a list of item by searching the contents of a specific folder. + * Calling this method results in a call to EWS. + * + * @param parentFolderId the parent folder id + * @param queryString the query string + * @param view the view + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindItemsResults findItems(FolderId parentFolderId, + String queryString, ItemView view) throws Exception { + EwsUtilities.validateParamAllowNull(queryString, "queryString"); + + List folderIdArray = new ArrayList(); + folderIdArray.add(parentFolderId); + + ServiceResponseCollection> responses = this + .findItems(folderIdArray, null, /* searchFilter */ + queryString, view, null, /* groupBy */ + ServiceErrorHandling.ThrowOnError); + + return responses.getResponseAtIndex(0).getResults(); + } + + /** + * Obtains a list of item by searching the contents of a specific folder. + * Calling this method results in a call to EWS. + * + * @param parentFolderId the parent folder id + * @param searchFilter the search filter + * @param view the view + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindItemsResults findItems(FolderId parentFolderId, + SearchFilter searchFilter, ItemView view) throws Exception { + EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); + List folderIdArray = new ArrayList(); + folderIdArray.add(parentFolderId); + ServiceResponseCollection> responses = this + .findItems(folderIdArray, searchFilter, null, /* queryString */ + view, null, /* groupBy */ + ServiceErrorHandling.ThrowOnError); + + return responses.getResponseAtIndex(0).getResults(); + } + + /** + * Obtains a list of item by searching the contents of a specific folder. + * Calling this method results in a call to EWS. + * + * @param parentFolderId the parent folder id + * @param view the view + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindItemsResults findItems(FolderId parentFolderId, + ItemView view) throws Exception { + List folderIdArray = new ArrayList(); + folderIdArray.add(parentFolderId); + ServiceResponseCollection> responses = this + .findItems(folderIdArray, null, /* searchFilter */ + null, /* queryString */ + view, null, /* groupBy */ + ServiceErrorHandling.ThrowOnError); + + return responses.getResponseAtIndex(0).getResults(); + } + + /** + * Obtains a list of item by searching the contents of a specific folder. + * Calling this method results in a call to EWS. + * + * @param parentFolderName the parent folder name + * @param queryString the query string + * @param view the view + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindItemsResults findItems( + WellKnownFolderName parentFolderName, String queryString, + ItemView view) throws Exception { + return this + .findItems(new FolderId(parentFolderName), queryString, view); + } + + /** + * Obtains a list of item by searching the contents of a specific folder. + * Calling this method results in a call to EWS. + * + * @param parentFolderName the parent folder name + * @param searchFilter the search filter + * @param view the view + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindItemsResults findItems( + WellKnownFolderName parentFolderName, SearchFilter searchFilter, + ItemView view) throws Exception { + return this.findItems(new FolderId(parentFolderName), searchFilter, + view); + } + + /** + * Obtains a list of item by searching the contents of a specific folder. + * Calling this method results in a call to EWS. + * + * @param parentFolderName the parent folder name + * @param view the view + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindItemsResults findItems( + WellKnownFolderName parentFolderName, ItemView view) + throws Exception { + return this.findItems(new FolderId(parentFolderName), (SearchFilter) null, view); + } + + /** + * Obtains a grouped list of item by searching the contents of a specific + * folder. Calling this method results in a call to EWS. + * + * @param parentFolderId the parent folder id + * @param queryString the query string + * @param view the view + * @param groupBy the group by + * @return A list of item containing the contents of the specified folder. + * @throws Exception the exception + */ + public GroupedFindItemsResults findItems(FolderId parentFolderId, + String queryString, ItemView view, Grouping groupBy) + throws Exception { + EwsUtilities.validateParam(groupBy, "groupBy"); + EwsUtilities.validateParamAllowNull(queryString, "queryString"); + + List folderIdArray = new ArrayList(); + folderIdArray.add(parentFolderId); + + ServiceResponseCollection> responses = this + .findItems(folderIdArray, null, /* searchFilter */ + queryString, view, groupBy, ServiceErrorHandling.ThrowOnError); + + return responses.getResponseAtIndex(0).getGroupedFindResults(); + } + + /** + * Obtains a grouped list of item by searching the contents of a specific + * folder. Calling this method results in a call to EWS. + * + * @param parentFolderId the parent folder id + * @param searchFilter the search filter + * @param view the view + * @param groupBy the group by + * @return A list of item containing the contents of the specified folder. + * @throws Exception the exception + */ + public GroupedFindItemsResults findItems(FolderId parentFolderId, + SearchFilter searchFilter, ItemView view, Grouping groupBy) + throws Exception { + EwsUtilities.validateParam(groupBy, "groupBy"); + EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); + + List folderIdArray = new ArrayList(); + folderIdArray.add(parentFolderId); + + ServiceResponseCollection> responses = this + .findItems(folderIdArray, searchFilter, null, /* queryString */ + view, groupBy, ServiceErrorHandling.ThrowOnError); + + return responses.getResponseAtIndex(0).getGroupedFindResults(); + } + + /** + * Obtains a grouped list of item by searching the contents of a specific + * folder. Calling this method results in a call to EWS. + * + * @param parentFolderId the parent folder id + * @param view the view + * @param groupBy the group by + * @return A list of item containing the contents of the specified folder. + * @throws Exception the exception + */ + public GroupedFindItemsResults findItems(FolderId parentFolderId, + ItemView view, Grouping groupBy) throws Exception { + EwsUtilities.validateParam(groupBy, "groupBy"); + + List folderIdArray = new ArrayList(); + folderIdArray.add(parentFolderId); + + ServiceResponseCollection> responses = this + .findItems(folderIdArray, null, /* searchFilter */ + null, /* queryString */ + view, groupBy, ServiceErrorHandling.ThrowOnError); + + return responses.getResponseAtIndex(0).getGroupedFindResults(); + } + + /** + * Obtains a grouped list of item by searching the contents of a specific + * folder. Calling this method results in a call to EWS. + * + * @param the generic type + * @param cls the cls + * @param parentFolderId the parent folder id + * @param searchFilter the search filter + * @param view the view + * @param groupBy the group by + * @return A list of item containing the contents of the specified folder. + * @throws Exception the exception + */ + protected ServiceResponseCollection> findItems( + Class cls, FolderId parentFolderId, + SearchFilter searchFilter, ViewBase view, Grouping groupBy) + throws Exception { + List folderIdArray = new ArrayList(); + folderIdArray.add(parentFolderId); + + return this.findItems(folderIdArray, searchFilter, null, /* queryString */ + view, groupBy, ServiceErrorHandling.ThrowOnError); + } + + /** + * Obtains a grouped list of item by searching the contents of a specific + * folder. Calling this method results in a call to EWS. + * + * @param parentFolderName the parent folder name + * @param queryString the query string + * @param view the view + * @param groupBy the group by + * @return A collection of grouped item containing the contents of the + * specified. + * @throws Exception the exception + */ + public GroupedFindItemsResults findItems( + WellKnownFolderName parentFolderName, String queryString, + ItemView view, Grouping groupBy) throws Exception { + EwsUtilities.validateParam(groupBy, "groupBy"); + return this.findItems(new FolderId(parentFolderName), queryString, + view, groupBy); + } + + /** + * Obtains a grouped list of item by searching the contents of a specific + * folder. Calling this method results in a call to EWS. + * + * @param parentFolderName the parent folder name + * @param searchFilter the search filter + * @param view the view + * @param groupBy the group by + * @return A collection of grouped item containing the contents of the + * specified. + * @throws Exception the exception + */ + public GroupedFindItemsResults findItems( + WellKnownFolderName parentFolderName, SearchFilter searchFilter, + ItemView view, Grouping groupBy) throws Exception { + return this.findItems(new FolderId(parentFolderName), searchFilter, view, groupBy); + } + + /** + * Obtains a list of appointments by searching the contents of a specific + * folder. Calling this method results in a call to EWS. + * + * @param parentFolderId the parent folder id + * @param calendarView the calendar view + * @return A collection of appointments representing the contents of the + * specified folder. + * @throws Exception the exception + */ + public FindItemsResults findAppointments( + FolderId parentFolderId, CalendarView calendarView) + throws Exception { + List folderIdArray = new ArrayList(); + folderIdArray.add(parentFolderId); + + ServiceResponseCollection> response = this + .findItems(folderIdArray, null, /* searchFilter */ + null /* queryString */, calendarView, null, /* groupBy */ + ServiceErrorHandling.ThrowOnError); + + return response.getResponseAtIndex(0).getResults(); + } + + /** + * Obtains a list of appointments by searching the contents of a specific + * folder. Calling this method results in a call to EWS. + * + * @param parentFolderName the parent folder name + * @param calendarView the calendar view + * @return A collection of appointments representing the contents of the + * specified folder. + * @throws Exception the exception + */ + public FindItemsResults findAppointments( + WellKnownFolderName parentFolderName, CalendarView calendarView) + throws Exception { + return this.findAppointments(new FolderId(parentFolderName), calendarView); + } + + /** + * Loads the property of multiple item in a single call to EWS. + * + * @param items the item + * @param propertySet the property set + * @return A ServiceResponseCollection providing results for each of the + * specified item. + * @throws Exception the exception + */ + public ServiceResponseCollection loadPropertiesForItems( + Iterable items, PropertySet propertySet) throws Exception { + EwsUtilities.validateParamCollection(items.iterator(), "item"); + EwsUtilities.validateParam(propertySet, "propertySet"); + + return this.internalLoadPropertiesForItems(items, propertySet, ServiceErrorHandling.ReturnErrors); + } + + /** + * Loads the property of multiple item in a single call to EWS. + * + * @param items the item + * @param propertySet the property set + * @param errorHandling the error handling + * @return A ServiceResponseCollection providing results for each of the + * specified item. + * @throws Exception the exception + */ + public ServiceResponseCollection internalLoadPropertiesForItems(Iterable items, + PropertySet propertySet, ServiceErrorHandling errorHandling) throws Exception { + GetItemRequestForLoad request = new GetItemRequestForLoad(this, + errorHandling); + // return null; + + request.getItemIds().addRangeItem(items); + request.setPropertySet(propertySet); + + return request.execute(); + } + + /** + * Binds to multiple item in a single call to EWS. + * + * @param itemIds the item ids + * @param propertySet the property set + * @param errorHandling the error handling + * @return A ServiceResponseCollection providing results for each of the + * specified item Ids. + * @throws Exception the exception + */ + private ServiceResponseCollection internalBindToItems( + Iterable itemIds, PropertySet propertySet, + ServiceErrorHandling errorHandling) throws Exception { + GetItemRequest request = new GetItemRequest(this, errorHandling); + request.getItemIds().addRange(itemIds); + request.setPropertySet(propertySet); + return request.execute(); + } + + /** + * Binds to multiple item in a single call to EWS. + * + * @param itemIds the item ids + * @param propertySet the property set + * @return A ServiceResponseCollection providing results for each of the + * specified item Ids. + * @throws Exception the exception + */ + public ServiceResponseCollection bindToItems( + Iterable itemIds, PropertySet propertySet) throws Exception { + EwsUtilities.validateParamCollection(itemIds.iterator(), "itemIds"); + EwsUtilities.validateParam(propertySet, "propertySet"); + + return this.internalBindToItems(itemIds, propertySet, ServiceErrorHandling.ReturnErrors); + } + + /** + * Binds to multiple item in a single call to EWS. + * + * @param itemId the item id + * @param propertySet the property set + * @return A ServiceResponseCollection providing results for each of the + * specified item Ids. + * @throws Exception the exception + */ + public Item bindToItem(ItemId itemId, PropertySet propertySet) + throws Exception { + EwsUtilities.validateParam(itemId, "itemId"); + EwsUtilities.validateParam(propertySet, "propertySet"); + List itmLst = new ArrayList(); + itmLst.add(itemId); + ServiceResponseCollection responses = this + .internalBindToItems(itmLst, propertySet, ServiceErrorHandling.ThrowOnError); + + return responses.getResponseAtIndex(0).getItem(); + } + + /** + * Bind to item. + * + * @param The type of the item. + * @param c the c + * @param itemId the item id + * @param propertySet the property set + * @return the t item + * @throws Exception the exception + */ + public TItem bindToItem(Class c, ItemId itemId, PropertySet propertySet) throws Exception { + Item result = this.bindToItem(itemId, propertySet); + if (c.isAssignableFrom(result.getClass())) { + return (TItem) result; + } else { + throw new ServiceLocalException(String.format( + "The item type returned by the service (%s) isn't compatible with the requested item type (%s).", result.getClass().getName(), + c.getName())); + } + } + + /** + * Deletes multiple item in a single call to EWS. + * + * @param itemIds the item ids + * @param deleteMode the delete mode + * @param sendCancellationsMode the send cancellations mode + * @param affectedTaskOccurrences the affected task occurrences + * @param errorHandling the error handling + * @return A ServiceResponseCollection providing deletion results for each + * of the specified item Ids. + * @throws Exception the exception + */ + private ServiceResponseCollection internalDeleteItems( + Iterable itemIds, DeleteMode deleteMode, + SendCancellationsMode sendCancellationsMode, + AffectedTaskOccurrence affectedTaskOccurrences, + ServiceErrorHandling errorHandling) throws Exception { + DeleteItemRequest request = new DeleteItemRequest(this, errorHandling); + + request.getItemIds().addRange(itemIds); + request.setDeleteMode(deleteMode); + request.setSendCancellationsMode(sendCancellationsMode); + request.setAffectedTaskOccurrences(affectedTaskOccurrences); + + return request.execute(); + } + + /** + * Deletes multiple item in a single call to EWS. + * + * @param itemIds the item ids + * @param deleteMode the delete mode + * @param sendCancellationsMode the send cancellations mode + * @param affectedTaskOccurrences the affected task occurrences + * @return A ServiceResponseCollection providing deletion results for each + * of the specified item Ids. + * @throws Exception the exception + */ + public ServiceResponseCollection deleteItems( + Iterable itemIds, DeleteMode deleteMode, + SendCancellationsMode sendCancellationsMode, + AffectedTaskOccurrence affectedTaskOccurrences) throws Exception { + EwsUtilities.validateParamCollection(itemIds.iterator(), "itemIds"); + + return this.internalDeleteItems(itemIds, deleteMode, + sendCancellationsMode, affectedTaskOccurrences, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Deletes an item. Calling this method results in a call to EWS. + * + * @param itemId the item id + * @param deleteMode the delete mode + * @param sendCancellationsMode the send cancellations mode + * @param affectedTaskOccurrences the affected task occurrences + * @throws Exception the exception + */ + public void deleteItem(ItemId itemId, DeleteMode deleteMode, SendCancellationsMode sendCancellationsMode, + AffectedTaskOccurrence affectedTaskOccurrences) throws Exception { + List itemIdArray = new ArrayList(); + itemIdArray.add(itemId); + + EwsUtilities.validateParam(itemId, "itemId"); + this.internalDeleteItems(itemIdArray, deleteMode, + sendCancellationsMode, affectedTaskOccurrences, + ServiceErrorHandling.ThrowOnError); + } + + /** + * Gets an attachment. + * + * @param attachments the attachments + * @param bodyType the body type + * @param additionalProperties the additional property + * @param errorHandling the error handling + * @throws Exception the exception + */ + private ServiceResponseCollection internalGetAttachments( + Iterable attachments, BodyType bodyType, + Iterable additionalProperties, ServiceErrorHandling errorHandling) + throws Exception { + GetAttachmentRequest request = new GetAttachmentRequest(this, errorHandling); + + Iterator it = attachments.iterator(); + while (it.hasNext()) { + request.getAttachments().add(it.next()); + } + request.setBodyType(bodyType); + + if (additionalProperties != null) { + List propsArray = new ArrayList(); + for (PropertyDefinitionBase propertyDefinitionBase : additionalProperties) { + propsArray.add(propertyDefinitionBase); + } + request.getAdditionalProperties().addAll(propsArray); + } + + return request.execute(); + } + + /** + * Gets attachments. + * + * @param attachments the attachments + * @param bodyType the body type + * @param additionalProperties the additional property + * @return service response collection + * @throws Exception on error + */ + protected ServiceResponseCollection getAttachments( + Attachment[] attachments, BodyType bodyType, + Iterable additionalProperties) + throws Exception { + return this.internalGetAttachments(Arrays.asList(attachments), bodyType, + additionalProperties, ServiceErrorHandling.ReturnErrors); + } + + /** + * Gets the attachment. + * + * @param attachment the attachment + * @param bodyType the body type + * @param additionalProperties the additional property + * @throws Exception the exception + */ + public void getAttachment(Attachment attachment, BodyType bodyType, + Iterable additionalProperties) + throws Exception { + + List attachmentArray = new ArrayList(); + attachmentArray.add(attachment); + + this.internalGetAttachments(attachmentArray, bodyType, additionalProperties, + ServiceErrorHandling.ThrowOnError); + + } + + /** + * Creates attachments. + * + * @param parentItemId the parent item id + * @param attachments the attachments + * @return Service response collection. + * @throws ServiceResponseException the service response exception + * @throws Exception the exception + */ + public ServiceResponseCollection createAttachments(String parentItemId, + Iterable attachments) + throws ServiceResponseException, Exception { + CreateAttachmentRequest request = new CreateAttachmentRequest(this, ServiceErrorHandling.ReturnErrors); + + request.setParentItemId(parentItemId); + /* + * if (null != attachments) { while (attachments.hasNext()) { + * request.getAttachments().add(attachments.next()); } } + */ + request.getAttachments().addAll( + (Collection) attachments); + + return request.execute(); + } + + /** + * Deletes attachments. + * + * @param attachments the attachments + * @return the service response collection + * @throws ServiceResponseException the service response exception + * @throws Exception the exception + */ + public ServiceResponseCollection deleteAttachments( + Iterable attachments) throws ServiceResponseException, + Exception { + DeleteAttachmentRequest request = new DeleteAttachmentRequest(this, ServiceErrorHandling.ReturnErrors); + + request.getAttachments().addAll((Collection) attachments); + + return request.execute(); + } + + /** + * Finds contacts in the user's Contacts folder and the Global Address + * List (in that order) that have names that match the one passed as a + * parameter. Calling this method results in a call to EWS. + * + * @param nameToResolve the name to resolve + * @return A collection of name resolutions whose names match the one passed + * as a parameter. + * @throws Exception the exception + */ + public NameResolutionCollection resolveName(String nameToResolve) + throws Exception { + return this.resolveName(nameToResolve, ResolveNameSearchLocation.ContactsThenDirectory, false); + } + + /** + * Finds contacts in the user's Contacts folder and the Global Address + * List (in that order) that have names that match the one passed as a + * parameter. Calling this method results in a call to EWS. + * + * @param nameToResolve the name to resolve + * @param parentFolderIds the parent folder ids + * @param searchScope the search scope + * @param returnContactDetails the return contact details + * @return A collection of name resolutions whose names match the one passed + * as a parameter. + * @throws Exception the exception + */ + public NameResolutionCollection resolveName(String nameToResolve, + Iterable parentFolderIds, + ResolveNameSearchLocation searchScope, boolean returnContactDetails) + throws Exception { + return resolveName(nameToResolve, parentFolderIds, searchScope, returnContactDetails, null); + + } + + /** + * Finds contacts in the Global Address List and/or in specific contact + * folder that have names that match the one passed as a parameter. Calling + * this method results in a call to EWS. + * + * @param nameToResolve The name to resolve. + * @param parentFolderIds The Ids of the contact folder in which to look for matching + * contacts. + * @param searchScope The scope of the search. + * @param returnContactDetails Indicates whether full contact information should be returned + * for each of the found contacts. + * @param contactDataPropertySet The property set for the contact details + * @return a collection of name resolutions whose names match the one passed as a parameter + * @throws Exception on error + */ + public NameResolutionCollection resolveName(String nameToResolve, + Iterable parentFolderIds, + ResolveNameSearchLocation searchScope, + boolean returnContactDetails, PropertySet contactDataPropertySet) + throws Exception { + if (contactDataPropertySet != null) { + EwsUtilities.validateMethodVersion(this, + ExchangeVersion.Exchange2010_SP1, "ResolveName"); + } + + EwsUtilities.validateParam(nameToResolve, "nameToResolve"); + + if (parentFolderIds != null) { + EwsUtilities.validateParamCollection(parentFolderIds.iterator(), + "parentFolderIds"); + } + ResolveNamesRequest request = new ResolveNamesRequest(this); + + request.setNameToResolve(nameToResolve); + request.setReturnFullContactData(returnContactDetails); + request.getParentFolderIds().addRangeFolderId(parentFolderIds); + request.setSearchLocation(searchScope); + request.setContactDataPropertySet(contactDataPropertySet); + + return request.execute().getResponseAtIndex(0).getResolutions(); + } + + /** + * Finds contacts in the Global Address List that have names that match the + * one passed as a parameter. Calling this method results in a call to EWS. + * + * @param nameToResolve The name to resolve. + * @param searchScope The scope of the search. + * @param returnContactDetails Indicates whether full contact information should be returned + * for each of the found contacts. + * @param contactDataPropertySet The property set for the contact details + * @return A collection of name resolutions whose names match the one + * passed as a parameter. + * @throws Exception on error + */ + public NameResolutionCollection resolveName(String nameToResolve, + ResolveNameSearchLocation searchScope, + boolean returnContactDetails, PropertySet contactDataPropertySet) + throws Exception { + return this.resolveName(nameToResolve, null, searchScope, + returnContactDetails, contactDataPropertySet); + } + + /** + * Finds contacts in the user's Contacts folder and the Global Address + * List (in that order) that have names that match the one passed as a + * parameter. Calling this method results in a call to EWS. + * + * @param nameToResolve the name to resolve + * @param searchScope the search scope + * @param returnContactDetails the return contact details + * @return A collection of name resolutions whose names match the one passed + * as a parameter. + * @throws Exception the exception + */ + public NameResolutionCollection resolveName(String nameToResolve, + ResolveNameSearchLocation searchScope, boolean returnContactDetails) + throws Exception { + return this.resolveName(nameToResolve, null, searchScope, returnContactDetails); + } + + /** + * Expands a group by retrieving a list of its members. Calling this + * method results in a call to EWS. + * + * @param emailAddress the email address + * @return URL of the Exchange Web Services. + * @throws Exception the exception + */ + public ExpandGroupResults expandGroup(EmailAddress emailAddress) + throws Exception { + EwsUtilities.validateParam(emailAddress, "emailAddress"); + ExpandGroupRequest request = new ExpandGroupRequest(this); + request.setEmailAddress(emailAddress); + return request.execute().getResponseAtIndex(0).getMembers(); + } + + /** + * Expands a group by retrieving a list of its members. Calling this + * method results in a call to EWS. + * + * @param groupId the group id + * @return An ExpandGroupResults containing the members of the group. + * @throws Exception the exception + */ + public ExpandGroupResults expandGroup(ItemId groupId) throws Exception { + EwsUtilities.validateParam(groupId, "groupId"); + EmailAddress emailAddress = new EmailAddress(); + emailAddress.setId(groupId); + return this.expandGroup(emailAddress); + } + + /** + * Expands a group by retrieving a list of its members. Calling this + * method results in a call to EWS. + * + * @param smtpAddress the smtp address + * @return An ExpandGroupResults containing the members of the group. + * @throws Exception the exception + */ + public ExpandGroupResults expandGroup(String smtpAddress) throws Exception { + EwsUtilities.validateParam(smtpAddress, "smtpAddress"); + return this.expandGroup(new EmailAddress(smtpAddress)); + } + + /** + * Expands a group by retrieving a list of its members. Calling this + * method results in a call to EWS. + * + * @param address the address + * @param routingType the routing type + * @return An ExpandGroupResults containing the members of the group. + * @throws Exception the exception + */ + public ExpandGroupResults expandGroup(String address, String routingType) + throws Exception { + EwsUtilities.validateParam(address, "address"); + EwsUtilities.validateParam(routingType, "routingType"); + + EmailAddress emailAddress = new EmailAddress(address); + emailAddress.setRoutingType(routingType); + return this.expandGroup(emailAddress); + } + + /** + * Get the password expiration date + * + * @param mailboxSmtpAddress The e-mail address of the user. + * @return The password expiration date + * @throws Exception on error + */ + public LocalDateTime getPasswordExpirationDate(String mailboxSmtpAddress) throws Exception { + GetPasswordExpirationDateRequest request = new GetPasswordExpirationDateRequest(this); + request.setMailboxSmtpAddress(mailboxSmtpAddress); + + return request.execute().getPasswordExpirationDate(); + } + + /** + * Subscribes to pull notification. Calling this method results in a call + * to EWS. + * + * @param folderIds The Ids of the folder to subscribe to + * @param timeout The timeout, in minutes, after which the subscription expires. + * Timeout must be between 1 and 1440. + * @param watermark An optional watermark representing a previously opened + * subscription. + * @param eventTypes The event types to subscribe to. + * @return A PullSubscription representing the new subscription. + * @throws Exception on error + */ + public PullSubscription subscribeToPullNotifications( + Iterable folderIds, int timeout, String watermark, + EventType... eventTypes) throws Exception { + EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds"); + + return this.buildSubscribeToPullNotificationsRequest(folderIds, + timeout, watermark, eventTypes).execute().getResponseAtIndex(0) + .getSubscription(); + } + + /** + * Begins an asynchronous request to subscribes to pull notification. + * Calling this method results in a call to EWS. + * + * @param callback The AsyncCallback delegate. + * @param state An object that contains state information for this request. + * @param folderIds The Ids of the folder to subscribe to. + * @param timeout The timeout, in minutes, after which the subscription expires. + * Timeout must be between 1 and 1440. + * @param watermark An optional watermark representing a previously opened + * subscription. + * @param eventTypes The event types to subscribe to. + * @return An IAsyncResult that references the asynchronous request. + * @throws Exception + */ + public AsyncRequestResult beginSubscribeToPullNotifications( + AsyncCallback callback, Object state, Iterable folderIds, + int timeout, String watermark, EventType... eventTypes) + throws Exception { + EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds"); + + return this.buildSubscribeToPullNotificationsRequest(folderIds, timeout, watermark, + eventTypes).beginExecute(callback); + } + + /** + * Subscribes to pull notification on all folder in the authenticated + * user's mailbox. Calling this method results in a call to EWS. + * + * @param timeout the timeout + * @param watermark the watermark + * @param eventTypes the event types + * @return A PullSubscription representing the new subscription. + * @throws Exception the exception + */ + public PullSubscription subscribeToPullNotificationsOnAllFolders( + int timeout, String watermark, EventType... eventTypes) + throws Exception { + EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010, + "SubscribeToPullNotificationsOnAllFolders"); + + return this.buildSubscribeToPullNotificationsRequest(null, timeout, + watermark, eventTypes).execute().getResponseAtIndex(0) + .getSubscription(); + } + + /** + * Begins an asynchronous request to subscribe to pull notification on all + * folder in the authenticated user's mailbox. Calling this method results + * in a call to EWS. + * + * @param callback The AsyncCallback delegate. + * @param state An object that contains state information for this request. + * @param timeout The timeout, in minutes, after which the subscription expires. + * Timeout must be between 1 and 1440. + * @param watermark An optional watermark representing a previously opened + * subscription. + * @param eventTypes The event types to subscribe to. + * @return An IAsyncResult that references the asynchronous request. + * @throws Exception + */ + public IAsyncResult beginSubscribeToPullNotificationsOnAllFolders(AsyncCallback callback, Object state, + int timeout, + String watermark, EventType... eventTypes) throws Exception { + EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010, + "BeginSubscribeToPullNotificationsOnAllFolders"); + + return this.buildSubscribeToPullNotificationsRequest(null, timeout, watermark, eventTypes).beginExecute( + null); + } + + /** + * Ends an asynchronous request to subscribe to pull notification in the + * authenticated user's mailbox. + * + * @param asyncResult An IAsyncResult that references the asynchronous request. + * @return A PullSubscription representing the new subscription. + * @throws Exception + */ + public PullSubscription endSubscribeToPullNotifications( + IAsyncResult asyncResult) throws Exception { + SubscribeToPullNotificationsRequest request = AsyncRequestResult + .extractServiceRequest(this, asyncResult); + + return request.endExecute(asyncResult).getResponseAtIndex(0) + .getSubscription(); + } + + /** + * Builds a request to subscribe to pull notification in the + * authenticated user's mailbox. + * + * @param folderIds The Ids of the folder to subscribe to. + * @param timeout The timeout, in minutes, after which the subscription expires. + * Timeout must be between 1 and 1440 + * @param watermark An optional watermark representing a previously opened + * subscription + * @param eventTypes The event types to subscribe to + * @return A request to subscribe to pull notification in the authenticated + * user's mailbox + * @throws Exception the exception + */ + private SubscribeToPullNotificationsRequest buildSubscribeToPullNotificationsRequest( + Iterable folderIds, int timeout, String watermark, + EventType... eventTypes) throws Exception { + if (timeout < 1 || timeout > 1440) { + throw new IllegalArgumentException("timeout", new Throwable( + "Timeout must be a value between 1 and 1440.")); + } + + EwsUtilities.validateParamCollection(eventTypes, "eventTypes"); + + SubscribeToPullNotificationsRequest request = new SubscribeToPullNotificationsRequest( + this); + + if (folderIds != null) { + request.getFolderIds().addRangeFolderId(folderIds); + } + + request.setTimeOut(timeout); + + for (EventType event : eventTypes) { + request.getEventTypes().add(event); + } + + request.setWatermark(watermark); + + return request; + } + + /** + * Unsubscribes from a pull subscription. Calling this method results in a + * call to EWS. + * + * @param subscriptionId the subscription id + * @throws Exception the exception + */ + public void unsubscribe(String subscriptionId) throws Exception { + + this.buildUnsubscribeRequest(subscriptionId).execute(); + } + + /** + * Begins an asynchronous request to unsubscribe from a subscription. + * Calling this method results in a call to EWS. + * + * @param callback The AsyncCallback delegate. + * @param state An object that contains state information for this request. + * @param subscriptionId The Id of the pull subscription to unsubscribe from. + * @return An IAsyncResult that references the asynchronous request. + * @throws Exception + */ + public IAsyncResult beginUnsubscribe(AsyncCallback callback, Object state, String subscriptionId) + throws Exception { + return this.buildUnsubscribeRequest(subscriptionId).beginExecute(callback); + } + + /** + * Ends an asynchronous request to unsubscribe from a subscription. + * + * @param asyncResult An IAsyncResult that references the asynchronous request. + * @throws Exception + */ + public void endUnsubscribe(IAsyncResult asyncResult) throws Exception { + UnsubscribeRequest request = AsyncRequestResult.extractServiceRequest(this, asyncResult); + + request.endExecute(asyncResult); + } + + /** + * Buids a request to unsubscribe from a subscription. + * + * @param subscriptionId The id of the subscription for which to get the events + * @return A request to unsubscripbe from a subscription + * @throws Exception + */ + private UnsubscribeRequest buildUnsubscribeRequest(String subscriptionId) + throws Exception { + EwsUtilities.validateParam(subscriptionId, "subscriptionId"); + + UnsubscribeRequest request = new UnsubscribeRequest(this); + + request.setSubscriptionId(subscriptionId); + + return request; + } + + /** + * Retrieves the latests events associated with a pull subscription. + * Calling this method results in a call to EWS. + * + * @param subscriptionId the subscription id + * @param waterMark the water mark + * @return A GetEventsResults containing a list of events associated with + * the subscription. + * @throws Exception the exception + */ + public GetEventsResults getEvents(String subscriptionId, String waterMark) + throws Exception { + + return this.buildGetEventsRequest(subscriptionId, waterMark).execute() + .getResponseAtIndex(0).getResults(); + } + + /** + * Begins an asynchronous request to retrieve the latest events associated + * with a pull subscription. Calling this method results in a call to EWS. + * + * @param callback The AsyncCallback delegate. + * @param state An object that contains state information for this request. + * @param subscriptionId The id of the pull subscription for which to get the events + * @param watermark The watermark representing the point in time where to start + * receiving events + * @return An IAsynResult that references the asynchronous request + * @throws Exception + */ + public IAsyncResult beginGetEvents(AsyncCallback callback, Object state, String subscriptionId, + String watermark) throws Exception { + return this.buildGetEventsRequest(subscriptionId, watermark) + .beginExecute(callback); + } + + /** + * Ends an asynchronous request to retrieve the latest events associated + * with a pull subscription. + * + * @param asyncResult An IAsyncResult that references the asynchronous request. + * @return A GetEventsResults containing a list of events associated with + * the subscription. + * @throws Exception + */ + public GetEventsResults endGetEvents(IAsyncResult asyncResult) throws Exception { + GetEventsRequest request = AsyncRequestResult.extractServiceRequest(this, asyncResult); + + return request.endExecute(asyncResult).getResponseAtIndex(0).getResults(); + } + + /** + * Builds a request to retrieve the letest events associated with a pull + * subscription + * + * @param subscriptionId The Id of the pull subscription for which to get the events + * @param watermark The watermark representing the point in time where to start + * receiving events + * @return An request to retrieve the latest events associated with a pull + * subscription + * @throws Exception + */ + private GetEventsRequest buildGetEventsRequest(String subscriptionId, + String watermark) throws Exception { + EwsUtilities.validateParam(subscriptionId, "subscriptionId"); + EwsUtilities.validateParam(watermark, "watermark"); + + GetEventsRequest request = new GetEventsRequest(this); + + request.setSubscriptionId(subscriptionId); + request.setWatermark(watermark); + + return request; + } + + /** + * Subscribes to push notification. Calling this method results in a call + * to EWS. + * + * @param folderIds the folder ids + * @param url the url + * @param frequency the frequency + * @param watermark the watermark + * @param eventTypes the event types + * @return A PushSubscription representing the new subscription. + * @throws Exception the exception + */ + public PushSubscription subscribeToPushNotifications( + Iterable folderIds, URI url, int frequency, + String watermark, EventType... eventTypes) throws Exception { + EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds"); + + return this.buildSubscribeToPushNotificationsRequest(folderIds, url, + frequency, watermark, eventTypes).execute().getResponseAtIndex(0).getSubscription(); + } + + /** + * Begins an asynchronous request to subscribe to push notification. + * Calling this method results in a call to EWS. + * + * @param callback The asynccallback delegate + * @param state An object that contains state information for this request + * @param folderIds The ids of the folder to subscribe + * @param url the url of web service endpoint the exchange server should + * @param frequency the frequency,in minutes at which the exchange server should + * contact the web Service endpoint. Frequency must be between 1 + * and 1440. + * @param watermark An optional watermark representing a previously opened + * subscription + * @param eventTypes The event types to subscribe to. + * @return An IAsyncResult that references the asynchronous request. + * @throws Exception + */ + public IAsyncResult beginSubscribeToPushNotifications( + AsyncCallback callback, Object state, Iterable folderIds, + URI url, int frequency, String watermark, EventType... eventTypes) + throws Exception { + EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds"); + + return this.buildSubscribeToPushNotificationsRequest(folderIds, url, frequency, watermark, + eventTypes).beginExecute(callback); + } + + /** + * Subscribes to push notification on all folder in the authenticated + * user's mailbox. Calling this method results in a call to EWS. + * + * @param url the url + * @param frequency the frequency + * @param watermark the watermark + * @param eventTypes the event types + * @return A PushSubscription representing the new subscription. + * @throws Exception the exception + */ + public PushSubscription subscribeToPushNotificationsOnAllFolders(URI url, + int frequency, String watermark, EventType... eventTypes) + throws Exception { + EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010, + "SubscribeToPushNotificationsOnAllFolders"); + + return this.buildSubscribeToPushNotificationsRequest(null, url, + frequency, watermark, eventTypes).execute().getResponseAtIndex(0).getSubscription(); + } + + /** + * Begins an asynchronous request to subscribe to push notification on all + * folder in the authenticated user's mailbox. Calling this method results + * in a call to EWS. + * + * @param callback The asynccallback delegate + * @param state An object that contains state inforamtion for this request + * @param url the url + * @param frequency the frequency,in minutes at which the exchange server should + * contact the web Service endpoint. Frequency must be between 1 + * and 1440. + * @param watermark An optional watermark representing a previously opened + * subscription + * @param eventTypes The event types to subscribe to. + * @return An IAsyncResult that references the asynchronous request. + * @throws Exception + */ + public IAsyncResult beginSubscribeToPushNotificationsOnAllFolders( + AsyncCallback callback, Object state, URI url, int frequency, + String watermark, EventType... eventTypes) throws Exception { + EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010, + "BeginSubscribeToPushNotificationsOnAllFolders"); + + return this.buildSubscribeToPushNotificationsRequest(null, url, frequency, watermark, + eventTypes).beginExecute(callback); + } + + + /** + * Ends an asynchronous request to subscribe to push notification in the + * authenticated user's mailbox. + * + * @param asyncResult An IAsyncResult that references the asynchronous request. + * @return A PushSubscription representing the new subscription + * @throws Exception + */ + public PushSubscription endSubscribeToPushNotifications( + IAsyncResult asyncResult) throws Exception { + SubscribeToPushNotificationsRequest request = AsyncRequestResult + .extractServiceRequest(this, asyncResult); + + return request.endExecute(asyncResult).getResponseAtIndex(0) + .getSubscription(); + } + + /** + * Builds an request to request to subscribe to push notification in the + * authenticated user's mailbox. + * + * @param folderIds the folder ids + * @param url the url + * @param frequency the frequency + * @param watermark the watermark + * @param eventTypes the event types + * @return A request to request to subscribe to push notification in the + * authenticated user's mailbox. + * @throws Exception the exception + */ + private SubscribeToPushNotificationsRequest buildSubscribeToPushNotificationsRequest( + Iterable folderIds, URI url, int frequency, + String watermark, EventType[] eventTypes) throws Exception { + EwsUtilities.validateParam(url, "url"); + if (frequency < 1 || frequency > 1440) { + throw new ArgumentOutOfRangeException("frequency", "The frequency must be a value between 1 and 1440."); + } + + EwsUtilities.validateParamCollection(eventTypes, "eventTypes"); + SubscribeToPushNotificationsRequest request = new SubscribeToPushNotificationsRequest(this); + + if (folderIds != null) { + request.getFolderIds().addRangeFolderId(folderIds); + } + + request.setUrl(url); + request.setFrequency(frequency); + + for (EventType event : eventTypes) { + request.getEventTypes().add(event); + } + + request.setWatermark(watermark); + + return request; + } + + /** + * Subscribes to streaming notification. Calling this method results in a + * call to EWS. + * + * @param folderIds The Ids of the folder to subscribe to. + * @param eventTypes The event types to subscribe to. + * @return A StreamingSubscription representing the new subscription + * @throws Exception + */ + public StreamingSubscription subscribeToStreamingNotifications( + Iterable folderIds, EventType... eventTypes) + throws Exception { + EwsUtilities.validateMethodVersion(this, + ExchangeVersion.Exchange2010_SP1, + "SubscribeToStreamingNotifications"); + + EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds"); + + return this.buildSubscribeToStreamingNotificationsRequest(folderIds, + eventTypes).execute().getResponseAtIndex(0).getSubscription(); + } + + /** + * Subscribes to streaming notification on all folder in the authenticated + * user's mailbox. Calling this method results in a call to EWS. + * + * @param eventTypes The event types to subscribe to. + * @return A StreamingSubscription representing the new subscription. + * @throws Exception + */ + public StreamingSubscription subscribeToStreamingNotificationsOnAllFolders( + EventType... eventTypes) throws Exception { + EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010_SP1, + "SubscribeToStreamingNotificationsOnAllFolders"); + + return this.buildSubscribeToStreamingNotificationsRequest(null, + eventTypes).execute().getResponseAtIndex(0).getSubscription(); + } + + /** + * Begins an asynchronous request to subscribe to streaming notification. + * Calling this method results in a call to EWS. + * + * @param callback The AsyncCallback delegate + * @param state An object that contains state information for this request. + * @param folderIds The Ids of the folder to subscribe to. + * @param eventTypes The event types to subscribe to. + * @return An IAsyncResult that references the asynchronous request + * @throws Exception + */ + public IAsyncResult beginSubscribeToStreamingNotifications(AsyncCallback callback, Object state, + Iterable folderIds, + EventType... eventTypes) throws Exception { + EwsUtilities.validateMethodVersion(this, + ExchangeVersion.Exchange2010_SP1, + "BeginSubscribeToStreamingNotifications"); + + EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds"); + + return this.buildSubscribeToStreamingNotificationsRequest(folderIds, + eventTypes).beginExecute(callback); + } + + /** + * Begins an asynchronous request to subscribe to streaming notification on + * all folder in the authenticated user's mailbox. Calling this method + * results in a call to EWS. + * + * @param callback The AsyncCallback delegate + * @param state An object that contains state information for this request. + * @return An IAsyncResult that references the asynchronous request. + * @throws Exception + */ + public IAsyncResult beginSubscribeToStreamingNotificationsOnAllFolders(AsyncCallback callback, Object state, + EventType... eventTypes) throws Exception { + EwsUtilities.validateMethodVersion(this, + ExchangeVersion.Exchange2010_SP1, + "BeginSubscribeToStreamingNotificationsOnAllFolders"); + + return this.buildSubscribeToStreamingNotificationsRequest(null, + eventTypes).beginExecute(callback); + } + + /** + * Ends an asynchronous request to subscribe to push notification in the + * authenticated user's mailbox. + * + * @param asyncResult An IAsyncResult that references the asynchronous request. + * @return A streamingSubscription representing the new subscription + * @throws Exception + * @throws IndexOutOfBoundsException + */ + public StreamingSubscription endSubscribeToStreamingNotifications(IAsyncResult asyncResult) + throws IndexOutOfBoundsException, Exception { + EwsUtilities.validateMethodVersion( + this, + ExchangeVersion.Exchange2010_SP1, + "EndSubscribeToStreamingNotifications"); + + SubscribeToStreamingNotificationsRequest request = + AsyncRequestResult.extractServiceRequest(this, asyncResult); + // SubscribeToStreamingNotificationsRequest request = AsyncRequestResult.extractServiceRequest(this, asyncResult); + return request.endExecute(asyncResult).getResponseAtIndex(0).getSubscription(); + } + + /** + * Builds request to subscribe to streaming notification in the + * authenticated user's mailbox. + * + * @param folderIds The Ids of the folder to subscribe to. + * @param eventTypes The event types to subscribe to. + * @return A request to subscribe to streaming notification in the + * authenticated user's mailbox + * @throws Exception + */ + private SubscribeToStreamingNotificationsRequest buildSubscribeToStreamingNotificationsRequest( + Iterable folderIds, EventType[] eventTypes) throws Exception { + EwsUtilities.validateParamCollection(eventTypes, "eventTypes"); + + SubscribeToStreamingNotificationsRequest request = new SubscribeToStreamingNotificationsRequest( + this); + + if (folderIds != null) { + request.getFolderIds().addRangeFolderId(folderIds); + } + + for (EventType event : eventTypes) { + request.getEventTypes().add(event); + } + + return request; + } + + + /** + * Synchronizes the item of a specific folder. Calling this method + * results in a call to EWS. + * + * @param syncFolderId The Id of the folder containing the item to synchronize with. + * @param propertySet The set of property to retrieve for synchronized item. + * @param ignoredItemIds The optional list of item Ids that should be ignored. + * @param maxChangesReturned The maximum number of changes that should be returned. + * @param syncScope The sync scope identifying item to include in the + * ChangeCollection. + * @param syncState The optional sync state representing the point in time when to + * start the synchronization. + * @return A ChangeCollection containing a list of changes that occurred in + * the specified folder. + * @throws Exception the exception + */ + public ChangeCollection syncFolderItems(FolderId syncFolderId, + PropertySet propertySet, Iterable ignoredItemIds, + int maxChangesReturned, SyncFolderItemsScope syncScope, + String syncState) throws Exception { + return this.buildSyncFolderItemsRequest(syncFolderId, propertySet, + ignoredItemIds, maxChangesReturned, syncScope, syncState) + .execute().getResponseAtIndex(0).getChanges(); + } + + /** + * Begins an asynchronous request to synchronize the item of a specific + * folder. Calling this method results in a call to EWS. + * + * @param callback The AsyncCallback delegate + * @param state An object that contains state information for this request + * @param syncFolderId The Id of the folder containing the item to synchronize with + * @param propertySet The set of property to retrieve for synchronized item. + * @param ignoredItemIds The optional list of item Ids that should be ignored. + * @param maxChangesReturned The maximum number of changes that should be returned. + * @param syncScope The sync scope identifying item to include in the + * ChangeCollection + * @param syncState The optional sync state representing the point in time when to + * start the synchronization + * @return An IAsyncResult that references the asynchronous request. + * @throws Exception + */ + public IAsyncResult beginSyncFolderItems(AsyncCallback callback, Object state, FolderId syncFolderId, + PropertySet propertySet, + Iterable ignoredItemIds, int maxChangesReturned, + SyncFolderItemsScope syncScope, String syncState) throws Exception { + return this.buildSyncFolderItemsRequest(syncFolderId, propertySet, + ignoredItemIds, maxChangesReturned, syncScope, syncState) + .beginExecute(callback); + } + + /** + * Ends an asynchronous request to synchronize the item of a specific + * folder. + * + * @param asyncResult An IAsyncResult that references the asynchronous request. + * @return A ChangeCollection containing a list of changes that occurred in + * the specified folder. + * @throws Exception + */ + public ChangeCollection endSyncFolderItems(IAsyncResult asyncResult) throws Exception { + SyncFolderItemsRequest request = AsyncRequestResult.extractServiceRequest(this, asyncResult); + + return request.endExecute(asyncResult).getResponseAtIndex(0).getChanges(); + } + + /** + * Builds a request to synchronize the item of a specific folder. + * + * @param syncFolderId The Id of the folder containing the item to synchronize with + * @param propertySet The set of property to retrieve for synchronized item. + * @param ignoredItemIds The optional list of item Ids that should be ignored + * @param maxChangesReturned The maximum number of changes that should be returned. + * @param syncScope The sync scope identifying item to include in the + * ChangeCollection. + * @param syncState The optional sync state representing the point in time when to + * start the synchronization. + * @return A request to synchronize the item of a specific folder. + * @throws Exception + */ + private SyncFolderItemsRequest buildSyncFolderItemsRequest( + FolderId syncFolderId, PropertySet propertySet, + Iterable ignoredItemIds, int maxChangesReturned, + SyncFolderItemsScope syncScope, String syncState) throws Exception { + EwsUtilities.validateParam(syncFolderId, "syncFolderId"); + EwsUtilities.validateParam(propertySet, "propertySet"); + + SyncFolderItemsRequest request = new SyncFolderItemsRequest(this); + + request.setSyncFolderId(syncFolderId); + request.setPropertySet(propertySet); + if (ignoredItemIds != null) { + request.getIgnoredItemIds().addRange(ignoredItemIds); + } + request.setMaxChangesReturned(maxChangesReturned); + request.setSyncScope(syncScope); + request.setSyncState(syncState); + + return request; + } + + /** + * Synchronizes the sub-folder of a specific folder. Calling this method + * results in a call to EWS. + * + * @param syncFolderId the sync folder id + * @param propertySet the property set + * @param syncState the sync state + * @return A ChangeCollection containing a list of changes that occurred in + * the specified folder. + * @throws Exception the exception + */ + public ChangeCollection syncFolderHierarchy( + FolderId syncFolderId, PropertySet propertySet, String syncState) + throws Exception { + return this.buildSyncFolderHierarchyRequest(syncFolderId, propertySet, + syncState).execute().getResponseAtIndex(0).getChanges(); + } + + /** + * Begins an asynchronous request to synchronize the sub-folder of a + * specific folder. Calling this method results in a call to EWS. + * + * @param callback The AsyncCallback delegate + * @param state An object that contains state information for this request. + * @param syncFolderId The Id of the folder containing the item to synchronize with. + * A null value indicates the root folder of the mailbox. + * @param propertySet The set of property to retrieve for synchronized item. + * @param syncState The optional sync state representing the point in time when to + * start the synchronization. + * @return An IAsyncResult that references the asynchronous request + * @throws Exception + */ + public IAsyncResult beginSyncFolderHierarchy(AsyncCallback callback, Object state, FolderId syncFolderId, + PropertySet propertySet, + String syncState) throws Exception { + return this.buildSyncFolderHierarchyRequest(syncFolderId, propertySet, + syncState).beginExecute(callback); + } + + /** + * Synchronizes the entire folder hierarchy of the mailbox this Service is + * connected to. Calling this method results in a call to EWS. + * + * @param propertySet The set of property to retrieve for synchronized item. + * @param syncState The optional sync state representing the point in time when to + * start the synchronization. + * @return A ChangeCollection containing a list of changes that occurred in + * the specified folder. + * @throws Exception + */ + public ChangeCollection syncFolderHierarchy( + PropertySet propertySet, String syncState) + throws Exception { + return this.syncFolderHierarchy(null, propertySet, syncState); + } + + /* + * Begins an asynchronous request to synchronize the entire folder hierarchy + * of the mailbox this Service is connected to. Calling this method results + * in a call to EWS + * + * @param callback + * The AsyncCallback delegate + * @param state + * An object that contains state information for this request. + * @param propertySet + * The set of property to retrieve for synchronized item. + * @param syncState + * The optional sync state representing the point in time when to + * start the synchronization. + * @return An IAsyncResult that references the asynchronous request + * @throws Exception + public IAsyncResult beginSyncFolderHierarchy(FolderId syncFolderId, PropertySet propertySet, String syncState) throws Exception { + return this.beginSyncFolderHierarchy(null,null, null, + propertySet, syncState); + }*/ + + /** + * Ends an asynchronous request to synchronize the specified folder + * hierarchy of the mailbox this Service is connected to. + * + * @param asyncResult An IAsyncResult that references the asynchronous request. + * @return A ChangeCollection containing a list of changes that occurred in + * the specified folder. + * @throws Exception + */ + public ChangeCollection endSyncFolderHierarchy(IAsyncResult asyncResult) throws Exception { + SyncFolderHierarchyRequest request = AsyncRequestResult.extractServiceRequest(this, asyncResult); + + return request.endExecute(asyncResult).getResponseAtIndex(0).getChanges(); + } + + /** + * Builds a request to synchronize the specified folder hierarchy of the + * mailbox this Service is connected to. + * + * @param syncFolderId The Id of the folder containing the item to synchronize with. + * A null value indicates the root folder of the mailbox. + * @param propertySet The set of property to retrieve for synchronized item. + * @param syncState The optional sync state representing the point in time when to + * start the synchronization. + * @return A request to synchronize the specified folder hierarchy of the + * mailbox this Service is connected to + * @throws Exception + */ + private SyncFolderHierarchyRequest buildSyncFolderHierarchyRequest( + FolderId syncFolderId, PropertySet propertySet, String syncState) + throws Exception { + EwsUtilities.validateParamAllowNull(syncFolderId, "syncFolderId"); // Null + // syncFolderId + // is + // allowed + EwsUtilities.validateParam(propertySet, "propertySet"); + + SyncFolderHierarchyRequest request = new SyncFolderHierarchyRequest(this); + + request.setPropertySet(propertySet); + request.setSyncFolderId(syncFolderId); + request.setSyncState(syncState); + + return request; + } + + // Availability operations + + /** + * Gets Out of Office (OOF) settings for a specific user. Calling this + * method results in a call to EWS. + * + * @param smtpAddress the smtp address + * @return An OofSettings instance containing OOF information for the + * specified user. + * @throws Exception the exception + */ + public OofSettings getUserOofSettings(String smtpAddress) throws Exception { + EwsUtilities.validateParam(smtpAddress, "smtpAddress"); + GetUserOofSettingsRequest request = new GetUserOofSettingsRequest(this); + request.setSmtpAddress(smtpAddress); + + return request.execute().getOofSettings(); + } + + /** + * Sets Out of Office (OOF) settings for a specific user. Calling this + * method results in a call to EWS. + * + * @param smtpAddress the smtp address + * @param oofSettings the oof settings + * @throws Exception the exception + */ + public void setUserOofSettings(String smtpAddress, OofSettings oofSettings) + throws Exception { + EwsUtilities.validateParam(smtpAddress, "smtpAddress"); + EwsUtilities.validateParam(oofSettings, "oofSettings"); + + SetUserOofSettingsRequest request = new SetUserOofSettingsRequest(this); + + request.setSmtpAddress(smtpAddress); + request.setOofSettings(oofSettings); + + request.execute(); + } + + /** + * Gets detailed information about the availability of a set of users, + * rooms, and resources within a specified time window. + * + * @param attendees the attendees + * @param timeWindow the time window + * @param requestedData the requested data + * @param options the options + * @return The availability information for each user appears in a unique + * FreeBusyResponse object. The order of users in the request + * determines the order of availability data for each user in the + * response. + * @throws Exception the exception + */ + public GetUserAvailabilityResults getUserAvailability( + Iterable attendees, TimeWindow timeWindow, + AvailabilityData requestedData, AvailabilityOptions options) + throws Exception { + EwsUtilities.validateParamCollection(attendees.iterator(), "attendees"); + EwsUtilities.validateParam(timeWindow, "timeWindow"); + EwsUtilities.validateParam(options, "options"); + + GetUserAvailabilityRequest request = new GetUserAvailabilityRequest(this); + + request.setAttendees(attendees); + request.setTimeWindow(timeWindow); + request.setRequestedData(requestedData); + request.setOptions(options); + + return request.execute(); + } + + /** + * Gets detailed information about the availability of a set of users, + * rooms, and resources within a specified time window. + * + * @param attendees the attendees + * @param timeWindow the time window + * @param requestedData the requested data + * @return The availability information for each user appears in a unique + * FreeBusyResponse object. The order of users in the request + * determines the order of availability data for each user in the + * response. + * @throws Exception the exception + */ + public GetUserAvailabilityResults getUserAvailability( + Iterable attendees, TimeWindow timeWindow, + AvailabilityData requestedData) throws Exception { + return this.getUserAvailability(attendees, timeWindow, requestedData, + new AvailabilityOptions()); + } + + /** + * Retrieves a collection of all room lists in the organization. + * + * @return An EmailAddressCollection containing all the room lists in the + * organization + * @throws Exception the exception + */ + public EmailAddressCollection getRoomLists() throws Exception { + GetRoomListsRequest request = new GetRoomListsRequest(this); + return request.execute().getRoomLists(); + } + + /** + * Retrieves a collection of all room lists in the specified room list in + * the organization. + * + * @param emailAddress the email address + * @return A collection of EmailAddress objects representing all the rooms + * within the specifed room list. + * @throws Exception the exception + */ + public Collection getRooms(EmailAddress emailAddress) + throws Exception { + EwsUtilities.validateParam(emailAddress, "emailAddress"); + GetRoomsRequest request = new GetRoomsRequest(this); + request.setRoomList(emailAddress); + + return request.execute().getRooms(); + } + + // region Conversation + + /** + * Retrieves a collection of all Conversations in the specified Folder. + * + * @param view The view controlling the number of conversations returned. + * @param filter The search filter. Only search filter class supported + * SearchFilter.IsEqualTo + * @param folderId The Id of the folder in which to search for conversations. + * @throws Exception + */ + private Collection findConversation( + ConversationIndexedItemView view, SearchFilter.IsEqualTo filter, + FolderId folderId) throws Exception { + EwsUtilities.validateParam(view, "view"); + EwsUtilities.validateParamAllowNull(filter, "filter"); + EwsUtilities.validateParam(folderId, "folderId"); + EwsUtilities.validateMethodVersion(this, + ExchangeVersion.Exchange2010_SP1, "FindConversation"); + + FindConversationRequest request = new FindConversationRequest(this); + request.setIndexedItemView(view); + request.setConversationViewFilter(filter); + request.setFolderId(new FolderIdWrapper(folderId)); + + return request.execute().getConversations(); + } + + /** + * Retrieves a collection of all Conversations in the specified Folder. + * + * @param view The view controlling the number of conversations returned. + * @param folderId The Id of the folder in which to search for conversations. + * @throws Exception + */ + public Collection findConversation( + ConversationIndexedItemView view, FolderId folderId) + throws Exception { + return this.findConversation(view, null, folderId); + } + + /** + * Applies ConversationAction on the specified conversation. + * + * @param actionType ConversationAction + * @param conversationIds The conversation ids. + * @param processRightAway True to process at once . This is blocking and false to let + * the Assitant process it in the back ground + * @param categories Catgories that need to be stamped can be null or empty + * @param enableAlwaysDelete True moves every current and future messages in the + * conversation to deleted item folder. False stops the alwasy + * delete action. This is applicable only if the action is + * AlwaysDelete + * @param destinationFolderId Applicable if the action is AlwaysMove. This moves every + * current message and future message in the conversation to the + * specified folder. Can be null if tis is then it stops the + * always move action + * @param errorHandlingMode The error handling mode. + * @throws Exception + */ + private ServiceResponseCollection applyConversationAction( + ConversationActionType actionType, + Iterable conversationIds, boolean processRightAway, + StringList categories, boolean enableAlwaysDelete, + FolderId destinationFolderId, ServiceErrorHandling errorHandlingMode) + throws Exception { + EwsUtilities.ewsAssert(actionType == ConversationActionType.AlwaysCategorize + || actionType == ConversationActionType.AlwaysMove + || actionType == ConversationActionType.AlwaysDelete, "ApplyConversationAction", + "Invalic actionType"); + + EwsUtilities.validateParam(conversationIds, "conversationId"); + EwsUtilities.validateMethodVersion(this, + ExchangeVersion.Exchange2010_SP1, "ApplyConversationAction"); + + ApplyConversationActionRequest request = new ApplyConversationActionRequest( + this, errorHandlingMode); + ConversationAction action = new ConversationAction(); + + for (ConversationId conversationId : conversationIds) { + action.setAction(actionType); + action.setConversationId(conversationId); + action.setProcessRightAway(processRightAway); + action.setCategories(categories); + action.setEnableAlwaysDelete(enableAlwaysDelete); + action + .setDestinationFolderId(destinationFolderId != null ? new FolderIdWrapper( + destinationFolderId) + : null); + request.getConversationActions().add(action); + } + + return request.execute(); + } + + /** + * Applies one time conversation action on item in specified folder inside + * the conversation. + * + * @param actionType The action + * @param idTimePairs The id time pairs. + * @param contextFolderId The context folder id. + * @param destinationFolderId The destination folder id. + * @param deleteType Type of the delete. + * @param isRead The is read. + * @param errorHandlingMode The error handling mode. + * @throws Exception + */ + private ServiceResponseCollection applyConversationOneTimeAction( + ConversationActionType actionType, + Iterable> idTimePairs, + FolderId contextFolderId, FolderId destinationFolderId, + DeleteMode deleteType, Boolean isRead, + ServiceErrorHandling errorHandlingMode) throws Exception { + EwsUtilities.ewsAssert( + actionType == ConversationActionType.Move || actionType == ConversationActionType.Delete + || actionType == ConversationActionType.SetReadState || actionType == ConversationActionType.Copy, + "ApplyConversationOneTimeAction", "Invalid actionType"); + + EwsUtilities.validateParamCollection(idTimePairs.iterator(), + "idTimePairs"); + EwsUtilities.validateMethodVersion(this, + ExchangeVersion.Exchange2010_SP1, "ApplyConversationAction"); + + ApplyConversationActionRequest request = new ApplyConversationActionRequest( + this, errorHandlingMode); + + for (Map idTimePair : idTimePairs) { + ConversationAction action = new ConversationAction(); + + action.setAction(actionType); + action.setConversationId(idTimePair.keySet().iterator().next()); + action + .setContextFolderId(contextFolderId != null ? new FolderIdWrapper( + contextFolderId) + : null); + action + .setDestinationFolderId(destinationFolderId != null ? new FolderIdWrapper( + destinationFolderId) + : null); + action.setConversationLastSyncTime(idTimePair.values().iterator().next()); + action.setIsRead(isRead); + action.setDeleteType(deleteType); + + request.getConversationActions().add(action); + } + + return request.execute(); + } + + /** + * Sets up a conversation so that any item received within that conversation + * is always categorized. Calling this method results in a call to EWS. + * + * @param conversationId The id of the conversation. + * @param categories The categories that should be stamped on item in the + * conversation. + * @param processSynchronously Indicates whether the method should return only once enabling + * this rule and stamping existing item in the conversation is + * completely done. If processSynchronously is false, the method + * returns immediately. + * @throws Exception + */ + public ServiceResponseCollection enableAlwaysCategorizeItemsInConversations( + Iterable conversationId, + Iterable categories, boolean processSynchronously) + throws Exception { + EwsUtilities.validateParamCollection(categories.iterator(), + "categories"); + return this.applyConversationAction( + ConversationActionType.AlwaysCategorize, conversationId, + processSynchronously, new StringList(categories), false, null, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Sets up a conversation so that any item received within that conversation + * is no longer categorized. Calling this method results in a call to EWS. + * + * @param conversationId The id of the conversation. + * @param processSynchronously Indicates whether the method should return only once enabling + * this rule and stamping existing item in the conversation is + * completely done. If processSynchronously is false, the method + * returns immediately. + * @throws Exception + */ + public ServiceResponseCollection disableAlwaysCategorizeItemsInConversations( + Iterable conversationId, + boolean processSynchronously) throws Exception { + return this.applyConversationAction( + ConversationActionType.AlwaysCategorize, conversationId, + processSynchronously, null, false, null, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Sets up a conversation so that any item received within that conversation + * is always moved to Deleted Items folder. Calling this method results in a + * call to EWS. + * + * @param conversationId The id of the conversation. + * @param processSynchronously Indicates whether the method should return only once enabling + * this rule and stamping existing item in the conversation is + * completely done. If processSynchronously is false, the method + * returns immediately. + * @throws Exception + */ + public ServiceResponseCollection enableAlwaysDeleteItemsInConversations( + Iterable conversationId, + boolean processSynchronously) throws Exception { + return this.applyConversationAction( + ConversationActionType.AlwaysDelete, conversationId, + processSynchronously, null, true, null, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Sets up a conversation so that any item received within that conversation + * is no longer moved to Deleted Items folder. Calling this method results + * in a call to EWS. + * + * @param conversationId The id of the conversation. + * @param processSynchronously Indicates whether the method should return only once enabling + * this rule and stamping existing item in the conversation is + * completely done. If processSynchronously is false, the method + * returns immediately. + * @throws Exception + */ + public ServiceResponseCollection disableAlwaysDeleteItemsInConversations( + Iterable conversationId, + boolean processSynchronously) throws Exception { + return this.applyConversationAction( + ConversationActionType.AlwaysDelete, conversationId, + processSynchronously, null, false, null, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Sets up a conversation so that any item received within that conversation + * is always moved to a specific folder. Calling this method results in a + * call to EWS. + * + * @param conversationId The Id of the folder to which conversation item should be + * moved. + * @param destinationFolderId The Id of the destination folder. + * @param processSynchronously Indicates whether the method should return only once enabling + * this rule and stamping existing item in the conversation is + * completely done. If processSynchronously is false, the method + * returns immediately. + * @throws Exception + */ + public ServiceResponseCollection enableAlwaysMoveItemsInConversations( + Iterable conversationId, + FolderId destinationFolderId, boolean processSynchronously) + throws Exception { + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + return this.applyConversationAction(ConversationActionType.AlwaysMove, + conversationId, processSynchronously, null, false, + destinationFolderId, ServiceErrorHandling.ReturnErrors); + } + + /** + * Sets up a conversation so that any item received within that conversation + * is no longer moved to a specific folder. Calling this method results in a + * call to EWS. + * + * @param conversationIds The conversation ids. + * @param processSynchronously Indicates whether the method should return only once disabling + * this rule is completely done. If processSynchronously is + * false, the method returns immediately. + * @throws Exception + */ + public ServiceResponseCollection disableAlwaysMoveItemsInConversations( + Iterable conversationIds, + boolean processSynchronously) throws Exception { + return this.applyConversationAction(ConversationActionType.AlwaysMove, + conversationIds, processSynchronously, null, false, null, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Moves the item in the specified conversation to the specified + * destination folder. Calling this method results in a call to EWS. + * + * @param idLastSyncTimePairs The pairs of Id of conversation whose item should be moved + * and the dateTime conversation was last synced (Items received + * after that dateTime will not be moved). + * @param contextFolderId The Id of the folder that contains the conversation. + * @param destinationFolderId The Id of the destination folder. + * @throws Exception + */ + public ServiceResponseCollection moveItemsInConversations( + Iterable> idLastSyncTimePairs, + FolderId contextFolderId, FolderId destinationFolderId) + throws Exception { + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + return this.applyConversationOneTimeAction(ConversationActionType.Move, + idLastSyncTimePairs, contextFolderId, destinationFolderId, + null, null, ServiceErrorHandling.ReturnErrors); + } + + /** + * Copies the item in the specified conversation to the specified + * destination folder. Calling this method results in a call to EWS. + * + * @param idLastSyncTimePairs The pairs of Id of conversation whose item should be copied + * and the dateTime conversation was last synced (Items received + * after that dateTime will not be copied). + * @param contextFolderId The context folder id. + * @param destinationFolderId The destination folder id. + * @throws Exception + */ + public ServiceResponseCollection copyItemsInConversations( + Iterable> idLastSyncTimePairs, + FolderId contextFolderId, FolderId destinationFolderId) + throws Exception { + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + return this.applyConversationOneTimeAction(ConversationActionType.Copy, + idLastSyncTimePairs, contextFolderId, destinationFolderId, + null, null, ServiceErrorHandling.ReturnErrors); + } + + /** + * Deletes the item in the specified conversation. Calling this method + * results in a call to EWS. + * + * @param idLastSyncTimePairs The pairs of Id of conversation whose item should be deleted + * and the date and time conversation was last synced (Items + * received after that date will not be deleted). conversation + * was last synced (Items received after that dateTime will not + * be copied). + * @param contextFolderId The Id of the folder that contains the conversation. + * @param deleteMode The deletion mode + * @throws Exception + */ + public ServiceResponseCollection deleteItemsInConversations( + Iterable> idLastSyncTimePairs, + FolderId contextFolderId, DeleteMode deleteMode) throws Exception { + return this.applyConversationOneTimeAction( + ConversationActionType.Delete, idLastSyncTimePairs, + contextFolderId, null, deleteMode, null, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Sets the read state for item in conversation. Calling this mehtod would + * result in call to EWS. + * + * @param idLastSyncTimePairs The pairs of Id of conversation whose item should read state + * set and the date and time conversation was last synced (Items + * received after that date will not have their read state set). + * was last synced (Items received after that date will not be + * deleted). conversation was last synced (Items received after + * that dateTime will not be copied). + * @param contextFolderId The Id of the folder that contains the conversation. + * @param isRead if set to true, conversation item are marked as read; + * otherwise they are marked as unread. + * @throws Exception + */ + public ServiceResponseCollection setReadStateForItemsInConversations( + Iterable> idLastSyncTimePairs, + FolderId contextFolderId, boolean isRead) throws Exception { + return this.applyConversationOneTimeAction( + ConversationActionType.SetReadState, idLastSyncTimePairs, + contextFolderId, null, null, isRead, + ServiceErrorHandling.ReturnErrors); + } + + // Id conversion operations + + /** + * Converts multiple Ids from one format to another in a single call to + * EWS. + * + * @param ids the ids + * @param destinationFormat the destination format + * @param errorHandling the error handling + * @return A ServiceResponseCollection providing conversion results for each + * specified Ids. + * @throws Exception the exception + */ + private ServiceResponseCollection internalConvertIds( + Iterable ids, IdFormat destinationFormat, + ServiceErrorHandling errorHandling) throws Exception { + EwsUtilities.validateParamCollection(ids.iterator(), "ids"); + + ConvertIdRequest request = new ConvertIdRequest(this, errorHandling); + + request.getIds().addAll((Collection) ids); + request.setDestinationFormat(destinationFormat); + + return request.execute(); + } + + /** + * Converts multiple Ids from one format to another in a single call to + * EWS. + * + * @param ids the ids + * @param destinationFormat the destination format + * @return A ServiceResponseCollection providing conversion results for each + * specified Ids. + * @throws Exception the exception + */ + public ServiceResponseCollection convertIds( + Iterable ids, IdFormat destinationFormat) + throws Exception { + EwsUtilities.validateParamCollection(ids.iterator(), "ids"); + + return this.internalConvertIds(ids, destinationFormat, + ServiceErrorHandling.ReturnErrors); + } + + /** + * Converts Id from one format to another in a single call to EWS. + * + * @param id the id + * @param destinationFormat the destination format + * @return The converted Id. + * @throws Exception the exception + */ + public AlternateIdBase convertId(AlternateIdBase id, + IdFormat destinationFormat) throws Exception { + EwsUtilities.validateParam(id, "id"); + + List alternateIdBaseArray = new ArrayList<>(); + alternateIdBaseArray.add(id); + + ServiceResponseCollection responses = this + .internalConvertIds(alternateIdBaseArray, destinationFormat, + ServiceErrorHandling.ThrowOnError); + + return responses.getResponseAtIndex(0).getConvertedId(); + } + + /** + * Adds delegates to a specific mailbox. Calling this method results in a + * call to EWS. + * + * @param mailbox the mailbox + * @param meetingRequestsDeliveryScope the meeting request delivery scope + * @param delegateUsers the delegate users + * @return A collection of DelegateUserResponse objects providing the + * results of the operation. + * @throws Exception the exception + */ + public Collection addDelegates(Mailbox mailbox, + MeetingRequestsDeliveryScope meetingRequestsDeliveryScope, + DelegateUser... delegateUsers) throws Exception { + return addDelegates(mailbox, meetingRequestsDeliveryScope, + Arrays.asList(delegateUsers)); + } + + /** + * Adds delegates to a specific mailbox. Calling this method results in a + * call to EWS. + * + * @param mailbox the mailbox + * @param meetingRequestsDeliveryScope the meeting request delivery scope + * @param delegateUsers the delegate users + * @return A collection of DelegateUserResponse objects providing the + * results of the operation. + * @throws Exception the exception + */ + public Collection addDelegates(Mailbox mailbox, + MeetingRequestsDeliveryScope meetingRequestsDeliveryScope, + Iterable delegateUsers) throws Exception { + EwsUtilities.validateParam(mailbox, "mailbox"); + EwsUtilities.validateParamCollection(delegateUsers.iterator(), + "delegateUsers"); + + AddDelegateRequest request = new AddDelegateRequest(this); + request.setMailbox(mailbox); + + for (DelegateUser user : delegateUsers) { + request.getDelegateUsers().add(user); + } + + request.setMeetingRequestsDeliveryScope(meetingRequestsDeliveryScope); + + DelegateManagementResponse response = request.execute(); + return response.getDelegateUserResponses(); + } + + /** + * Updates delegates on a specific mailbox. Calling this method results in + * a call to EWS. + * + * @param mailbox the mailbox + * @param meetingRequestsDeliveryScope the meeting request delivery scope + * @param delegateUsers the delegate users + * @return A collection of DelegateUserResponse objects providing the + * results of the operation. + * @throws Exception the exception + */ + public Collection updateDelegates(Mailbox mailbox, + MeetingRequestsDeliveryScope meetingRequestsDeliveryScope, + DelegateUser... delegateUsers) throws Exception { + return this.updateDelegates(mailbox, meetingRequestsDeliveryScope, + Arrays.asList(delegateUsers)); + } + + /** + * Updates delegates on a specific mailbox. Calling this method results in + * a call to EWS. + * + * @param mailbox the mailbox + * @param meetingRequestsDeliveryScope the meeting request delivery scope + * @param delegateUsers the delegate users + * @return A collection of DelegateUserResponse objects providing the + * results of the operation. + * @throws Exception the exception + */ + public Collection updateDelegates(Mailbox mailbox, + MeetingRequestsDeliveryScope meetingRequestsDeliveryScope, + Iterable delegateUsers) throws Exception { + EwsUtilities.validateParam(mailbox, "mailbox"); + EwsUtilities.validateParamCollection(delegateUsers.iterator(), + "delegateUsers"); + + UpdateDelegateRequest request = new UpdateDelegateRequest(this); + + request.setMailbox(mailbox); + + ArrayList delUser = new ArrayList(); + for (DelegateUser user : delegateUsers) { + delUser.add(user); + } + request.getDelegateUsers().addAll(delUser); + request.setMeetingRequestsDeliveryScope(meetingRequestsDeliveryScope); + + DelegateManagementResponse response = request.execute(); + return response.getDelegateUserResponses(); + } + + /** + * Removes delegates on a specific mailbox. Calling this method results in + * a call to EWS. + * + * @param mailbox the mailbox + * @param userIds the user ids + * @return A collection of DelegateUserResponse objects providing the + * results of the operation. + * @throws Exception the exception + */ + public Collection removeDelegates(Mailbox mailbox, + UserId... userIds) throws Exception { + return removeDelegates(mailbox, Arrays.asList(userIds)); + } + + /** + * Removes delegates on a specific mailbox. Calling this method results in + * a call to EWS. + * + * @param mailbox the mailbox + * @param userIds the user ids + * @return A collection of DelegateUserResponse objects providing the + * results of the operation. + * @throws Exception the exception + */ + public Collection removeDelegates(Mailbox mailbox, + Iterable userIds) throws Exception { + EwsUtilities.validateParam(mailbox, "mailbox"); + EwsUtilities.validateParamCollection(userIds.iterator(), "userIds"); + + RemoveDelegateRequest request = new RemoveDelegateRequest(this); + request.setMailbox(mailbox); + + ArrayList delUser = new ArrayList(); + for (UserId user : userIds) { + delUser.add(user); + } + request.getUserIds().addAll(delUser); + + DelegateManagementResponse response = request.execute(); + return response.getDelegateUserResponses(); + } + + /** + * Retrieves the delegates of a specific mailbox. Calling this method + * results in a call to EWS. + * + * @param mailbox the mailbox + * @param includePermissions the include permissions + * @param userIds the user ids + * @return A GetDelegateResponse providing the results of the operation. + * @throws Exception the exception + */ + public DelegateInformation getDelegates(Mailbox mailbox, + boolean includePermissions, UserId... userIds) throws Exception { + return this.getDelegates(mailbox, includePermissions, Arrays.asList(userIds)); + } + + /** + * Retrieves the delegates of a specific mailbox. Calling this method + * results in a call to EWS. + * + * @param mailbox the mailbox + * @param includePermissions the include permissions + * @param userIds the user ids + * @return A GetDelegateResponse providing the results of the operation. + * @throws Exception the exception + */ + public DelegateInformation getDelegates(Mailbox mailbox, + boolean includePermissions, Iterable userIds) + throws Exception { + EwsUtilities.validateParam(mailbox, "mailbox"); + + GetDelegateRequest request = new GetDelegateRequest(this); + + request.setMailbox(mailbox); + + ArrayList delUser = new ArrayList(); + for (UserId user : userIds) { + delUser.add(user); + } + request.getUserIds().addAll(delUser); + request.setIncludePermissions(includePermissions); + + GetDelegateResponse response = request.execute(); + DelegateInformation delegateInformation = new DelegateInformation( + (List) response + .getDelegateUserResponses(), response + .getMeetingRequestsDeliveryScope()); + + return delegateInformation; + } + + /** + * Creates the user configuration. + * + * @param userConfiguration the user configuration + * @throws Exception the exception + */ + public void createUserConfiguration(UserConfiguration userConfiguration) + throws Exception { + EwsUtilities.validateParam(userConfiguration, "userConfiguration"); + + CreateUserConfigurationRequest request = new CreateUserConfigurationRequest( + this); + + request.setUserConfiguration(userConfiguration); + + request.execute(); + } + + /** + * Creates a UserConfiguration. + * + * @param name the name + * @param parentFolderId the parent folder id + * @throws Exception the exception + */ + public void deleteUserConfiguration(String name, FolderId parentFolderId) + throws Exception { + EwsUtilities.validateParam(name, "name"); + EwsUtilities.validateParam(parentFolderId, "parentFolderId"); + + DeleteUserConfigurationRequest request = new DeleteUserConfigurationRequest( + this); + + request.setName(name); + request.setParentFolderId(parentFolderId); + request.execute(); + } + + /** + * Creates a UserConfiguration. + * + * @param name the name + * @param parentFolderId the parent folder id + * @param properties the property + * @return the user configuration + * @throws Exception the exception + */ + public UserConfiguration getUserConfiguration(String name, FolderId parentFolderId, + UserConfigurationProperties properties) + throws Exception { + EwsUtilities.validateParam(name, "name"); + EwsUtilities.validateParam(parentFolderId, "parentFolderId"); + + GetUserConfigurationRequest request = new GetUserConfigurationRequest(this); + + request.setName(name); + request.setParentFolderId(parentFolderId); + request.setProperties(EnumSet.of(properties)); + + return request.execute().getResponseAtIndex(0).getUserConfiguration(); + } + + /** + * Loads the property of the specified userConfiguration. + * + * @param userConfiguration the user configuration + * @param properties the property + * @throws Exception the exception + */ + public void loadPropertiesForUserConfiguration(UserConfiguration userConfiguration, + UserConfigurationProperties properties) throws Exception { + EwsUtilities.ewsAssert(userConfiguration != null, "ExchangeService.LoadPropertiesForUserConfiguration", + "userConfiguration is null"); + + GetUserConfigurationRequest request = new GetUserConfigurationRequest( + this); + + request.setUserConfiguration(userConfiguration); + request.setProperties(EnumSet.of(properties)); + + request.execute(); + } + + /** + * Updates a UserConfiguration. + * + * @param userConfiguration the user configuration + * @throws Exception the exception + */ + public void updateUserConfiguration(UserConfiguration userConfiguration) + throws Exception { + EwsUtilities.validateParam(userConfiguration, "userConfiguration"); + UpdateUserConfigurationRequest request = new UpdateUserConfigurationRequest(this); + + request.setUserConfiguration(userConfiguration); + + request.execute(); + } + + // region InboxRule operations + + /** + * Retrieves inbox rules of the authenticated user. + * + * @return A RuleCollection object containing the authenticated users inbox + * rules. + * @throws Exception + */ + public RuleCollection getInboxRules() throws Exception { + GetInboxRulesRequest request = new GetInboxRulesRequest(this); + return request.execute().getRules(); + } + + /** + * Retrieves the inbox rules of the specified user. + * + * @param mailboxSmtpAddress The SMTP address of the user whose inbox rules should be + * retrieved + * @return A RuleCollection object containing the inbox rules of the + * specified user. + * @throws Exception + */ + public RuleCollection getInboxRules(String mailboxSmtpAddress) + throws Exception { + EwsUtilities.validateParam(mailboxSmtpAddress, "MailboxSmtpAddress"); + + GetInboxRulesRequest request = new GetInboxRulesRequest(this); + request.setmailboxSmtpAddress(mailboxSmtpAddress); + return request.execute().getRules(); + } + + /** + * Updates the authenticated user's inbox rules by applying the specified + * operations. + * + * @param operations The operations that should be applied to the user's inbox + * rules. + * @param removeOutlookRuleBlob Indicate whether or not to remove Outlook Rule Blob. + * @throws Exception + */ + public void updateInboxRules(Iterable operations, + boolean removeOutlookRuleBlob) throws Exception { + UpdateInboxRulesRequest request = new UpdateInboxRulesRequest(this); + request.setInboxRuleOperations(operations); + request.setRemoveOutlookRuleBlob(removeOutlookRuleBlob); + request.execute(); + } + + /** + * Updates the authenticated user's inbox rules by applying the specified + * operations. + * + * @param operations The operations that should be applied to the user's inbox + * rules. + * @param removeOutlookRuleBlob Indicate whether or not to remove Outlook Rule Blob. + * @param mailboxSmtpAddress The SMTP address of the user whose inbox rules should be + * retrieved + * @throws Exception + */ + public void updateInboxRules(Iterable operations, + boolean removeOutlookRuleBlob, String mailboxSmtpAddress) + throws Exception { + UpdateInboxRulesRequest request = new UpdateInboxRulesRequest(this); + request.setInboxRuleOperations(operations); + request.setRemoveOutlookRuleBlob(removeOutlookRuleBlob); + request.setMailboxSmtpAddress(mailboxSmtpAddress); + request.execute(); + } + + /** + * Default implementation of AutodiscoverRedirectionUrlValidationCallback. + * Always returns true indicating that the URL can be used. + * + * @param redirectionUrl the redirection url + * @return Returns true. + * @throws AutodiscoverLocalException the autodiscover local exception + */ + private boolean defaultAutodiscoverRedirectionUrlValidationCallback( + String redirectionUrl) throws AutodiscoverLocalException { + throw new AutodiscoverLocalException(String.format( + "Autodiscover blocked a potentially insecure redirection to %s. To allow Autodiscover to follow the redirection, use the AutodiscoverUrl(string, AutodiscoverRedirectionUrlValidationCallback) overload.", redirectionUrl)); + } + + /** + * Initializes the Url property to the Exchange Web Services URL for the + * specified e-mail address by calling the Autodiscover service. + * + * @param emailAddress the email address + * @throws Exception the exception + */ + public void autodiscoverUrl(String emailAddress) throws Exception { + this.autodiscoverUrl(emailAddress, this); + } + + /** + * Initializes the Url property to the Exchange Web Services URL for the + * specified e-mail address by calling the Autodiscover service. + * + * @param emailAddress the email address to use. + * @param validateRedirectionUrlCallback The callback used to validate redirection URL + * @throws Exception the exception + */ + public void autodiscoverUrl(String emailAddress, + IAutodiscoverRedirectionUrl validateRedirectionUrlCallback) + throws Exception { + URI exchangeServiceUrl = null; + + if (this.getRequestedServerVersion().ordinal() > ExchangeVersion.Exchange2007_SP1 + .ordinal()) { + try { + exchangeServiceUrl = this.getAutodiscoverUrl(emailAddress, this + .getRequestedServerVersion(), + validateRedirectionUrlCallback); + this.setUrl(this + .adjustServiceUriFromCredentials(exchangeServiceUrl)); + return; + } catch (AutodiscoverLocalException ex) { + + this.traceMessage(TraceFlags.AutodiscoverResponse, String + .format("Autodiscover service call " + + "failed with error '%s'. " + + "Will try legacy service", ex.getMessage())); + + } catch (ServiceRemoteException ex) { + // E14:321785 -- Special case: if + // the caller's account is locked + // we want to return this exception, not continue. + if (ex instanceof AccountIsLockedException) { + throw new AccountIsLockedException(ex.getMessage(), + exchangeServiceUrl, ex); + } + + this.traceMessage(TraceFlags.AutodiscoverResponse, String + .format("Autodiscover service call " + + "failed with error '%s'. " + + "Will try legacy service", ex.getMessage())); + } + } + + // Try legacy Autodiscover provider + + exchangeServiceUrl = this.getAutodiscoverUrl(emailAddress, + ExchangeVersion.Exchange2007_SP1, + validateRedirectionUrlCallback); + + this.setUrl(this.adjustServiceUriFromCredentials(exchangeServiceUrl)); + } + + /** + * Autodiscover will always return the "plain" EWS endpoint URL but if the + * client is using WindowsLive credential, ExchangeService needs to use the + * WS-Security endpoint. + * + * @param uri the uri + * @return Adjusted URL. + * @throws Exception + */ + private URI adjustServiceUriFromCredentials(URI uri) + throws Exception { + return (this.getCredentials() != null) ? this.getCredentials() + .adjustUrl(uri) : uri; + } + + /** + * Gets the autodiscover url. + * + * @param emailAddress the email address + * @param requestedServerVersion the Exchange version + * @param validateRedirectionUrlCallback the validate redirection url callback + * @return the autodiscover url + * @throws Exception the exception + */ + private URI getAutodiscoverUrl(String emailAddress, + ExchangeVersion requestedServerVersion, + IAutodiscoverRedirectionUrl validateRedirectionUrlCallback) + throws Exception { + + AutodiscoverService autodiscoverService = new AutodiscoverService(this, requestedServerVersion); + autodiscoverService.setTimeout(getTimeout()); + + autodiscoverService.setRedirectionUrlValidationCallback(validateRedirectionUrlCallback); + autodiscoverService.setEnableScpLookup(this.getEnableScpLookup()); + + GetUserSettingsResponse response = autodiscoverService.getUserSettings( + emailAddress, UserSettingName.InternalEwsUrl, + UserSettingName.ExternalEwsUrl); + + switch (response.getErrorCode()) { + case NoError: + return this.getEwsUrlFromResponse(response, autodiscoverService + .isExternal().TRUE); + + case InvalidUser: + throw new ServiceRemoteException(String.format("Invalid user: '%s'", + emailAddress)); + + case InvalidRequest: + throw new ServiceRemoteException(String.format("Invalid Autodiscover request: '%s'", response + .getErrorMessage())); + + default: + this.traceMessage(TraceFlags.AutodiscoverConfiguration, String + .format("No EWS Url returned for user %s, " + + "error code is %s", emailAddress, response + .getErrorCode())); + + throw new ServiceRemoteException(response.getErrorMessage()); + } + } + + private URI getEwsUrlFromResponse(GetUserSettingsResponse response, + boolean isExternal) throws URISyntaxException, AutodiscoverLocalException { + String uriString; + + // Bug E14:59063 -- Figure out which URL to use: Internal or External. + // Bug E14:67646 -- AutoDiscover may not return an external protocol. + // First try external, then internal. + // Bug E14:82650 -- Either protocol + // may be returned without a configured URL. + OutParam outParam = new OutParam(); + if ((isExternal && response.tryGetSettingValue(String.class, + UserSettingName.ExternalEwsUrl, outParam))) { + uriString = outParam.getParam(); + if (!(uriString == null || uriString.isEmpty())) { + return new URI(uriString); + } + } + if ((response.tryGetSettingValue(String.class, + UserSettingName.InternalEwsUrl, outParam) || response + .tryGetSettingValue(String.class, + UserSettingName.ExternalEwsUrl, outParam))) { + uriString = outParam.getParam(); + if (!(uriString == null || uriString.isEmpty())) { + return new URI(uriString); + } + } + + // If Autodiscover doesn't return an + // internal or external EWS URL, throw an exception. + throw new AutodiscoverLocalException( + "The Autodiscover service didn't return an appropriate URL that can be used for the ExchangeService Autodiscover URL."); + } + + // region Diagnostic Method -- Only used by test + + /** + * Executes the diagnostic method. + * + * @param verb The verb. + * @param parameter The parameter. + * @throws Exception + */ + protected Document executeDiagnosticMethod(String verb, Node parameter) + throws Exception { + ExecuteDiagnosticMethodRequest request = new ExecuteDiagnosticMethodRequest(this); + request.setVerb(verb); + request.setParameter(parameter); + + return request.execute().getResponseAtIndex(0).getReturnValue(); + + } + + // endregion + + // region Validation + + /** + * Validates this instance. + * + * @throws ServiceLocalException the service local exception + */ + @Override + public void validate() throws ServiceLocalException { + super.validate(); + if (this.getUrl() == null) { + throw new ServiceLocalException("The Url property on the ExchangeService object must be set."); + } + } + + // region Constructors + + /** + * Initializes a new instance of the class, + * targeting the specified version of EWS and scoped to the to the system's + * current time zone. + */ + public ExchangeService(ExchangeHttpClient client) { + super(client); + } + + /** + * Initializes a new instance of the class, + * targeting the specified version of EWS and scoped to the system's current + * time zone. + * + * @param requestedServerVersion the requested server version + */ + public ExchangeService(ExchangeHttpClient client, ExchangeVersion requestedServerVersion) { + super(requestedServerVersion, client); + } + + // Utilities + + /** + * Prepare http web request. + * + * @return the http web request + * @throws ServiceLocalException the service local exception + * @throws java.net.URISyntaxException the uRI syntax exception + */ + public ExchangeHttpClient.Request prepareHttpWebRequest() + throws ServiceLocalException, URISyntaxException { + try { + this.url = this.adjustServiceUriFromCredentials(this.getUrl()); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error preparing HTTP request", e); + } + return this.prepareHttpWebRequestForUrl(url, this + .getAcceptGzipEncoding(), true); + } + + /** + * Prepares a http web request from a pooling connection manager, used for subscriptions. + * + * @return A http web request + * @throws ServiceLocalException The service local exception + * @throws java.net.URISyntaxException the uRI syntax exception + */ + public ExchangeHttpClient.Request prepareHttpPoolingWebRequest() throws ServiceLocalException, URISyntaxException { + try { + this.url = this.adjustServiceUriFromCredentials(this.getUrl()); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error preparing pooling HTTP request", e); + } + return this.prepareHttpPoolingWebRequestForUrl(url, this.getAcceptGzipEncoding(), true); + } + + /** + * Processes an HTTP error response. + */ + @Override + public void processHttpErrorResponse(ExchangeHttpClient.Request httpWebResponse, Exception webException) throws Exception { + this.internalProcessHttpErrorResponse(httpWebResponse, webException, + TraceFlags.EwsResponseHttpHeaders, TraceFlags.EwsResponse); + } + + // Properties + + /** + * Gets the URL of the Exchange Web Services. + * + * @return URL of the Exchange Web Services. + */ + public URI getUrl() { + return url; + } + + /** + * Sets the URL of the Exchange Web Services. + * + * @param url URL of the Exchange Web Services. + */ + public void setUrl(URI url) { + this.url = url; + } + + /** + * Gets the impersonated user id. + * + * @return the impersonated user id + */ + public ImpersonatedUserId getImpersonatedUserId() { + return impersonatedUserId; + } + + /** + * Sets the impersonated user id. + * + * @param impersonatedUserId the new impersonated user id + */ + public void setImpersonatedUserId(ImpersonatedUserId impersonatedUserId) { + this.impersonatedUserId = impersonatedUserId; + } + + /** + * Gets the preferred culture. + * + * @return the preferred culture + */ + public Locale getPreferredCulture() { + return preferredCulture; + } + + /** + * Sets the preferred culture. + * + * @param preferredCulture the new preferred culture + */ + public void setPreferredCulture(Locale preferredCulture) { + this.preferredCulture = preferredCulture; + } + + /** + * Gets the DateTime precision for DateTime values returned from Exchange + * Web Services. + * + * @return the DateTimePrecision + */ + public DateTimePrecision getDateTimePrecision() { + return this.dateTimePrecision; + } + + /** + * Sets the DateTime precision for DateTime values Web Services. + * + * @param d date time precision + */ + public void setDateTimePrecision(DateTimePrecision d) { + this.dateTimePrecision = d; + } + + /** + * Sets the DateTime precision for DateTime values returned from Exchange + * Web Services. + * + * @param dateTimePrecision the new DateTimePrecision + */ + public void setPreferredCulture(DateTimePrecision dateTimePrecision) { + this.dateTimePrecision = dateTimePrecision; + } + + /** + * Gets the file attachment content handler. + * + * @return the file attachment content handler + */ + public IFileAttachmentContentHandler getFileAttachmentContentHandler() { + return this.fileAttachmentContentHandler; + } + + /** + * Sets the file attachment content handler. + * + * @param fileAttachmentContentHandler the new file attachment content handler + */ + public void setFileAttachmentContentHandler( + IFileAttachmentContentHandler fileAttachmentContentHandler) { + this.fileAttachmentContentHandler = fileAttachmentContentHandler; + } + + /** + * Provides access to the Unified Messaging functionalities. + * + * @return the unified messaging + */ + public UnifiedMessaging getUnifiedMessaging() { + if (this.unifiedMessaging == null) { + this.unifiedMessaging = new UnifiedMessaging(this); + } + + return this.unifiedMessaging; + } + + /** + * Gets or sets a value indicating whether the AutodiscoverUrl method should + * perform SCP (Service Connection Point) record lookup when determining the + * Autodiscover service URL. + * + * @return enable scp lookup flag. + */ + public boolean getEnableScpLookup() { + return this.enableScpLookup; + } + + + public void setEnableScpLookup(boolean value) { + this.enableScpLookup = value; + } + + /** + * Returns true whether Exchange2007 compatibility mode is enabled, false otherwise. + */ + public boolean getExchange2007CompatibilityMode() { + return this.exchange2007CompatibilityMode; + } + + /** + * Set the flag indicating if the Exchange2007 compatibility mode is enabled. + * + * + * In order to support E12 servers, the exchange2007CompatibilityMode property, + * set to true, can be used to indicate that we should use "Exchange2007" as the server version String + * rather than Exchange2007_SP1. + * + * + * @param value true if the Exchange2007 compatibility mode is enabled. + */ + public void setExchange2007CompatibilityMode(boolean value) { + this.exchange2007CompatibilityMode = value; + } + + /** + * Retrieves the definitions of the specified server-side time zones. + * + * @param timeZoneIds the time zone ids + * @return A Collection containing the definitions of the specified time + * zones. + * @throws Exception + */ + public Collection getServerTimeZones( + Iterable timeZoneIds) throws Exception { + Map timeZoneMap = new HashMap(); + + GetServerTimeZonesRequest request = new GetServerTimeZonesRequest(this); + ServiceResponseCollection responses = request.execute(); + for (GetServerTimeZonesResponse response : responses) { + for (TimeZoneDefinition tzd : response.getTimeZones()) { + timeZoneMap.put(tzd.getId(), tzd); + } + } + + Collection timeZoneList = new ArrayList(); + + for (String timeZoneId : timeZoneIds) { + timeZoneList.add(timeZoneMap.get(timeZoneId)); + } + + return timeZoneList; + } + + /** + * Retrieves the definitions of all server-side time zones. + * + * @return A Collection containing the definitions of the specified time + * zones. + * @throws Exception + */ + public Collection getServerTimeZones() throws Exception { + GetServerTimeZonesRequest request = new GetServerTimeZonesRequest(this); + Collection timeZoneList = new ArrayList(); + ServiceResponseCollection responses = request.execute(); + for (GetServerTimeZonesResponse response : responses) { + timeZoneList.addAll(response.getTimeZones()); + } + + return timeZoneList; + } + + /* + * (non-Javadoc) + * + * @seemicrosoft.exchange.webservices.AutodiscoverRedirectionUrlInterface# + * autodiscoverRedirectionUrlValidationCallback(java.lang.String) + */ + public boolean autodiscoverRedirectionUrlValidationCallback( + String redirectionUrl) throws AutodiscoverLocalException { + return defaultAutodiscoverRedirectionUrlValidationCallback(redirectionUrl); + + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/ExchangeServiceBase.java b/ews-api/src/main/java/com/eischet/ews/api/core/ExchangeServiceBase.java new file mode 100644 index 000000000..a92bcc207 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/ExchangeServiceBase.java @@ -0,0 +1,742 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.EWSConstants; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.TraceFlags; +import com.eischet.ews.api.core.exception.http.EWSHttpException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.remote.AccountIsLockedException; +import com.eischet.ews.api.credential.ExchangeCredentials; +import com.eischet.ews.api.http.ExchangeHttpClient; +import com.eischet.ews.api.misc.EwsTraceListener; +import com.eischet.ews.api.misc.ITraceListener; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import java.io.ByteArrayOutputStream; +import java.io.Closeable; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.logging.Logger; + +/** + * Represents an abstract binding to an Exchange Service. + */ +public abstract class ExchangeServiceBase implements Closeable { + + private static final Logger LOG = Logger.getLogger(ExchangeService.class.getCanonicalName()); + + private ExchangeCredentials credentials; + private boolean useDefaultCredentials; + private static byte[] binarySecret; + private int timeout = 100000; + private boolean traceEnabled; + private EnumSet traceFlags = EnumSet.allOf(TraceFlags.class); + private ITraceListener traceListener = new EwsTraceListener(); + private boolean preAuthenticate; + private String userAgent = ExchangeServiceBase.defaultUserAgent; + private boolean acceptGzipEncoding = true; + private ExchangeVersion requestedServerVersion = ExchangeVersion.Exchange2010_SP2; + private ExchangeServerInfo serverInfo; + private Map httpHeaders = new HashMap<>(); + private final Map httpResponseHeaders = new HashMap(); + + protected ExchangeHttpClient httpClient; + + @Override + public void close() throws IOException { + httpClient.close(); + } + +// protected HttpClientWebRequest request = null; + + // protected static HttpStatusCode AccountIsLocked = (HttpStatusCode)456; + + /** + * Default UserAgent. + */ + private static final String defaultUserAgent = "ExchangeServicesClient/" + EwsUtilities.getBuildVersion(); + + /** + * Initializes a new instance. + *

+ * This constructor performs the initialization of the HTTP connection manager, so it should be called by + * every other constructor. + */ + protected ExchangeServiceBase(final ExchangeHttpClient exchangeHttpClient) { + setUseDefaultCredentials(true); + this.httpClient = exchangeHttpClient; + } + + protected ExchangeServiceBase(ExchangeVersion requestedServerVersion, final ExchangeHttpClient exchangeHttpClient) { + this(exchangeHttpClient); + this.requestedServerVersion = requestedServerVersion; + } + + protected ExchangeServiceBase(ExchangeServiceBase service, ExchangeVersion requestedServerVersion) { + this(requestedServerVersion, service.httpClient); + this.useDefaultCredentials = service.getUseDefaultCredentials(); + this.credentials = service.getCredentials(); + this.traceEnabled = service.isTraceEnabled(); + this.traceListener = service.getTraceListener(); + this.traceFlags = service.getTraceFlags(); + this.timeout = service.getTimeout(); + this.preAuthenticate = service.isPreAuthenticate(); + this.userAgent = service.getUserAgent(); + this.acceptGzipEncoding = service.getAcceptGzipEncoding(); + this.httpHeaders = service.getHttpHeaders(); + } + + + + // Event handlers + + /** + * Calls the custom SOAP header serialisation event handlers, if defined. + * + * @param writer The XmlWriter to which to write the custom SOAP headers. + */ + public void doOnSerializeCustomSoapHeaders(XMLStreamWriter writer) { + EwsUtilities + .ewsAssert(writer != null, "ExchangeService.DoOnSerializeCustomSoapHeaders", "writer is null"); + + if (null != getOnSerializeCustomSoapHeaders() && + !getOnSerializeCustomSoapHeaders().isEmpty()) { + for (ICustomXmlSerialization customSerialization : getOnSerializeCustomSoapHeaders()) { + customSerialization.CustomXmlSerialization(writer); + } + } + } + + // Utilities + + /** + * Creates an HttpWebRequest instance and initialises it with the + * appropriate parameters, based on the configuration of this service + * object. + * + * @param url The URL that the HttpWebRequest should target. + * @param acceptGzipEncoding If true, ask server for GZip compressed content. + * @param allowAutoRedirect If true, redirection response will be automatically followed. + * @return An initialised instance of HttpWebRequest. + * @throws ServiceLocalException the service local exception + * @throws java.net.URISyntaxException the uRI syntax exception + */ + protected ExchangeHttpClient.Request prepareHttpWebRequestForUrl(URI url, boolean acceptGzipEncoding, + boolean allowAutoRedirect) throws ServiceLocalException, URISyntaxException { + // Verify that the protocol is something that we can handle + String scheme = url.getScheme(); + if (!scheme.equalsIgnoreCase(EWSConstants.HTTP_SCHEME) + && !scheme.equalsIgnoreCase(EWSConstants.HTTPS_SCHEME)) { + String strErr = String.format("Protocol %s isn't supported for service request.", scheme); + throw new ServiceLocalException(strErr); + } + + final ExchangeHttpClient.Request request = httpClient.createRequest(); + // HttpClientWebRequest request = new HttpClientWebRequest(httpClient, httpContext); + prepareHttpWebRequestForUrl(url, acceptGzipEncoding, allowAutoRedirect, request); + + return request; + } + + /** + * 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. + *

+ * + * @param url The URL that the HttpWebRequest should target. + * @param acceptGzipEncoding If true, ask server for GZip compressed content. + * @param allowAutoRedirect If true, redirection response will be automatically followed. + * @return An initialised instance of HttpWebRequest. + * @throws ServiceLocalException the service local exception + * @throws java.net.URISyntaxException the uRI syntax exception + */ + protected ExchangeHttpClient.Request prepareHttpPoolingWebRequestForUrl(URI url, boolean acceptGzipEncoding, + boolean allowAutoRedirect) throws ServiceLocalException, URISyntaxException { + // Verify that the protocol is something that we can handle + String scheme = url.getScheme(); + if (!scheme.equalsIgnoreCase(EWSConstants.HTTP_SCHEME) + && !scheme.equalsIgnoreCase(EWSConstants.HTTPS_SCHEME)) { + String strErr = String.format("Protocol %s isn't supported for service request.", scheme); + throw new ServiceLocalException(strErr); + } + + final ExchangeHttpClient.Request request = httpClient.createPoolingRequest(); + prepareHttpWebRequestForUrl(url, acceptGzipEncoding, allowAutoRedirect, request); + + return request; + } + + private void prepareHttpWebRequestForUrl(URI url, boolean acceptGzipEncoding, boolean allowAutoRedirect, + ExchangeHttpClient.Request request) throws ServiceLocalException, URISyntaxException { + try { + request.setUrl(url.toURL()); + } catch (MalformedURLException e) { + String strErr = String.format("Incorrect format : %s", url); + throw new ServiceLocalException(strErr); + } + + request.setPreAuthenticate(preAuthenticate); + request.setTimeout(timeout); + request.setContentType("text/xml; charset=utf-8"); + request.setAccept("text/xml"); + request.setUserAgent(userAgent); + request.setAllowAutoRedirect(allowAutoRedirect); + request.setAcceptGzipEncoding(acceptGzipEncoding); + request.setHeaders(getHttpHeaders()); + prepareCredentials(request); + + request.prepareConnection(); + + httpResponseHeaders.clear(); + } + + protected void prepareCredentials(ExchangeHttpClient.Request request) throws ServiceLocalException, URISyntaxException { + request.setUseDefaultCredentials(useDefaultCredentials); + if (!useDefaultCredentials) { + if (credentials == null) { + throw new ServiceLocalException("Credentials are required to make a service request."); + } + + // Make sure that credential have been authenticated if required + credentials.preAuthenticate(); + + // Apply credential to the request + credentials.prepareWebRequest(request); + } + } + + /** + * 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. + * + * @param httpWebResponse HTTP web response + * @param webException web exception + * @param responseHeadersTraceFlag trace flag for response headers + * @param responseTraceFlag trace flag for respone + * @throws Exception on error + */ + protected void internalProcessHttpErrorResponse(ExchangeHttpClient.Request httpWebResponse, Exception webException, + TraceFlags responseHeadersTraceFlag, TraceFlags responseTraceFlag) throws Exception { + EwsUtilities.ewsAssert(500 != httpWebResponse.getResponseCode(), + "ExchangeServiceBase.InternalProcessHttpErrorResponse", + "InternalProcessHttpErrorResponse does not handle 500 ISE errors, the caller is supposed to handle this."); + + this.processHttpResponseHeaders(responseHeadersTraceFlag, httpWebResponse); + + // E14:321785 -- Deal with new HTTP error code indicating that account is locked. + // The "unlock" URL is returned as the status description in the response. + if (httpWebResponse.getResponseCode() == 456) { + String location = httpWebResponse.getResponseContentType(); + + URI accountUnlockUrl = null; + if (checkURIPath(location)) { + accountUnlockUrl = new URI(location); + } + + final String message = String.format("This account is locked. Visit %s to unlock it.", accountUnlockUrl); + this.traceMessage(responseTraceFlag, message); + throw new AccountIsLockedException(message, accountUnlockUrl, webException); + } + } + + /** + * @param location file path + * @return false if location is null,true if this abstract pathname is absolute + */ + public static boolean checkURIPath(String location) { + if (location == null) { + return false; + } + final File file = new File(location); + return file.isAbsolute(); + } + + /** + * @param httpWebResponse HTTP web response + * @param webException web exception + * @throws Exception on error + */ + protected abstract void processHttpErrorResponse(ExchangeHttpClient.Request httpWebResponse, Exception webException) + throws Exception; + + /** + * Determines whether tracing is enabled for specified trace flag(s). + * + * @param traceFlags The trace flags. + * @return True if tracing is enabled for specified trace flag(s). + */ + public boolean isTraceEnabledFor(TraceFlags traceFlags) { + return this.isTraceEnabled() && this.traceFlags.contains(traceFlags); + } + + /** + * Logs the specified string to the TraceListener if tracing is enabled. + * + * @param traceType kind of trace entry + * @param logEntry the entry to log + * @throws XMLStreamException the XML stream exception + * @throws IOException signals that an I/O exception has occurred + */ + public void traceMessage(TraceFlags traceType, String logEntry) throws XMLStreamException, IOException { + if (this.isTraceEnabledFor(traceType)) { + String traceTypeStr = traceType.toString(); + String logMessage = EwsUtilities.formatLogMessage(traceTypeStr, logEntry); + this.traceListener.trace(traceTypeStr, logMessage); + } + } + + /** + * Logs the specified XML to the TraceListener if tracing is enabled. + * + * @param traceType Kind of trace entry. + * @param stream The stream containing XML. + */ + public void traceXml(TraceFlags traceType, ByteArrayOutputStream stream) { + if (this.isTraceEnabledFor(traceType)) { + String traceTypeStr = traceType.toString(); + String logMessage = EwsUtilities.formatLogMessageWithXmlContent(traceTypeStr, stream); + this.traceListener.trace(traceTypeStr, logMessage); + } + } + + /** + * Traces the HTTP request headers. + * + * @param traceType Kind of trace entry. + * @param request The request + * @throws EWSHttpException EWS http exception + * @throws URISyntaxException URI syntax error + * @throws IOException signals that an I/O exception has occurred + * @throws XMLStreamException the XML stream exception + */ + public void traceHttpRequestHeaders(TraceFlags traceType, ExchangeHttpClient.Request request) + throws URISyntaxException, EWSHttpException, XMLStreamException, IOException { + if (this.isTraceEnabledFor(traceType)) { + String traceTypeStr = traceType.toString(); + String headersAsString = EwsUtilities.formatHttpRequestHeaders(request); + String logMessage = EwsUtilities.formatLogMessage(traceTypeStr, headersAsString); + this.traceListener.trace(traceTypeStr, logMessage); + } + } + + /** + * Traces the HTTP response headers. + * + * @param traceType kind of trace entry + * @param request the HttpRequest object + * @throws XMLStreamException the XML stream exception + * @throws IOException signals that an I/O exception has occurred + * @throws EWSHttpException the EWS http exception + */ + private void traceHttpResponseHeaders(TraceFlags traceType, ExchangeHttpClient.Request request) + throws XMLStreamException, IOException, EWSHttpException { + if (this.isTraceEnabledFor(traceType)) { + String traceTypeStr = traceType.toString(); + String headersAsString = EwsUtilities.formatHttpResponseHeaders(request); + String logMessage = EwsUtilities.formatLogMessage(traceTypeStr, headersAsString); + this.traceListener.trace(traceTypeStr, logMessage); + } + } + + /** + * Converts the date time to universal date time string. + * + * @param dt the date + * @return String representation of DateTime in yyyy-MM-ddTHH:mm:ssZ format. + */ + public String convertDateTimeToUniversalDateTimeString(LocalDateTime dt) { + String utcPattern = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + DateTimeFormatter fmt = DateTimeFormatter.ofPattern(utcPattern); + return fmt.format(dt); + /* + DateFormat utcFormatter = new SimpleDateFormat(utcPattern); + utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); + return utcFormatter.format(dt); + */ + } + + /** + * Converts the DATE to universal date time string. + * + * @param dt the date + * @return String representation of DateTime in yyyy-MM-ddTHH:mm:ssZ format. + */ + public String convertDateTimeToUniversalDateTimeString(LocalDate dt) { + String utcPattern = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + DateFormat utcFormatter = new SimpleDateFormat(utcPattern); + utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); + return utcFormatter.format(dt); + } + + + /** + * Sets the user agent to a custom value + * + * @param userAgent User agent string to set on the service + */ + protected void setCustomUserAgent(String userAgent) { + this.userAgent = userAgent; + } + + /** + * Validates this instance. + * + * @throws ServiceLocalException the service local exception + */ + public void validate() throws ServiceLocalException { + } + + /** + * Gets a value indicating whether tracing is enabled. + * + * @return True is tracing is enabled + */ + public boolean isTraceEnabled() { + return this.traceEnabled; + } + + /** + * Sets a value indicating whether tracing is enabled. + * + * @param traceEnabled true to enable tracing + */ + public void setTraceEnabled(boolean traceEnabled) { + this.traceEnabled = traceEnabled; + if (this.traceEnabled && (this.traceListener == null)) { + this.traceListener = new EwsTraceListener(); + } + } + + /** + * Gets the trace flags. + * + * @return Set of trace flags. + */ + public EnumSet getTraceFlags() { + return traceFlags; + } + + /** + * Sets the trace flags. + * + * @param traceFlags A set of trace flags + */ + public void setTraceFlags(EnumSet traceFlags) { + this.traceFlags = traceFlags; + } + + /** + * Gets the trace listener. + * + * @return The trace listener. + */ + public ITraceListener getTraceListener() { + return traceListener; + } + + /** + * Sets the trace listener. + * + * @param traceListener the trace listener. + */ + public void setTraceListener(ITraceListener traceListener) { + this.traceListener = traceListener; + this.traceEnabled = (traceListener != null); + } + + /** + * Gets the credential used to authenticate with the Exchange Web Services. + * + * @return credential + */ + public ExchangeCredentials getCredentials() { + return this.credentials; + } + + /** + * Sets the credential used to authenticate with the Exchange Web Services. + * Setting the Credentials property automatically sets the + * UseDefaultCredentials to false. + * + * @param credentials Exchange credential. + */ + public void setCredentials(ExchangeCredentials credentials) { + this.credentials = credentials; + this.useDefaultCredentials = false; + + // Reset the httpContext, to remove any existing authentication cookies from subsequent request + // TODO: restore this and/or move into the new Http Client: initializeHttpContext(); + } + + /** + * Gets a value indicating whether the credential of the user currently + * logged into Windows should be used to authenticate with the Exchange Web + * Services. + * + * @return true if credential of the user currently logged in are used + */ + public boolean getUseDefaultCredentials() { + return this.useDefaultCredentials; + } + + /** + * 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. + * + * @param value the new use default credential + */ + public void setUseDefaultCredentials(boolean value) { + this.useDefaultCredentials = value; + if (value) { + this.credentials = null; + } + + // Reset the httpContext, to remove any existing authentication cookies from subsequent request + // TODO: restore/move: initializeHttpContext(); + } + + /** + * Gets the timeout used when sending HTTP request and when receiving HTTP + * response, in milliseconds. + * + * @return timeout in milliseconds + */ + public int getTimeout() { + return timeout; + } + + /** + * Sets the timeout used when sending HTTP request and when receiving HTTP + * respones, in milliseconds. Defaults to 100000. + * + * @param timeout timeout in milliseconds + */ + public void setTimeout(int timeout) { + if (timeout < 1) { + throw new IllegalArgumentException("Timeout must be greater than zero."); + } + this.timeout = timeout; + } + + /** + * Gets a value that indicates whether HTTP pre-authentication should be + * performed. + * + * @return true indicates pre-authentication is set + */ + public boolean isPreAuthenticate() { + return preAuthenticate; + } + + /** + * Sets a value that indicates whether HTTP pre-authentication should be + * performed. + * + * @param preAuthenticate true to enable pre-authentication + */ + public void setPreAuthenticate(boolean preAuthenticate) { + this.preAuthenticate = preAuthenticate; + } + + /** + * 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. + * + * @return true if compression is used + */ + public boolean getAcceptGzipEncoding() { + return 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. + * + * @param acceptGzipEncoding true to enable compression + */ + public void setAcceptGzipEncoding(boolean acceptGzipEncoding) { + this.acceptGzipEncoding = acceptGzipEncoding; + } + + /** + * Gets the requested server version. + * + * @return The requested server version. + */ + public ExchangeVersion getRequestedServerVersion() { + return this.requestedServerVersion; + } + + /** + * Gets the user agent. + * + * @return The user agent. + */ + public String getUserAgent() { + return this.userAgent; + } + + /** + * Sets the user agent. + * + * @param userAgent The user agent + */ + public void setUserAgent(String userAgent) { + this.userAgent = userAgent + " (" + ExchangeServiceBase.defaultUserAgent + ")"; + } + + /** + * Gets information associated with the server that processed the last + * request. Will be null if no request have been processed. + * + * @return the server info + */ + public ExchangeServerInfo getServerInfo() { + return serverInfo; + } + + /** + * Sets information associated with the server that processed the last + * request. + * + * @param serverInfo Server Information + */ + public void setServerInfo(ExchangeServerInfo serverInfo) { + this.serverInfo = serverInfo; + } + + + /** + * Gets a collection of HTTP headers that will be sent with each request to + * EWS. + * + * @return httpHeaders + */ + public Map getHttpHeaders() { + return this.httpHeaders; + } + + // Events + + /** + * Provides an event that applications can implement to emit custom SOAP + * headers in request that are sent to Exchange. + */ + private List OnSerializeCustomSoapHeaders; + + /** + * Gets the on serialize custom soap headers. + * + * @return the on serialize custom soap headers + */ + public List getOnSerializeCustomSoapHeaders() { + return OnSerializeCustomSoapHeaders; + } + + /** + * Sets the on serialize custom soap headers. + * + * @param onSerializeCustomSoapHeaders the new on serialize custom soap headers + */ + public void setOnSerializeCustomSoapHeaders(List onSerializeCustomSoapHeaders) { + OnSerializeCustomSoapHeaders = onSerializeCustomSoapHeaders; + } + + /** + * Traces the HTTP response headers. + * + * @param traceType kind of trace entry + * @param request The request + * @throws EWSHttpException EWS http exception + * @throws IOException signals that an I/O exception has occurred + * @throws XMLStreamException the XML stream exception + */ + public void processHttpResponseHeaders(TraceFlags traceType, ExchangeHttpClient.Request request) + throws XMLStreamException, IOException, EWSHttpException { + this.traceHttpResponseHeaders(traceType, request); + this.saveHttpResponseHeaders(request.getResponseHeaders()); + } + + /** + * Save the HTTP response headers. + * + * @param headers The response headers + */ + private void saveHttpResponseHeaders(Map headers) { + this.httpResponseHeaders.clear(); + + for (String key : headers.keySet()) { + this.httpResponseHeaders.put(key, headers.get(key)); + } + } + + /** + * Gets a collection of HTTP headers from the last response. + * + * @return HTTP response headers + */ + public Map getHttpResponseHeaders() { + return this.httpResponseHeaders; + } + + /** + * Gets the session key. + * + * @return session key + */ + public static byte[] getSessionKey() { + // this has to be computed only once. + synchronized (ExchangeServiceBase.class) { + if (ExchangeServiceBase.binarySecret == null) { + Random randomNumberGenerator = new Random(); + ExchangeServiceBase.binarySecret = new byte[256 / 8]; + randomNumberGenerator.nextBytes(binarySecret); + } + + return ExchangeServiceBase.binarySecret; + } + } + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/IAction.java b/ews-api/src/main/java/com/eischet/ews/api/core/IAction.java similarity index 82% rename from src/main/java/microsoft/exchange/webservices/data/core/IAction.java rename to ews-api/src/main/java/com/eischet/ews/api/core/IAction.java index 8859c8a58..36596146e 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/IAction.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/IAction.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core; +package com.eischet.ews.api.core; /** * The Interface IAction. @@ -29,13 +29,14 @@ * @param The type of the parameter of the * method that this delegate encapsulates. */ +@FunctionalInterface public interface IAction { - /** - * Encapsulates a method that takes a single parameter and does not return a - * value. - * - * @param obj The parameter of the method that this delegate encapsulates. - */ - void action(T obj); + /** + * Encapsulates a method that takes a single parameter and does not return a + * value. + * + * @param obj The parameter of the method that this delegate encapsulates. + */ + void action(T obj); } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/ICustomXmlSerialization.java b/ews-api/src/main/java/com/eischet/ews/api/core/ICustomXmlSerialization.java similarity index 86% rename from src/main/java/microsoft/exchange/webservices/data/core/ICustomXmlSerialization.java rename to ews-api/src/main/java/com/eischet/ews/api/core/ICustomXmlSerialization.java index 3f03384d6..f7f9a4265 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/ICustomXmlSerialization.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/ICustomXmlSerialization.java @@ -21,20 +21,21 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core; +package com.eischet.ews.api.core; import javax.xml.stream.XMLStreamWriter; /** * The Interface CustomXmlSerializationInterface. */ +@FunctionalInterface public interface ICustomXmlSerialization { - /** - * Custom xml serialization. - * - * @param writer the writer - */ - void CustomXmlSerialization(XMLStreamWriter writer); + /** + * Custom xml serialization. + * + * @param writer the writer + */ + void CustomXmlSerialization(XMLStreamWriter writer); } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/ICustomXmlUpdateSerializer.java b/ews-api/src/main/java/com/eischet/ews/api/core/ICustomXmlUpdateSerializer.java new file mode 100644 index 000000000..f80013e9e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/ICustomXmlUpdateSerializer.java @@ -0,0 +1,56 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +/** + * Interface defined for property that produce their own update serialization. + */ +public interface ICustomXmlUpdateSerializer { + + /** + * Writes the update to XML. + * + * @param writer the writer + * @param ewsObject The ews object + * @param propertyDefinition property definition + * @return true if property generated serialization + * @throws Exception the exception + */ + boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, + ServiceObject ewsObject, PropertyDefinition propertyDefinition) throws Exception; + + /** + * Writes the deletion update to XML. + * + * @param writer The writer. + * @param ewsObject The ews object. + * @return True if property generated serialization. + * @throws Exception the exception + */ + boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, + ServiceObject ewsObject) throws Exception; +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/IDisposable.java b/ews-api/src/main/java/com/eischet/ews/api/core/IDisposable.java similarity index 92% rename from src/main/java/microsoft/exchange/webservices/data/core/IDisposable.java rename to ews-api/src/main/java/com/eischet/ews/api/core/IDisposable.java index b8628427e..b0e110ee7 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/IDisposable.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/IDisposable.java @@ -21,15 +21,15 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core; +package com.eischet.ews.api.core; /** * The Interface IDisposable. */ public interface IDisposable { - /** - * Dispose. - */ - void dispose(); + /** + * Dispose. + */ + void dispose(); } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/IFileAttachmentContentHandler.java b/ews-api/src/main/java/com/eischet/ews/api/core/IFileAttachmentContentHandler.java similarity index 78% rename from src/main/java/microsoft/exchange/webservices/data/core/IFileAttachmentContentHandler.java rename to ews-api/src/main/java/com/eischet/ews/api/core/IFileAttachmentContentHandler.java index e12eec887..741f9d776 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/IFileAttachmentContentHandler.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/IFileAttachmentContentHandler.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core; +package com.eischet.ews.api.core; import java.io.OutputStream; @@ -30,14 +30,15 @@ * IFileAttachmentContentHandler /// to provide a stream in which the content of * file attachment should be written. */ +@FunctionalInterface public interface IFileAttachmentContentHandler { - /** - * Provides a stream to which the content of the attachment with the - * specified Id should be written. - * - * @param attachmentId The Id of the attachment that is being loaded. - * @return A Stream to which the content of the attachment will be written. - */ - OutputStream getOutputStream(String attachmentId); + /** + * Provides a stream to which the content of the attachment with the + * specified Id should be written. + * + * @param attachmentId The Id of the attachment that is being loaded. + * @return A Stream to which the content of the attachment will be written. + */ + OutputStream getOutputStream(String attachmentId); } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/ILazyMember.java b/ews-api/src/main/java/com/eischet/ews/api/core/ILazyMember.java similarity index 89% rename from src/main/java/microsoft/exchange/webservices/data/core/ILazyMember.java rename to ews-api/src/main/java/com/eischet/ews/api/core/ILazyMember.java index 6c8a39388..ee352e19e 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/ILazyMember.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/ILazyMember.java @@ -21,19 +21,20 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core; +package com.eischet.ews.api.core; /** * The Interface ILazyMember. * * @param the generic type */ +@FunctionalInterface public interface ILazyMember { - /** - * Creates the instance. - * - * @return the t - */ - T createInstance(); + /** + * Creates the instance. + * + * @return the t + */ + T createInstance(); } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/IPredicate.java b/ews-api/src/main/java/com/eischet/ews/api/core/IPredicate.java new file mode 100644 index 000000000..46663cbbe --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/IPredicate.java @@ -0,0 +1,51 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * The Interface IPredicate. + * + * @param The type of the object to compare. + */ +@FunctionalInterface +public interface IPredicate { + + /** + * Represents the method that defines a + * set of criteria and determines whether + * the specified object meets those criteria. + * + * @param obj The object to compare against + * the criteria defined within the method represented + * by this delegate. + * @return true if obj meets the criteria + * defined within the method represented by this + * delegate; otherwise, false. + * @throws ServiceLocalException + */ + boolean predicate(T obj) throws ExchangeXmlException; +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/LazyMember.java b/ews-api/src/main/java/com/eischet/ews/api/core/LazyMember.java new file mode 100644 index 000000000..039e24c8a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/LazyMember.java @@ -0,0 +1,77 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +/** + * Wrapper class for lazy members. Does lazy initialization of member on first + * access. + * + * @param Type of the lazy member + *

+ * If we find ourselves creating a whole bunch of these in our code, + * we need to rethink this. Each lazy member holds the actual member + * and a delegate. That can turn into a whole lot of overhead + *

+ */ +public class LazyMember { + + /** + * The lazy member. + */ + private volatile T lazyMember; + + /** + * The lazy implementation. + */ + private final ILazyMember lazyImplementation; + + /** + * Public accessor for the lazy member. Lazy initializes the member on first + * access + * + * @return the member + */ + public T getMember() { + T result = this.lazyMember; + if (result == null) { // first check (no locking) + synchronized (this) { + result = this.lazyMember; + if (result == null) { // second check (with locking) + this.lazyMember = result = lazyImplementation.createInstance(); + } + } + } + return result; + } + + /** + * Constructor. + * + * @param lazyImplementation The initialization delegate to call for the item on first + * access + */ + public LazyMember(ILazyMember lazyImplementation) { + this.lazyImplementation = lazyImplementation; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/PropertyBag.java b/ews-api/src/main/java/com/eischet/ews/api/core/PropertyBag.java new file mode 100644 index 000000000..72bec0375 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/PropertyBag.java @@ -0,0 +1,863 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.ISelfValidate; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.BasePropertySet; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ServiceObjectPropertyException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.complex.ComplexProperty; +import com.eischet.ews.api.property.complex.IComplexPropertyChanged; +import com.eischet.ews.api.property.complex.IComplexPropertyChangedDelegate; +import com.eischet.ews.api.property.complex.IOwnedProperty; +import com.eischet.ews.api.property.definition.ComplexPropertyDefinitionBase; +import com.eischet.ews.api.property.definition.PropertyDefinition; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.*; +import java.util.Map.Entry; + +/** + * Represents a property bag keyed on PropertyDefinition objects. + */ +public class PropertyBag implements IComplexPropertyChanged, IComplexPropertyChangedDelegate { + + /** + * The owner. + */ + private final ServiceObject owner; + + /** + * The is dirty. + */ + private boolean isDirty; + + /** + * The loading. + */ + private boolean loading; + + /** + * The only summary property requested. + */ + private boolean onlySummaryPropertiesRequested; + + /** + * The loaded property. + */ + private final List loadedProperties = + new ArrayList(); + + /** + * The property. + */ + private final Map properties = + new HashMap(); + + /** + * The deleted property. + */ + private final Map deletedProperties = + new HashMap(); + + /** + * The modified property. + */ + private final List modifiedProperties = + new ArrayList(); + + /** + * The added property. + */ + private final List addedProperties = + new ArrayList(); + + /** + * The requested property set. + */ + private PropertySet requestedPropertySet; + + /** + * Initializes a new instance of PropertyBag. + * + * @param owner The owner of the bag. + */ + public PropertyBag(ServiceObject owner) { + EwsUtilities.ewsAssert(owner != null, "PropertyBag.ctor", "owner is null"); + + this.owner = owner; + } + + /** + * Gets a Map holding the bag's property. + * + * @return A Map holding the bag's property. + */ + public Map getProperties() { + return this.properties; + } + + /** + * Gets the owner of this bag. + * + * @return The owner of this bag. + */ + public ServiceObject getOwner() { + return this.owner; + } + + /** + * Indicates if a bag has pending changes. + * + * @return True if the bag has pending changes, false otherwise. + */ + public boolean getIsDirty() { + int changes = this.modifiedProperties.size() + + this.deletedProperties.size() + this.addedProperties.size(); + return changes > 0 || this.isDirty; + } + + /** + * Adds the specified property to the specified change list if it is not + * already present. + * + * @param propertyDefinition The property to add to the change list. + * @param changeList The change list to add the property to. + */ + protected static void addToChangeList( + PropertyDefinition propertyDefinition, + List changeList) { + if (!changeList.contains(propertyDefinition)) { + changeList.add(propertyDefinition); + } + } + + /** + * Checks if is property loaded. + * + * @param propertyDefinition the property definition + * @return true, if is property loaded + */ + public boolean isPropertyLoaded(PropertyDefinition propertyDefinition) { + // Is the property loaded? + if (this.loadedProperties.contains(propertyDefinition)) { + return true; + } else { + // Was the property requested? + return this.isRequestedProperty(propertyDefinition); + } + } + + /** + * Checks if is requested property. + * + * @param propertyDefinition the property definition + * @return true, if is requested property + */ + private boolean isRequestedProperty(PropertyDefinition propertyDefinition) { + // If no requested property set, then property wasn't requested. + if (this.requestedPropertySet == null) { + return false; + } + + // If base property set is all first-class property, use the + // appropriate list of + // property definitions to see if this property was requested. + // Otherwise, property had + // to be explicitly requested and needs to be listed in + // AdditionalProperties. + if (this.requestedPropertySet.getBasePropertySet() == BasePropertySet.FirstClassProperties) { + List firstClassProps = + this.onlySummaryPropertiesRequested ? this + .getOwner().getSchema().getFirstClassSummaryProperties() : + this.getOwner().getSchema().getFirstClassProperties(); + + return firstClassProps.contains(propertyDefinition) || + this.requestedPropertySet.contains(propertyDefinition); + } else { + return this.requestedPropertySet.contains(propertyDefinition); + } + } + + /** + * Determines whether the specified property has been updated. + * + * @param propertyDefinition The property definition. + * @return true if the specified property has been updated; otherwise, + * false. + */ + public boolean isPropertyUpdated(PropertyDefinition propertyDefinition) { + return this.modifiedProperties.contains(propertyDefinition) || + this.addedProperties.contains(propertyDefinition); + } + + /** + * Tries to get a property value based on a property definition. + * + * @param propertyDefinition The property definition. + * @param propertyValueOutParam The property value. + * @return True if property was retrieved. + */ + protected boolean tryGetProperty(PropertyDefinition propertyDefinition, + OutParam propertyValueOutParam) { + OutParam serviceExceptionOutParam = + new OutParam<>(); + propertyValueOutParam.setParam(this.getPropertyValueOrException( + propertyDefinition, serviceExceptionOutParam)); + return serviceExceptionOutParam.getParam() == null; + } + + /** + * Tries to get a property value based on a property definition. + * + * @param the types of the property + * @param propertyDefinition the property definition + * @param propertyValue the property value + * @return true if property was retrieved + * @throws ArgumentException on validation error + */ + public boolean tryGetPropertyType(Class cls, PropertyDefinition propertyDefinition, + OutParam propertyValue) throws ArgumentException { + // Verify that the type parameter and + //property definition's type are compatible. + if (!cls.isAssignableFrom(propertyDefinition.getType())) { + String errorMessage = String.format( + "Property definition type '%s' and type parameter '%s' aren't compatible.", + propertyDefinition.getType().getSimpleName(), + cls.getSimpleName()); + throw new ArgumentException(errorMessage, "propertyDefinition"); + } + + OutParam value = new OutParam(); + boolean result = this.tryGetProperty(propertyDefinition, value); + if (result) { + propertyValue.setParam((T) value.getParam()); + } else { + propertyValue.setParam(null); + } + + return result; + } + + + /** + * Gets the property value. + * + * @param propertyDefinition The property definition. + * @param serviceExceptionOutParam Exception that would be raised if there's an error retrieving + * the property. + * @return Property value. May be null. + */ + private T getPropertyValueOrException( + PropertyDefinition propertyDefinition, + OutParam serviceExceptionOutParam) { + OutParam propertyValueOutParam = new OutParam(); + propertyValueOutParam.setParam(null); + serviceExceptionOutParam.setParam(null); + + if (propertyDefinition.getVersion().ordinal() > this.getOwner() + .getService().getRequestedServerVersion().ordinal()) { + serviceExceptionOutParam.setParam(new ServiceVersionException( + String.format("The property %s is valid only for Exchange %s or later versions.", + propertyDefinition.getName(), propertyDefinition + .getVersion()))); + return null; + } + + if (this.tryGetValue(propertyDefinition, propertyValueOutParam)) { + // If the requested property is in the bag, return it. + return propertyValueOutParam.getParam(); + } else { + if (propertyDefinition + .hasFlag(PropertyDefinitionFlags.AutoInstantiateOnRead)) { + EwsUtilities + .ewsAssert(propertyDefinition instanceof ComplexPropertyDefinitionBase, + "PropertyBag.get_this[]", + "propertyDefinition is " + + "marked with AutoInstantiateOnRead " + + "but is not a descendant " + + "of ComplexPropertyDefinitionBase"); + + // The requested property is an auto-instantiate-on-read + // property + ComplexPropertyDefinitionBase complexPropertyDefinition = + (ComplexPropertyDefinitionBase) propertyDefinition; + ComplexProperty propertyValue = complexPropertyDefinition + .createPropertyInstance(getOwner()); + + // XXX: It could be dangerous to return complex value instead of + propertyValueOutParam.setParam((T) propertyValue); + if (propertyValue != null) { + this.initComplexProperty(propertyValue); + this.properties.put(propertyDefinition, propertyValue); + } + } else { + // If the property is not the Id (we need to let developers read + // the Id when it's null) and if has + // not been loaded, we throw. + if (propertyDefinition != this.getOwner() + .getIdPropertyDefinition()) { + if (!this.isPropertyLoaded(propertyDefinition)) { + serviceExceptionOutParam + .setParam(new ServiceObjectPropertyException( + "You must load or assign this property before you can read its value.", + propertyDefinition)); + return null; + } + + // Non-nullable property (int, bool, etc.) must be + // assigned or loaded; cannot return null value. + if (!propertyDefinition.isNullable()) { + String errorMessage = this + .isRequestedProperty(propertyDefinition) ? "This property was requested, but it wasn't returned by the server." + : "You must assign this property before you can read its value."; + serviceExceptionOutParam + .setParam(new ServiceObjectPropertyException( + errorMessage, propertyDefinition)); + } + } + } + return propertyValueOutParam.getParam(); + } + } + + /** + * Sets the isDirty flag to true and triggers dispatch of the change event + * to the owner of the property bag. Changed must be called whenever an + * operation that changes the state of this property bag is performed (e.g. + * adding or removing a property). + */ + public void changed() { + this.isDirty = true; + this.getOwner().changed(); + } + + /** + * Determines whether the property bag contains a specific property. + * + * @param propertyDefinition The property to check against. + * @return True if the specified property is in the bag, false otherwise. + */ + public boolean contains(PropertyDefinition propertyDefinition) { + return this.properties.containsKey(propertyDefinition); + } + + + /** + * Tries to retrieve the value of the specified property. + * + * @param propertyDefinition the property for which to retrieve a value + * @param propertyValueOutParam if the method succeeds, contains the value of the property + * @return true if the value could be retrieved, false otherwise + */ + public boolean tryGetValue(PropertyDefinition propertyDefinition, OutParam propertyValueOutParam) { + if (this.properties.containsKey(propertyDefinition)) { + T param = (T) properties.get(propertyDefinition); + propertyValueOutParam.setParam(param); + return true; + } else { + propertyValueOutParam.setParam(null); + return false; + } + } + + /** + * Handles a change event for the specified property. + * + * @param complexProperty The property that changes. + */ + protected void propertyChanged(ComplexProperty complexProperty) { + Iterator> it = this.properties + .entrySet().iterator(); + while (it.hasNext()) { + Entry keyValuePair = it.next(); + if (keyValuePair.getValue().equals(complexProperty)) { + if (!this.deletedProperties.containsKey(keyValuePair.getKey())) { + addToChangeList(keyValuePair.getKey(), + this.modifiedProperties); + this.changed(); + } + } + } + } + + /** + * Deletes the property from the bag. + * + * @param propertyDefinition The property to delete. + */ + protected void deleteProperty(PropertyDefinition propertyDefinition) { + if (!this.deletedProperties.containsKey(propertyDefinition)) { + Object propertyValue = null; + + if (this.properties.containsKey(propertyDefinition)) { + propertyValue = this.properties.get(propertyDefinition); + } + + this.properties.remove(propertyDefinition); + this.modifiedProperties.remove(propertyDefinition); + this.deletedProperties.put(propertyDefinition, propertyValue); + + if (propertyValue instanceof ComplexProperty) { + ComplexProperty complexProperty = + (ComplexProperty) propertyValue; + complexProperty.addOnChangeEvent(this); + } + } + } + + /** + * Clears the bag. + */ + protected void clear() { + this.clearChangeLog(); + this.properties.clear(); + this.loadedProperties.clear(); + this.requestedPropertySet = null; + } + + /** + * Clears the bag's change log. + */ + public void clearChangeLog() { + this.deletedProperties.clear(); + this.modifiedProperties.clear(); + this.addedProperties.clear(); + + Iterator> it = this.properties + .entrySet().iterator(); + while (it.hasNext()) { + Entry keyValuePair = it.next(); + if (keyValuePair.getValue() instanceof ComplexProperty) { + ComplexProperty complexProperty = (ComplexProperty) keyValuePair + .getValue(); + complexProperty.clearChangeLog(); + } + } + + this.isDirty = false; + } + + /** + * Loads property from XML and inserts them in the bag. + * + * @param reader The reader from which to read the property. + * @param clear Indicates whether the bag should be cleared before property + * are loaded. + * @param requestedPropertySet The requested property set. + * @param onlySummaryPropertiesRequested Indicates whether summary or full property were requested. + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader, boolean clear, PropertySet requestedPropertySet, boolean onlySummaryPropertiesRequested) throws ExchangeXmlException { + if (clear) { + this.clear(); + } + + // Put the property bag in "loading" mode. When in loading mode, no + // checking is done + // when setting property values. + this.loading = true; + + this.requestedPropertySet = requestedPropertySet; + this.onlySummaryPropertiesRequested = onlySummaryPropertiesRequested; + + try { + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + OutParam propertyDefinitionOut = + new OutParam(); + PropertyDefinition propertyDefinition; + + if (this.getOwner().schema().tryGetPropertyDefinition( + reader.getLocalName(), propertyDefinitionOut)) { + propertyDefinition = propertyDefinitionOut.getParam(); + propertyDefinition.loadPropertyValueFromXml(reader, + this); + + this.loadedProperties.add(propertyDefinition); + } else { + reader.skipCurrentElement(); + } + } + } while (!reader.isEndElement(XmlNamespace.Types, this.getOwner() + .getXmlElementName())); + + this.clearChangeLog(); + } finally { + this.loading = false; + } + } + + /** + * Writes the bag's property to XML. + * + * @param writer The writer to write the property to. + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer) throws Exception { + writer.writeStartElement(XmlNamespace.Types, this.getOwner() + .getXmlElementName()); + + Iterator it = this.getOwner().getSchema() + .iterator(); + while (it.hasNext()) { + PropertyDefinition propertyDefinition = it.next(); + // The following test should not be necessary since the property bag + // prevents + // property to be set if they don't have the CanSet flag, but it + // doesn't hurt... + if (propertyDefinition + .hasFlag(PropertyDefinitionFlags.CanSet, writer.getService().getRequestedServerVersion())) { + if (this.contains(propertyDefinition)) { + propertyDefinition.writePropertyValueToXml(writer, this, + false /* isUpdateOperation */); + } + } + } + + writer.writeEndElement(); + } + + /** + * Writes the EWS update operations corresponding to the changes that + * occurred in the bag to XML. + * + * @param writer The writer to write the updates to. + * @throws Exception the exception + */ + public void writeToXmlForUpdate(EwsServiceXmlWriter writer) + throws Exception { + writer.writeStartElement(XmlNamespace.Types, this.getOwner() + .getChangeXmlElementName()); + + this.getOwner().getId().writeToXml(writer); + + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Updates); + + for (PropertyDefinition propertyDefinition : this.addedProperties) { + this.writeSetUpdateToXml(writer, propertyDefinition); + } + + for (PropertyDefinition propertyDefinition : this.modifiedProperties) { + this.writeSetUpdateToXml(writer, propertyDefinition); + } + + Iterator> it = this.deletedProperties + .entrySet().iterator(); + while (it.hasNext()) { + Entry property = it.next(); + this.writeDeleteUpdateToXml(writer, property.getKey(), property + .getValue()); + } + + writer.writeEndElement(); + writer.writeEndElement(); + } + + /** + * Determines whether an EWS UpdateItem/UpdateFolder call is necessary to + * save the changes that occurred in the bag. + * + * @return True if an UpdateItem/UpdateFolder call is necessary, false + * otherwise. + */ + public boolean getIsUpdateCallNecessary() { + List propertyDefinitions = + new ArrayList(); + propertyDefinitions.addAll(this.addedProperties); + propertyDefinitions.addAll(this.modifiedProperties); + propertyDefinitions.addAll(this.deletedProperties.keySet()); + for (PropertyDefinition propertyDefinition : propertyDefinitions) { + if (propertyDefinition.hasFlag(PropertyDefinitionFlags.CanUpdate)) { + return true; + } + } + return false; + } + + /** + * Initializes a ComplexProperty instance. When a property is inserted into + * the bag, it needs to be initialized in order for changes that occur on + * that property to be properly detected and dispatched. + * + * @param complexProperty The ComplexProperty instance to initialize. + */ + private void initComplexProperty(ComplexProperty complexProperty) { + if (complexProperty != null) { + complexProperty.addOnChangeEvent(this); + if (complexProperty instanceof IOwnedProperty) { + IOwnedProperty ownedProperty = (IOwnedProperty) complexProperty; + ownedProperty.setOwner(this.getOwner()); + } + } + } + + /** + * Writes an EWS SetUpdate opeartion for the specified property. + * + * @param writer The writer to write the update to. + * @param propertyDefinition The property fro which to write the update. + * @throws Exception the exception + */ + private void writeSetUpdateToXml(EwsServiceXmlWriter writer, + PropertyDefinition propertyDefinition) throws Exception { + // The following test should not be necessary since the property bag + // prevents + // property to be updated if they don't have the CanUpdate flag, but + // it + // doesn't hurt... + if (propertyDefinition.hasFlag(PropertyDefinitionFlags.CanUpdate)) { + Object propertyValue = this + .getObjectFromPropertyDefinition(propertyDefinition); + + boolean handled = false; + + if (propertyValue instanceof ICustomXmlUpdateSerializer) { + ICustomXmlUpdateSerializer updateSerializer = + (ICustomXmlUpdateSerializer) propertyValue; + handled = updateSerializer.writeSetUpdateToXml(writer, this + .getOwner(), propertyDefinition); + } + + if (!handled) { + writer.writeStartElement(XmlNamespace.Types, this.getOwner() + .getSetFieldXmlElementName()); + + propertyDefinition.writeToXml(writer); + + writer.writeStartElement(XmlNamespace.Types, this.getOwner() + .getXmlElementName()); + propertyDefinition + .writePropertyValueToXml(writer, this, + true /* isUpdateOperation */); + writer.writeEndElement(); + + writer.writeEndElement(); + } + } + } + + /** + * Writes an EWS DeleteUpdate opeartion for the specified property. + * + * @param writer The writer to write the update to. + * @param propertyDefinition The property fro which to write the update. + * @param propertyValue The current value of the property. + * @throws Exception the exception + */ + private void writeDeleteUpdateToXml(EwsServiceXmlWriter writer, + PropertyDefinition propertyDefinition, Object propertyValue) + throws Exception { + // The following test should not be necessary since the property bag + // prevents + // property to be deleted (set to null) if they don't have the + // CanDelete flag, + // but it doesn't hurt... + if (propertyDefinition.hasFlag(PropertyDefinitionFlags.CanDelete)) { + boolean handled = false; + + if (propertyValue instanceof ICustomXmlUpdateSerializer) { + ICustomXmlUpdateSerializer updateSerializer = + (ICustomXmlUpdateSerializer) propertyValue; + handled = updateSerializer.writeDeleteUpdateToXml(writer, this + .getOwner()); + } + + if (!handled) { + writer.writeStartElement(XmlNamespace.Types, this.getOwner() + .getDeleteFieldXmlElementName()); + propertyDefinition.writeToXml(writer); + writer.writeEndElement(); + } + } + } + + /** + * Validate property bag instance. + * + * @throws Exception the exception + */ + public void validate() throws Exception { + for (PropertyDefinition propertyDefinition : this.addedProperties) { + this.validatePropertyValue(propertyDefinition); + } + + for (PropertyDefinition propertyDefinition : this.modifiedProperties) { + this.validatePropertyValue(propertyDefinition); + } + } + + /** + * Validates the property value. + * + * @param propertyDefinition The property definition. + * @throws Exception the exception + */ + private void validatePropertyValue(PropertyDefinition propertyDefinition) + throws Exception { + OutParam propertyValueOut = new OutParam(); + if (this.tryGetProperty(propertyDefinition, propertyValueOut)) { + Object propertyValue = propertyValueOut.getParam(); + + if (propertyValue instanceof ISelfValidate) { + ISelfValidate validatingValue = (ISelfValidate) propertyValue; + validatingValue.validate(); + } + } + } + + /** + * Gets the value of a property. + * + * @param propertyDefinition The property to get or set. + * @return An object representing the value of the property. + * @throws ServiceLocalException ServiceVersionException will be raised if this property + * requires a later version of Exchange. + * ServiceObjectPropertyException will be raised for get if + * property hasn't been assigned or loaded, raised for set if + * property cannot be updated or deleted. + */ + public T getObjectFromPropertyDefinition(PropertyDefinition propertyDefinition) throws ExchangeXmlException { + OutParam serviceExceptionOut = new OutParam<>(); + T propertyValue = getPropertyValueOrException(propertyDefinition, serviceExceptionOut); + + ExchangeXmlException serviceException = serviceExceptionOut.getParam(); + if (serviceException != null) { + throw serviceException; + } + return propertyValue; + } + + /** + * Gets the value of a property. + * + * @param propertyDefinition The property to get or set. + * @param object An object representing the value of the property. + */ + public void setObjectFromPropertyDefinition(PropertyDefinition propertyDefinition, Object object) throws ExchangeXmlException { + if (propertyDefinition.getVersion().ordinal() > this.getOwner() + .getService().getRequestedServerVersion().ordinal()) { + throw new ExchangeXmlException(String.format("The property %s is valid only for Exchange %s or later versions.", propertyDefinition.getName(), propertyDefinition.getVersion())); + } + + // If the property bag is not in the loading state, we need to verify + // whether + // the property can actually be set or updated. + if (!this.loading) { + // If the owner is new and if the property cannot be set, throw. + if (this.getOwner().isNew() + && !propertyDefinition + .hasFlag(PropertyDefinitionFlags.CanSet, this.getOwner() + .getService().getRequestedServerVersion())) { + throw new ServiceObjectPropertyException("This property is read-only and can't be set.", propertyDefinition); + } + + if (!this.getOwner().isNew()) { + // If owner is an item attachment, property cannot be updated + // (EWS doesn't support updating item attachments) + + if ((this.getOwner() instanceof Item)) { + Item ownerItem = (Item) this.getOwner(); + if (ownerItem.isAttachment()) { + throw new ServiceObjectPropertyException("Item attachments can't be updated.", propertyDefinition); + } + } + + // If the property cannot be deleted, throw. + if (object == null && !propertyDefinition.hasFlag(PropertyDefinitionFlags.CanDelete)) { + throw new ServiceObjectPropertyException("This property can't be deleted.", propertyDefinition); + } + + // If the property cannot be updated, throw. + if (!propertyDefinition.hasFlag(PropertyDefinitionFlags.CanUpdate)) { + throw new ServiceObjectPropertyException("This property can't be updated.", propertyDefinition); + } + } + } + + // If the value is set to null, delete the property. + if (object == null) { + this.deleteProperty(propertyDefinition); + } else { + ComplexProperty complexProperty; + Object currentValue; + + if (this.properties.containsKey(propertyDefinition)) { + currentValue = this.properties.get(propertyDefinition); + + if (currentValue instanceof ComplexProperty) { + complexProperty = (ComplexProperty) currentValue; + complexProperty.removeChangeEvent(this); + } + } + + // If the property was to be deleted, the deletion becomes an + // update. + if (this.deletedProperties.containsKey(propertyDefinition)) { + this.deletedProperties.remove(propertyDefinition); + addToChangeList(propertyDefinition, this.modifiedProperties); + } else { + // If the property value was not set, we have a newly set + // property. + if (!this.properties.containsKey(propertyDefinition)) { + addToChangeList(propertyDefinition, this.addedProperties); + } else { + // The last case is that we have a modified property. + if (!this.modifiedProperties.contains(propertyDefinition)) { + addToChangeList(propertyDefinition, + this.modifiedProperties); + } + } + } + + if (object instanceof ComplexProperty) { + this.initComplexProperty((ComplexProperty) object); + } + this.properties.put(propertyDefinition, object); + this.changed(); + } + + } + + /* + * (non-Javadoc) + * + * @seemicrosoft.exchange.webservices.ComplexPropertyChangedInterface# + * complexPropertyChanged(microsoft.exchange.webservices.ComplexProperty) + */ + @Override + public void complexPropertyChanged(ComplexProperty complexProperty) { + this.propertyChanged(complexProperty); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/PropertySet.java b/ews-api/src/main/java/com/eischet/ews/api/core/PropertySet.java new file mode 100644 index 000000000..1bb02edb8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/PropertySet.java @@ -0,0 +1,582 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.ISelfValidate; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.BasePropertySet; +import com.eischet.ews.api.core.enumeration.property.BodyType; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.enumeration.service.ServiceObjectType; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.request.ServiceRequestBase; +import com.eischet.ews.api.property.definition.PropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinitionBase; + +import javax.xml.stream.XMLStreamException; +import java.util.*; + +/** + * Represents a set of item or folder property. Property sets are used to + * indicate what property of an item or folder should be loaded when binding + * to an existing item or folder or when loading an item or folder's property. + */ +public final class PropertySet implements ISelfValidate, + Iterable { + + /** + * The Constant IdOnly. + */ + public static final PropertySet IdOnly = PropertySet. + createReadonlyPropertySet(BasePropertySet.IdOnly); + + /** + * Returns a predefined property set that only includes the Id property. + * + * @return Returns a predefined property set that only includes the Id + * property. + */ + public static PropertySet getIdOnly() { + return IdOnly; + } + + /** + * The Constant FirstClassProperties. + */ + public static final PropertySet FirstClassProperties = PropertySet. + createReadonlyPropertySet(BasePropertySet.FirstClassProperties); + + /** + * Returns a predefined property set that includes the first class + * property of an item or folder. + * + * @return A predefined property set that includes the first class + * property of an item or folder. + */ + public static PropertySet getFirstClassProperties() { + return FirstClassProperties; + } + + /** + * Maps BasePropertySet values to EWS's BaseShape values. + */ + private static final LazyMember> defaultPropertySetMap = + new LazyMember>(new + ILazyMember>() { + @Override + public Map createInstance() { + Map result = new + HashMap(); + result.put(BasePropertySet.IdOnly, + BasePropertySet.IdOnly + .getBaseShapeValue()); + result.put(BasePropertySet.FirstClassProperties, + BasePropertySet.FirstClassProperties + .getBaseShapeValue()); + return result; + } + }); + /** + * The base property set this property set is based upon. + */ + private BasePropertySet basePropertySet; + + /** + * The list of additional property included in this property set. + */ + private final List additionalProperties = new + ArrayList(); + + /** + * The requested body type for get and find operations. If null, the + * "best body" is returned. + */ + private BodyType requestedBodyType; + + /** + * Value indicating whether or not the server should filter HTML content. + */ + private Boolean filterHtml; + + /** + * Value indicating whether or not the server + * should convert HTML code page to UTF8. + */ + private Boolean convertHtmlCodePageToUTF8; + + /** + * Value indicating whether or not this PropertySet can be modified. + */ + private boolean isReadOnly; + + /** + * Initializes a new instance of PropertySet. + * + * @param basePropertySet The base property set to base the property set upon. + * @param additionalProperties Additional property to include in the property set. Property + * definitions are available as static members from schema + * classes (for example, EmailMessageSchema.Subject, + * AppointmentSchema.Start, ContactSchema.GivenName, etc.) + */ + public PropertySet(BasePropertySet basePropertySet, + PropertyDefinitionBase... additionalProperties) { + this.basePropertySet = basePropertySet; + if (null != additionalProperties) { + this.additionalProperties.addAll(Arrays.asList(additionalProperties)); + } + } + + /** + * Initializes a new instance of PropertySet. + * + * @param basePropertySet The base property set to base the property set upon. + * @param additionalProperties Additional property to include in the property set. Property + * definitions are available as static members from schema + * classes (for example, EmailMessageSchema.Subject, + * AppointmentSchema.Start, ContactSchema.GivenName, etc.) + */ + public PropertySet(BasePropertySet basePropertySet, + Iterator additionalProperties) { + this.basePropertySet = basePropertySet; + if (null != additionalProperties) { + while (additionalProperties.hasNext()) { + this.additionalProperties.add(additionalProperties.next()); + } + } + } + + /** + * Initializes a new instance of PropertySet based upon + * BasePropertySet.IdOnly. + */ + public PropertySet() { + this.basePropertySet = BasePropertySet.IdOnly; + } + + /** + * Initializes a new instance of PropertySet. + * + * @param basePropertySet The base property set to base the property set upon. + */ + public PropertySet(BasePropertySet basePropertySet) { + this.basePropertySet = basePropertySet; + } + + /** + * Initializes a new instance of PropertySet based upon + * BasePropertySet.IdOnly. + * + * @param additionalProperties Additional property to include in the property set. Property + * definitions are available as static members from schema + * classes (for example, EmailMessageSchema.Subject, + * AppointmentSchema.Start, ContactSchema.GivenName, etc.) + */ + public PropertySet(PropertyDefinitionBase... additionalProperties) { + this(BasePropertySet.IdOnly, additionalProperties); + } + + /** + * Initializes a new instance of PropertySet based upon + * BasePropertySet.IdOnly. + * + * @param additionalProperties Additional property to include in the property set. Property + * definitions are available as static members from schema + * classes (for example, EmailMessageSchema.Subject, + * AppointmentSchema.Start, ContactSchema.GivenName, etc.) + */ + public PropertySet(Iterator additionalProperties) { + this(BasePropertySet.IdOnly, additionalProperties); + } + + /** + * Implements an implicit conversion between + * PropertySet and BasePropertySet. + * + * @param basePropertySet The BasePropertySet value to convert from. + * @return A PropertySet instance based on the specified base property set. + */ + public static PropertySet getPropertySetFromBasePropertySet(BasePropertySet + basePropertySet) { + return new PropertySet(basePropertySet); + } + + + /** + * Adds the specified property to the property set. + * + * @param property The property to add. + * @throws Exception the exception + */ + public void add(PropertyDefinitionBase property) throws Exception { + this.throwIfReadonly(); + EwsUtilities.validateParam(property, "property"); + + if (!this.additionalProperties.contains(property)) { + this.additionalProperties.add(property); + } + } + + /** + * Adds the specified property to the property set. + * + * @param properties The property to add. + * @throws Exception the exception + */ + public void addRange(Iterable properties) + throws Exception { + this.throwIfReadonly(); + Iterator property = properties.iterator(); + EwsUtilities.validateParamCollection(property, "property"); + + for (Iterator it = properties.iterator(); it + .hasNext(); ) { + this.add(it.next()); + } + } + + /** + * Remove all explicitly added property from the property set. + */ + public void clear() { + this.throwIfReadonly(); + this.additionalProperties.clear(); + } + + /** + * Creates a read-only PropertySet. + * + * @param basePropertySet The base property set. + * @return PropertySet + */ + private static PropertySet createReadonlyPropertySet( + BasePropertySet basePropertySet) { + PropertySet propertySet = new PropertySet(basePropertySet); + propertySet.isReadOnly = true; + return propertySet; + } + + /** + * Throws if readonly property set. + */ + private void throwIfReadonly() { + if (this.isReadOnly) { + throw new UnsupportedOperationException("This PropertySet is read-only and can't be modified."); + } + } + + /** + * Determines whether the specified property has been explicitly added to + * this property set using the Add or AddRange methods. + * + * @param property The property. + * @return true if this property set contains the specified property + * otherwise, false + */ + public boolean contains(PropertyDefinitionBase property) { + return this.additionalProperties.contains(property); + } + + /** + * Removes the specified property from the set. + * + * @param property The property to remove. + * @return true if the property was successfully removed, false otherwise. + */ + public boolean remove(PropertyDefinitionBase property) { + this.throwIfReadonly(); + return this.additionalProperties.remove(property); + } + + /** + * Gets the base property set, the property set is based upon. + * + * @return the base property set + */ + public BasePropertySet getBasePropertySet() { + return this.basePropertySet; + } + + /** + * Maps BasePropertySet values to EWS's BaseShape values. + * + * @return the base property set + */ + public static LazyMember> getDefaultPropertySetMap() { + return PropertySet.defaultPropertySetMap; + + } + + /** + * Sets the base property set, the property set is based upon. + * + * @param basePropertySet Base property set. + */ + public void setBasePropertySet(BasePropertySet basePropertySet) { + this.throwIfReadonly(); + this.basePropertySet = basePropertySet; + } + + /** + * Gets type of body that should be loaded on item. If RequestedBodyType + * is null, body is returned as HTML if available, plain text otherwise. + * + * @return the requested body type + */ + public BodyType getRequestedBodyType() { + return this.requestedBodyType; + } + + /** + * Sets type of body that should be loaded on item. If RequestedBodyType is + * null, body is returned as HTML if available, plain text otherwise. + * + * @param requestedBodyType Type of body that should be loaded on item. + */ + public void setRequestedBodyType(BodyType requestedBodyType) { + this.throwIfReadonly(); + this.requestedBodyType = requestedBodyType; + } + + /** + * Gets the number of explicitly added property in this set. + * + * @return the count + */ + public int getCount() { + return this.additionalProperties.size(); + } + + /** + * Gets value indicating whether or not to filter potentially unsafe HTML + * content from message bodies. + * + * @return the filter html content + */ + public Boolean getFilterHtmlContent() { + return this.filterHtml; + } + + /** + * Sets value indicating whether or not to filter potentially unsafe HTML + * content from message bodies. + * + * @param filterHtml true to filter otherwise false. + */ + public void setFilterHtmlContent(Boolean filterHtml) { + this.throwIfReadonly(); + this.filterHtml = filterHtml; + } + + + /** + * Gets value indicating whether or not to convert + * HTML code page to UTF8 encoding. + */ + public Boolean getConvertHtmlCodePageToUTF8() { + return this.convertHtmlCodePageToUTF8; + + } + + /** + * Sets value indicating whether or not to + * convert HTML code page to UTF8 encoding. + */ + public void setConvertHtmlCodePageToUTF8(Boolean value) { + this.throwIfReadonly(); + this.convertHtmlCodePageToUTF8 = value; + + } + + + /** + * Gets the PropertyDefinitionBase at the specified index. + * + * @param index Index. + * @return the property definition base at + */ + public PropertyDefinitionBase getPropertyDefinitionBaseAt(int index) { + return this.additionalProperties.get(index); + } + + + /** + * Validate. + * + * @throws ExchangeValidationException the service validation exception + */ + @Override + public void validate() throws ExchangeValidationException { + this.internalValidate(); + } + + /** + * Writes additional property to XML. + * + * @param writer The writer to write to + * @param propertyDefinitions The property definitions to write + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + public static void writeAdditionalPropertiesToXml(EwsServiceXmlWriter writer, Iterator propertyDefinitions) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.AdditionalProperties); + + while (propertyDefinitions.hasNext()) { + PropertyDefinitionBase propertyDefinition = propertyDefinitions.next(); + propertyDefinition.writeToXml(writer); + } + + writer.writeEndElement(); + } + + /** + * Validates this property set. + * + * @throws ExchangeValidationException the service validation exception + */ + public void internalValidate() throws ExchangeValidationException { + for (int i = 0; i < this.additionalProperties.size(); i++) { + if (this.additionalProperties.get(i) == null) { + throw new ExchangeValidationException(String.format("The additional property at index %d is null.", i)); + } + } + } + + /** + * Validates this property set instance for request to ensure that: 1. + * Properties are valid for the request server version 2. If only summary + * property are legal for this request (e.g. FindItem) then only summary + * property were specified. + * + * @param request The request. + * @param summaryPropertiesOnly if set to true then only summary property are allowed. + * @throws ServiceVersionException the service version exception + * @throws ExchangeValidationException the service validation exception + */ + public void validateForRequest(ServiceRequestBase request, boolean summaryPropertiesOnly) throws ServiceVersionException, + ExchangeValidationException { + for (PropertyDefinitionBase propDefBase : this.additionalProperties) { + if (propDefBase instanceof PropertyDefinition) { + PropertyDefinition propertyDefinition = + (PropertyDefinition) propDefBase; + if (propertyDefinition.getVersion().ordinal() > request + .getService().getRequestedServerVersion().ordinal()) { + throw new ServiceVersionException(String.format( + "The property %s is valid only for Exchange %s or later versions.", + propertyDefinition.getName(), propertyDefinition + .getVersion())); + } + + if (summaryPropertiesOnly && + !propertyDefinition.hasFlag( + PropertyDefinitionFlags.CanFind, request. + getService().getRequestedServerVersion())) { + throw new ExchangeValidationException(String.format("The property %s can't be used in %s request.", + propertyDefinition.getName(), request + .getXmlElementName())); + } + } + } + if (this.getFilterHtmlContent() != null) { + if (request.getService().getRequestedServerVersion().compareTo(ExchangeVersion.Exchange2010) < 0) { + throw new ServiceVersionException( + String.format("The property %s is valid only for Exchange %s or later versions.", + "FilterHtmlContent", + ExchangeVersion.Exchange2010)); + } + } + + if (this.getConvertHtmlCodePageToUTF8() != null) { + if (request.getService().getRequestedServerVersion().compareTo(ExchangeVersion.Exchange2010_SP1) < 0) { + throw new ServiceVersionException( + String.format("The property %s is valid only for Exchange %s or later versions.", + "ConvertHtmlCodePageToUTF8", + ExchangeVersion.Exchange2010_SP1)); + } + } + } + + /** + * Writes the property set to XML. + * + * @param writer The writer to write to + * @param serviceObjectType The type of service object the property set is emitted for + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + public void writeToXml(EwsServiceXmlWriter writer, ServiceObjectType serviceObjectType) throws ExchangeXmlException { + writer + .writeStartElement( + XmlNamespace.Messages, + serviceObjectType == ServiceObjectType.Item ? + XmlElementNames.ItemShape + : XmlElementNames.FolderShape); + + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.BaseShape, + this.getBasePropertySet().getBaseShapeValue()); + + if (serviceObjectType == ServiceObjectType.Item) { + if (this.getRequestedBodyType() != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.BodyType, this.getRequestedBodyType()); + } + + if (this.getFilterHtmlContent() != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.FilterHtmlContent, this + .getFilterHtmlContent()); + } + if ((this.getConvertHtmlCodePageToUTF8() != null) && + writer.getService().getRequestedServerVersion(). + compareTo(ExchangeVersion.Exchange2010_SP1) >= 0) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.ConvertHtmlCodePageToUTF8, + this.getConvertHtmlCodePageToUTF8()); + } + } + + if (this.additionalProperties.size() > 0) { + writeAdditionalPropertiesToXml(writer, this.additionalProperties + .iterator()); + } + + writer.writeEndElement(); // Item/FolderShape + } + + /* + * (non-Javadoc) + * + * @see java.lang.Iterable#iterator() + */ + @Override + public Iterator iterator() { + return this.additionalProperties.iterator(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/SimplePropertyBag.java b/ews-api/src/main/java/com/eischet/ews/api/core/SimplePropertyBag.java new file mode 100644 index 000000000..1cbcf1756 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/SimplePropertyBag.java @@ -0,0 +1,245 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.complex.IPropertyBagChangedDelegate; + +import java.util.*; + +/** + * Represents a simple property bag. + * + * @param The type of key + */ +public class SimplePropertyBag implements Iterable> { + + /** + * The item. + */ + private final Map items = new HashMap(); + + /** + * The removed item. + */ + private final List removedItems = new ArrayList(); + + /** + * The added item. + */ + private final List addedItems = new ArrayList(); + + /** + * The modified item. + */ + private final List modifiedItems = new ArrayList(); + + /** + * Add item to change list. + * + * @param key the key + * @param changeList the change list + */ + private void internalAddItemToChangeList(TKey key, List changeList) { + if (!changeList.contains(key)) { + changeList.add(key); + } + } + + /** + * Triggers dispatch of the change event. + */ + private void changed() { + if (!onChange.isEmpty()) { + for (IPropertyBagChangedDelegate change : onChange) { + change.propertyBagChanged(this); + } + } + } + + /** + * Remove item. + * + * @param key the key + */ + private void internalRemoveItem(TKey key) { + OutParam value = new OutParam(); + if (this.tryGetValue(key, value)) { + this.items.remove(key); + this.removedItems.add(key); + this.changed(); + } + } + + + /** + * Gets the added item. The added item. + * + * @return the added item + */ + public Iterable getAddedItems() { + return this.addedItems; + } + + /** + * Gets the removed item. The removed item. + * + * @return the removed item + */ + public Iterable getRemovedItems() { + return this.removedItems; + } + + /** + * Gets the modified item. The modified item. + * + * @return the modified item + */ + public Iterable getModifiedItems() { + return this.modifiedItems; + } + + /** + * Initializes a new instance of the class. + */ + public SimplePropertyBag() { + } + + /** + * Clears the change log. + */ + public void clearChangeLog() { + this.removedItems.clear(); + this.addedItems.clear(); + this.modifiedItems.clear(); + } + + /** + * Determines whether the specified key is in the property bag. + * + * @param key the key + * @return true, if successful if the specified key exists; otherwise, . + */ + public boolean containsKey(TKey key) { + return this.items.containsKey(key); + } + + /** + * Tries to get value. + * + * @param key the key + * @param value the value + * @return True if value exists in property bag. + */ + public boolean tryGetValue(TKey key, OutParam value) { + if (this.items.containsKey(key)) { + value.setParam(this.items.get(key)); + return true; + } else { + value.setParam(null); + return false; + } + } + + /** + * Gets the simple property bag. + * + * @param key the key + * @return the simple property bag + */ + public Object getSimplePropertyBag(TKey key) { + OutParam value = new OutParam(); + if (this.tryGetValue(key, value)) { + return value.getParam(); + } else { + return null; + } + } + + /** + * Sets the simple property bag. + * + * @param key the key + * @param value the value + */ + public void setSimplePropertyBag(TKey key, Object value) { + if (value == null) { + this.internalRemoveItem(key); + } else { + // If the item was to be deleted, the deletion becomes an update. + if (this.removedItems.remove(key)) { + internalAddItemToChangeList(key, this.modifiedItems); + } else { + // If the property value was not set, we have a newly set + // property. + if (!this.containsKey(key)) { + internalAddItemToChangeList(key, this.addedItems); + } else { + // The last case is that we have a modified property. + if (!this.modifiedItems.contains(key)) { + internalAddItemToChangeList(key, this.modifiedItems); + } + } + } + + this.items.put(key, value); + this.changed(); + } + } + + /** + * Occurs when Changed. + */ + private final List> onChange = + new ArrayList>(); + + /** + * Set event to happen when property changed. + * + * @param change change event + */ + public void addOnChangeEvent(IPropertyBagChangedDelegate change) { + onChange.add(change); + } + + /** + * Remove the event from happening when property changed. + * + * @param change change event + */ + public void removeChangeEvent(IPropertyBagChangedDelegate change) { + onChange.remove(change); + } + + /** + * Returns an iterator over a set of elements of type T. + * + * @return an Iterator. + */ + @Override + public Iterator> iterator() { + return (Iterator>) this.items.keySet().iterator(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/WebAsyncCallStateAnchor.java b/ews-api/src/main/java/com/eischet/ews/api/core/WebAsyncCallStateAnchor.java new file mode 100644 index 000000000..ddb391fde --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/WebAsyncCallStateAnchor.java @@ -0,0 +1,81 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.core.request.HttpWebRequest; +import com.eischet.ews.api.core.request.ServiceRequestBase; +import com.eischet.ews.api.misc.AsyncCallback; + +public class WebAsyncCallStateAnchor { + + ServiceRequestBase serviceRequest; + HttpWebRequest webRequest; + AsyncCallback asyncCallback; + Object asyncState; + + public WebAsyncCallStateAnchor(ServiceRequestBase serviceRequest, + HttpWebRequest webRequest, + AsyncCallback asyncCallback, + Object asyncState) + throws Exception { + EwsUtilities.validateParam(serviceRequest, "serviceRequest"); + EwsUtilities.validateParam(webRequest, "webRequest"); + this.serviceRequest = serviceRequest; + this.webRequest = webRequest; + this.asyncCallback = asyncCallback; + this.asyncState = asyncState; + } + + public ServiceRequestBase getServiceRequest() { + return this.serviceRequest; + } + + public void setAsyncCallback(AsyncCallback asyncCallback) { + this.asyncCallback = asyncCallback; + } + + public AsyncCallback getAsyncCallback() { + return this.asyncCallback; + } + + public void setServiceRequest(ServiceRequestBase wasserviceRequest) { + serviceRequest = wasserviceRequest; + } + + public void setHttpWebRequest(HttpWebRequest waswebRequest) { + webRequest = waswebRequest; + } + + public HttpWebRequest getHttpWebRequest() { + return this.webRequest; + } + + public void setAsynncState(Object wasasyncState) { + asyncState = wasasyncState; + } + + public Object getAsyncState() { + return this.asyncState; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/WebProxy.java b/ews-api/src/main/java/com/eischet/ews/api/core/WebProxy.java new file mode 100644 index 000000000..62c7e8aac --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/WebProxy.java @@ -0,0 +1,116 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.credential.WebProxyCredentials; + +/** + * WebProxy is used for setting proxy details for proxy authentication schemes such as + * basic, digest, NTLM, and Kerberos authentication. + */ +public class WebProxy { + + private final String host; + + private int port; + + private WebProxyCredentials credentials; + + + /** + * Initializes a new instance to use specified proxy details. + * + * @param host proxy host. + * @param port proxy port. + */ + public WebProxy(String host, int port) { + this.host = host; + this.port = port; + } + + /** + * Initializes a new instance to use specified proxy with default port 80. + * + * @param host proxy host. + */ + public WebProxy(String host) { + this.host = host; + this.port = 80; + } + + /** + * Initializes a new instance to use specified proxy with default port 80. + * + * @param host proxy host. + * @param credentials the credential to use for the proxy. + */ + public WebProxy(String host, WebProxyCredentials credentials) { + this.host = host; + this.credentials = credentials; + } + + /** + * Initializes a new instance to use specified proxy details. + * + * @param host proxy host. + * @param port proxy port. + * @param credentials the credential to use for the proxy. + */ + public WebProxy(String host, int port, WebProxyCredentials credentials) { + this.host = host; + this.port = port; + this.credentials = credentials; + } + + /** + * Gets the Proxy Host. + * + * @return the host + */ + public String getHost() { + return this.host; + } + + /** + * Gets the Proxy Port. + * + * @return the port + */ + public int getPort() { + return this.port; + } + + public boolean hasCredentials() { + return credentials != null; + } + + /** + * Gets the Proxy Credentials. + * + * @return the proxy credential + */ + public WebProxyCredentials getCredentials() { + return credentials; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/XmlAttributeNames.java b/ews-api/src/main/java/com/eischet/ews/api/core/XmlAttributeNames.java new file mode 100644 index 000000000..196ea29b1 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/XmlAttributeNames.java @@ -0,0 +1,386 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +/** + * XML attribute names. + */ +public class XmlAttributeNames { + + /** + * The Constant XmlNs. + */ + public static final String XmlNs = "xmlns"; + + /** + * The Constant Id. + */ + public static final String Id = "Id"; + + /** + * The Constant ChangeKey. + */ + public static final String ChangeKey = "ChangeKey"; + + /** + * The Constant RecurringMasterId. + */ + public static final String RecurringMasterId = "RecurringMasterId"; + + /** + * The Constant InstanceIndex. + */ + public static final String InstanceIndex = "InstanceIndex"; + + /** + * The Constant OccurrenceId. + */ + public static final String OccurrenceId = "OccurrenceId"; + + /** + * The Constant Traversal. + */ + public static final String Traversal = "Traversal"; + + /** + * The Constant Offset. + */ + public static final String Offset = "Offset"; + + /** + * The Constant MaxEntriesReturned. + */ + public static final String MaxEntriesReturned = "MaxEntriesReturned"; + + /** + * The Constant BasePoint. + */ + public static final String BasePoint = "BasePoint"; + + /** + * The Constant ResponseClass. + */ + public static final String ResponseClass = "ResponseClass"; + + /** + * The Constant IndexedPagingOffset. + */ + public static final String IndexedPagingOffset = "IndexedPagingOffset"; + + /** + * The Constant TotalItemsInView. + */ + public static final String TotalItemsInView = "TotalItemsInView"; + + /** + * The Constant IncludesLastItemInRange. + */ + public static final String IncludesLastItemInRange = + "IncludesLastItemInRange"; + + /** + * The Constant BodyType. + */ + public static final String BodyType = "BodyType"; + + /** + * The Constant MessageDisposition. + */ + public static final String MessageDisposition = "MessageDisposition"; + + /** + * The Constant SaveItemToFolder. + */ + public static final String SaveItemToFolder = "SaveItemToFolder"; + + /** + * The Constant RootItemChangeKey. + */ + public static final String RootItemChangeKey = "RootItemChangeKey"; + + /** + * The Constant DeleteType. + */ + public static final String DeleteType = "DeleteType"; + + /** + * The Constant DeleteSubFolders. + */ + public static final String DeleteSubFolders = "DeleteSubFolders"; + + /** + * The Constant AffectedTaskOccurrences. + */ + public static final String AffectedTaskOccurrences = + "AffectedTaskOccurrences"; + + /** + * The Constant SendMeetingCancellations. + */ + public static final String SendMeetingCancellations = + "SendMeetingCancellations"; + + /** + * The Constant FieldURI. + */ + public static final String FieldURI = "FieldURI"; + + /** + * The Constant FieldIndex. + */ + public static final String FieldIndex = "FieldIndex"; + + /** + * The Constant ConflictResolution. + */ + public static final String ConflictResolution = "ConflictResolution"; + + /** + * The Constant SendMeetingInvitationsOrCancellations. + */ + public static final String SendMeetingInvitationsOrCancellations = + "SendMeetingInvitationsOrCancellations"; + + /** + * The Constant CharacterSet. + */ + public static final String CharacterSet = "CharacterSet"; + + /** + * The Constant HeaderName. + */ + public static final String HeaderName = "HeaderName"; + + /** + * The Constant SendMeetingInvitations. + */ + public static final String SendMeetingInvitations = + "SendMeetingInvitations"; + + /** + * The Constant Key. + */ + public static final String Key = "Key"; + + /** + * The Constant RoutingType. + */ + public static final String RoutingType = "RoutingType"; + + /** + * The Constant MailboxType. + */ + public static final String MailboxType = "MailboxType"; + + /** + * The Constant DistinguishedPropertySetId. + */ + public static final String DistinguishedPropertySetId = + "DistinguishedPropertySetId"; + + /** + * The Constant PropertySetId. + */ + public static final String PropertySetId = "PropertySetId"; + + /** + * The Constant PropertyTag. + */ + public static final String PropertyTag = "PropertyTag"; + + /** + * The Constant PropertyName. + */ + public static final String PropertyName = "PropertyName"; + + /** + * The Constant PropertyId. + */ + public static final String PropertyId = "PropertyId"; + + /** + * The Constant PropertyType. + */ + public static final String PropertyType = "PropertyType"; + + /** + * The Constant TimeZoneName. + */ + public static final String TimeZoneName = "TimeZoneName"; + + /** + * The Constant ReturnFullContactData. + */ + public static final String ReturnFullContactData = "ReturnFullContactData"; + + /** + * The Constant ContactDataShape. + */ + public static final String ContactDataShape = "ContactDataShape"; + + /** + * The Constant Numerator. + */ + public static final String Numerator = "Numerator"; + + /** + * The Constant Denominator. + */ + public static final String Denominator = "Numerator"; + + /** + * The Constant Value. + */ + public static final String Value = "Value"; + + /** + * The Constant ContainmentMode. + */ + public static final String ContainmentMode = "ContainmentMode"; + + /** + * The Constant ContainmentComparison. + */ + public static final String ContainmentComparison = "ContainmentComparison"; + + /** + * The Constant Order. + */ + public static final String Order = "Order"; + + /** + * The Constant StartDate. + */ + public static final String StartDate = "StartDate"; + + /** + * The Constant EndDate. + */ + public static final String EndDate = "EndDate"; + + /** + * The Constant Version. + */ + public static final String Version = "Version"; + + /** + * The Constant Aggregate. + */ + public static final String Aggregate = "Aggregate"; + + /** + * The Constant SearchScope. + */ + public static final String SearchScope = "SearchScope"; + + /** + * The Constant Format. + */ + public static final String Format = "Format"; + + /** + * The Constant Mailbox. + */ + public static final String Mailbox = "Mailbox"; + + /** + * The Constant DestinationFormat. + */ + public static final String DestinationFormat = "DestinationFormat"; + + /** + * The Constant FolderId. + */ + public static final String FolderId = "FolderId"; + + /** + * The Constant ItemId. + */ + public static final String ItemId = "ItemId"; + + /** + * The Constant IncludePermissions. + */ + public static final String IncludePermissions = "IncludePermissions"; + + /** + * The Constant InitialName. + */ + public static final String InitialName = "InitialName"; + + /** + * The Constant FinalName. + */ + public static final String FinalName = "FinalName"; + + /** + * The Constant AuthenticationMethod. + */ + public static final String AuthenticationMethod = "AuthenticationMethod"; + + /** + * The Constant Time. + */ + public static final String Time = "Time"; + + /** + * The Constant Name. + */ + public static final String Name = "Name"; + + /** + * The Constant Bias. + */ + public static final String Bias = "Bias"; + + /** + * The Constant Kind. + */ + public static final String Kind = "Kind"; + + /** + * The Constant SubscribeToAllFolders. + */ + public static final String SubscribeToAllFolders = "SubscribeToAllFolders"; + + /** + * The Constant PublicFolderServer. + */ + public static final String PublicFolderServer = "PublicFolderServer"; + + /** + * The Constant IsArchive. + */ + public static final String IsArchive = "IsArchive"; + // xsi attribute + /** + * The Constant Nil. + */ + public static final String Nil = "nil"; + + /** + * The Constant Type. + */ + public static final String Type = "type"; +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/XmlElementNames.java b/ews-api/src/main/java/com/eischet/ews/api/core/XmlElementNames.java new file mode 100644 index 000000000..91ef3ef82 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/XmlElementNames.java @@ -0,0 +1,4788 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +/** + * XML element names. + */ +public class XmlElementNames { + + /** + * The Constant AllProperties. + */ + public static final String AllProperties = "AllProperties"; + + /** + * The Constant ParentFolderIds. + */ + public static final String ParentFolderIds = "ParentFolderIds"; + + /** + * The Constant DistinguishedFolderId. + */ + public static final String DistinguishedFolderId = "DistinguishedFolderId"; + + /** + * The Constant ItemId. + */ + public static final String ItemId = "ItemId"; + + /** + * The Constant ItemIds. + */ + public static final String ItemIds = "ItemIds"; + + /** + * The Constant FolderId. + */ + public static final String FolderId = "FolderId"; + + /** + * The Constant FolderIds. + */ + public static final String FolderIds = "FolderIds"; + + /** + * The Constant OccurrenceItemId. + */ + public static final String OccurrenceItemId = "OccurrenceItemId"; + + /** + * The Constant RecurringMasterItemId. + */ + public static final String RecurringMasterItemId = "RecurringMasterItemId"; + + /** + * The Constant ItemShape. + */ + public static final String ItemShape = "ItemShape"; + + /** + * The Constant FolderShape. + */ + public static final String FolderShape = "FolderShape"; + + /** + * The Constant BaseShape. + */ + public static final String BaseShape = "BaseShape"; + + /** + * The Constant IndexedPageItemView. + */ + public static final String IndexedPageItemView = "IndexedPageItemView"; + + /** + * The Constant IndexedPageFolderView. + */ + public static final String IndexedPageFolderView = "IndexedPageFolderView"; + + /** + * The Constant FractionalPageItemView. + */ + public static final String FractionalPageItemView = "FractionalPageItemView"; + + /** + * The Constant FractionalPageFolderView. + */ + public static final String FractionalPageFolderView = + "FractionalPageFolderView"; + + /** + * The Constant ResponseCode. + */ + public static final String ResponseCode = "ResponseCode"; + + /** + * The Constant RootFolder. + */ + public static final String RootFolder = "RootFolder"; + + /** + * The Constant Folder. + */ + public static final String Folder = "Folder"; + + /** + * The Constant ContactsFolder. + */ + public static final String ContactsFolder = "ContactsFolder"; + + /** + * The Constant TasksFolder. + */ + public static final String TasksFolder = "TasksFolder"; + + /** + * The Constant SearchFolder. + */ + public static final String SearchFolder = "SearchFolder"; + + /** + * The Constant Folders. + */ + public static final String Folders = "Folders"; + + /** + * The Constant Item. + */ + public static final String Item = "Item"; + + /** + * The Constant Items. + */ + public static final String Items = "Items"; + + /** + * The Constant Message. + */ + public static final String Message = "Message"; + + /** + * The Constant Mailbox. + */ + public static final String Mailbox = "Mailbox"; + + /** + * The Constant Body. + */ + public static final String Body = "Body"; + + /** + * The Constant From. + */ + public static final String From = "From"; + + /** + * The Constant Sender. + */ + public static final String Sender = "Sender"; + + /** + * The Constant Name. + */ + public static final String Name = "Name"; + + /** + * The Constant Address. + */ + public static final String Address = "Address"; + + /** + * The Constant EmailAddress. + */ + public static final String EmailAddress = "EmailAddress"; + + /** + * The Constant RoutingType. + */ + public static final String RoutingType = "RoutingType"; + + /** + * The Constant MailboxType. + */ + public static final String MailboxType = "MailboxType"; + + /** + * The Constant ToRecipients. + */ + public static final String ToRecipients = "ToRecipients"; + + /** + * The Constant CcRecipients. + */ + public static final String CcRecipients = "CcRecipients"; + + /** + * The Constant BccRecipients. + */ + public static final String BccRecipients = "BccRecipients"; + + /** + * The Constant ReplyTo. + */ + public static final String ReplyTo = "ReplyTo"; + + /** + * The Constant ConversationTopic. + */ + public static final String ConversationTopic = "ConversationTopic"; + + /** + * The Constant ConversationIndex. + */ + public static final String ConversationIndex = "ConversationIndex"; + + /** + * The Constant IsDeliveryReceiptRequested. + */ + public static final String IsDeliveryReceiptRequested = + "IsDeliveryReceiptRequested"; + + /** + * The Constant IsRead. + */ + public static final String IsRead = "IsRead"; + + /** + * The Constant IsReadReceiptRequested. + */ + public static final String IsReadReceiptRequested = "IsReadReceiptRequested"; + + /** + * The Constant IsResponseRequested. + */ + public static final String IsResponseRequested = "IsResponseRequested"; + + /** + * The Constant InternetMessageId. + */ + public static final String InternetMessageId = "InternetMessageId"; + + /** + * The Constant References. + */ + public static final String References = "References"; + + /** + * The Constant ParentItemId. + */ + public static final String ParentItemId = "ParentItemId"; + + /** + * The Constant ParentFolderId. + */ + public static final String ParentFolderId = "ParentFolderId"; + + /** + * The Constant ChildFolderCount. + */ + public static final String ChildFolderCount = "ChildFolderCount"; + + /** + * The Constant DisplayName. + */ + public static final String DisplayName = "DisplayName"; + + /** + * The Constant TotalCount. + */ + public static final String TotalCount = "TotalCount"; + + /** + * The Constant ItemClass. + */ + public static final String ItemClass = "ItemClass"; + + /** + * The Constant FolderClass. + */ + public static final String FolderClass = "FolderClass"; + + /** + * The Constant Subject. + */ + public static final String Subject = "Subject"; + + /** + * The Constant MimeContent. + */ + public static final String MimeContent = "MimeContent"; + + /** + * The Constant Sensitivity. + */ + public static final String Sensitivity = "Sensitivity"; + + /** + * The Constant Attachments. + */ + public static final String Attachments = "Attachments"; + + /** + * The Constant DateTimeReceived. + */ + public static final String DateTimeReceived = "DateTimeReceived"; + + /** + * The Constant Size. + */ + public static final String Size = "Size"; + + /** + * The Constant Categories. + */ + public static final String Categories = "Categories"; + + /** + * The Constant Importance. + */ + public static final String Importance = "Importance"; + + /** + * The Constant InReplyTo. + */ + public static final String InReplyTo = "InReplyTo"; + + /** + * The Constant IsSubmitted. + */ + public static final String IsSubmitted = "IsSubmitted"; + + /** + * The Constant IsAssociated. + */ + public static final String IsAssociated = "IsAssociated"; + + /** + * The Constant IsDraft. + */ + public static final String IsDraft = "IsDraft"; + + /** + * The Constant IsFromMe. + */ + public static final String IsFromMe = "IsFromMe"; + + /** + * The Constant IsResend. + */ + public static final String IsResend = "IsResend"; + + /** + * The Constant IsUnmodified. + */ + public static final String IsUnmodified = "IsUnmodified"; + + /** + * The Constant InternetMessageHeader. + */ + public static final String InternetMessageHeader = "InternetMessageHeader"; + + /** + * The Constant InternetMessageHeaders. + */ + public static final String InternetMessageHeaders = "InternetMessageHeaders"; + + /** + * The Constant DateTimeSent. + */ + public static final String DateTimeSent = "DateTimeSent"; + + /** + * The Constant DateTimeCreated. + */ + public static final String DateTimeCreated = "DateTimeCreated"; + + /** + * The Constant ResponseObjects. + */ + public static final String ResponseObjects = "ResponseObjects"; + + /** + * The Constant ReminderDueBy. + */ + public static final String ReminderDueBy = "ReminderDueBy"; + + /** + * The Constant ReminderIsSet. + */ + public static final String ReminderIsSet = "ReminderIsSet"; + + /** + * The Constant ReminderMinutesBeforeStart. + */ + public static final String ReminderMinutesBeforeStart = + "ReminderMinutesBeforeStart"; + + /** + * The Constant DisplayCc. + */ + public static final String DisplayCc = "DisplayCc"; + + /** + * The Constant DisplayTo. + */ + public static final String DisplayTo = "DisplayTo"; + + /** + * The Constant HasAttachments. + */ + public static final String HasAttachments = "HasAttachments"; + + /** + * The Constant ExtendedProperty. + */ + public static final String ExtendedProperty = "ExtendedProperty"; + + /** + * The Constant Culture. + */ + public static final String Culture = "Culture"; + + /** + * The Constant FileAttachment. + */ + public static final String FileAttachment = "FileAttachment"; + + /** + * The Constant ItemAttachment. + */ + public static final String ItemAttachment = "ItemAttachment"; + + /** + * The Constant AttachmentIds. + */ + public static final String AttachmentIds = "AttachmentIds"; + + /** + * The Constant AttachmentId. + */ + public static final String AttachmentId = "AttachmentId"; + + /** + * The Constant ContentType. + */ + public static final String ContentType = "ContentType"; + + /** + * The Constant ContentLocation. + */ + public static final String ContentLocation = "ContentLocation"; + + /** + * The Constant ContentId. + */ + public static final String ContentId = "ContentId"; + + /** + * The Constant Content. + */ + public static final String Content = "Content"; + + /** + * The Constant SavedItemFolderId. + */ + public static final String SavedItemFolderId = "SavedItemFolderId"; + + /** + * The Constant MessageText. + */ + public static final String MessageText = "MessageText"; + + /** + * The Constant DescriptiveLinkKey. + */ + public static final String DescriptiveLinkKey = "DescriptiveLinkKey"; + + /** + * The Constant ItemChange. + */ + public static final String ItemChange = "ItemChange"; + + /** + * The Constant ItemChanges. + */ + public static final String ItemChanges = "ItemChanges"; + + /** + * The Constant FolderChange. + */ + public static final String FolderChange = "FolderChange"; + + /** + * The Constant FolderChanges. + */ + public static final String FolderChanges = "FolderChanges"; + + /** + * The Constant Updates. + */ + public static final String Updates = "Updates"; + + /** + * The Constant AppendToItemField. + */ + public static final String AppendToItemField = "AppendToItemField"; + + /** + * The Constant SetItemField. + */ + public static final String SetItemField = "SetItemField"; + + /** + * The Constant DeleteItemField. + */ + public static final String DeleteItemField = "DeleteItemField"; + + /** + * The Constant SetFolderField. + */ + public static final String SetFolderField = "SetFolderField"; + + /** + * The Constant DeleteFolderField. + */ + public static final String DeleteFolderField = "DeleteFolderField"; + + /** + * The Constant FieldURI. + */ + public static final String FieldURI = "FieldURI"; + + /** + * The Constant RootItemId. + */ + public static final String RootItemId = "RootItemId"; + + /** + * The Constant ReferenceItemId. + */ + public static final String ReferenceItemId = "ReferenceItemId"; + + /** + * The Constant NewBodyContent. + */ + public static final String NewBodyContent = "NewBodyContent"; + + /** + * The Constant ReplyToItem. + */ + public static final String ReplyToItem = "ReplyToItem"; + + /** + * The Constant ReplyAllToItem. + */ + public static final String ReplyAllToItem = "ReplyAllToItem"; + + /** + * The Constant ForwardItem. + */ + public static final String ForwardItem = "ForwardItem"; + + /** + * The Constant AcceptItem. + */ + public static final String AcceptItem = "AcceptItem"; + + /** + * The Constant TentativelyAcceptItem. + */ + public static final String TentativelyAcceptItem = "TentativelyAcceptItem"; + + /** + * The Constant DeclineItem. + */ + public static final String DeclineItem = "DeclineItem"; + + /** + * The Constant CancelCalendarItem. + */ + public static final String CancelCalendarItem = "CancelCalendarItem"; + + /** + * The Constant RemoveItem. + */ + public static final String RemoveItem = "RemoveItem"; + + /** + * The Constant SuppressReadReceipt. + */ + public static final String SuppressReadReceipt = "SuppressReadReceipt"; + + /** + * The Constant String. + */ + public static final String String = "String"; + + /** + * The Constant Start. + */ + public static final String Start = "Start"; + + /** + * The Constant End. + */ + public static final String End = "End"; + + /** + * The Constant OriginalStart. + */ + public static final String OriginalStart = "OriginalStart"; + + /** + * The Constant IsAllDayEvent. + */ + public static final String IsAllDayEvent = "IsAllDayEvent"; + + /** + * The Constant LegacyFreeBusyStatus. + */ + public static final String LegacyFreeBusyStatus = "LegacyFreeBusyStatus"; + + /** + * The Constant Location. + */ + public static final String Location = "Location"; + + /** + * The Constant When. + */ + public static final String When = "When"; + + /** + * The Constant IsMeeting. + */ + public static final String IsMeeting = "IsMeeting"; + + /** + * The Constant IsCancelled. + */ + public static final String IsCancelled = "IsCancelled"; + + /** + * The Constant IsRecurring. + */ + public static final String IsRecurring = "IsRecurring"; + + /** + * The Constant MeetingRequestWasSent. + */ + public static final String MeetingRequestWasSent = "MeetingRequestWasSent"; + + /** + * The Constant CalendarItemType. + */ + public static final String CalendarItemType = "CalendarItemType"; + + /** + * The Constant MyResponseType. + */ + public static final String MyResponseType = "MyResponseType"; + + /** + * The Constant Organizer. + */ + public static final String Organizer = "Organizer"; + + /** + * The Constant RequiredAttendees. + */ + public static final String RequiredAttendees = "RequiredAttendees"; + + /** + * The Constant OptionalAttendees. + */ + public static final String OptionalAttendees = "OptionalAttendees"; + + /** + * The Constant Resources. + */ + public static final String Resources = "Resources"; + + /** + * The Constant ConflictingMeetingCount. + */ + public static final String ConflictingMeetingCount = + "ConflictingMeetingCount"; + + /** + * The Constant AdjacentMeetingCount. + */ + public static final String AdjacentMeetingCount = "AdjacentMeetingCount"; + + /** + * The Constant ConflictingMeetings. + */ + public static final String ConflictingMeetings = "ConflictingMeetings"; + + /** + * The Constant AdjacentMeetings. + */ + public static final String AdjacentMeetings = "AdjacentMeetings"; + + /** + * The Constant Duration. + */ + public static final String Duration = "Duration"; + + /** + * The Constant TimeZone. + */ + public static final String TimeZone = "TimeZone"; + + /** + * The Constant AppointmentReplyTime. + */ + public static final String AppointmentReplyTime = "AppointmentReplyTime"; + + /** + * The Constant AppointmentSequenceNumber. + */ + public static final String AppointmentSequenceNumber = + "AppointmentSequenceNumber"; + + /** + * The Constant AppointmentState. + */ + public static final String AppointmentState = "AppointmentState"; + + /** + * The Constant Recurrence. + */ + public static final String Recurrence = "Recurrence"; + + /** + * The Constant FirstOccurrence. + */ + public static final String FirstOccurrence = "FirstOccurrence"; + + /** + * The Constant LastOccurrence. + */ + public static final String LastOccurrence = "LastOccurrence"; + + /** + * The Constant ModifiedOccurrences. + */ + public static final String ModifiedOccurrences = "ModifiedOccurrences"; + + /** + * The Constant DeletedOccurrences. + */ + public static final String DeletedOccurrences = "DeletedOccurrences"; + + /** + * The Constant MeetingTimeZone. + */ + public static final String MeetingTimeZone = "MeetingTimeZone"; + + /** + * The Constant ConferenceType. + */ + public static final String ConferenceType = "ConferenceType"; + + /** + * The Constant AllowNewTimeProposal. + */ + public static final String AllowNewTimeProposal = "AllowNewTimeProposal"; + + /** + * The Constant IsOnlineMeeting. + */ + public static final String IsOnlineMeeting = "IsOnlineMeeting"; + + /** + * The Constant MeetingWorkspaceUrl. + */ + public static final String MeetingWorkspaceUrl = "MeetingWorkspaceUrl"; + + /** + * The Constant NetShowUrl. + */ + public static final String NetShowUrl = "NetShowUrl"; + + /** + * The Constant CalendarItem. + */ + public static final String CalendarItem = "CalendarItem"; + + /** + * The Constant CalendarFolder. + */ + public static final String CalendarFolder = "CalendarFolder"; + + /** + * The Constant Attendee. + */ + public static final String Attendee = "Attendee"; + + /** + * The Constant ResponseType. + */ + public static final String ResponseType = "ResponseType"; + + /** + * The Constant LastResponseTime. + */ + public static final String LastResponseTime = "LastResponseTime"; + + /** + * The Constant Occurrence. + */ + public static final String Occurrence = "Occurrence"; + + /** + * The Constant DeletedOccurrence. + */ + public static final String DeletedOccurrence = "DeletedOccurrence"; + + /** + * The Constant RelativeYearlyRecurrence. + */ + public static final String RelativeYearlyRecurrence = + "RelativeYearlyRecurrence"; + + /** + * The Constant AbsoluteYearlyRecurrence. + */ + public static final String AbsoluteYearlyRecurrence = + "AbsoluteYearlyRecurrence"; + + /** + * The Constant RelativeMonthlyRecurrence. + */ + public static final String RelativeMonthlyRecurrence = + "RelativeMonthlyRecurrence"; + + /** + * The Constant AbsoluteMonthlyRecurrence. + */ + public static final String AbsoluteMonthlyRecurrence = + "AbsoluteMonthlyRecurrence"; + + /** + * The Constant WeeklyRecurrence. + */ + public static final String WeeklyRecurrence = "WeeklyRecurrence"; + + /** + * The Constant DailyRecurrence. + */ + public static final String DailyRecurrence = "DailyRecurrence"; + + /** + * The Constant DailyRegeneration. + */ + public static final String DailyRegeneration = "DailyRegeneration"; + + /** + * The Constant WeeklyRegeneration. + */ + public static final String WeeklyRegeneration = "WeeklyRegeneration"; + + /** + * The Constant MonthlyRegeneration. + */ + public static final String MonthlyRegeneration = "MonthlyRegeneration"; + + /** + * The Constant YearlyRegeneration. + */ + public static final String YearlyRegeneration = "YearlyRegeneration"; + + /** + * The Constant NoEndRecurrence. + */ + public static final String NoEndRecurrence = "NoEndRecurrence"; + + /** + * The Constant EndDateRecurrence. + */ + public static final String EndDateRecurrence = "EndDateRecurrence"; + + /** + * The Constant NumberedRecurrence. + */ + public static final String NumberedRecurrence = "NumberedRecurrence"; + + /** + * The Constant Interval. + */ + public static final String Interval = "Interval"; + + /** + * The Constant DayOfMonth. + */ + public static final String DayOfMonth = "DayOfMonth"; + + /** + * The Constant DayOfWeek. + */ + public static final String DayOfWeek = "DayOfWeek"; + + /** + * The Constant DaysOfWeek. + */ + public static final String DaysOfWeek = "DaysOfWeek"; + + /** + * The Constant DayOfWeekIndex. + */ + public static final String DayOfWeekIndex = "DayOfWeekIndex"; + + /** + * The Constant Month. + */ + public static final String Month = "Month"; + + /** + * The Constant StartDate. + */ + public static final String StartDate = "StartDate"; + + /** + * The Constant EndDate. + */ + public static final String EndDate = "EndDate"; + + /** + * The Constant StartTime. + */ + public static final String StartTime = "StartTime"; + + /** + * The Constant EndTime. + */ + public static final String EndTime = "EndTime"; + + /** + * The Constant NumberOfOccurrences. + */ + public static final String NumberOfOccurrences = "NumberOfOccurrences"; + + /** + * The Constant AssociatedCalendarItemId. + */ + public static final String AssociatedCalendarItemId = + "AssociatedCalendarItemId"; + + /** + * The Constant IsDelegated. + */ + public static final String IsDelegated = "IsDelegated"; + + /** + * The Constant IsOutOfDate. + */ + public static final String IsOutOfDate = "IsOutOfDate"; + + /** + * The Constant HasBeenProcessed. + */ + public static final String HasBeenProcessed = "HasBeenProcessed"; + + /** + * The Constant MeetingMessage. + */ + public static final String MeetingMessage = "MeetingMessage"; + + /** + * The Constant FileAs. + */ + public static final String FileAs = "FileAs"; + + /** + * The Constant FileAsMapping. + */ + public static final String FileAsMapping = "FileAsMapping"; + + /** + * The Constant GivenName. + */ + public static final String GivenName = "GivenName"; + + /** + * The Constant Initials. + */ + public static final String Initials = "Initials"; + + /** + * The Constant MiddleName. + */ + public static final String MiddleName = "MiddleName"; + + /** + * The Constant NickName. + */ + public static final String NickName = "Nickname"; + + /** + * The Constant CompleteName. + */ + public static final String CompleteName = "CompleteName"; + + /** + * The Constant CompanyName. + */ + public static final String CompanyName = "CompanyName"; + + /** + * The Constant EmailAddresses. + */ + public static final String EmailAddresses = "EmailAddresses"; + + /** + * The Constant PhysicalAddresses. + */ + public static final String PhysicalAddresses = "PhysicalAddresses"; + + /** + * The Constant PhoneNumbers. + */ + public static final String PhoneNumbers = "PhoneNumbers"; + + /** + * The Constant PhoneNumber. + */ + public static final String PhoneNumber = "PhoneNumber"; + + /** + * The Constant AssistantName. + */ + public static final String AssistantName = "AssistantName"; + + /** + * The Constant Birthday. + */ + public static final String Birthday = "Birthday"; + + /** + * The Constant BusinessHomePage. + */ + public static final String BusinessHomePage = "BusinessHomePage"; + + /** + * The Constant Children. + */ + public static final String Children = "Children"; + + /** + * The Constant Companies. + */ + public static final String Companies = "Companies"; + + /** + * The Constant ContactSource. + */ + public static final String ContactSource = "ContactSource"; + + /** + * The Constant Department. + */ + public static final String Department = "Department"; + + /** + * The Constant Generation. + */ + public static final String Generation = "Generation"; + + /** + * The Constant ImAddresses. + */ + public static final String ImAddresses = "ImAddresses"; + + /** + * The Constant ImAddress. + */ + public static final String ImAddress = "ImAddress"; + + /** + * The Constant JobTitle. + */ + public static final String JobTitle = "JobTitle"; + + /** + * The Constant Manager. + */ + public static final String Manager = "Manager"; + + /** + * The Constant Mileage. + */ + public static final String Mileage = "Mileage"; + + /** + * The Constant OfficeLocation. + */ + public static final String OfficeLocation = "OfficeLocation"; + + /** + * The Constant PostalAddressIndex. + */ + public static final String PostalAddressIndex = "PostalAddressIndex"; + + /** + * The Constant Profession. + */ + public static final String Profession = "Profession"; + + /** + * The Constant SpouseName. + */ + public static final String SpouseName = "SpouseName"; + + /** + * The Constant Surname. + */ + public static final String Surname = "Surname"; + + /** + * The Constant WeddingAnniversary. + */ + public static final String WeddingAnniversary = "WeddingAnniversary"; + + /** + * The Constant HasPicture. + */ + public static final String HasPicture = "HasPicture"; + + /** + * The Constant Title. + */ + public static final String Title = "Title"; + + /** + * The Constant FirstName. + */ + public static final String FirstName = "FirstName"; + + /** + * The Constant LastName. + */ + public static final String LastName = "LastName"; + + /** + * The Constant Suffix. + */ + public static final String Suffix = "Suffix"; + + /** + * The Constant FullName. + */ + public static final String FullName = "FullName"; + + /** + * The Constant YomiFirstName. + */ + public static final String YomiFirstName = "YomiFirstName"; + + /** + * The Constant YomiLastName. + */ + public static final String YomiLastName = "YomiLastName"; + + /** + * The Constant Contact. + */ + public static final String Contact = "Contact"; + + /** + * The Constant Entry. + */ + public static final String Entry = "Entry"; + + /** + * The Constant Street. + */ + public static final String Street = "Street"; + + /** + * The Constant City. + */ + public static final String City = "City"; + + /** + * The Constant State. + */ + public static final String State = "State"; + + /** + * The Constant CountryOrRegion. + */ + public static final String CountryOrRegion = "CountryOrRegion"; + + /** + * The Constant PostalCode. + */ + public static final String PostalCode = "PostalCode"; + + /** + * The Constant Members. + */ + public static final String Members = "Members"; + + /** + * The Constant Member. + */ + public static final String Member = "Member"; + + /** + * The Constant AdditionalProperties. + */ + public static final String AdditionalProperties = "AdditionalProperties"; + + /** + * The Constant ExtendedFieldURI. + */ + public static final String ExtendedFieldURI = "ExtendedFieldURI"; + + /** + * The Constant Value. + */ + public static final String Value = "Value"; + + /** + * The Constant Values. + */ + public static final String Values = "Values"; + + /** + * The Constant ToFolderId. + */ + public static final String ToFolderId = "ToFolderId"; + + /** + * The Constant ActualWork. + */ + public static final String ActualWork = "ActualWork"; + + /** + * The Constant AssignedTime. + */ + public static final String AssignedTime = "AssignedTime"; + + /** + * The Constant BillingInformation. + */ + public static final String BillingInformation = "BillingInformation"; + + /** + * The Constant ChangeCount. + */ + public static final String ChangeCount = "ChangeCount"; + + /** + * The Constant CompleteDate. + */ + public static final String CompleteDate = "CompleteDate"; + + /** + * The Constant Contacts. + */ + public static final String Contacts = "Contacts"; + + /** + * The Constant DelegationState. + */ + public static final String DelegationState = "DelegationState"; + + /** + * The Constant Delegator. + */ + public static final String Delegator = "Delegator"; + + /** + * The Constant DueDate. + */ + public static final String DueDate = "DueDate"; + + /** + * The Constant IsAssignmentEditable. + */ + public static final String IsAssignmentEditable = "IsAssignmentEditable"; + + /** + * The Constant IsComplete. + */ + public static final String IsComplete = "IsComplete"; + + /** + * The Constant IsTeamTask. + */ + public static final String IsTeamTask = "IsTeamTask"; + + /** + * The Constant Owner. + */ + public static final String Owner = "Owner"; + + /** + * The Constant PercentComplete. + */ + public static final String PercentComplete = "PercentComplete"; + + /** + * The Constant Status. + */ + public static final String Status = "Status"; + + /** + * The Constant StatusDescription. + */ + public static final String StatusDescription = "StatusDescription"; + + /** + * The Constant TotalWork. + */ + public static final String TotalWork = "TotalWork"; + + /** + * The Constant Task. + */ + public static final String Task = "Task"; + + /** + * The Constant MailboxCulture. + */ + public static final String MailboxCulture = "MailboxCulture"; + + /** + * The Constant MeetingRequestType. + */ + public static final String MeetingRequestType = "MeetingRequestType"; + + /** + * The Constant IntendedFreeBusyStatus. + */ + public static final String IntendedFreeBusyStatus = "IntendedFreeBusyStatus"; + + /** + * The Constant MeetingRequest. + */ + public static final String MeetingRequest = "MeetingRequest"; + + /** + * The Constant MeetingResponse. + */ + public static final String MeetingResponse = "MeetingResponse"; + + /** + * The Constant MeetingCancellation. + */ + public static final String MeetingCancellation = "MeetingCancellation"; + + /** + * The Constant BaseOffset. + */ + public static final String BaseOffset = "BaseOffset"; + + /** + * The Constant Offset. + */ + public static final String Offset = "Offset"; + + /** + * The Constant Standard. + */ + public static final String Standard = "Standard"; + + /** + * The Constant Daylight. + */ + public static final String Daylight = "Daylight"; + + /** + * The Constant Time. + */ + public static final String Time = "Time"; + + /** + * The Constant AbsoluteDate. + */ + public static final String AbsoluteDate = "AbsoluteDate"; + + /** + * The Constant UnresolvedEntry. + */ + public static final String UnresolvedEntry = "UnresolvedEntry"; + + /** + * The Constant ResolutionSet. + */ + public static final String ResolutionSet = "ResolutionSet"; + + /** + * The Constant Resolution. + */ + public static final String Resolution = "Resolution"; + + /** + * The Constant DistributionList. + */ + public static final String DistributionList = "DistributionList"; + + /** + * The Constant DLExpansion. + */ + public static final String DLExpansion = "DLExpansion"; + + /** + * The Constant IndexedFieldURI. + */ + public static final String IndexedFieldURI = "IndexedFieldURI"; + + /** + * The Constant PullSubscriptionRequest. + */ + public static final String PullSubscriptionRequest = + "PullSubscriptionRequest"; + + /** + * The Constant PushSubscriptionRequest. + */ + public static final String PushSubscriptionRequest = + "PushSubscriptionRequest"; + + /** + * The Constant StreamingSubscriptionRequest. + */ + public static final String StreamingSubscriptionRequest = + "StreamingSubscriptionRequest"; + /** + * The Constant EventTypes. + */ + public static final String EventTypes = "EventTypes"; + + /** + * The Constant EventType. + */ + public static final String EventType = "EventType"; + + /** + * The Constant Timeout. + */ + public static final String Timeout = "Timeout"; + + /** + * The Constant Watermark. + */ + public static final String Watermark = "Watermark"; + + /** + * The Constant SubscriptionId. + */ + public static final String SubscriptionId = "SubscriptionId"; + + /** + * The Constant SubscriptionId. + */ + public static final String SubscriptionIds = "SubscriptionIds"; + + /** + * The Constant StatusFrequency. + */ + public static final String StatusFrequency = "StatusFrequency"; + + /** + * The Constant URL. + */ + public static final String URL = "URL"; + + /** + * The Constant Notification. + */ + public static final String Notification = "Notification"; + + /** + * The Constant Notifications. + */ + public static final String Notifications = "Notifications"; + + /** + * The Constant PreviousWatermark. + */ + public static final String PreviousWatermark = "PreviousWatermark"; + + /** + * The Constant MoreEvents. + */ + public static final String MoreEvents = "MoreEvents"; + + /** + * The Constant TimeStamp. + */ + public static final String TimeStamp = "TimeStamp"; + + /** + * The Constant UnreadCount. + */ + public static final String UnreadCount = "UnreadCount"; + + /** + * The Constant OldParentFolderId. + */ + public static final String OldParentFolderId = "OldParentFolderId"; + + /** + * The Constant CopiedEvent. + */ + public static final String CopiedEvent = "CopiedEvent"; + + /** + * The Constant CreatedEvent. + */ + public static final String CreatedEvent = "CreatedEvent"; + + /** + * The Constant DeletedEvent. + */ + public static final String DeletedEvent = "DeletedEvent"; + + /** + * The Constant ModifiedEvent. + */ + public static final String ModifiedEvent = "ModifiedEvent"; + + /** + * The Constant MovedEvent. + */ + public static final String MovedEvent = "MovedEvent"; + + /** + * The Constant NewMailEvent. + */ + public static final String NewMailEvent = "NewMailEvent"; + + /** + * The Constant StatusEvent. + */ + public static final String StatusEvent = "StatusEvent"; + + /** + * The Constant FreeBusyChangedEvent. + */ + public static final String FreeBusyChangedEvent = "FreeBusyChangedEvent"; + + /** + * The Constant ExchangeImpersonation. + */ + public static final String ExchangeImpersonation = "ExchangeImpersonation"; + + /** + * The Constant ConnectingSID. + */ + public static final String ConnectingSID = "ConnectingSID"; + + /** + * The Constant SyncFolderId. + */ + public static final String SyncFolderId = "SyncFolderId"; + + /** + * The Constant SyncScope. + */ + public static final String SyncScope = "SyncScope"; + + /** + * The Constant SyncState. + */ + public static final String SyncState = "SyncState"; + + /** + * The Constant Ignore. + */ + public static final String Ignore = "Ignore"; + + /** + * The Constant MaxChangesReturned. + */ + public static final String MaxChangesReturned = "MaxChangesReturned"; + + /** + * The Constant Changes. + */ + public static final String Changes = "Changes"; + + /** + * The Constant IncludesLastItemInRange. + */ + public static final String IncludesLastItemInRange = + "IncludesLastItemInRange"; + + /** + * The Constant IncludesLastFolderInRange. + */ + public static final String IncludesLastFolderInRange = + "IncludesLastFolderInRange"; + + /** + * The Constant Create. + */ + public static final String Create = "Create"; + + /** + * The Constant Update. + */ + public static final String Update = "Update"; + + /** + * The Constant Delete. + */ + public static final String Delete = "Delete"; + + /** + * The Constant ReadFlagChange. + */ + public static final String ReadFlagChange = "ReadFlagChange"; + + /** + * The Constant SearchParameters. + */ + public static final String SearchParameters = "SearchParameters"; + + /** + * The Constant SoftDeleted. + */ + public static final String SoftDeleted = "SoftDeleted"; + + /** + * The Constant Shallow. + */ + public static final String Shallow = "Shallow"; + + /** + * The Constant Associated. + */ + public static final String Associated = "Associated"; + + /** + * The Constant BaseFolderIds. + */ + public static final String BaseFolderIds = "BaseFolderIds"; + + /** + * The Constant SortOrder. + */ + public static final String SortOrder = "SortOrder"; + + /** + * The Constant FieldOrder. + */ + public static final String FieldOrder = "FieldOrder"; + + /** + * The Constant CanDelete. + */ + public static final String CanDelete = "CanDelete"; + + /** + * The Constant CanRenameOrMove. + */ + public static final String CanRenameOrMove = "CanRenameOrMove"; + + /** + * The Constant MustDisplayComment. + */ + public static final String MustDisplayComment = "MustDisplayComment"; + + /** + * The Constant HasQuota. + */ + public static final String HasQuota = "HasQuota"; + + /** + * The Constant IsManagedFoldersRoot. + */ + public static final String IsManagedFoldersRoot = "IsManagedFoldersRoot"; + + /** + * The Constant ManagedFolderId. + */ + public static final String ManagedFolderId = "ManagedFolderId"; + + /** + * The Constant Comment. + */ + public static final String Comment = "Comment"; + + /** + * The Constant StorageQuota. + */ + public static final String StorageQuota = "StorageQuota"; + + /** + * The Constant FolderSize. + */ + public static final String FolderSize = "FolderSize"; + + /** + * The Constant HomePage. + */ + public static final String HomePage = "HomePage"; + + /** + * The Constant ManagedFolderInformation. + */ + public static final String ManagedFolderInformation = + "ManagedFolderInformation"; + + /** + * The Constant CalendarView. + */ + public static final String CalendarView = "CalendarView"; + + /** + * The Constant PostedTime. + */ + public static final String PostedTime = "PostedTime"; + + /** + * The Constant PostItem. + */ + public static final String PostItem = "PostItem"; + + /** + * The Constant RequestServerVersion. + */ + public static final String RequestServerVersion = "RequestServerVersion"; + + /** + * The Constant PostReplyItem. + */ + public static final String PostReplyItem = "PostReplyItem"; + + /** + * The Constant CreateAssociated. + */ + public static final String CreateAssociated = "CreateAssociated"; + + /** + * The Constant CreateContents. + */ + public static final String CreateContents = "CreateContents"; + + /** + * The Constant CreateHierarchy. + */ + public static final String CreateHierarchy = "CreateHierarchy"; + + /** + * The Constant Modify. + */ + public static final String Modify = "Modify"; + + /** + * The Constant Read. + */ + public static final String Read = "Read"; + + /** + * The Constant EffectiveRights. + */ + public static final String EffectiveRights = "EffectiveRights"; + + /** + * The Constant LastModifiedName. + */ + public static final String LastModifiedName = "LastModifiedName"; + + /** + * The Constant LastModifiedTime. + */ + public static final String LastModifiedTime = "LastModifiedTime"; + + /** + * The Constant ConversationId. + */ + public static final String ConversationId = "ConversationId"; + + /** + * The Constant UniqueBody. + */ + public static final String UniqueBody = "UniqueBody"; + + /** + * The Constant BodyType. + */ + public static final String BodyType = "BodyType"; + + /** + * The Constant AttachmentShape. + */ + public static final String AttachmentShape = "AttachmentShape"; + + /** + * The Constant UserId. + */ + public static final String UserId = "UserId"; + + /** + * The Constant UserIds. + */ + public static final String UserIds = "UserIds"; + + /** + * The Constant CanCreateItems. + */ + public static final String CanCreateItems = "CanCreateItems"; + + /** + * The Constant CanCreateSubFolders. + */ + public static final String CanCreateSubFolders = "CanCreateSubFolders"; + + /** + * The Constant IsFolderOwner. + */ + public static final String IsFolderOwner = "IsFolderOwner"; + + /** + * The Constant IsFolderVisible. + */ + public static final String IsFolderVisible = "IsFolderVisible"; + + /** + * The Constant IsFolderContact. + */ + public static final String IsFolderContact = "IsFolderContact"; + + /** + * The Constant EditItems. + */ + public static final String EditItems = "EditItems"; + + /** + * The Constant DeleteItems. + */ + public static final String DeleteItems = "DeleteItems"; + + /** + * The Constant ReadItems. + */ + public static final String ReadItems = "ReadItems"; + + /** + * The Constant PermissionLevel. + */ + public static final String PermissionLevel = "PermissionLevel"; + + /** + * The Constant CalendarPermissionLevel. + */ + public static final String CalendarPermissionLevel = + "CalendarPermissionLevel"; + + /** + * The Constant SID. + */ + public static final String SID = "SID"; + + /** + * The Constant PrimarySmtpAddress. + */ + public static final String PrimarySmtpAddress = "PrimarySmtpAddress"; + + /** + * The Constant DistinguishedUser. + */ + public static final String DistinguishedUser = "DistinguishedUser"; + + /** + * The Constant PermissionSet. + */ + public static final String PermissionSet = "PermissionSet"; + + /** + * The Constant Permissions. + */ + public static final String Permissions = "Permissions"; + + /** + * The Constant Permission. + */ + public static final String Permission = "Permission"; + + /** + * The Constant CalendarPermissions. + */ + public static final String CalendarPermissions = "CalendarPermissions"; + + /** + * The Constant CalendarPermission. + */ + public static final String CalendarPermission = "CalendarPermission"; + + /** + * The Constant GroupBy. + */ + public static final String GroupBy = "GroupBy"; + + /** + * The Constant AggregateOn. + */ + public static final String AggregateOn = "AggregateOn"; + + /** + * The Constant Groups. + */ + public static final String Groups = "Groups"; + + /** + * The Constant GroupedItems. + */ + public static final String GroupedItems = "GroupedItems"; + + /** + * The Constant GroupIndex. + */ + public static final String GroupIndex = "GroupIndex"; + + /** + * The Constant ConflictResults. + */ + public static final String ConflictResults = "ConflictResults"; + + /** + * The Constant Count. + */ + public static final String Count = "Count"; + + /** + * The Constant OofSettings. + */ + public static final String OofSettings = "OofSettings"; + + /** + * The Constant UserOofSettings. + */ + public static final String UserOofSettings = "UserOofSettings"; + + /** + * The Constant OofState. + */ + public static final String OofState = "OofState"; + + /** + * The Constant ExternalAudience. + */ + public static final String ExternalAudience = "ExternalAudience"; + + /** + * The Constant AllowExternalOof. + */ + public static final String AllowExternalOof = "AllowExternalOof"; + + /** + * The Constant InternalReply. + */ + public static final String InternalReply = "InternalReply"; + + /** + * The Constant ExternalReply. + */ + public static final String ExternalReply = "ExternalReply"; + + /** + * The Constant Bias. + */ + public static final String Bias = "Bias"; + + /** + * The Constant DayOrder. + */ + public static final String DayOrder = "DayOrder"; + + /** + * The Constant Year. + */ + public static final String Year = "Year"; + + /** + * The Constant StandardTime. + */ + public static final String StandardTime = "StandardTime"; + + /** + * The Constant DaylightTime. + */ + public static final String DaylightTime = "DaylightTime"; + + /** + * The Constant MailboxData. + */ + public static final String MailboxData = "MailboxData"; + + /** + * The Constant MailboxDataArray. + */ + public static final String MailboxDataArray = "MailboxDataArray"; + + /** + * The Constant Email. + */ + public static final String Email = "Email"; + + /** + * The Constant AttendeeType. + */ + public static final String AttendeeType = "AttendeeType"; + + /** + * The Constant ExcludeConflicts. + */ + public static final String ExcludeConflicts = "ExcludeConflicts"; + + /** + * The Constant FreeBusyViewOptions. + */ + public static final String FreeBusyViewOptions = "FreeBusyViewOptions"; + + /** + * The Constant SuggestionsViewOptions. + */ + public static final String SuggestionsViewOptions = "SuggestionsViewOptions"; + + /** + * The Constant FreeBusyView. + */ + public static final String FreeBusyView = "FreeBusyView"; + + /** + * The Constant TimeWindow. + */ + public static final String TimeWindow = "TimeWindow"; + + /** + * The Constant MergedFreeBusyIntervalInMinutes. + */ + public static final String MergedFreeBusyIntervalInMinutes = + "MergedFreeBusyIntervalInMinutes"; + + /** + * The Constant RequestedView. + */ + public static final String RequestedView = "RequestedView"; + + /** + * The Constant FreeBusyViewType. + */ + public static final String FreeBusyViewType = "FreeBusyViewType"; + + /** + * The Constant CalendarEventArray. + */ + public static final String CalendarEventArray = "CalendarEventArray"; + + /** + * The Constant CalendarEvent. + */ + public static final String CalendarEvent = "CalendarEvent"; + + /** + * The Constant BusyType. + */ + public static final String BusyType = "BusyType"; + + /** + * The Constant MergedFreeBusy. + */ + public static final String MergedFreeBusy = "MergedFreeBusy"; + + /** + * The Constant WorkingHours. + */ + public static final String WorkingHours = "WorkingHours"; + + /** + * The Constant WorkingPeriodArray. + */ + public static final String WorkingPeriodArray = "WorkingPeriodArray"; + + /** + * The Constant WorkingPeriod. + */ + public static final String WorkingPeriod = "WorkingPeriod"; + + /** + * The Constant StartTimeInMinutes. + */ + public static final String StartTimeInMinutes = "StartTimeInMinutes"; + + /** + * The Constant EndTimeInMinutes. + */ + public static final String EndTimeInMinutes = "EndTimeInMinutes"; + + /** + * The Constant GoodThreshold. + */ + public static final String GoodThreshold = "GoodThreshold"; + + /** + * The Constant MaximumResultsByDay. + */ + public static final String MaximumResultsByDay = "MaximumResultsByDay"; + + /** + * The Constant MaximumNonWorkHourResultsByDay. + */ + public static final String MaximumNonWorkHourResultsByDay = + "MaximumNonWorkHourResultsByDay"; + + /** + * The Constant MeetingDurationInMinutes. + */ + public static final String MeetingDurationInMinutes = + "MeetingDurationInMinutes"; + + /** + * The Constant MinimumSuggestionQuality. + */ + public static final String MinimumSuggestionQuality = + "MinimumSuggestionQuality"; + + /** + * The Constant DetailedSuggestionsWindow. + */ + public static final String DetailedSuggestionsWindow = + "DetailedSuggestionsWindow"; + + /** + * The Constant CurrentMeetingTime. + */ + public static final String CurrentMeetingTime = "CurrentMeetingTime"; + + /** + * The Constant GlobalObjectId. + */ + public static final String GlobalObjectId = "GlobalObjectId"; + + /** + * The Constant SuggestionDayResultArray. + */ + public static final String SuggestionDayResultArray = + "SuggestionDayResultArray"; + + /** + * The Constant SuggestionDayResult. + */ + public static final String SuggestionDayResult = "SuggestionDayResult"; + + /** + * The Constant Date. + */ + public static final String Date = "Date"; + + /** + * The Constant DayQuality. + */ + public static final String DayQuality = "DayQuality"; + + /** + * The Constant SuggestionArray. + */ + public static final String SuggestionArray = "SuggestionArray"; + + /** + * The Constant Suggestion. + */ + public static final String Suggestion = "Suggestion"; + + /** + * The Constant MeetingTime. + */ + public static final String MeetingTime = "MeetingTime"; + + /** + * The Constant IsWorkTime. + */ + public static final String IsWorkTime = "IsWorkTime"; + + /** + * The Constant SuggestionQuality. + */ + public static final String SuggestionQuality = "SuggestionQuality"; + + /** + * The Constant AttendeeConflictDataArray. + */ + public static final String AttendeeConflictDataArray = + "AttendeeConflictDataArray"; + + /** + * The Constant UnknownAttendeeConflictData. + */ + public static final String UnknownAttendeeConflictData = + "UnknownAttendeeConflictData"; + + /** + * The Constant TooBigGroupAttendeeConflictData. + */ + public static final String TooBigGroupAttendeeConflictData = + "TooBigGroupAttendeeConflictData"; + + /** + * The Constant IndividualAttendeeConflictData. + */ + public static final String IndividualAttendeeConflictData = + "IndividualAttendeeConflictData"; + + /** + * The Constant GroupAttendeeConflictData. + */ + public static final String GroupAttendeeConflictData = + "GroupAttendeeConflictData"; + + /** + * The Constant NumberOfMembers. + */ + public static final String NumberOfMembers = "NumberOfMembers"; + + /** + * The Constant NumberOfMembersAvailable. + */ + public static final String NumberOfMembersAvailable = + "NumberOfMembersAvailable"; + + /** + * The Constant NumberOfMembersWithConflict. + */ + public static final String NumberOfMembersWithConflict = + "NumberOfMembersWithConflict"; + + /** + * The Constant NumberOfMembersWithNoData. + */ + public static final String NumberOfMembersWithNoData = + "NumberOfMembersWithNoData"; + + /** + * The Constant SourceIds. + */ + public static final String SourceIds = "SourceIds"; + + /** + * The Constant AlternateId. + */ + public static final String AlternateId = "AlternateId"; + + /** + * The Constant AlternatePublicFolderId. + */ + public static final String AlternatePublicFolderId = + "AlternatePublicFolderId"; + + /** + * The Constant AlternatePublicFolderItemId. + */ + public static final String AlternatePublicFolderItemId = + "AlternatePublicFolderItemId"; + + /** + * The Constant DelegatePermissions. + */ + public static final String DelegatePermissions = "DelegatePermissions"; + + /** + * The Constant ReceiveCopiesOfMeetingMessages. + */ + public static final String ReceiveCopiesOfMeetingMessages = + "ReceiveCopiesOfMeetingMessages"; + + /** + * The Constant ViewPrivateItems. + */ + public static final String ViewPrivateItems = "ViewPrivateItems"; + + /** + * The Constant CalendarFolderPermissionLevel. + */ + public static final String CalendarFolderPermissionLevel = + "CalendarFolderPermissionLevel"; + + /** + * The Constant TasksFolderPermissionLevel. + */ + public static final String TasksFolderPermissionLevel = + "TasksFolderPermissionLevel"; + + /** + * The Constant InboxFolderPermissionLevel. + */ + public static final String InboxFolderPermissionLevel = + "InboxFolderPermissionLevel"; + + /** + * The Constant ContactsFolderPermissionLevel. + */ + public static final String ContactsFolderPermissionLevel = + "ContactsFolderPermissionLevel"; + + /** + * The Constant NotesFolderPermissionLevel. + */ + public static final String NotesFolderPermissionLevel = + "NotesFolderPermissionLevel"; + + /** + * The Constant JournalFolderPermissionLevel. + */ + public static final String JournalFolderPermissionLevel = + "JournalFolderPermissionLevel"; + + /** + * The Constant DelegateUser. + */ + public static final String DelegateUser = "DelegateUser"; + + /** + * The Constant DelegateUsers. + */ + public static final String DelegateUsers = "DelegateUsers"; + + /** + * The Constant DeliverMeetingRequests. + */ + public static final String DeliverMeetingRequests = "DeliverMeetingRequests"; + + /** + * The Constant MessageXml. + */ + public static final String MessageXml = "MessageXml"; + + /** + * The Constant UserConfiguration. + */ + public static final String UserConfiguration = "UserConfiguration"; + + /** + * The Constant UserConfigurationName. + */ + public static final String UserConfigurationName = "UserConfigurationName"; + + /** + * The Constant UserConfigurationProperties. + */ + public static final String UserConfigurationProperties = + "UserConfigurationProperties"; + + /** + * The Constant Dictionary. + */ + public static final String Dictionary = "Dictionary"; + + /** + * The Constant DictionaryEntry. + */ + public static final String DictionaryEntry = "DictionaryEntry"; + + /** + * The Constant DictionaryKey. + */ + public static final String DictionaryKey = "DictionaryKey"; + + /** + * The Constant DictionaryValue. + */ + public static final String DictionaryValue = "DictionaryValue"; + + /** + * The Constant XmlData. + */ + public static final String XmlData = "XmlData"; + + /** + * The Constant BinaryData. + */ + public static final String BinaryData = "BinaryData"; + + /** + * The Constant FilterHtmlContent. + */ + public static final String FilterHtmlContent = "FilterHtmlContent"; + + /** + * The Constant ConvertHtmlCodePageToUTF8. + */ + public static final String ConvertHtmlCodePageToUTF8 = + "ConvertHtmlCodePageToUTF8"; + + /** + * The Constant UnknownEntries. + */ + public static final String UnknownEntries = "UnknownEntries"; + + /** + * The Constant UnknownEntry. + */ + public static final String UnknownEntry = "UnknownEntry"; + + /** + * The Constant PhoneCallId. + */ + public static final String PhoneCallId = "PhoneCallId"; + + /** + * The Constant DialString. + */ + public static final String DialString = "DialString"; + + /** + * The Constant PhoneCallInformation. + */ + public static final String PhoneCallInformation = "PhoneCallInformation"; + + /** + * The Constant PhoneCallState. + */ + public static final String PhoneCallState = "PhoneCallState"; + + /** + * The Constant ConnectionFailureCause. + */ + public static final String ConnectionFailureCause = "ConnectionFailureCause"; + + /** + * The Constant SIPResponseCode. + */ + public static final String SIPResponseCode = "SIPResponseCode"; + + /** + * The Constant SIPResponseText. + */ + public static final String SIPResponseText = "SIPResponseText"; + + /** + * The Constant WebClientReadFormQueryString. + */ + public static final String WebClientReadFormQueryString = + "WebClientReadFormQueryString"; + + /** + * The Constant WebClientEditFormQueryString. + */ + public static final String WebClientEditFormQueryString = + "WebClientEditFormQueryString"; + + /** + * The Constant Ids. + */ + public static final String Ids = "Ids"; + + /** + * The Constant Id. + */ + public static final String Id = "Id"; + + /** + * The Constant TimeZoneDefinitions. + */ + public static final String TimeZoneDefinitions = "TimeZoneDefinitions"; + + /** + * The Constant TimeZoneDefinition. + */ + public static final String TimeZoneDefinition = "TimeZoneDefinition"; + + /** + * The Constant Periods. + */ + public static final String Periods = "Periods"; + + /** + * The Constant Period. + */ + public static final String Period = "Period"; + + /** + * The Constant TransitionsGroups. + */ + public static final String TransitionsGroups = "TransitionsGroups"; + + /** + * The Constant TransitionsGroup. + */ + public static final String TransitionsGroup = "TransitionsGroup"; + + /** + * The Constant Transitions. + */ + public static final String Transitions = "Transitions"; + + /** + * The Constant Transition. + */ + public static final String Transition = "Transition"; + + /** + * The Constant AbsoluteDateTransition. + */ + public static final String AbsoluteDateTransition = "AbsoluteDateTransition"; + + /** + * The Constant RecurringDayTransition. + */ + public static final String RecurringDayTransition = "RecurringDayTransition"; + + /** + * The Constant RecurringDateTransition. + */ + public static final String RecurringDateTransition = + "RecurringDateTransition"; + + /** + * The Constant DateTime. + */ + public static final String DateTime = "DateTime"; + + /** + * The Constant TimeOffset. + */ + public static final String TimeOffset = "TimeOffset"; + + /** + * The Constant Day. + */ + public static final String Day = "Day"; + + /** + * The Constant TimeZoneContext. + */ + public static final String TimeZoneContext = "TimeZoneContext"; + + /** + * The Constant StartTimeZone. + */ + public static final String StartTimeZone = "StartTimeZone"; + + /** + * The Constant EndTimeZone. + */ + public static final String EndTimeZone = "EndTimeZone"; + + /** + * The Constant ReceivedBy. + */ + public static final String ReceivedBy = "ReceivedBy"; + + /** + * The Constant ReceivedRepresenting. + */ + public static final String ReceivedRepresenting = "ReceivedRepresenting"; + + /** + * The Constant Uid. + */ + public static final String Uid = "UID"; + + /** + * The Constant RecurrenceId. + */ + public static final String RecurrenceId = "RecurrenceId"; + + /** + * The Constant DateTimeStamp. + */ + public static final String DateTimeStamp = "DateTimeStamp"; + + /** + * The Constant IsInline. + */ + public static final String IsInline = "IsInline"; + + /** + * The Constant IsContactPhoto. + */ + public static final String IsContactPhoto = "IsContactPhoto"; + + /** + * The Constant QueryString. + */ + public static final String QueryString = "QueryString"; + + /** + * The Constant CalendarEventDetails. + */ + public static final String CalendarEventDetails = "CalendarEventDetails"; + + /** + * The Constant ID. + */ + public static final String ID = "ID"; + + /** + * The Constant IsException. + */ + public static final String IsException = "IsException"; + + /** + * The Constant IsReminderSet. + */ + public static final String IsReminderSet = "IsReminderSet"; + + /** + * The Constant IsPrivate. + */ + public static final String IsPrivate = "IsPrivate"; + + /** + * The Constant FirstDayOfWeek. + */ + public static final String FirstDayOfWeek = "FirstDayOfWeek"; + + /** + * The Constant Verb. + */ + public static final String Verb = "Verb"; + + /** + * The Constant Parameter. + */ + public static final String Parameter = "Parameter"; + + /** + * The Constant ReturnValue. + */ + public static final String ReturnValue = "ReturnValue"; + + /** + * The Constant ReturnNewItemIds. + */ + public static final String ReturnNewItemIds = "ReturnNewItemIds"; + + /** + * The Constant DateTimePrecision. + */ + public static final String DateTimePrecision = "DateTimePrecision"; + + /** + * The Constant PasswordExpirationDate. + */ + public static final String PasswordExpirationDate = "PasswordExpirationDate"; + + /** + * The Constant StoreEntryId. + */ + public static final String StoreEntryId = "StoreEntryId"; + + // Conversations + /** + * The Constant Conversations. + */ + public static final String Conversations = "Conversations"; + + /** + * The Constant Conversation. + */ + public static final String Conversation = "Conversation"; + + /** + * The Constant UniqueRecipients. + */ + public static final String UniqueRecipients = "UniqueRecipients"; + + /** + * The Constant GlobalUniqueRecipients. + */ + public static final String GlobalUniqueRecipients = "GlobalUniqueRecipients"; + + /** + * The Constant UniqueUnreadSenders. + */ + public static final String UniqueUnreadSenders = "UniqueUnreadSenders"; + + /** + * The Constant GlobalUniqueUnreadSenders. + */ + public static final String GlobalUniqueUnreadSenders = + "GlobalUniqueUnreadSenders"; + + /** + * The Constant UniqueSenders. + */ + public static final String UniqueSenders = "UniqueSenders"; + + /** + * The Constant GlobalUniqueSenders. + */ + public static final String GlobalUniqueSenders = "GlobalUniqueSenders"; + + /** + * The Constant LastDeliveryTime. + */ + public static final String LastDeliveryTime = "LastDeliveryTime"; + + /** + * The Constant GlobalLastDeliveryTime. + */ + public static final String GlobalLastDeliveryTime = "GlobalLastDeliveryTime"; + + /** + * The Constant GlobalCategories. + */ + public static final String GlobalCategories = "GlobalCategories"; + + /** + * The Constant FlagStatus. + */ + public static final String FlagStatus = "FlagStatus"; + + /** + * The Constant GlobalFlagStatus. + */ + public static final String GlobalFlagStatus = "GlobalFlagStatus"; + + /** + * The Constant GlobalHasAttachments. + */ + public static final String GlobalHasAttachments = "GlobalHasAttachments"; + + /** + * The Constant MessageCount. + */ + public static final String MessageCount = "MessageCount"; + + /** + * The Constant GlobalMessageCount. + */ + public static final String GlobalMessageCount = "GlobalMessageCount"; + + /** + * The Constant GlobalUnreadCount. + */ + public static final String GlobalUnreadCount = "GlobalUnreadCount"; + + /** + * The Constant GlobalSize. + */ + public static final String GlobalSize = "GlobalSize"; + + /** + * The Constant ItemClasses. + */ + public static final String ItemClasses = "ItemClasses"; + + /** + * The Constant GlobalItemClasses. + */ + public static final String GlobalItemClasses = "GlobalItemClasses"; + + /** + * The Constant GlobalImportance. + */ + public static final String GlobalImportance = "GlobalImportance"; + + /** + * The Constant GlobalItemIds. + */ + public static final String GlobalItemIds = "GlobalItemIds"; + + // ApplyConversationAction + + /** + * The Constant ApplyConversationAction. + */ + public static final String ApplyConversationAction = + "ApplyConversationAction"; + + /** + * The Constant ConversationActions. + */ + public static final String ConversationActions = "ConversationActions"; + + /** + * The Constant ConversationAction. + */ + public static final String ConversationAction = "ConversationAction"; + + /** + * The Constant ApplyConversationActionResponse. + */ + public static final String ApplyConversationActionResponse = + "ApplyConversationActionResponse"; + + /** + * The Constant ApplyConversationActionResponseMessage. + */ + public static final String ApplyConversationActionResponseMessage = + "ApplyConversationActionResponseMessage"; + + /** + * The Constant EnableAlwaysDelete. + */ + public static final String EnableAlwaysDelete = "EnableAlwaysDelete"; + + /** + * The Constant ProcessRightAway. + */ + public static final String ProcessRightAway = "ProcessRightAway"; + + /** + * The Constant DestinationFolderId. + */ + public static final String DestinationFolderId = "DestinationFolderId"; + + /** + * The Constant ContextFolderId. + */ + public static final String ContextFolderId = "ContextFolderId"; + + /** + * The Constant ConversationLastSyncTime. + */ + public static final String ConversationLastSyncTime = + "ConversationLastSyncTime"; + + /** + * The Constant AlwaysCategorize. + */ + public static final String AlwaysCategorize = "AlwaysCategorize"; + + /** + * The Constant AlwaysDelete. + */ + public static final String AlwaysDelete = "AlwaysDelete"; + + /** + * The Constant AlwaysMove. + */ + public static final String AlwaysMove = "AlwaysMove"; + + /** + * The Constant Move. + */ + public static final String Move = "Move"; + + /** + * The Constant Copy. + */ + public static final String Copy = "Copy"; + + /** + * The Constant SetReadState. + */ + public static final String SetReadState = "SetReadState"; + + /** + * The Constant DeleteType. + */ + public static final String DeleteType = "DeleteType"; + // RoomList & Room + + /** + * The Constant RoomLists. + */ + public static final String RoomLists = "RoomLists"; + + /** + * The Constant Rooms. + */ + public static final String Rooms = "Rooms"; + + /** + * The Constant Room. + */ + public static final String Room = "Room"; + + /** + * The Constant RoomList. + */ + public static final String RoomList = "RoomList"; + + /** + * The Constant RoomId. + */ + public static final String RoomId = "Id"; + + // Autodiscover + + /** + * The Constant Autodiscover. + */ + public static final String Autodiscover = "Autodiscover"; + + /** + * The Constant BinarySecret. + */ + public static final String BinarySecret = "BinarySecret"; + + /** + * The Constant Response. + */ + public static final String Response = "Response"; + + /** + * The Constant User. + */ + public static final String User = "User"; + + /** + * The Constant LegacyDN. + */ + public static final String LegacyDN = "LegacyDN"; + + /** + * The Constant DeploymentId. + */ + public static final String DeploymentId = "DeploymentId"; + + /** + * The Constant Account. + */ + public static final String Account = "Account"; + + /** + * The Constant AccountType. + */ + public static final String AccountType = "AccountType"; + + /** + * The Constant Action. + */ + public static final String Action = "Action"; + + /** + * The Constant To. + */ + public static final String To = "To"; + + /** + * The Constant RedirectAddr. + */ + public static final String RedirectAddr = "RedirectAddr"; + + /** + * The Constant RedirectUrl. + */ + public static final String RedirectUrl = "RedirectUrl"; + + /** + * The Constant Protocol. + */ + public static final String Protocol = "Protocol"; + + /** + * The Constant Type. + */ + public static final String Type = "Type"; + + /** + * The Constant Server. + */ + public static final String Server = "Server"; + + /** + * The Constant ServerDN. + */ + public static final String ServerDN = "ServerDN"; + + /** + * The Constant ServerVersion. + */ + public static final String ServerVersion = "ServerVersion"; + + /** + * The Constant ServerVersionInfo. + */ + public static final String ServerVersionInfo = "ServerVersionInfo"; + + + /** + * The Constant SmtpAddress. + */ + public static final String SmtpAddress = "SmtpAddress"; + + /** + * The Constant OwnerSmtpAddress. + */ + public static final String OwnerSmtpAddress = "OwnerSmtpAddress"; + + /** + * The Constant AD. + */ + public static final String AD = "AD"; + + /** + * The Constant AuthPackage. + */ + public static final String AuthPackage = "AuthPackage"; + + /** + * The Constant MdbDN. + */ + public static final String MdbDN = "MdbDN"; + + /** + * The Constant EWSUrl. + */ + public static final String EWSUrl = "EWSUrl"; + + /** + * The Constant ASUrl. + */ + public static final String ASUrl = "ASUrl"; + + /** + * The Constant OOFUrl. + */ + public static final String OOFUrl = "OOFUrl"; + + /** + * The Constant UMUrl. + */ + public static final String UMUrl = "UMUrl"; + + /** + * The Constant OABUrl. + */ + public static final String OABUrl = "OABUrl"; + + /** + * The Constant Internal. + */ + public static final String Internal = "Internal"; + + /** + * The Constant External. + */ + public static final String External = "External"; + + /** + * The Constant OWAUrl. + */ + public static final String OWAUrl = "OWAUrl"; + + /** + * The Constant Error. + */ + public static final String Error = "Error"; + + /** + * The Constant ErrorCode. + */ + public static final String ErrorCode = "ErrorCode"; + + /** + * The Constant DebugData. + */ + public static final String DebugData = "DebugData"; + + /** + * The Constant Users. + */ + public static final String Users = "Users"; + + /** + * The Constant RequestedSettings. + */ + public static final String RequestedSettings = "RequestedSettings"; + + /** + * The Constant Setting. + */ + public static final String Setting = "Setting"; + + /** + * The Constant GetUserSettingsRequestMessage. + */ + public static final String GetUserSettingsRequestMessage = + "GetUserSettingsRequestMessage"; + + /** + * The Constant RequestedServerVersion. + */ + public static final String RequestedServerVersion = "RequestedServerVersion"; + + /** + * The Constant Request. + */ + public static final String Request = "Request"; + + /** + * The Constant RedirectTarget. + */ + public static final String RedirectTarget = "RedirectTarget"; + + /** + * The Constant UserSettings. + */ + public static final String UserSettings = "UserSettings"; + + /** + * The Constant UserSettingErrors. + */ + public static final String UserSettingErrors = "UserSettingErrors"; + + /** + * The Constant GetUserSettingsResponseMessage. + */ + public static final String GetUserSettingsResponseMessage = + "GetUserSettingsResponseMessage"; + + /** + * The Constant ErrorMessage. + */ + public static final String ErrorMessage = "ErrorMessage"; + + /** + * The Constant UserResponse. + */ + public static final String UserResponse = "UserResponse"; + + /** + * The Constant UserResponses. + */ + public static final String UserResponses = "UserResponses"; + + /** + * The Constant UserSettingError. + */ + public static final String UserSettingError = "UserSettingError"; + + /** + * The Constant Domain. + */ + public static final String Domain = "Domain"; + + /** + * The Constant Domains. + */ + public static final String Domains = "Domains"; + + /** + * The Constant DomainResponse. + */ + public static final String DomainResponse = "DomainResponse"; + + /** + * The Constant DomainResponses. + */ + public static final String DomainResponses = "DomainResponses"; + + /** + * The Constant DomainSetting. + */ + public static final String DomainSetting = "DomainSetting"; + + /** + * The Constant DomainSettings. + */ + public static final String DomainSettings = "DomainSettings"; + + /** + * The Constant DomainStringSetting. + */ + public static final String DomainStringSetting = "DomainStringSetting"; + + /** + * The Constant DomainSettingError. + */ + public static final String DomainSettingError = "DomainSettingError"; + + /** + * The Constant DomainSettingErrors. + */ + public static final String DomainSettingErrors = "DomainSettingErrors"; + + /** + * The Constant GetDomainSettingsRequestMessage. + */ + public static final String GetDomainSettingsRequestMessage = + "GetDomainSettingsRequestMessage"; + + /** + * The Constant GetDomainSettingsResponseMessage. + */ + public static final String GetDomainSettingsResponseMessage = + "GetDomainSettingsResponseMessage"; + + /** + * The Constant SettingName. + */ + public static final String SettingName = "SettingName"; + + /** + * The Constant UserSetting. + */ + public static final String UserSetting = "UserSetting"; + + /** + * The Constant StringSetting. + */ + public static final String StringSetting = "StringSetting"; + + /** + * The Constant WebClientUrlCollectionSetting. + */ + public static final String WebClientUrlCollectionSetting = + "WebClientUrlCollectionSetting"; + + /** + * The Constant WebClientUrls. + */ + public static final String WebClientUrls = "WebClientUrls"; + + /** + * The Constant WebClientUrl. + */ + public static final String WebClientUrl = "WebClientUrl"; + + /** + * The Constant AuthenticationMethods. + */ + public static final String AuthenticationMethods = "AuthenticationMethods"; + + /** + * The Constant Url. + */ + public static final String Url = "Url"; + + /** + * The Constant AlternateMailboxCollectionSetting. + */ + public static final String AlternateMailboxCollectionSetting = + "AlternateMailboxCollectionSetting"; + + /** + * The Constant AlternateMailboxes. + */ + public static final String AlternateMailboxes = "AlternateMailboxes"; + + /** + * The Constant AlternateMailbox. + */ + public static final String AlternateMailbox = "AlternateMailbox"; + + /** + * The Constant ProtocolConnectionCollectionSetting. + */ + public static final String ProtocolConnectionCollectionSetting = + "ProtocolConnectionCollectionSetting"; + + /** + * The Constant ProtocolConnections. + */ + public static final String ProtocolConnections = "ProtocolConnections"; + + /** + * The Constant ProtocolConnection. + */ + public static final String ProtocolConnection = "ProtocolConnection"; + + /** + * The Constant EncryptionMethod. + */ + public static final String EncryptionMethod = "EncryptionMethod"; + + /** + * The Constant Hostname. + */ + public static final String Hostname = "Hostname"; + + /** + * The Constant Port. + */ + public static final String Port = "Port"; + + /** + * The Constant Version. + */ + public static final String Version = "Version"; + + /** + * The Constant MajorVersion. + */ + public static final String MajorVersion = "MajorVersion"; + + /** + * The Constant MinorVersion. + */ + public static final String MinorVersion = "MinorVersion"; + + /** + * The Constant MajorBuildNumber. + */ + public static final String MajorBuildNumber = "MajorBuildNumber"; + + /** + * The Constant MinorBuildNumber. + */ + public static final String MinorBuildNumber = "MinorBuildNumber"; + + /** + * The Constant RequestedVersion. + */ + public static final String RequestedVersion = "RequestedVersion"; + + /** + * The Constant PublicFolderServer. + */ + public static final String PublicFolderServer = "PublicFolderServer"; + + /** + * The Constant Ssl. + */ + public static final String Ssl = "SSL"; + + /** + * The Constant SharingUrl. + */ + public static final String SharingUrl = "SharingUrl"; + + /** + * The Constant EcpUrl. + */ + public static final String EcpUrl = "EcpUrl"; + + /** + * The Constant EcpUrl_um. + */ + public static final String EcpUrl_um = "EcpUrl-um"; + + /** + * The Constant EcpUrl_aggr. + */ + public static final String EcpUrl_aggr = "EcpUrl-aggr"; + + /** + * The Constant EcpUrl_sms. + */ + public static final String EcpUrl_sms = "EcpUrl-sms"; + + /** + * The Constant EcpUrl_mt. + */ + public static final String EcpUrl_mt = "EcpUrl-mt"; + + /** + * The Constant EcpUrl_ret. + */ + public static final String EcpUrl_ret = "EcpUrl-ret"; + + /** + * The Constant EcpUrl_publish. + */ + public static final String EcpUrl_publish = "EcpUrl-publish"; + + /** + * The Constant ExchangeRpcUrl. + */ + public static final String ExchangeRpcUrl = "ExchangeRpcUrl"; + + /** + * The Constant PartnerToken. + */ + public static final String PartnerToken = "PartnerToken"; + + /** + * The Constant PartnerTokenReference. + */ + public static final String PartnerTokenReference = "PartnerTokenReference"; + + /** + * The Constant GroupingInformation. + */ + public static final String GroupingInformation = "GroupingInformation"; + + // InboxRule + /** + * The Constant MinorBuildNumber. + */ + public static final String MailboxSmtpAddress = "MailboxSmtpAddress"; + + /** + * The Constant RuleId. + */ + public static final String RuleId = "RuleId"; + + /** + * The Constant Priority. + */ + public static final String Priority = "Priority"; + + /** + * The Constant IsEnabled. + */ + public static final String IsEnabled = "IsEnabled"; + + /** + * The Constant IsNotSupported. + */ + public static final String IsNotSupported = "IsNotSupported"; + + /** + * The Constant IsInError. + */ + public static final String IsInError = "IsInError"; + + /** + * The Constant Conditions. + */ + public static final String Conditions = "Conditions"; + + /** + * The Constant Exceptions. + */ + public static final String Exceptions = "Exceptions"; + + /** + * The Constant Actions. + */ + public static final String Actions = "Actions"; + + /** + * The Constant InboxRules. + */ + public static final String InboxRules = "InboxRules"; + + /** + * The Constant Rule. + */ + public static final String Rule = "Rule"; + + /** + * The Constant OutlookRuleBlobExists. + */ + public static final String OutlookRuleBlobExists = "OutlookRuleBlobExists"; + + /** + * The Constant RemoveOutlookRuleBlob. + */ + public static final String RemoveOutlookRuleBlob = "RemoveOutlookRuleBlob"; + + /** + * The Constant ContainsBodyStrings. + */ + public static final String ContainsBodyStrings = "ContainsBodyStrings"; + + /** + * The Constant ContainsHeaderStrings. + */ + public static final String ContainsHeaderStrings = "ContainsHeaderStrings"; + + /** + * The Constant ContainsRecipientStrings. + */ + public static final String ContainsRecipientStrings = + "ContainsRecipientStrings"; + + /** + * The Constant ContainsSenderStrings. + */ + public static final String ContainsSenderStrings = "ContainsSenderStrings"; + + /** + * The Constant ContainsSubjectOrBodyStrings. + */ + public static final String ContainsSubjectOrBodyStrings = + "ContainsSubjectOrBodyStrings"; + + /** + * The Constant ContainsSubjectStrings. + */ + public static final String ContainsSubjectStrings = "ContainsSubjectStrings"; + + /** + * The Constant FlaggedForAction. + */ + public static final String FlaggedForAction = "FlaggedForAction"; + + /** + * The Constant FromAddresses. + */ + public static final String FromAddresses = "FromAddresses"; + + /** + * The Constant FromConnectedAccounts. + */ + public static final String FromConnectedAccounts = "FromConnectedAccounts"; + + /** + * The Constant IsApprovalRequest. + */ + public static final String IsApprovalRequest = "IsApprovalRequest"; + + /** + * The Constant IsAutomaticForward. + */ + public static final String IsAutomaticForward = "IsAutomaticForward"; + + /** + * The Constant IsAutomaticReply. + */ + public static final String IsAutomaticReply = "IsAutomaticReply"; + + /** + * The Constant IsEncrypted. + */ + public static final String IsEncrypted = "IsEncrypted"; + + /** + * The Constant IsMeetingRequest. + */ + public static final String IsMeetingRequest = "IsMeetingRequest"; + + /** + * The Constant IsMeetingResponse. + */ + public static final String IsMeetingResponse = "IsMeetingResponse"; + + /** + * The Constant IsNDR. + */ + public static final String IsNDR = "IsNDR"; + + /** + * The Constant IsPermissionControlled. + */ + public static final String IsPermissionControlled = "IsPermissionControlled"; + + /** + * The Constant IsSigned. + */ + public static final String IsSigned = "IsSigned"; + + /** + * The Constant IsVoicemail. + */ + public static final String IsVoicemail = "IsVoicemail"; + + /** + * The Constant IsReadReceipt. + */ + public static final String IsReadReceipt = "IsReadReceipt"; + + /** + * The Constant MessageClassifications. + */ + public static final String MessageClassifications = "MessageClassifications"; + + /** + * The Constant NotSentToMe. + */ + public static final String NotSentToMe = "NotSentToMe"; + + /** + * The Constant SentCcMe. + */ + public static final String SentCcMe = "SentCcMe"; + + /** + * The Constant SentOnlyToMe. + */ + public static final String SentOnlyToMe = "SentOnlyToMe"; + + /** + * The Constant SentToAddresses. + */ + public static final String SentToAddresses = "SentToAddresses"; + + /** + * The Constant SentToMe. + */ + public static final String SentToMe = "SentToMe"; + + /** + * The Constant SentToOrCcMe. + */ + public static final String SentToOrCcMe = "SentToOrCcMe"; + + /** + * The Constant WithinDateRange. + */ + public static final String WithinDateRange = "WithinDateRange"; + + /** + * The Constant WithinSizeRange. + */ + public static final String WithinSizeRange = "WithinSizeRange"; + + /** + * The Constant MinimumSize. + */ + public static final String MinimumSize = "MinimumSize"; + + /** + * The Constant MaximumSize. + */ + public static final String MaximumSize = "MaximumSize"; + + /** + * The Constant StartDateTime. + */ + public static final String StartDateTime = "StartDateTime"; + + /** + * The Constant EndDateTime. + */ + public static final String EndDateTime = "EndDateTime"; + + /** + * The Constant AssignCategories. + */ + public static final String AssignCategories = "AssignCategories"; + + /** + * The Constant CopyToFolder. + */ + public static final String CopyToFolder = "CopyToFolder"; + + /** + * The Constant FlagMessage. + */ + public static final String FlagMessage = "FlagMessage"; + + /** + * The Constant ForwardAsAttachmentToRecipients. + */ + public static final String ForwardAsAttachmentToRecipients = + "ForwardAsAttachmentToRecipients"; + + /** + * The Constant ForwardToRecipients. + */ + public static final String ForwardToRecipients = "ForwardToRecipients"; + + /** + * The Constant MarkImportance. + */ + public static final String MarkImportance = "MarkImportance"; + + /** + * The Constant MarkAsRead. + */ + public static final String MarkAsRead = "MarkAsRead"; + + /** + * The Constant MoveToFolder. + */ + public static final String MoveToFolder = "MoveToFolder"; + + /** + * The Constant PermanentDelete. + */ + public static final String PermanentDelete = "PermanentDelete"; + + /** + * The Constant RedirectToRecipients. + */ + public static final String RedirectToRecipients = "RedirectToRecipients"; + + /** + * The Constant SendSMSAlertToRecipients. + */ + public static final String SendSMSAlertToRecipients = + "SendSMSAlertToRecipients"; + + /** + * The Constant ServerReplyWithMessage. + */ + public static final String ServerReplyWithMessage = "ServerReplyWithMessage"; + + /** + * The Constant StopProcessingRules. + */ + public static final String StopProcessingRules = "StopProcessingRules"; + + /** + * The Constant CreateRuleOperation. + */ + public static final String CreateRuleOperation = "CreateRuleOperation"; + + /** + * The Constant SetRuleOperation. + */ + public static final String SetRuleOperation = "SetRuleOperation"; + + /** + * The Constant DeleteRuleOperation. + */ + public static final String DeleteRuleOperation = "DeleteRuleOperation"; + + /** + * The Constant Operations. + */ + public static final String Operations = "Operations"; + + /** + * The Constant RuleOperationErrors. + */ + public static final String RuleOperationErrors = "RuleOperationErrors"; + + /** + * The Constant RuleOperationError. + */ + public static final String RuleOperationError = "RuleOperationError"; + + /** + * The Constant OperationIndex. + */ + public static final String OperationIndex = "OperationIndex"; + + /** + * The Constant ValidationErrors. + */ + public static final String ValidationErrors = "ValidationErrors"; + + /** + * The Constant FieldValue. + */ + public static final String FieldValue = "FieldValue"; + + // Restrictions + /** + * The Constant Not. + */ + public static final String Not = "Not"; + + /** + * The Constant Bitmask. + */ + public static final String Bitmask = "Bitmask"; + + /** + * The Constant Constant. + */ + public static final String Constant = "Constant"; + + /** + * The Constant Restriction. + */ + public static final String Restriction = "Restriction"; + + /** + * The Constant Contains. + */ + public static final String Contains = "Contains"; + + /** + * The Constant Excludes. + */ + public static final String Excludes = "Excludes"; + + /** + * The Constant Exists. + */ + public static final String Exists = "Exists"; + + /** + * The Constant FieldURIOrConstant. + */ + public static final String FieldURIOrConstant = "FieldURIOrConstant"; + + /** + * The Constant And. + */ + public static final String And = "And"; + + /** + * The Constant Or. + */ + public static final String Or = "Or"; + + /** + * The Constant IsEqualTo. + */ + public static final String IsEqualTo = "IsEqualTo"; + + /** + * The Constant IsNotEqualTo. + */ + public static final String IsNotEqualTo = "IsNotEqualTo"; + + /** + * The Constant IsGreaterThan. + */ + public static final String IsGreaterThan = "IsGreaterThan"; + + /** + * The Constant IsGreaterThanOrEqualTo. + */ + public static final String IsGreaterThanOrEqualTo = "IsGreaterThanOrEqualTo"; + + /** + * The Constant IsLessThan. + */ + public static final String IsLessThan = "IsLessThan"; + + /** + * The Constant IsLessThanOrEqualTo. + */ + public static final String IsLessThanOrEqualTo = "IsLessThanOrEqualTo"; + + // Directory only contact property + /** + * The Constant PhoneticFullName. + */ + public static final String PhoneticFullName = "PhoneticFullName"; + + /** + * The Constant PhoneticFirstName. + */ + public static final String PhoneticFirstName = "PhoneticFirstName"; + + /** + * The Constant PhoneticLastName. + */ + public static final String PhoneticLastName = "PhoneticLastName"; + + /** + * The Constant Alias. + */ + public static final String Alias = "Alias"; + + /** + * The Constant Notes. + */ + public static final String Notes = "Notes"; + + /** + * The Constant Photo. + */ + public static final String Photo = "Photo"; + + /** + * The Constant UserSMIMECertificate. + */ + public static final String UserSMIMECertificate = "UserSMIMECertificate"; + + /** + * The Constant MSExchangeCertificate. + */ + public static final String MSExchangeCertificate = "MSExchangeCertificate"; + + /** + * The Constant DirectoryId. + */ + public static final String DirectoryId = "DirectoryId"; + + /** + * The Constant ManagerMailbox. + */ + public static final String ManagerMailbox = "ManagerMailbox"; + + /** + * The Constant DirectReports. + */ + public static final String DirectReports = "DirectReports"; + + // Request/response element names + /** + * The Constant ResponseMessage. + */ + public static final String ResponseMessage = "ResponseMessage"; + + /** + * The Constant ResponseMessages. + */ + public static final String ResponseMessages = "ResponseMessages"; + + // FindConversation + /** + * The Constant FindConversation. + */ + public static final String FindConversation = "FindConversation"; + + /** + * The Constant FindConversationResponse. + */ + public static final String FindConversationResponse = + "FindConversationResponse"; + + /** + * The Constant FindConversationResponseMessage. + */ + public static final String FindConversationResponseMessage = + "FindConversationResponseMessage"; + + // FindItem + /** + * The Constant FindItem. + */ + public static final String FindItem = "FindItem"; + + /** + * The Constant FindItemResponse. + */ + public static final String FindItemResponse = "FindItemResponse"; + + /** + * The Constant FindItemResponseMessage. + */ + public static final String FindItemResponseMessage = + "FindItemResponseMessage"; + + // GetItem + /** + * The Constant GetItem. + */ + public static final String GetItem = "GetItem"; + + /** + * The Constant GetItemResponse. + */ + public static final String GetItemResponse = "GetItemResponse"; + + /** + * The Constant GetItemResponseMessage. + */ + public static final String GetItemResponseMessage = "GetItemResponseMessage"; + + // CreateItem + /** + * The Constant CreateItem. + */ + public static final String CreateItem = "CreateItem"; + + /** + * The Constant CreateItemResponse. + */ + public static final String CreateItemResponse = "CreateItemResponse"; + + /** + * The Constant CreateItemResponseMessage. + */ + public static final String CreateItemResponseMessage = + "CreateItemResponseMessage"; + + // SendItem + /** + * The Constant SendItem. + */ + public static final String SendItem = "SendItem"; + + /** + * The Constant SendItemResponse. + */ + public static final String SendItemResponse = "SendItemResponse"; + + /** + * The Constant SendItemResponseMessage. + */ + public static final String SendItemResponseMessage = + "SendItemResponseMessage"; + + // DeleteItem + /** + * The Constant DeleteItem. + */ + public static final String DeleteItem = "DeleteItem"; + + /** + * The Constant DeleteItemResponse. + */ + public static final String DeleteItemResponse = "DeleteItemResponse"; + + /** + * The Constant DeleteItemResponseMessage. + */ + public static final String DeleteItemResponseMessage = + "DeleteItemResponseMessage"; + + // UpdateItem + /** + * The Constant UpdateItem. + */ + public static final String UpdateItem = "UpdateItem"; + + /** + * The Constant UpdateItemResponse. + */ + public static final String UpdateItemResponse = "UpdateItemResponse"; + + /** + * The Constant UpdateItemResponseMessage. + */ + public static final String UpdateItemResponseMessage = + "UpdateItemResponseMessage"; + + // CopyItem + /** + * The Constant CopyItem. + */ + public static final String CopyItem = "CopyItem"; + + /** + * The Constant CopyItemResponse. + */ + public static final String CopyItemResponse = "CopyItemResponse"; + + /** + * The Constant CopyItemResponseMessage. + */ + public static final String CopyItemResponseMessage = + "CopyItemResponseMessage"; + + // MoveItem + /** + * The Constant MoveItem. + */ + public static final String MoveItem = "MoveItem"; + + /** + * The Constant MoveItemResponse. + */ + public static final String MoveItemResponse = "MoveItemResponse"; + + /** + * The Constant MoveItemResponseMessage. + */ + public static final String MoveItemResponseMessage = + "MoveItemResponseMessage"; + + // FindFolder + /** + * The Constant FindFolder. + */ + public static final String FindFolder = "FindFolder"; + + /** + * The Constant FindFolderResponse. + */ + public static final String FindFolderResponse = "FindFolderResponse"; + + /** + * The Constant FindFolderResponseMessage. + */ + public static final String FindFolderResponseMessage = + "FindFolderResponseMessage"; + + // GetFolder + /** + * The Constant GetFolder. + */ + public static final String GetFolder = "GetFolder"; + + /** + * The Constant GetFolderResponse. + */ + public static final String GetFolderResponse = "GetFolderResponse"; + + /** + * The Constant GetFolderResponseMessage. + */ + public static final String GetFolderResponseMessage = + "GetFolderResponseMessage"; + + // CreateFolder + /** + * The Constant CreateFolder. + */ + public static final String CreateFolder = "CreateFolder"; + + /** + * The Constant CreateFolderResponse. + */ + public static final String CreateFolderResponse = "CreateFolderResponse"; + + /** + * The Constant CreateFolderResponseMessage. + */ + public static final String CreateFolderResponseMessage = + "CreateFolderResponseMessage"; + + // DeleteFolder + /** + * The Constant DeleteFolder. + */ + public static final String DeleteFolder = "DeleteFolder"; + + /** + * The Constant DeleteFolderResponse. + */ + public static final String DeleteFolderResponse = "DeleteFolderResponse"; + + /** + * The Constant DeleteFolderResponseMessage. + */ + public static final String DeleteFolderResponseMessage = + "DeleteFolderResponseMessage"; + + // EmptyFolder + /** + * The Constant EmptyFolder. + */ + public static final String EmptyFolder = "EmptyFolder"; + + /** + * The Constant EmptyFolderResponse. + */ + public static final String EmptyFolderResponse = "EmptyFolderResponse"; + + /** + * The Constant EmptyFolderResponseMessage. + */ + public static final String EmptyFolderResponseMessage = + "EmptyFolderResponseMessage"; + + // UpdateFolder + /** + * The Constant UpdateFolder. + */ + public static final String UpdateFolder = "UpdateFolder"; + + /** + * The Constant UpdateFolderResponse. + */ + public static final String UpdateFolderResponse = "UpdateFolderResponse"; + + /** + * The Constant UpdateFolderResponseMessage. + */ + public static final String UpdateFolderResponseMessage = + "UpdateFolderResponseMessage"; + + // CopyFolder + /** + * The Constant CopyFolder. + */ + public static final String CopyFolder = "CopyFolder"; + + /** + * The Constant CopyFolderResponse. + */ + public static final String CopyFolderResponse = "CopyFolderResponse"; + + /** + * The Constant CopyFolderResponseMessage. + */ + public static final String CopyFolderResponseMessage = + "CopyFolderResponseMessage"; + + // MoveFolder + /** + * The Constant MoveFolder. + */ + public static final String MoveFolder = "MoveFolder"; + + /** + * The Constant MoveFolderResponse. + */ + public static final String MoveFolderResponse = "MoveFolderResponse"; + + /** + * The Constant MoveFolderResponseMessage. + */ + public static final String MoveFolderResponseMessage = + "MoveFolderResponseMessage"; + + // GetAttachment + /** + * The Constant GetAttachment. + */ + public static final String GetAttachment = "GetAttachment"; + + /** + * The Constant GetAttachmentResponse. + */ + public static final String GetAttachmentResponse = "GetAttachmentResponse"; + + /** + * The Constant GetAttachmentResponseMessage. + */ + public static final String GetAttachmentResponseMessage = + "GetAttachmentResponseMessage"; + + // CreateAttachment + /** + * The Constant CreateAttachment. + */ + public static final String CreateAttachment = "CreateAttachment"; + + /** + * The Constant CreateAttachmentResponse. + */ + public static final String CreateAttachmentResponse = + "CreateAttachmentResponse"; + + /** + * The Constant CreateAttachmentResponseMessage. + */ + public static final String CreateAttachmentResponseMessage = + "CreateAttachmentResponseMessage"; + + // DeleteAttachment + /** + * The Constant DeleteAttachment. + */ + public static final String DeleteAttachment = "DeleteAttachment"; + + /** + * The Constant DeleteAttachmentResponse. + */ + public static final String DeleteAttachmentResponse = + "DeleteAttachmentResponse"; + + /** + * The Constant DeleteAttachmentResponseMessage. + */ + public static final String DeleteAttachmentResponseMessage = + "DeleteAttachmentResponseMessage"; + + // ResolveNames + /** + * The Constant ResolveNames. + */ + public static final String ResolveNames = "ResolveNames"; + + /** + * The Constant ResolveNamesResponse. + */ + public static final String ResolveNamesResponse = "ResolveNamesResponse"; + + /** + * The Constant ResolveNamesResponseMessage. + */ + public static final String ResolveNamesResponseMessage = + "ResolveNamesResponseMessage"; + + // ExpandDL + /** + * The Constant ExpandDL. + */ + public static final String ExpandDL = "ExpandDL"; + + /** + * The Constant ExpandDLResponse. + */ + public static final String ExpandDLResponse = "ExpandDLResponse"; + + /** + * The Constant ExpandDLResponseMessage. + */ + public static final String ExpandDLResponseMessage = + "ExpandDLResponseMessage"; + + // Subscribe + /** + * The Constant Subscribe. + */ + public static final String Subscribe = "Subscribe"; + + /** + * The Constant SubscribeResponse. + */ + public static final String SubscribeResponse = "SubscribeResponse"; + + /** + * The Constant SubscribeResponseMessage. + */ + public static final String SubscribeResponseMessage = + "SubscribeResponseMessage"; + + // Unsubscribe + /** + * The Constant Unsubscribe. + */ + public static final String Unsubscribe = "Unsubscribe"; + + /** + * The Constant UnsubscribeResponse. + */ + public static final String UnsubscribeResponse = "UnsubscribeResponse"; + + /** + * The Constant UnsubscribeResponseMessage. + */ + public static final String UnsubscribeResponseMessage = + "UnsubscribeResponseMessage"; + + // GetEvents + /** + * The Constant GetEvents. + */ + public static final String GetEvents = "GetEvents"; + + /** + * The Constant GetEventsResponse. + */ + public static final String GetEventsResponse = "GetEventsResponse"; + + /** + * The Constant GetEventsResponseMessage. + */ + public static final String GetEventsResponseMessage = + "GetEventsResponseMessage"; + + // GetStreamingEvents + /** + * The Constant GetStreamingEvents. + */ + public static final String GetStreamingEvents = "GetStreamingEvents"; + + /** + * The Constant GetStreamingEventsResponse. + */ + public static final String GetStreamingEventsResponse = + "GetStreamingEventsResponse"; + + /** + * The Constant GetStreamingEventsResponseMessage. + */ + public static final String GetStreamingEventsResponseMessage = + "GetStreamingEventsResponseMessage"; + + /** + * The Constant ConnectionStatus. + */ + public static final String ConnectionStatus = "ConnectionStatus"; + + /** + * The Constant ErrorSubscriptionIds. + */ + public static final String ErrorSubscriptionIds = "ErrorSubscriptionIds"; + + /** + * The Constant ConnectionTimeout. + */ + public static final String ConnectionTimeout = "ConnectionTimeout"; + + /** + * The Constant HeartbeatFrequency. + */ + public static final String HeartbeatFrequency = "HeartbeatFrequency"; + + + // SyncFolderItems + /** + * The Constant SyncFolderItems. + */ + public static final String SyncFolderItems = "SyncFolderItems"; + + /** + * The Constant SyncFolderItemsResponse. + */ + public static final String SyncFolderItemsResponse = + "SyncFolderItemsResponse"; + + /** + * The Constant SyncFolderItemsResponseMessage. + */ + public static final String SyncFolderItemsResponseMessage = + "SyncFolderItemsResponseMessage"; + + // SyncFolderHierarchy + /** + * The Constant SyncFolderHierarchy. + */ + public static final String SyncFolderHierarchy = "SyncFolderHierarchy"; + + /** + * The Constant SyncFolderHierarchyResponse. + */ + public static final String SyncFolderHierarchyResponse = + "SyncFolderHierarchyResponse"; + + /** + * The Constant SyncFolderHierarchyResponseMessage. + */ + public static final String SyncFolderHierarchyResponseMessage = + "SyncFolderHierarchyResponseMessage"; + + // GetUserOofSettings + /** + * The Constant GetUserOofSettingsRequest. + */ + public static final String GetUserOofSettingsRequest = + "GetUserOofSettingsRequest"; + + /** + * The Constant GetUserOofSettingsResponse. + */ + public static final String GetUserOofSettingsResponse = + "GetUserOofSettingsResponse"; + + // SetUserOofSettings + /** + * The Constant SetUserOofSettingsRequest. + */ + public static final String SetUserOofSettingsRequest = + "SetUserOofSettingsRequest"; + + /** + * The Constant SetUserOofSettingsResponse. + */ + public static final String SetUserOofSettingsResponse = + "SetUserOofSettingsResponse"; + + // GetUserAvailability + /** + * The Constant GetUserAvailabilityRequest. + */ + public static final String GetUserAvailabilityRequest = + "GetUserAvailabilityRequest"; + + /** + * The Constant GetUserAvailabilityResponse. + */ + public static final String GetUserAvailabilityResponse = + "GetUserAvailabilityResponse"; + + /** + * The Constant FreeBusyResponseArray. + */ + public static final String FreeBusyResponseArray = "FreeBusyResponseArray"; + + /** + * The Constant FreeBusyResponse. + */ + public static final String FreeBusyResponse = "FreeBusyResponse"; + + /** + * The Constant SuggestionsResponse. + */ + public static final String SuggestionsResponse = "SuggestionsResponse"; + + // GetRoomLists + /** + * The Constant GetRoomListsRequest. + */ + public static final String GetRoomListsRequest = "GetRoomLists"; + + /** + * The Constant GetRoomListsResponse. + */ + public static final String GetRoomListsResponse = "GetRoomListsResponse"; + + // GetRooms + /** + * The Constant GetRoomsRequest. + */ + public static final String GetRoomsRequest = "GetRooms"; + + /** + * The Constant GetRoomsResponse. + */ + public static final String GetRoomsResponse = "GetRoomsResponse"; + + // ConvertId + /** + * The Constant ConvertId. + */ + public static final String ConvertId = "ConvertId"; + + /** + * The Constant ConvertIdResponse. + */ + public static final String ConvertIdResponse = "ConvertIdResponse"; + + /** + * The Constant ConvertIdResponseMessage. + */ + public static final String ConvertIdResponseMessage = + "ConvertIdResponseMessage"; + + // AddDelegate + /** + * The Constant AddDelegate. + */ + public static final String AddDelegate = "AddDelegate"; + + /** + * The Constant AddDelegateResponse. + */ + public static final String AddDelegateResponse = "AddDelegateResponse"; + + /** + * The Constant DelegateUserResponseMessageType. + */ + public static final String DelegateUserResponseMessageType = + "DelegateUserResponseMessageType"; + + // RemoveDelegte + /** + * The Constant RemoveDelegate. + */ + public static final String RemoveDelegate = "RemoveDelegate"; + + /** + * The Constant RemoveDelegateResponse. + */ + public static final String RemoveDelegateResponse = "RemoveDelegateResponse"; + + // GetDelegate + /** + * The Constant GetDelegate. + */ + public static final String GetDelegate = "GetDelegate"; + + /** + * The Constant GetDelegateResponse. + */ + public static final String GetDelegateResponse = "GetDelegateResponse"; + + // UpdateDelegate + /** + * The Constant UpdateDelegate. + */ + public static final String UpdateDelegate = "UpdateDelegate"; + + /** + * The Constant UpdateDelegateResponse. + */ + public static final String UpdateDelegateResponse = "UpdateDelegateResponse"; + + // CreateUserConfiguration + /** + * The Constant CreateUserConfiguration. + */ + public static final String CreateUserConfiguration = + "CreateUserConfiguration"; + + /** + * The Constant CreateUserConfigurationResponse. + */ + public static final String CreateUserConfigurationResponse = + "CreateUserConfigurationResponse"; + + /** + * The Constant CreateUserConfigurationResponseMessage. + */ + public static final String CreateUserConfigurationResponseMessage = + "CreateUserConfigurationResponseMessage"; + + // DeleteUserConfiguration + /** + * The Constant DeleteUserConfiguration. + */ + public static final String DeleteUserConfiguration = + "DeleteUserConfiguration"; + + /** + * The Constant DeleteUserConfigurationResponse. + */ + public static final String DeleteUserConfigurationResponse = + "DeleteUserConfigurationResponse"; + + /** + * The Constant DeleteUserConfigurationResponseMessage. + */ + public static final String DeleteUserConfigurationResponseMessage = + "DeleteUserConfigurationResponseMessage"; + + // GetUserConfiguration + /** + * The Constant GetUserConfiguration. + */ + public static final String GetUserConfiguration = "GetUserConfiguration"; + + /** + * The Constant GetUserConfigurationResponse. + */ + public static final String GetUserConfigurationResponse = + "GetUserConfigurationResponse"; + + /** + * The Constant GetUserConfigurationResponseMessage. + */ + public static final String GetUserConfigurationResponseMessage = + "GetUserConfigurationResponseMessage"; + + // UpdateUserConfiguration + /** + * The Constant UpdateUserConfiguration. + */ + public static final String UpdateUserConfiguration = + "UpdateUserConfiguration"; + + /** + * The Constant UpdateUserConfigurationResponse. + */ + public static final String UpdateUserConfigurationResponse = + "UpdateUserConfigurationResponse"; + + /** + * The Constant UpdateUserConfigurationResponseMessage. + */ + public static final String UpdateUserConfigurationResponseMessage = + "UpdateUserConfigurationResponseMessage"; + + // PlayOnPhone + /** + * The Constant PlayOnPhone. + */ + public static final String PlayOnPhone = "PlayOnPhone"; + + /** + * The Constant PlayOnPhoneResponse. + */ + public static final String PlayOnPhoneResponse = "PlayOnPhoneResponse"; + + // GetPhoneCallInformation + /** + * The Constant GetPhoneCall. + */ + public static final String GetPhoneCall = "GetPhoneCallInformation"; + + /** + * The Constant GetPhoneCallResponse. + */ + public static final String GetPhoneCallResponse = + "GetPhoneCallInformationResponse"; + + // DisconnectCall + /** + * The Constant DisconnectPhoneCall. + */ + public static final String DisconnectPhoneCall = "DisconnectPhoneCall"; + + /** + * The Constant DisconnectPhoneCallResponse. + */ + public static final String DisconnectPhoneCallResponse = + "DisconnectPhoneCallResponse"; + + // GetServerTimeZones + /** + * The Constant GetServerTimeZones. + */ + public static final String GetServerTimeZones = "GetServerTimeZones"; + + /** + * The Constant GetServerTimeZonesResponse. + */ + public static final String GetServerTimeZonesResponse = + "GetServerTimeZonesResponse"; + + /** + * The Constant GetServerTimeZonesResponseMessage. + */ + public static final String GetServerTimeZonesResponseMessage = + "GetServerTimeZonesResponseMessage"; + + // GetInboxRules + /** + * The Constant GetInboxRules. + */ + public static final String GetInboxRules = "GetInboxRules"; + + /** + * The Constant GetInboxRulesResponse. + */ + public static final String GetInboxRulesResponse = "GetInboxRulesResponse"; + + // UpdateInboxRules + /** + * The Constant UpdateInboxRules. + */ + public static final String UpdateInboxRules = "UpdateInboxRules"; + + /** + * The Constant UpdateInboxRulesResponse. + */ + public static final String UpdateInboxRulesResponse = + "UpdateInboxRulesResponse"; + + // ExecuteDiagnosticMethod + /** + * The Constant ExecuteDiagnosticMethod. + */ + public static final String ExecuteDiagnosticMethod = + "ExecuteDiagnosticMethod"; + + /** + * The Constant ExecuteDiagnosticMethodResponse. + */ + public static final String ExecuteDiagnosticMethodResponse = + "ExecuteDiagnosticMethodResponse"; + + /** + * The Constant ExecuteDiagnosticMethodResponseMEssage. + */ + public static final String ExecuteDiagnosticMethodResponseMEssage = + "ExecuteDiagnosticMethodResponseMessage"; + + // GetPasswordExpirationDate + /** + * The Constant GetPasswordExpirationDate. + */ + public static final String GetPasswordExpirationDateRequest = + "GetPasswordExpirationDate"; + + /** + * The Constant GetPasswordExpirationDateResponse. + */ + public static final String GetPasswordExpirationDateResponse = + "GetPasswordExpirationDateResponse"; + + // SOAP element names + + /** + * The Constant SOAPEnvelopeElementName. + */ + public static final String SOAPEnvelopeElementName = "Envelope"; + + /** + * The Constant SOAPHeaderElementName. + */ + public static final String SOAPHeaderElementName = "Header"; + + /** + * The Constant SOAPBodyElementName. + */ + public static final String SOAPBodyElementName = "Body"; + + /** + * The Constant SOAPFaultElementName. + */ + public static final String SOAPFaultElementName = "Fault"; + + /** + * The Constant SOAPFaultCodeElementName. + */ + public static final String SOAPFaultCodeElementName = "faultcode"; + + /** + * The Constant SOAPFaultStringElementName. + */ + public static final String SOAPFaultStringElementName = "faultstring"; + + /** + * The Constant SOAPFaultActorElementName. + */ + public static final String SOAPFaultActorElementName = "faultactor"; + + /** + * The Constant SOAPDetailElementName. + */ + public static final String SOAPDetailElementName = "detail"; + + /** + * The Constant EwsResponseCodeElementName. + */ + public static final String EwsResponseCodeElementName = "ResponseCode"; + + /** + * The Constant EwsMessageElementName. + */ + public static final String EwsMessageElementName = "Message"; + + /** + * The Constant EwsLineElementName. + */ + public static final String EwsLineElementName = "Line"; + + /** + * The Constant EwsPositionElementName. + */ + public static final String EwsPositionElementName = "Position"; + + /** + * The Constant EwsErrorCodeElementName. + */ + public static final String EwsErrorCodeElementName = "ErrorCode"; // Generated + + + // by + // Availability + /** + * The Constant EwsExceptionTypeElementName. + */ + public static final String EwsExceptionTypeElementName = "ExceptionType"; // Generated + + // by + // UM + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/attribute/EditorBrowsableState.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/attribute/EditorBrowsableState.java new file mode 100644 index 000000000..8f1ca41dc --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/attribute/EditorBrowsableState.java @@ -0,0 +1,52 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.attribute; + +/** + * The Enum EditorBrowsableState. + */ +public enum EditorBrowsableState { + + // Summary: + // The property or method is always browsable from within an editor. + /** + * The Always. + */ + Always, + // + // Summary: + // The property or method is never browsable from within an editor. + /** + * The Never. + */ + Never, + // + // Summary: + // The property or method is a feature that only advanced users should see. + // An editor can either show or hide such property. + /** + * The Advanced. + */ + Advanced, +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/availability/AvailabilityData.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/availability/AvailabilityData.java similarity index 78% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/availability/AvailabilityData.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/availability/AvailabilityData.java index 06adb95b6..eec0d7dbb 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/availability/AvailabilityData.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/availability/AvailabilityData.java @@ -21,29 +21,15 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.availability; +package com.eischet.ews.api.core.enumeration.availability; /** * Defines the type of data that can be requested via GetUserAvailability. */ public enum AvailabilityData { - // Only return free/busy data. - /** - * The Free busy. - */ - FreeBusy, - - // Only return suggestions. - /** - * The Suggestions. - */ - Suggestions, - - // Return both free/busy data and suggestions. - /** - * The Free busy and suggestions. - */ - FreeBusyAndSuggestions + /** Only return free/busy data. */ FreeBusy, + /** Only return suggestions. */ Suggestions, + /** Return both free/busy data and suggestions. */ FreeBusyAndSuggestions, } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/availability/FreeBusyViewType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/availability/FreeBusyViewType.java new file mode 100644 index 000000000..05c8ff4ee --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/availability/FreeBusyViewType.java @@ -0,0 +1,85 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.availability; + +/** + * Defines the type of free/busy information returned by a GetUserAvailability + * operation. + */ +public enum FreeBusyViewType { + + /** + * No view could be returned. This value cannot be specified in a call to GetUserAvailability. + */ + None, + + /** + * Represents an aggregated free/busy stream. In cross-forest scenarios in + * which the target user in one forest + * does not have an Availability service configured, the Availability + * service of the requestor retrieves the + * target users free/busy information from the free/busy public folder. + * Because public folder only store + * free/busy information in merged form, MergedOnly is the only available + * information. + */ + MergedOnly, + + /** + * Represents the legacy status information: free, busy, tentative, and OOF. + * This also includes the start/end + * times of the appointments. This view is richer than the legacy free/busy + * view because individual meeting + * start and end times are provided instead of an aggregated free/busy + * stream. + */ + FreeBusy, + + /** + * Represents all the property in FreeBusy with a stream of merged free/busy availability information. + */ + FreeBusyMerged, + + /** + * Represents the legacy status information: free, busy, tentative, and OOF; + * the start/end times of the + * appointments; and various property of the appointment such as subject, + * location, and importance. + * This requested view will return the maximum amount of information for + * which the requesting user is privileged. + * If merged free/busy information only is available, as with requesting + * information for users in a Microsoft + * Exchange Server 2003 forest, MergedOnly will be returned. Otherwise, + * FreeBusy or Detailed will be returned. + */ + Detailed, + + /** + * Represents all the property in Detailed with a stream of merged free/busy availability information. + * If only merged free/busy information is available, for example if the mailbox exists on a computer + * running Exchange 2003, MergedOnly will be returned. Otherwise, FreeBusyMerged or DetailedMerged will be returned. + */ + DetailedMerged + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/availability/MeetingAttendeeType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/availability/MeetingAttendeeType.java new file mode 100644 index 000000000..7a2771deb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/availability/MeetingAttendeeType.java @@ -0,0 +1,56 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.availability; + +/** + * Defines the type of a meeting attendee. + */ +public enum MeetingAttendeeType { + + /** + * The attendee is the organizer of the meeting. + */ + Organizer, + + /** + * The attendee is required. + */ + Required, + + /** + * The attendee is optional. + */ + Optional, + + /** + * The attendee is a room. + */ + Room, + + /** + * The attendee is a resource. + */ + Resource + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/availability/SuggestionQuality.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/availability/SuggestionQuality.java similarity index 78% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/availability/SuggestionQuality.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/availability/SuggestionQuality.java index 3fd970082..2c2c91f1b 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/availability/SuggestionQuality.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/availability/SuggestionQuality.java @@ -21,35 +21,31 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.availability; +package com.eischet.ews.api.core.enumeration.availability; /** * Defines the quality of an availability suggestion. */ public enum SuggestionQuality { - // The suggestion is excellent. - /** - * The Excellent. - */ - Excellent, + /** + * The suggestion is excellent. + */ + Excellent, - // The suggestion is good. - /** - * The Good. - */ - Good, + /** + * The suggestion is good. + */ + Good, - // The suggestion is fair. - /** - * The Fair. - */ - Fair, + /** + * The suggestion is fair. + */ + Fair, - // The suggestion is poor. - /** - * The Poor. - */ - Poor + /** + * The suggestion is poor. + */ + Poor } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/ConnectingIdType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/ConnectingIdType.java similarity index 79% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/ConnectingIdType.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/ConnectingIdType.java index 910eba747..af6d045b1 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/ConnectingIdType.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/ConnectingIdType.java @@ -21,28 +21,28 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.misc; +package com.eischet.ews.api.core.enumeration.misc; /** * Defines the type of Id of a ConnectingId object. */ public enum ConnectingIdType { - // / The connecting Id is a principal name. - /** - * The Principal name. - */ - PrincipalName, + // / The connecting Id is a principal name. + /** + * The Principal name. + */ + PrincipalName, - // / The Id is an SID. - /** - * The SID. - */ - SID, + // / The Id is an SID. + /** + * The SID. + */ + SID, - // / The Id is an SMTP address. - /** - * The Smtp address. - */ - SmtpAddress + // / The Id is an SMTP address. + /** + * The Smtp address. + */ + SmtpAddress } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/ConversationActionType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/ConversationActionType.java new file mode 100644 index 000000000..63e441365 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/ConversationActionType.java @@ -0,0 +1,67 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.misc; + +/** + * Defines actions applicable to Conversation. + */ +public enum ConversationActionType { + + /** + * Categorizes every current and future message in the conversation + */ + AlwaysCategorize, + + /** + * Deletes every current and future message in the conversation + */ + AlwaysDelete, + + /** + * Moves every current and future message in the conversation + */ + AlwaysMove, + + /** + * Deletes current item in context folder in the conversation + */ + Delete, + + /** + * Moves current item in context folder in the conversation + */ + Move, + + /** + * Copies current item in context folder in the conversation + */ + Copy, + + /** + * Marks current item in context folder in the conversation with + * provided read state + */ + SetReadState, + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/DateTimePrecision.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/DateTimePrecision.java similarity index 85% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/DateTimePrecision.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/DateTimePrecision.java index e0137de39..69540fd56 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/DateTimePrecision.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/DateTimePrecision.java @@ -21,21 +21,20 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.misc; +package com.eischet.ews.api.core.enumeration.misc; /** * Defines the precision for returned DateTime values */ public enum DateTimePrecision { - // Default value. No SOAP header emitted. - Default, + /** Default value. No SOAP header emitted. */ + Default, - // Seconds + /** Seconds precision. */ + Seconds, - Seconds, + /** Milliseconds precision. */ - // Milliseconds - - Milliseconds + Milliseconds } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/ExchangeVersion.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/ExchangeVersion.java new file mode 100644 index 000000000..3678a3410 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/ExchangeVersion.java @@ -0,0 +1,53 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.misc; + +/** + * Defines the each available Exchange release version. + */ +public enum ExchangeVersion { + + // / Microsoft Exchange 2007, Service Pack 1 + /** + * The Exchange2007_ s p1. + */ + Exchange2007_SP1, + // / Microsoft Exchange 2010 + /** + * The Exchange2010. + */ + Exchange2010, + + /// Microsoft Exchange 2010, Service Pack 1 + /** + * Exchange2010_SP1. + */ + Exchange2010_SP1, + + // Microsoft Exchange 2010, Service Pack 2 + /** + * Exchange2010_SP2. + */ + Exchange2010_SP2, +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/FlaggedForAction.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/FlaggedForAction.java new file mode 100644 index 000000000..0ceb95bdb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/FlaggedForAction.java @@ -0,0 +1,86 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.misc; + +/** + * Defines the follow-up actions that may be stamped on a message. + */ +public enum FlaggedForAction { + + /** + * The message is flagged with any action. + */ + Any, + + /** + * The recipient is requested to call the sender. + */ + Call, + + /** + * The recipient is requested not to forward the message. + */ + DoNotForward, + + /** + * The recipient is requested to follow up on the message. + */ + FollowUp, + + /** + * The recipient received the message for information. + */ + FYI, + + /** + * The recipient is requested to forward the message. + */ + Forward, + + /** + * The recipient is informed that a response to the message is not required. + */ + NoResponseNecessary, + + /** + * The recipient is requested to read the message. + */ + Read, + + /** + * The recipient is requested to reply to the sender of the message. + */ + Reply, + + /** + * The recipient is requested to reply to everyone the message was sent to. + */ + ReplyToAll, + + /** + * The recipient is requested to review the message. + */ + Review + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/HangingRequestDisconnectReason.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/HangingRequestDisconnectReason.java similarity index 77% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/HangingRequestDisconnectReason.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/HangingRequestDisconnectReason.java index 3852e173d..55afd0ff5 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/HangingRequestDisconnectReason.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/HangingRequestDisconnectReason.java @@ -21,30 +21,30 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.misc; +package com.eischet.ews.api.core.enumeration.misc; /** * Enumeration of reasons that a hanging request may disconnect. */ public enum HangingRequestDisconnectReason { - /** - * The server cleanly closed the connection. - */ - Clean, + /** + * The server cleanly closed the connection. + */ + Clean, - /** - * The client closed the connection. - */ - UserInitiated, + /** + * The client closed the connection. + */ + UserInitiated, - /** - * The connection timed out do to a lack of a heartbeat received. - */ - Timeout, + /** + * The connection timed out do to a lack of a heartbeat received. + */ + Timeout, - /** - * An exception occurred on the connection - */ - Exception + /** + * An exception occurred on the connection + */ + Exception } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/IdFormat.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/IdFormat.java new file mode 100644 index 000000000..4c910dd0f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/IdFormat.java @@ -0,0 +1,66 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.misc; + +/** + * Defines supported Id formats in ConvertId operations. + */ +public enum IdFormat { + + // The EWS Id format used in Exchange 2007 RTM. + /** + * The Ews legacy id. + */ + EwsLegacyId, + + // The EWS Id format used in Exchange 2007 SP1 and above. + /** + * The Ews id. + */ + EwsId, + + // The base64-encoded PR_ENTRYID property. + /** + * The Entry id. + */ + EntryId, + + // The hexadecimal representation of the PR_ENTRYID property. + /** + * The Hex entry id. + */ + HexEntryId, + + // The Store Id format. + /** + * The Store id. + */ + StoreId, + + // The Outlook Web Access Id format. + /** + * The Owa id. + */ + OwaId +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/TraceFlags.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/TraceFlags.java new file mode 100644 index 000000000..40e47ee18 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/TraceFlags.java @@ -0,0 +1,111 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.misc; + +/** + * Defines flags to control tracing details. + */ +public enum TraceFlags { + /* + * No tracing. + */ + /** + * The None. + */ + None, + /* + * Trace EWS request messages. + */ + /** + * The Ews request. + */ + EwsRequest, + /* + * Trace EWS response messages. + */ + /** + * The Ews response. + */ + EwsResponse, + /* + * Trace EWS response HTTP headers. + */ + /** + * The Ews response http headers. + */ + EwsResponseHttpHeaders, + /* + * Trace Autodiscover request messages. + */ + /** + * The Autodiscover request. + */ + AutodiscoverRequest, + /* + * Trace Autodiscover response messages. + */ + /** + * The Autodiscover response. + */ + AutodiscoverResponse, + /* + * Trace Autodiscover response HTTP headers. + */ + /** + * The Autodiscover response http headers. + */ + AutodiscoverResponseHttpHeaders, + /* + * Trace Autodiscover configuration logic. + */ + /** + * The Autodiscover configuration. + */ + AutodiscoverConfiguration, + + /* + * Trace messages used in debugging the Exchange Web Services Managed API + */ + /** + * The Debug Message. + */ + DebugMessage, + + /* + * Trace EWS request HTTP headers. + */ + /** + * The Ews Request Http Headers. + */ + EwsRequestHttpHeaders, + + /* + * Trace Autodiscover request HTTP headers. + */ + /** + * The Autodiscover Request HttpHeaders + */ + AutodiscoverRequestHttpHeaders, + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/UserConfigurationProperties.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/UserConfigurationProperties.java new file mode 100644 index 000000000..f030ea77e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/UserConfigurationProperties.java @@ -0,0 +1,92 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.misc; + +/** + * Identifies the user configuration property to retrieve. + */ +public enum UserConfigurationProperties { + + // Retrieve the Id property. + /** + * The Id. + */ + Id(1), + + // Retrieve the Dictionary property. + /** + * The Dictionary. + */ + Dictionary(2), + + // Retrieve the XmlData property. + /** + * The Xml data. + */ + XmlData(4), + + // Retrieve the BinaryData property. + /** + * The Binary data. + */ + BinaryData(8), + + // Retrieve all property. + /** + * The All. + */ + All(UserConfigurationProperties.Id, UserConfigurationProperties.Dictionary, + UserConfigurationProperties.XmlData, + UserConfigurationProperties.BinaryData); + + /** + * The config property. + */ + private int configProperties = 0; + + /** + * Instantiates a new user configuration property. + * + * @param configProperties the config property + */ + UserConfigurationProperties(int configProperties) { + this.configProperties = configProperties; + } + + /** + * Instantiates a new user configuration property. + * + * @param id the id + * @param dictionary the dictionary + * @param xmlData the xml data + * @param binaryData the binary data + */ + UserConfigurationProperties(UserConfigurationProperties id, + UserConfigurationProperties dictionary, + UserConfigurationProperties xmlData, + UserConfigurationProperties binaryData) { + + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/XmlNamespace.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/XmlNamespace.java new file mode 100644 index 000000000..7d26e1fce --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/XmlNamespace.java @@ -0,0 +1,137 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.misc; + +import com.eischet.ews.api.core.EwsUtilities; + +/** + * Defines the namespaces as used by the EwsXmlReader, EwsServiceXmlReader, and + * EwsServiceXmlWriter classes. + */ +public enum XmlNamespace { + /* + * The namespace is not specified. + */ + /** + * The Not specified. + */ + NotSpecified("", ""), + + /** + * The Messages. + */ + Messages(EwsUtilities.EwsMessagesNamespacePrefix, + EwsUtilities.EwsMessagesNamespace), + + /** + * The Types. + */ + Types(EwsUtilities.EwsTypesNamespacePrefix, EwsUtilities.EwsTypesNamespace), + + /** + * The Errors. + */ + Errors(EwsUtilities.EwsErrorsNamespacePrefix, + EwsUtilities.EwsErrorsNamespace), + + /** + * The Soap. + */ + Soap(EwsUtilities.EwsSoapNamespacePrefix, EwsUtilities.EwsSoapNamespace), + + /** + * The Soap12. + */ + Soap12(EwsUtilities.EwsSoapNamespacePrefix, + EwsUtilities.EwsSoap12Namespace), + + /** + * The Xml schema instance. + */ + XmlSchemaInstance(EwsUtilities.EwsXmlSchemaInstanceNamespacePrefix, + EwsUtilities.EwsXmlSchemaInstanceNamespace), + + /** + * The Passport soap fault. + */ + PassportSoapFault(EwsUtilities.PassportSoapFaultNamespacePrefix, + EwsUtilities.PassportSoapFaultNamespace), + + /** + * The WS trust february2005. + */ + WSTrustFebruary2005(EwsUtilities.WSTrustFebruary2005NamespacePrefix, + EwsUtilities.WSTrustFebruary2005Namespace), + + /** + * The WS addressing. + */ + WSAddressing(EwsUtilities.WSAddressingNamespacePrefix, + EwsUtilities.WSAddressingNamespace), + + /** + * The Autodiscover. + */ + Autodiscover(EwsUtilities.AutodiscoverSoapNamespacePrefix, + EwsUtilities.AutodiscoverSoapNamespace); + + /** + * The prefix. + */ + private final String prefix; + + /** + * The name space uri. + */ + private final String nameSpaceUri; + + /** + * Instantiates a new xml namespace. + * + * @param prefix the prefix + * @param nameSpaceUri the name space uri + */ + XmlNamespace(String prefix, String nameSpaceUri) { + this.prefix = prefix; + this.nameSpaceUri = nameSpaceUri; + } + + /** + * Gets the name space uri. + * + * @return the name space uri + */ + public String getNameSpaceUri() { + return this.nameSpaceUri; + } + + /** + * Gets the name space prefix. + * + * @return the name space prefix + */ + public String getNameSpacePrefix() { + return this.prefix; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/error/ServiceError.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/error/ServiceError.java new file mode 100644 index 000000000..8256227cf --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/error/ServiceError.java @@ -0,0 +1,2193 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.misc.error; + +/** + * Defines the error codes that can be returned by the Exchange Web Services. + */ +public enum ServiceError { + + // NoError. Indicates that an error has not occurred. + /** + * The No error. + */ + NoError, + + // ErrorAccessDenied + /** + * The Error access denied. + */ + ErrorAccessDenied, + + // ErrorAccessModeSpecified + /** + * The impersonation authentication header should not be included. + */ + ErrorAccessModeSpecified, + + // ErrorAccountDisabled + /** + * The Error account disabled. + */ + ErrorAccountDisabled, + + // ErrorAddDelegatesFailed + /** + * The Error add delegates failed. + */ + ErrorAddDelegatesFailed, + + // ErrorAddressSpaceNotFound + /** + * ErrorAddressSpaceNotFound + */ + ErrorAddressSpaceNotFound, + + // ErrorADOperation + /** + * The Error ad operation. + */ + ErrorADOperation, + + // ErrorADSessionFilter + /** + * The Error ad session filter. + */ + ErrorADSessionFilter, + + // ErrorADUnavailable + /** + * The Error ad unavailable. + */ + ErrorADUnavailable, + + // ErrorAffectedTaskOccurrencesRequired + /** + * The Error affected task occurrences required. + */ + ErrorAffectedTaskOccurrencesRequired, + + /** + * The conversation action alwayscategorize or alwaysmove or alwaysdelete + * has failed. + */ + ErrorApplyConversationActionFailed, + + /** + * The item has attachment at more than the maximum supported nest level. + */ + ErrorAttachmentNestLevelLimitExceeded, + + // ErrorAttachmentSizeLimitExceeded + /** + * The Error attachment size limit exceeded. + */ + ErrorAttachmentSizeLimitExceeded, + + // ErrorAutoDiscoverFailed + /** + * The Error auto discover failed. + */ + ErrorAutoDiscoverFailed, + + // ErrorAvailabilityConfigNotFound + /** + * The Error availability config not found. + */ + ErrorAvailabilityConfigNotFound, + + // ErrorBatchProcessingStopped + /** + * The Error batch processing stopped. + */ + ErrorBatchProcessingStopped, + + // ErrorCalendarCannotMoveOrCopyOccurrence + /** + * The Error calendar cannot move or copy occurrence. + */ + ErrorCalendarCannotMoveOrCopyOccurrence, + + // ErrorCalendarCannotUpdateDeletedItem + /** + * The Error calendar cannot update deleted item. + */ + ErrorCalendarCannotUpdateDeletedItem, + + // ErrorCalendarCannotUseIdForOccurrenceId + /** + * The Error calendar cannot use id for occurrence id. + */ + ErrorCalendarCannotUseIdForOccurrenceId, + + // ErrorCalendarCannotUseIdForRecurringMasterId + /** + * The Error calendar cannot use id for recurring master id. + */ + ErrorCalendarCannotUseIdForRecurringMasterId, + + // ErrorCalendarDurationIsTooLong + /** + * The Error calendar duration is too long. + */ + ErrorCalendarDurationIsTooLong, + + // ErrorCalendarEndDateIsEarlierThanStartDate + /** + * The Error calendar end date is earlier than start date. + */ + ErrorCalendarEndDateIsEarlierThanStartDate, + + // ErrorCalendarFolderIsInvalidForCalendarView + /** + * The Error calendar folder is invalid for calendar view. + */ + ErrorCalendarFolderIsInvalidForCalendarView, + + // ErrorCalendarInvalidAttributeValue + /** + * The Error calendar invalid attribute value. + */ + ErrorCalendarInvalidAttributeValue, + + // ErrorCalendarInvalidDayForTimeChangePattern + /** + * The Error calendar invalid day for time change pattern. + */ + ErrorCalendarInvalidDayForTimeChangePattern, + + // ErrorCalendarInvalidDayForWeeklyRecurrence + /** + * The Error calendar invalid day for weekly recurrence. + */ + ErrorCalendarInvalidDayForWeeklyRecurrence, + + // ErrorCalendarInvalidPropertyState + /** + * The Error calendar invalid property state. + */ + ErrorCalendarInvalidPropertyState, + + // ErrorCalendarInvalidPropertyValue + /** + * The Error calendar invalid property value. + */ + ErrorCalendarInvalidPropertyValue, + + // ErrorCalendarInvalidRecurrence + /** + * The Error calendar invalid recurrence. + */ + ErrorCalendarInvalidRecurrence, + + // ErrorCalendarInvalidTimeZone + /** + * The Error calendar invalid time zone. + */ + ErrorCalendarInvalidTimeZone, + + // ErrorCalendarIsCancelledForAccept + /** + * The Error calendar is cancelled for accept. + */ + ErrorCalendarIsCancelledForAccept, + + // ErrorCalendarIsCancelledForDecline + /** + * The Error calendar is cancelled for decline. + */ + ErrorCalendarIsCancelledForDecline, + + // ErrorCalendarIsCancelledForRemove + /** + * The Error calendar is cancelled for remove. + */ + ErrorCalendarIsCancelledForRemove, + + // ErrorCalendarIsCancelledForTentative + /** + * The Error calendar is cancelled for tentative. + */ + ErrorCalendarIsCancelledForTentative, + + // ErrorCalendarIsDelegatedForAccept + /** + * The Error calendar is delegated for accept. + */ + ErrorCalendarIsDelegatedForAccept, + + // ErrorCalendarIsDelegatedForDecline + /** + * The Error calendar is delegated for decline. + */ + ErrorCalendarIsDelegatedForDecline, + + // ErrorCalendarIsDelegatedForRemove + /** + * The Error calendar is delegated for remove. + */ + ErrorCalendarIsDelegatedForRemove, + + // ErrorCalendarIsDelegatedForTentative + /** + * The Error calendar is delegated for tentative. + */ + ErrorCalendarIsDelegatedForTentative, + + // ErrorCalendarIsNotOrganizer + /** + * The Error calendar is not organizer. + */ + ErrorCalendarIsNotOrganizer, + + // ErrorCalendarIsOrganizerForAccept + /** + * The Error calendar is organizer for accept. + */ + ErrorCalendarIsOrganizerForAccept, + + // ErrorCalendarIsOrganizerForDecline + /** + * The Error calendar is organizer for decline. + */ + ErrorCalendarIsOrganizerForDecline, + + // ErrorCalendarIsOrganizerForRemove + /** + * The Error calendar is organizer for remove. + */ + ErrorCalendarIsOrganizerForRemove, + + // ErrorCalendarIsOrganizerForTentative + /** + * The Error calendar is organizer for tentative. + */ + ErrorCalendarIsOrganizerForTentative, + + // ErrorCalendarMeetingRequestIsOutOfDate + /** + * The Error calendar meeting request is out of date. + */ + ErrorCalendarMeetingRequestIsOutOfDate, + + // ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange + /** + * The Error calendar occurrence index is out of recurrence range. + */ + ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange, + + // ErrorCalendarOccurrenceIsDeletedFromRecurrence + /** + * The Error calendar occurrence is deleted from recurrence. + */ + ErrorCalendarOccurrenceIsDeletedFromRecurrence, + + // ErrorCalendarOutOfRange + /** + * The Error calendar out of range. + */ + ErrorCalendarOutOfRange, + + // ErrorCalendarViewRangeTooBig + /** + * The Error calendar view range too big. + */ + ErrorCalendarViewRangeTooBig, + + // ErrorCallerIsInvalidADAccount + /** + * The Error caller is invalid ad account. + */ + ErrorCallerIsInvalidADAccount, + + // ErrorCannotCreateCalendarItemInNonCalendarFolder + /** + * The Error cannot create calendar item in non calendar folder. + */ + ErrorCannotCreateCalendarItemInNonCalendarFolder, + + // ErrorCannotCreateContactInNonContactFolder + /** + * The Error cannot create contact in non contact folder. + */ + ErrorCannotCreateContactInNonContactFolder, + + // ErrorCannotCreatePostItemInNonMailFolder + /** + * The Error cannot create post item in non mail folder. + */ + ErrorCannotCreatePostItemInNonMailFolder, + + // ErrorCannotCreateTaskInNonTaskFolder + /** + * The Error cannot create task in non task folder. + */ + ErrorCannotCreateTaskInNonTaskFolder, + + // ErrorCannotDeleteObject + /** + * The Error cannot delete object. + */ + ErrorCannotDeleteObject, + + // ErrorCannotDeleteTaskOccurrence + /** + * The Error cannot delete task occurrence. + */ + ErrorCannotDeleteTaskOccurrence, + + /** + * Folder cannot be emptied. + */ + ErrorCannotEmptyFolder, + + // ErrorCannotOpenFileAttachment + /** + * The Error cannot open file attachment. + */ + ErrorCannotOpenFileAttachment, + + // ErrorCannotSetCalendarPermissionOnNonCalendarFolder + /** + * The Error cannot set calendar permission on non calendar folder. + */ + ErrorCannotSetCalendarPermissionOnNonCalendarFolder, + + // ErrorCannotSetNonCalendarPermissionOnCalendarFolder + /** + * The Error cannot set non calendar permission on calendar folder. + */ + ErrorCannotSetNonCalendarPermissionOnCalendarFolder, + + // ErrorCannotSetPermissionUnknownEntries + /** + * The Error cannot set permission unknown entries. + */ + ErrorCannotSetPermissionUnknownEntries, + + // ErrorCannotUseFolderIdForItemId + /** + * The Error cannot use folder id for item id. + */ + ErrorCannotUseFolderIdForItemId, + + // ErrorCannotUseItemIdForFolderId + /** + * The Error cannot use item id for folder id. + */ + ErrorCannotUseItemIdForFolderId, + + // ErrorChangeKeyRequired + /** + * The Error change key required. + */ + ErrorChangeKeyRequired, + + // ErrorChangeKeyRequiredForWriteOperations + /** + * The Error change key required for write operations. + */ + ErrorChangeKeyRequiredForWriteOperations, + + /** + * ErrorClientDisconnected + */ + ErrorClientDisconnected, + + // ErrorConnectionFailed + /** + * The Error connection failed. + */ + ErrorConnectionFailed, + + // ErrorContainsFilterWrongType + /** + * The Error contains filter wrong type. + */ + ErrorContainsFilterWrongType, + + // ErrorContentConversionFailed + /** + * The Error content conversion failed. + */ + ErrorContentConversionFailed, + + // ErrorCorruptData + /** + * The Error corrupt data. + */ + ErrorCorruptData, + + // ErrorCreateItemAccessDenied + /** + * The Error create item access denied. + */ + ErrorCreateItemAccessDenied, + + // ErrorCreateManagedFolderPartialCompletion + /** + * The Error create managed folder partial completion. + */ + ErrorCreateManagedFolderPartialCompletion, + + // ErrorCreateSubfolderAccessDenied + /** + * The Error create subfolder access denied. + */ + ErrorCreateSubfolderAccessDenied, + + // ErrorCrossMailboxMoveCopy + /** + * The Error cross mailbox move copy. + */ + ErrorCrossMailboxMoveCopy, + + // ErrorCrossSiteRequest + /** + * The Error cross site request. + */ + ErrorCrossSiteRequest, + + // ErrorDataSizeLimitExceeded + /** + * The Error data size limit exceeded. + */ + ErrorDataSizeLimitExceeded, + + // ErrorDataSourceOperation + /** + * The Error data source operation. + */ + ErrorDataSourceOperation, + + // ErrorDelegateAlreadyExists + /** + * The Error delegate already exists. + */ + ErrorDelegateAlreadyExists, + + // ErrorDelegateCannotAddOwner + /** + * The Error delegate cannot add owner. + */ + ErrorDelegateCannotAddOwner, + + // ErrorDelegateMissingConfiguration + /** + * The Error delegate missing configuration. + */ + ErrorDelegateMissingConfiguration, + + // ErrorDelegateNoUser + /** + * The Error delegate no user. + */ + ErrorDelegateNoUser, + + // ErrorDelegateValidationFailed + /** + * The Error delegate validation failed. + */ + ErrorDelegateValidationFailed, + + // ErrorDeleteDistinguishedFolder + /** + * The Error delete distinguished folder. + */ + ErrorDeleteDistinguishedFolder, + + // ErrorDeleteItemsFailed + /** + * The Error delete item failed. + */ + ErrorDeleteItemsFailed, + + // ErrorDistinguishedUserNotSupported + /** + * The Error distinguished user not supported. + */ + ErrorDistinguishedUserNotSupported, + + // ErrorDistributionListMemberNotExist + /** + * The Error distribution list member not exist. + */ + ErrorDistributionListMemberNotExist, + + // ErrorDuplicateInputFolderNames + /** + * The Error duplicate input folder names. + */ + ErrorDuplicateInputFolderNames, + + // ErrorDuplicateSOAPHeader + /** + * The Error duplicate soap header. + */ + ErrorDuplicateSOAPHeader, + + // ErrorDuplicateUserIdsSpecified + /** + * The Error duplicate user ids specified. + */ + ErrorDuplicateUserIdsSpecified, + + // ErrorEmailAddressMismatch + /** + * The Error email address mismatch. + */ + ErrorEmailAddressMismatch, + + // ErrorEventNotFound + /** + * The Error event not found. + */ + ErrorEventNotFound, + + // ErrorExceededConnectionCount + /** + * The Error exceeded connection count. + */ + ErrorExceededConnectionCount, + + // ErrorExceededFindCountLimmit + /** + * The Error exceeded find count limit. + */ + ErrorExceededFindCountLimit, + + // ErrorExceededSubscritionCount + /** + * The Error exceeded subscription count. + */ + ErrorExceededSubscriptionCount, + + // ErrorExpiredSubscription + /** + * The Error expired subscription. + */ + ErrorExpiredSubscription, + + // ErrorFolderCorrupt + /** + * The Error folder corrupt. + */ + ErrorFolderCorrupt, + + // ErrorFolderExists + /** + * The Error folder exists. + */ + ErrorFolderExists, + + // ErrorFolderNotFound + /** + * The specified folder could not be found in the store. + */ + ErrorFolderNotFound, + + // ErrorFolderPropertRequestFailed + /** + * ErrorFolderPropertRequestFailed + */ + ErrorFolderPropertRequestFailed, + + // ErrorFolderSave + /** + * The folder save operation did not succeed. + */ + ErrorFolderSave, + + // ErrorFolderSaveFailed + /** + * The save operation failed or partially succeeded. + */ + ErrorFolderSaveFailed, + + // ErrorFolderSavePropertyError + /** + * The folder save operation failed due to invalid property values. + */ + ErrorFolderSavePropertyError, + + // ErrorFreeBusyDLLimitReached + /** + * ErrorFreeBusyDLLimitReached + */ + ErrorFreeBusyDLLimitReached, + + // ErrorFreeBusyGenerationFailed + /** + * ErrorFreeBusyGenerationFailed + */ + ErrorFreeBusyGenerationFailed, + + // ErrorGetServerSecurityDescriptorFailed + /** + * ErrorGetServerSecurityDescriptorFailed + */ + ErrorGetServerSecurityDescriptorFailed, + + // ErrorImpersonateUserDenied + /** + * The account does not have permission to impersonate the requested user. + */ + ErrorImpersonateUserDenied, + + // ErrorImpersonationDenied + /** + * ErrorImpersonationDenied + */ + ErrorImpersonationDenied, + + // ErrorImpersonationFailed + /** + * Impersonation failed. + */ + ErrorImpersonationFailed, + + // ErrorInboxRulesValidationError + /** + * ErrorInboxRulesValidationError + */ + ErrorInboxRulesValidationError, + + // ErrorIncorrectSchemaVersion + /** + * The request is valid but does not specify the correct server version in + * the RequestServerVersion SOAP header. Ensure that the + * RequestServerVersion SOAP header is set with the correct + * RequestServerVersionValue. + */ + ErrorIncorrectSchemaVersion, + + // ErrorIncorrectUpdatePropertyCount + /** + * An object within a change description must contain one and only one + * property to modify. + */ + ErrorIncorrectUpdatePropertyCount, + + // ErrorIndividualMailboxLimitReached + /** + * ErrorIndividualMailboxLimitReached + */ + ErrorIndividualMailboxLimitReached, + + // ErrorInsufficientResources + /** + * Resources are unavailable. Try again later. + */ + ErrorInsufficientResources, + + // ErrorInternalServerError + /** + * An internal server error occurred. The operation failed. + */ + ErrorInternalServerError, + + // ErrorInternalServerTransientError + /** + * An internal server error occurred. Try again later. + */ + ErrorInternalServerTransientError, + + // ErrorInvalidAccessLevel + /** + * ErrorInvalidAccessLevel + */ + ErrorInvalidAccessLevel, + + // ErrorInvalidArgument + /** + * ErrorInvalidArgument + */ + ErrorInvalidArgument, + + // ErrorInvalidAttachmentId + /** + * The specified attachment Id is invalid. + */ + ErrorInvalidAttachmentId, + + // ErrorInvalidAttachmentSubfilter + /** + * Attachment subfilters must have a single TextFilter therein. + */ + ErrorInvalidAttachmentSubfilter, + + // ErrorInvalidAttachmentSubfilterTextFilter + /** + * Attachment subfilters must have a single TextFilter on the display name + * only. + */ + ErrorInvalidAttachmentSubfilterTextFilter, + + // ErrorInvalidAuthorizationContext + /** + * ErrorInvalidAuthorizationContext + */ + ErrorInvalidAuthorizationContext, + + // ErrorInvalidChangeKey + /** + * The change key is invalid. + */ + ErrorInvalidChangeKey, + + // ErrorInvalidClientSecurityContext + /** + * ErrorInvalidClientSecurityContext + */ + ErrorInvalidClientSecurityContext, + + // ErrorInvalidCompleteDate + /** + * CompleteDate cannot be set to a date in the future. + */ + ErrorInvalidCompleteDate, + + // ErrorInvalidContactEmailAddress + /** + * The e-mail address that was supplied isn't valid. + */ + ErrorInvalidContactEmailAddress, + + // ErrorInvalidContactEmailIndex + /** + * The e-mail index supplied isn't valid. + */ + ErrorInvalidContactEmailIndex, + + // ErrorInvalidCrossForestCredentials + /** + * ErrorInvalidCrossForestCredentials + */ + ErrorInvalidCrossForestCredentials, + + /** + * Invalid Delegate Folder Permission. + */ + ErrorInvalidDelegatePermission, + + /** + * One or more UserId parameters are invalid. Make sure that the + * PrimarySmtpAddress, Sid and DisplayName property refer to the same user + * when specified. + */ + ErrorInvalidDelegateUserId, + + /** + * An ExchangeImpersonation SOAP header must contain a user principal name, + * user SID, or primary SMTP address. + */ + ErrorInvalidExchangeImpersonationHeaderData, + + /** + * Second operand in Excludes expression must be uint compatible. + */ + ErrorInvalidExcludesRestriction, + + /** + * FieldURI can only be used in Contains expressions. + */ + ErrorInvalidExpressionTypeForSubFilter, + + /** + * The extended property attribute combination is invalid. + */ + ErrorInvalidExtendedProperty, + + /** + * The extended property value is inconsistent with its type. + */ + ErrorInvalidExtendedPropertyValue, + + /** + * The original sender of the message (initiator field in the sharing + * metadata) is not valid. + */ + ErrorInvalidExternalSharingInitiator, + + /** + * The sharing message is not intended for this caller. + */ + ErrorInvalidExternalSharingSubscriber, + + /** + * The organization is either not federated, or it's configured incorrectly. + */ + ErrorInvalidFederatedOrganizationId, + + /** + * Folder Id is invalid. + */ + ErrorInvalidFolderId, + + /** + * ErrorInvalidFolderTypeForOperation + */ + ErrorInvalidFolderTypeForOperation, + + /** + * Invalid fractional paging offset values. + */ + ErrorInvalidFractionalPagingParameters, + + /** + * ErrorInvalidFreeBusyViewType + */ + ErrorInvalidFreeBusyViewType, + + /** + * Either DataType or SharedFolderId must be specified, but not both. + */ + ErrorInvalidGetSharingFolderRequest, + + // ErrorInvalidId + /** + * The Error invalid id. + */ + ErrorInvalidId, + + /** + * Id must be non-empty. + */ + ErrorInvalidIdEmpty, + + /** + * Id is malformed. + */ + ErrorInvalidIdMalformed, + + /** + * The EWS Id is in EwsLegacyId format which is not supported by the + * Exchange version specified by your request. Please use the ConvertId + * method to convert from EwsLegacyId to EwsId format. + */ + ErrorInvalidIdMalformedEwsLegacyIdFormat, + + /** + * Moniker exceeded allowable length. + */ + ErrorInvalidIdMonikerTooLong, + + /** + * The Id does not represent an item attachment. + */ + ErrorInvalidIdNotAnItemAttachmentId, + + /** + * ResolveNames returned an invalid Id. + */ + ErrorInvalidIdReturnedByResolveNames, + + /** + * Id exceeded allowable length. + */ + ErrorInvalidIdStoreObjectIdTooLong, + + /** + * Too many attachment levels. + */ + ErrorInvalidIdTooManyAttachmentLevels, + + /** + * The Id Xml is invalid. + */ + ErrorInvalidIdXml, + + /** + * The specified indexed paging values are invalid. + */ + ErrorInvalidIndexedPagingParameters, + + /** + * Only one child node is allowed when setting an Internet Message Header. + */ + ErrorInvalidInternetHeaderChildNodes, + + /** + * Item type is invalid for AcceptItem action. + */ + ErrorInvalidItemForOperationAcceptItem, + + /** + * Item type is invalid for CancelCalendarItem action. + */ + ErrorInvalidItemForOperationCancelItem, + + /** + * Item type is invalid for CreateItem operation. + */ + ErrorInvalidItemForOperationCreateItem, + + /** + * Item type is invalid for CreateItemAttachment operation. + */ + ErrorInvalidItemForOperationCreateItemAttachment, + + /** + * Item type is invalid for DeclineItem operation. + */ + ErrorInvalidItemForOperationDeclineItem, + + /** + * ExpandDL operation does not support this item type. + */ + ErrorInvalidItemForOperationExpandDL, + + /** + * Item type is invalid for RemoveItem operation. + */ + ErrorInvalidItemForOperationRemoveItem, + + /** + * Item type is invalid for SendItem operation. + */ + ErrorInvalidItemForOperationSendItem, + + /** + * The item of this type is invalid for TentativelyAcceptItem action. + */ + ErrorInvalidItemForOperationTentative, + + /** + * The logon type isn't valid. + */ + ErrorInvalidLogonType, + + /** + * Mailbox is invalid. Verify the specified Mailbox property. + */ + ErrorInvalidMailbox, + + /** + * The Managed Folder property is corrupt or otherwise invalid. + */ + ErrorInvalidManagedFolderProperty, + + /** + * The managed folder has an invalid quota. + */ + ErrorInvalidManagedFolderQuota, + + /** + * The managed folder has an invalid storage limit value. + */ + ErrorInvalidManagedFolderSize, + + /** + * ErrorInvalidMergedFreeBusyInterval + */ + ErrorInvalidMergedFreeBusyInterval, + + /** + * The specified value is not a valid name for name resolution. + */ + ErrorInvalidNameForNameResolution, + + /** + * ErrorInvalidNetworkServiceContext + */ + ErrorInvalidNetworkServiceContext, + + /** + * ErrorInvalidOofParameter + */ + ErrorInvalidOofParameter, + + /** + * ErrorInvalidOperation + */ + ErrorInvalidOperation, + + /** + * ErrorInvalidOrganizationRelationshipForFreeBusy + */ + ErrorInvalidOrganizationRelationshipForFreeBusy, + + /** + * MaxEntriesReturned must be greater than zero. + */ + ErrorInvalidPagingMaxRows, + + /** + * Cannot create a subfolder within a SearchFolder. + */ + ErrorInvalidParentFolder, + + /** + * PercentComplete must be an integer between 0 and 100. + */ + ErrorInvalidPercentCompleteValue, + + /** + * The permission settings were not valid. + */ + ErrorInvalidPermissionSettings, + + /** + * The phone call ID isn't valid. + */ + ErrorInvalidPhoneCallId, + + /** + * The phone number isn't valid. + */ + ErrorInvalidPhoneNumber, + + /** + * The append action is not supported for this property. + */ + ErrorInvalidPropertyAppend, + + /** + * The delete action is not supported for this property. + */ + ErrorInvalidPropertyDelete, + + /** + * Property cannot be used in Exists expression. Use IsEqualTo instead. + */ + ErrorInvalidPropertyForExists, + + /** + * Property is not valid for this operation. + */ + ErrorInvalidPropertyForOperation, + + /** + * Property is not valid for this object type. + */ + ErrorInvalidPropertyRequest, + + /** + * Set action is invalid for property. + */ + ErrorInvalidPropertySet, + + // / + // / Update operation is invalid for property of a sent message. + // / + ErrorInvalidPropertyUpdateSentMessage, + + // / + // / The proxy security context is invalid. + // / + ErrorInvalidProxySecurityContext, + + // / + // / SubscriptionId is invalid. Subscription is not a pull subscription. + // / + ErrorInvalidPullSubscriptionId, + + // / + // / URL specified for push subscription is invalid. + // / + ErrorInvalidPushSubscriptionUrl, + + // / + // / One or more recipients are invalid. + // / + ErrorInvalidRecipients, + + // / + // / Recipient subfilters are only supported when + // /there are two expressions within a single + // / AND filter. + // / + ErrorInvalidRecipientSubfilter, + + // / + // / Recipient subfilter must have a comparison filter + // /that tests equality to recipient type + // / or attendee type. + // / + ErrorInvalidRecipientSubfilterComparison, + + // / + // / Recipient subfilters must have a text filter + // /and a comparison filter in that order. + // / + ErrorInvalidRecipientSubfilterOrder, + + // / + // / Recipient subfilter must have a TextFilter on the SMTP address only. + // / + ErrorInvalidRecipientSubfilterTextFilter, + + // / + // / The reference item does not support the requested operation. + // / + ErrorInvalidReferenceItem, + + // / + // / The request is invalid. + // / + ErrorInvalidRequest, + + // / + // / The restriction is invalid. + // / + ErrorInvalidRestriction, + + // / + // / The routing type format is invalid. + // / + ErrorInvalidRoutingType, + + // / + // / ErrorInvalidScheduledOofDuration + // / + ErrorInvalidScheduledOofDuration, + + // / + // / The mailbox that was requested doesn't support + // /the specified RequestServerVersion. + // / + ErrorInvalidSchemaVersionForMailboxVersion, + + // / + // / ErrorInvalidSecurityDescriptor + // / + ErrorInvalidSecurityDescriptor, + + // / + // / Invalid combination of SaveItemToFolder + // /attribute and SavedItemFolderId element. + // / + ErrorInvalidSendItemSaveSettings, + + // / + // / Invalid serialized access token. + // / + ErrorInvalidSerializedAccessToken, + + // / + // / The specified server version is invalid. + // / + ErrorInvalidServerVersion, + + // / + // / The sharing message metadata is not valid. + // / + ErrorInvalidSharingData, + + // / + // / The sharing message is not valid. + // / + ErrorInvalidSharingMessage, + + // / + // / A SID with an invalid format was encountered. + // / + ErrorInvalidSid, + + // / + // / The SIP address isn't valid. + // / + ErrorInvalidSIPUri, + + // / + // / The SMTP address format is invalid. + // / + ErrorInvalidSmtpAddress, + + // / + // / Invalid subFilterType. + // / + ErrorInvalidSubfilterType, + + // / + // / SubFilterType is not attendee type. + // / + ErrorInvalidSubfilterTypeNotAttendeeType, + + // / + // / SubFilterType is not recipient type. + // / + ErrorInvalidSubfilterTypeNotRecipientType, + + // / + // / Subscription is invalid. + // / + ErrorInvalidSubscription, + + // / + // / A subscription can only be established on + // /a single public folder or on folder from a + // / single mailbox. + // / + ErrorInvalidSubscriptionRequest, + + // / + // / Synchronization state data is corrupt or otherwise invalid. + // / + ErrorInvalidSyncStateData, + + // / + // / ErrorInvalidTimeInterval + // / + ErrorInvalidTimeInterval, + + // / + // / A UserId was not valid. + // / + ErrorInvalidUserInfo, + + // / + // / ErrorInvalidUserOofSettings + // / + ErrorInvalidUserOofSettings, + + // / + // / The impersonation principal name is invalid. + // / + ErrorInvalidUserPrincipalName, + + // / + // / The user SID is invalid or does not map + // /to a user in the Active Directory. + // / + ErrorInvalidUserSid, + + // / + // / ErrorInvalidUserSidMissingUPN + // / + ErrorInvalidUserSidMissingUPN, + + // / + // / The specified value is invalid for property. + // / + ErrorInvalidValueForProperty, + + // / + // / The watermark is invalid. + // / + ErrorInvalidWatermark, + + // / + // / A valid IP gateway couldn't be found. + // / + ErrorIPGatewayNotFound, + + // / + // / The send or update operation could not be + // /performed because the change key passed in the + // / request does not match the current change key for the item. + // / + ErrorIrresolvableConflict, + + // / + // / The item is corrupt. + // / + ErrorItemCorrupt, + + // / + // / The specified object was not found in the store. + // / + ErrorItemNotFound, + + // / + // / One or more of the property requested for + // /this item could not be retrieved. + // / + ErrorItemPropertyRequestFailed, + + // / + // / The item save operation did not succeed. + // / + ErrorItemSave, + + // / + // / Item save operation did not succeed. + // / + ErrorItemSavePropertyError, + + // / + // / ErrorLegacyMailboxFreeBusyViewTypeNotMerged + // / + ErrorLegacyMailboxFreeBusyViewTypeNotMerged, + + // / + // / ErrorLocalServerObjectNotFound + // / + ErrorLocalServerObjectNotFound, + + // / + // / ErrorLogonAsNetworkServiceFailed + // / + ErrorLogonAsNetworkServiceFailed, + + // / + // / Unable to access an account or mailbox. + // / + ErrorMailboxConfiguration, + + // / + // / ErrorMailboxDataArrayEmpty + // / + ErrorMailboxDataArrayEmpty, + + // / + // / ErrorMailboxDataArrayTooBig + // / + ErrorMailboxDataArrayTooBig, + + // / + // / ErrorMailboxFailover + // / + ErrorMailboxFailover, + + // / + // / ErrorMailboxLogonFailed + // / + ErrorMailboxLogonFailed, + + // / + // / Mailbox move in progress. Try again later. + // / + ErrorMailboxMoveInProgress, + + // / + // / The mailbox database is temporarily unavailable. + // / + ErrorMailboxStoreUnavailable, + + // / + // / ErrorMailRecipientNotFound + // / + ErrorMailRecipientNotFound, + + // / + // / MailTips aren't available for your organization. + // / + ErrorMailTipsDisabled, + + // / + // / The specified Managed Folder already exists in the mailbox. + // / + ErrorManagedFolderAlreadyExists, + + // / + // / Unable to find the specified managed folder in the Active Directory. + // / + ErrorManagedFolderNotFound, + + // / + // / Failed to create or bind to the folder: Managed Folders + // / + ErrorManagedFoldersRootFailure, + + // / + // / ErrorMeetingSuggestionGenerationFailed + // / + ErrorMeetingSuggestionGenerationFailed, + + // / + // / MessageDisposition attribute is required. + // / + ErrorMessageDispositionRequired, + + // / + // / The message exceeds the maximum supported size. + // / + ErrorMessageSizeExceeded, + + // / + // / The domain specified in the tracking request doesn't exist. + // / + ErrorMessageTrackingNoSuchDomain, + + // / + // / The log search service can't track this message. + // / + ErrorMessageTrackingPermanentError, + + // / + // / The log search service isn't currently + // /available. Please try again later. + // / + ErrorMessageTrackingTransientError, + + // / + // / MIME content conversion failed. + // / + ErrorMimeContentConversionFailed, + + // / + // / Invalid MIME content. + // / + ErrorMimeContentInvalid, + + // / + // / Invalid base64 string for MIME content. + // / + ErrorMimeContentInvalidBase64String, + + // / + // / The subscription has missed events, + // /but will continue service on this connection. + // / + ErrorMissedNotificationEvents, + + // / + // / ErrorMissingArgument + // / + ErrorMissingArgument, + + // / + // / When making a request as an account that does + // /not have a mailbox, you must specify the + // / mailbox primary SMTP address for any distinguished folder Ids. + // / + ErrorMissingEmailAddress, + + // / + // / When making a request with an account that does not + // /have a mailbox, you must specify the + // / primary SMTP address for an existing mailbox. + // / + ErrorMissingEmailAddressForManagedFolder, + + // / + // / EmailAddress or ItemId must be included in the request. + // / + ErrorMissingInformationEmailAddress, + + // / + // / ReferenceItemId must be included in the request. + // / + ErrorMissingInformationReferenceItemId, + + // / + // / SharingFolderId must be included in the request. + // / + ErrorMissingInformationSharingFolderId, + + // / + // / An item must be specified when creating an item attachment. + // / + ErrorMissingItemForCreateItemAttachment, + + // / + // / The managed folder Id is missing. + // / + ErrorMissingManagedFolderId, + + // / + // / A message needs to have at least one recipient. + // / + ErrorMissingRecipients, + + // / + // / Missing information for delegate user. You must + // /either specify a valid SMTP address or + // / SID. + // / + ErrorMissingUserIdInformation, + + // / + // / Only one access mode header may be specified. + // / + ErrorMoreThanOneAccessModeSpecified, + + // / + // / The move or copy operation failed. + // / + ErrorMoveCopyFailed, + + // / + // / Cannot move distinguished folder. + // / + ErrorMoveDistinguishedFolder, + + // / + // / Multiple results were found. + // / + ErrorNameResolutionMultipleResults, + + // / + // / User must have a mailbox for name resolution operations. + // / + ErrorNameResolutionNoMailbox, + + // / + // / No results were found. + // / + ErrorNameResolutionNoResults, + + // / + // / Another connection was opened against this subscription. + // / + ErrorNewEventStreamConnectionOpened, + + // / + // / Exchange Web Services are not currently available + // /for this request because there are no + // / available Client Access Services Servers in the target AD Site. + // / + ErrorNoApplicableProxyCASServersAvailable, + + // / + // / ErrorNoCalendar + // / + ErrorNoCalendar, + + // / + // / Exchange Web Services aren't available for this + // /request because there is no Client Access + // / server with the necessary configuration in the + // /Active Directory site where the mailbox is + // / stored. If the problem continues, click Help. + // / + ErrorNoDestinationCASDueToKerberosRequirements, + + // / + // / Exchange Web Services aren't currently available + // /for this request because an SSL + // / connection couldn't be established to the Client + // /Access server that should be used for + // / mailbox access. If the problem continues, click Help. + // / + ErrorNoDestinationCASDueToSSLRequirements, + + // / + // / Exchange Web Services aren't currently available + // /for this request because the Client + // / Access server used for proxying has an older + // /version of Exchange installed than the + // / Client Access server in the mailbox Active Directory site. + // / + ErrorNoDestinationCASDueToVersionMismatch, + + // / + // / You cannot specify the FolderClass when creating a non-generic folder. + // / + ErrorNoFolderClassOverride, + + // / + // / ErrorNoFreeBusyAccess + // / + ErrorNoFreeBusyAccess, + + // / + // / Mailbox does not exist. + // / + ErrorNonExistentMailbox, + + // / + // / The primary SMTP address must be specified when referencing a mailbox. + // / + ErrorNonPrimarySmtpAddress, + + // / + // / Custom property cannot be specified using + // /property tags. The GUID and Id/Name + // / combination must be used instead. + // / + ErrorNoPropertyTagForCustomProperties, + + // / + // / ErrorNoPublicFolderReplicaAvailable + // / + ErrorNoPublicFolderReplicaAvailable, + + // / + // / There are no public folder servers available. + // / + ErrorNoPublicFolderServerAvailable, + + // / + // / Exchange Web Services are not currently available + // /for this request because none of the + // / Client Access Servers in the destination site could process the + // request. + // / + ErrorNoRespondingCASInDestinationSite, + + // / + // / Policy does not allow granting of permissions to external users. + // / + ErrorNotAllowedExternalSharingByPolicy, + + // / + // / The user is not a delegate for the mailbox. + // / + ErrorNotDelegate, + + // / + // / There was not enough memory to complete the request. + // / + ErrorNotEnoughMemory, + + // / + // / The sharing message is not supported. + // / + ErrorNotSupportedSharingMessage, + + // / + // / Operation would change object type, which is not permitted. + // / + ErrorObjectTypeChanged, + + // / + // / Modified occurrence is crossing or overlapping adjacent occurrence. + // / + ErrorOccurrenceCrossingBoundary, + + // / + // / One occurrence of the recurring calendar item + // /overlaps with another occurrence of the + // / same calendar item. + // / + ErrorOccurrenceTimeSpanTooBig, + + // / + // / Operation not allowed with public folder root. + // / + ErrorOperationNotAllowedWithPublicFolderRoot, + + // / + // / Organization is not federated. + // / + ErrorOrganizationNotFederated, + + // / + // / ErrorOutlookRuleBlobExists + // / + ErrorOutlookRuleBlobExists, + + // / + // / You must specify the parent folder Id for this operation. + // / + ErrorParentFolderIdRequired, + + // / + // / The specified parent folder could not be found. + // / + ErrorParentFolderNotFound, + + // / + // / Password change is required. + // / + ErrorPasswordChangeRequired, + + // / + // / Password has expired. Change password. + // / + ErrorPasswordExpired, + + // / + // / Policy does not allow granting permission level to user. + // / + ErrorPermissionNotAllowedByPolicy, + + // / + // / Dialing restrictions are preventing the phone number + // /that was entered from being dialed. + // / + ErrorPhoneNumberNotDialable, + + // / + // / Property update did not succeed. + // / + ErrorPropertyUpdate, + + // / + // / At least one property failed validation. + // / + ErrorPropertyValidationFailure, + + // / + // / Subscription related request failed because EWS + // /could not contact the appropriate CAS + // / server for this request. If this problem persists, + // /recreate the subscription. + // / + ErrorProxiedSubscriptionCallFailure, + + // / + // / Request failed because EWS could not contact + // /the appropriate CAS server for this request. + // / + ErrorProxyCallFailed, + + // / + // / Exchange Web Services (EWS) is not available for + // /this mailbox because the user account + // / associated with the mailbox is a member of + // /too many groups. EWS limits the group + // / membership it can proxy between Client Access Service Servers to 3000. + // / + ErrorProxyGroupSidLimitExceeded, + + // / + // / ErrorProxyRequestNotAllowed + // / + ErrorProxyRequestNotAllowed, + + // / + // / ErrorProxyRequestProcessingFailed + // / + ErrorProxyRequestProcessingFailed, + + // / + // / Exchange Web Services are not currently + // /available for this mailbox because it could not + // / determine the Client Access Services Server to use for the mailbox. + // / + ErrorProxyServiceDiscoveryFailed, + + // / + // / Proxy token has expired. + // / + ErrorProxyTokenExpired, + + // / + // / ErrorPublicFolderRequestProcessingFailed + // / + ErrorPublicFolderRequestProcessingFailed, + + // / + // / ErrorPublicFolderServerNotFound + // / + ErrorPublicFolderServerNotFound, + + // / + // / The search folder has a restriction that is too long to return. + // / + ErrorQueryFilterTooLong, + + // / + // / Mailbox has exceeded maximum mailbox size. + // / + ErrorQuotaExceeded, + + // / + // / Unable to retrieve events for this subscription. + // /The subscription must be recreated. + // / + ErrorReadEventsFailed, + + // / + // / Unable to suppress read receipt. Read receipts are not pending. + // / + ErrorReadReceiptNotPending, + + // / + // / Recurrence end date can not exceed Sep 1, 4500 00:00:00. + // / + ErrorRecurrenceEndDateTooBig, + + // / + // / Recurrence has no occurrences in the specified range. + // / + ErrorRecurrenceHasNoOccurrence, + + // / + // / Failed to remove one or more delegates. + // / + ErrorRemoveDelegatesFailed, + + // / + // / ErrorRequestAborted + // / + ErrorRequestAborted, + + // / + // / ErrorRequestStreamTooBig + // / + ErrorRequestStreamTooBig, + + // / + // / Required property is missing. + // / + ErrorRequiredPropertyMissing, + + // / + // / Cannot perform ResolveNames for non-contact folder. + // / + ErrorResolveNamesInvalidFolderType, + + // / + // / Only one contacts folder can be specified in request. + // / + ErrorResolveNamesOnlyOneContactsFolderAllowed, + + // / + // / The response failed schema validation. + // / + ErrorResponseSchemaValidation, + + // / + // / The restriction or sort order is too complex for this operation. + // / + ErrorRestrictionTooComplex, + + // / + // / Restriction contained too many elements. + // / + ErrorRestrictionTooLong, + + // / + // / ErrorResultSetTooBig + // / + ErrorResultSetTooBig, + + // / + // / ErrorRulesOverQuota + // / + ErrorRulesOverQuota, + + // / + // / The folder in which item were to be saved could not be found. + // / + ErrorSavedItemFolderNotFound, + + // / + // / The request failed schema validation. + // / + ErrorSchemaValidation, + + // / + // / The search folder is not initialized. + // / + ErrorSearchFolderNotInitialized, + + // / + // / The user account which was used to submit this request + // /does not have the right to send + // / mail on behalf of the specified sending account. + // / + ErrorSendAsDenied, + + // / + // / SendMeetingCancellations attribute is required for Calendar item. + // / + ErrorSendMeetingCancellationsRequired, + + // / + // / The SendMeetingInvitationsOrCancellations attribute + // /is required for calendar item. + // / + ErrorSendMeetingInvitationsOrCancellationsRequired, + + // ErrorSendMeetingInvitationsRequired + /** + * The SendMeetingInvitations attribute is required for calendar item. + */ + ErrorSendMeetingInvitationsRequired, + + // ErrorSentMeetingRequestUpdate + /** + * The meeting request has already been sent and might not be updated. + */ + ErrorSentMeetingRequestUpdate, + + // ErrorSentTaskRequestUpdate + /** + * The task request has already been sent and may not be updated. + */ + ErrorSentTaskRequestUpdate, + + // ErrorServerBusy + /** + * The server cannot service this request right now. Try again later. + */ + ErrorServerBusy, + + // ErrorServiceDiscoveryFailed + /** + * ErrorServiceDiscoveryFailed + */ + ErrorServiceDiscoveryFailed, + + // ErrorSharingNoExternalEwsAvailable + /** + * No external Exchange Web Service URL available. + */ + ErrorSharingNoExternalEwsAvailable, + + // ErrorSharingSynchronizationFailed + /** + * Failed to synchronize the sharing folder. + */ + ErrorSharingSynchronizationFailed, + + // ErrorStaleObject + /** + * The current ChangeKey is required for this operation. + */ + ErrorStaleObject, + + // ErrorSubmissionQuotaExceeded + /** + * The message couldn't be sent because the sender's submission quota was + * exceeded. Please try again later. + */ + ErrorSubmissionQuotaExceeded, + + // ErrorSubscriptionAccessDenied + /** + * Access is denied. Only the subscription owner may access the + * subscription. + */ + ErrorSubscriptionAccessDenied, + + // ErrorSubscriptionDelegateAccessNotSupported + /** + * Subscriptions are not supported for delegate user access. + */ + ErrorSubscriptionDelegateAccessNotSupported, + + // ErrorSubscriptionNotFound + /** + * The specified subscription was not found. + */ + ErrorSubscriptionNotFound, + + // ErrorSubscriptionUnsubscribed + /** + * The StreamingSubscription was unsubscribed while the current connection + * was servicing it. + */ + ErrorSubscriptionUnsubscribed, + + // ErrorSyncFolderNotFound + /** + * The folder to be synchronized could not be found. + */ + ErrorSyncFolderNotFound, + + // ErrorTimeIntervalTooBig + /** + * ErrorTimeIntervalTooBig + */ + ErrorTimeIntervalTooBig, + + // ErrorTimeoutExpired + /** + * ErrorTimeoutExpired + */ + ErrorTimeoutExpired, + + // ErrorTimeZone + /** + * The time zone isn't valid. + */ + ErrorTimeZone, + + // ErrorToFolderNotFound + /** + * The specified target folder could not be found. + */ + ErrorToFolderNotFound, + + // ErrorTokenSerializationDenied + /** + * The requesting account does not have permission to serialize tokens. + */ + ErrorTokenSerializationDenied, + + // ErrorUnableToGetUserOofSettings + /** + * ErrorUnableToGetUserOofSettings + */ + ErrorUnableToGetUserOofSettings, + + // ErrorUnifiedMessagingDialPlanNotFound + /** + * A dial plan could not be found. + */ + ErrorUnifiedMessagingDialPlanNotFound, + + // ErrorUnifiedMessagingRequestFailed + /** + * The UnifiedMessaging request failed. + */ + ErrorUnifiedMessagingRequestFailed, + + // ErrorUnifiedMessagingServerNotFound + /** + * A connection couldn't be made to the Unified Messaging server. + */ + ErrorUnifiedMessagingServerNotFound, + + // ErrorUnsupportedCulture + /** + * The specified item culture is not supported on this server. + */ + ErrorUnsupportedCulture, + + // ErrorUnsupportedMapiPropertyType + /** + * The MAPI property type is not supported. + */ + ErrorUnsupportedMapiPropertyType, + + // ErrorUnsupportedMimeConversion + /** + * MIME conversion is not supported for this item type. + */ + ErrorUnsupportedMimeConversion, + + // ErrorUnsupportedPathForQuery + /** + * The property can not be used with this type of restriction. + */ + ErrorUnsupportedPathForQuery, + + // ErrorUnsupportedPathForSortGroup + /** + * The property can not be used for sorting or grouping results. + */ + ErrorUnsupportedPathForSortGroup, + + // ErrorUnsupportedPropertyDefinition + /** + * PropertyDefinition is not supported in searches. + */ + ErrorUnsupportedPropertyDefinition, + + // ErrorUnsupportedQueryFilter + /** + * QueryFilter type is not supported. + */ + ErrorUnsupportedQueryFilter, + + // ErrorUnsupportedRecurrence + /** + * The specified recurrence is not supported. + */ + ErrorUnsupportedRecurrence, + + // ErrorUnsupportedSubFilter + /** + * Unsupported subfilter type. + */ + ErrorUnsupportedSubFilter, + + // ErrorUnsupportedTypeForConversion + /** + * Unsupported type for restriction conversion. + */ + ErrorUnsupportedTypeForConversion, + + // ErrorUpdateDelegatesFailed + /** + * Failed to update one or more delegates. + */ + ErrorUpdateDelegatesFailed, + + // ErrorUpdatePropertyMismatch + /** + * Property for update does not match property in object. + */ + ErrorUpdatePropertyMismatch, + + // ErrorUserNotAllowedByPolicy + /** + * Policy does not allow granting permissions to user. + */ + ErrorUserNotAllowedByPolicy, + + // ErrorUserNotUnifiedMessagingEnabled + /** + * The user isn't enabled for Unified Messaging + */ + ErrorUserNotUnifiedMessagingEnabled, + + // ErrorUserWithoutFederatedProxyAddress + /** + * The user doesn't have an SMTP proxy address from a federated domain. + */ + ErrorUserWithoutFederatedProxyAddress, + + // ErrorValueOutOfRange + /** + * The value is out of range. + */ + ErrorValueOutOfRange, + + // ErrorVirusDetected + /** + * Virus detected in the message. + */ + ErrorVirusDetected, + + // ErrorVirusMessageDeleted + /** + * The item has been deleted as a result of a virus scan. + */ + ErrorVirusMessageDeleted, + + // ErrorVoiceMailNotImplemented + /** + * The Voice Mail distinguished folder is not implemented. + */ + ErrorVoiceMailNotImplemented, + + // ErrorWebRequestInInvalidState + /** + * ErrorWebRequestInInvalidState + */ + ErrorWebRequestInInvalidState, + + // ErrorWin32InteropError + /** + * ErrorWin32InteropError + */ + ErrorWin32InteropError, + + // ErrorWorkingHoursSaveFailed + /** + * ErrorWorkingHoursSaveFailed + */ + ErrorWorkingHoursSaveFailed, + + // ErrorWorkingHoursXmlMalformed + /** + * ErrorWorkingHoursXmlMalformed + */ + ErrorWorkingHoursXmlMalformed, + + // ErrorWrongServerVersion + /** + * The Client Access server version doesn't match the Mailbox server version + * of the resource that was being accessed. To determine the correct URL to + * use to access the resource, use Autodiscover with the address of the + * resource. + */ + ErrorWrongServerVersion, + + // ErrorWrongServerVersionDelegate + /** + * The mailbox of the authenticating user and the mailbox of the resource + * being accessed must have the same Mailbox server version. + */ + ErrorWrongServerVersionDelegate, + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/error/WebExceptionStatus.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/error/WebExceptionStatus.java new file mode 100644 index 000000000..a4933974a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/misc/error/WebExceptionStatus.java @@ -0,0 +1,123 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.misc.error; + +public enum WebExceptionStatus { + // Summary: + // No error was encountered. + Success, + // + // Summary: + // The name resolver service could not resolve the host name. + NameResolutionFailure, + // + // Summary: + // The remote service point could not be contacted at the transport level. + ConnectFailure, + // + // Summary: + // A complete response was not received from the remote server. + ReceiveFailure, + // + // Summary: + // A complete request could not be sent to the remote server. + SendFailure, + // + // Summary: + // The request was a piplined request and the connection was closed before the + // response was received. + PipelineFailure, + // + // Summary: + // The request was canceled, the System.Net.WebRequest.Abort() method was called, + // or an unclassifiable error occurred. This is the default value for System.Net.WebException.Status. + RequestCanceled, + // + // Summary: + // The response received from the server was complete but indicated a protocol-level + // error. For example, an HTTP protocol error such as 401 Access Denied would + // use this status. + ProtocolError, + // + // Summary: + // The connection was prematurely closed. + ConnectionClosed, + // + // Summary: + // A server certificate could not be validated. + TrustFailure, + // + // Summary: + // An error occurred while establishing a connection using SSL. + SecureChannelFailure, + // + // Summary: + // The server response was not a valid HTTP response. + ServerProtocolViolation, + // + // Summary: + // The connection for a request that specifies the Keep-alive header was closed + // unexpectedly. + KeepAliveFailure, + // + // Summary: + // An internal asynchronous request is pending. + Pending, + // + // Summary: + // No response was received during the time-out period for a request. + Timeout, + // + // Summary: + // The name resolver service could not resolve the proxy host name. + ProxyNameResolutionFailure, + // + // Summary: + // An exception of unknown type has occurred. + UnknownError, + // + // Summary: + // A message was received that exceeded the specified limit when sending a request + // or receiving a response from the server. + MessageLengthLimitExceeded, + // + // Summary: + // The specified cache entry was not found. + CacheEntryNotFound, + // + // Summary: + // The request was not permitted by the cache policy. In general, this occurs + // when a request is not cacheable and the effective policy prohibits sending + // the request to the server. You might receive this status if a request method + // implies the presence of a request body, a request method requires direct + // interaction with the server, or a request contains a conditional header. + RequestProhibitedByCachePolicy, + // + // Summary: + // This request was not permitted by the proxy. + RequestProhibitedByProxy, + + +} + diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/notification/EventType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/notification/EventType.java new file mode 100644 index 000000000..ea8aadf49 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/notification/EventType.java @@ -0,0 +1,91 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.notification; + +import com.eischet.ews.api.attribute.EwsEnum; +import com.eischet.ews.api.attribute.RequiredServerVersion; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; + +/** + * Defines the types of event that can occur in a folder. + */ +public enum EventType { + // This event is sent to a client application by push notification to + // indicate that + // the subscription is still alive. + /** + * The Status. + */ + @EwsEnum(schemaName = "StatusEvent") + Status, + + // This event indicates that a new e-mail message was received. + /** + * The New mail. + */ + @EwsEnum(schemaName = "NewMailEvent") + NewMail, + + // This event indicates that an item or folder has been deleted. + /** + * The Deleted. + */ + @EwsEnum(schemaName = "DeletedEvent") + Deleted, + + // This event indicates that an item or folder has been modified. + /** + * The Modified. + */ + @EwsEnum(schemaName = "ModifiedEvent") + Modified, + + // This event indicates that an item or folder has been moved to another + // folder. + /** + * The Moved. + */ + @EwsEnum(schemaName = "MovedEvent") + Moved, + + // This event indicates that an item or folder has been copied to another + // folder. + /** + * The Copied. + */ + @EwsEnum(schemaName = "CopiedEvent") + Copied, + + // This event indicates that a new item or folder has been created. + /** + * The Created. + */ + @EwsEnum(schemaName = "CreatedEvent") + Created, + + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + @EwsEnum(schemaName = "FreeBusyChangedEvent") + FreeBusyChanged + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/permission/PermissionScope.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/permission/PermissionScope.java similarity index 79% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/permission/PermissionScope.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/permission/PermissionScope.java index fe792622c..88a962cf2 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/permission/PermissionScope.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/permission/PermissionScope.java @@ -21,26 +21,26 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.permission; +package com.eischet.ews.api.core.enumeration.permission; /** * Defines the scope of a user's permission on a folder. */ public enum PermissionScope { - /** - * The user does not have the associated permission. - */ - None, + /** + * The user does not have the associated permission. + */ + None, - /** - * The user has the associated permission on item that it owns. - */ - Owned, + /** + * The user has the associated permission on item that it owns. + */ + Owned, - /** - * The user has the associated permission on all item. - */ - All + /** + * The user has the associated permission on all item. + */ + All } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/permission/folder/DelegateFolderPermissionLevel.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/permission/folder/DelegateFolderPermissionLevel.java new file mode 100644 index 000000000..07228f25b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/permission/folder/DelegateFolderPermissionLevel.java @@ -0,0 +1,60 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.permission.folder; + +/** + * Defines a delegate user's permission level on a specific folder. + */ +public enum DelegateFolderPermissionLevel { + + // The delegate has no permission. + /** + * The None. + */ + None, + + // The delegate has Editor permissions. + /** + * The Editor. + */ + Editor, + + // The delegate has Reviewer permissions. + /** + * The Reviewer. + */ + Reviewer, + + // The delegate has Author permissions. + /** + * The Author. + */ + Author, + + // The delegate has custom permissions. + /** + * The Custom. + */ + Custom +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/permission/folder/FolderPermissionLevel.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/permission/folder/FolderPermissionLevel.java new file mode 100644 index 000000000..789e59d77 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/permission/folder/FolderPermissionLevel.java @@ -0,0 +1,107 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.permission.folder; + +//TODO : Do we want to include more information about +//what those levels actually allow users to do? + + +/** + * Defines permission levels for calendar folder. + */ +public enum FolderPermissionLevel { + + // No permission is granted. + /** + * The None. + */ + None, + + // The Owner level. + /** + * The Owner. + */ + Owner, + + // The Publishing Editor level. + /** + * The Publishing editor. + */ + PublishingEditor, + + // The Editor level. + /** + * The Editor. + */ + Editor, + + // The Pusnlishing Author level. + /** + * The Publishing author. + */ + PublishingAuthor, + + // The Author level. + /** + * The Author. + */ + Author, + + // The Non-editing Author level. + /** + * The Nonediting author. + */ + NoneditingAuthor, + + // The Reviewer level. + /** + * The Reviewer. + */ + Reviewer, + + // The Contributor level. + /** + * The Contributor. + */ + Contributor, + + // The Free/busy Time Only level. (Can only be applied to Calendar folder). + /** + * The Free busy time only. + */ + FreeBusyTimeOnly, + + // The Free/busy Time, Subject and Location level. (Can only be applied to + // Calendar folder). + /** + * The Free busy time and subject and location. + */ + FreeBusyTimeAndSubjectAndLocation, + + // The Custom level. + /** + * The Custom. + */ + Custom +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/permission/folder/FolderPermissionReadAccess.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/permission/folder/FolderPermissionReadAccess.java new file mode 100644 index 000000000..0957d2ab7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/permission/folder/FolderPermissionReadAccess.java @@ -0,0 +1,56 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.permission.folder; + +/** + * Defines a user's read access permission on item in a non-calendar folder. + */ +public enum FolderPermissionReadAccess { + + // The user has no read access on the item in the folder. + /** + * The None. + */ + None, + + // The user can read the start and end date and time of appointments. (Can + // only be applied to Calendar folder). + /** + * The Time only. + */ + TimeOnly, + + // The user can read the start and end date and time, subject and location + // of appointments. (Can only be applied to Calendar folder). + /** + * The Time and subject and location. + */ + TimeAndSubjectAndLocation, + + // The user has access to the full details of item. + /** + * The Full details. + */ + FullDetails +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/BasePropertySet.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/BasePropertySet.java new file mode 100644 index 000000000..8caae692a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/BasePropertySet.java @@ -0,0 +1,67 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +/** + * Defines base property sets that are used as the base for custom property + * sets. + */ +public enum BasePropertySet { + + // Only includes the Id of item and folder. + /** + * The Id only. + */ + IdOnly("IdOnly"), + + // Includes all the first class property of item and folder. + /** + * The First class property. + */ + FirstClassProperties("AllProperties"); + + /** + * The base shape value. + */ + private final String baseShapeValue; + + /** + * Instantiates a new base property set. + * + * @param baseShapeValue the base shape value + */ + BasePropertySet(String baseShapeValue) { + this.baseShapeValue = baseShapeValue; + } + + /** + * Gets the base shape value. + * + * @return the base shape value + */ + public String getBaseShapeValue() { + return this.baseShapeValue; + } + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/BodyType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/BodyType.java similarity index 87% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/BodyType.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/BodyType.java index aca947c18..cd54f822e 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/BodyType.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/BodyType.java @@ -21,18 +21,18 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.property; +package com.eischet.ews.api.core.enumeration.property; /** * Defines the type of body of an item. */ public enum BodyType { - /** - * The body is formatted in HTML. - */ - HTML, - /** - * The body is in plain text. - */ - Text + /** + * The body is formatted in HTML. + */ + HTML, + /** + * The body is in plain text. + */ + Text } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/ConflictType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/ConflictType.java new file mode 100644 index 000000000..e81092fb7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/ConflictType.java @@ -0,0 +1,57 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +/** + * Defines the conflict types that can be returned in meeting time suggestions. + */ +public enum ConflictType { + + // There is a conflict with an indicidual attendee. + /** + * The Individual attendee conflict. + */ + IndividualAttendeeConflict, + + // There is a conflict with at least one member of a group. + /** + * The Group conflict. + */ + GroupConflict, + + // There is a conflict with at least one member of a group, but the group + // was too big for detailed information to be returned. + /** + * The Group too big conflict. + */ + GroupTooBigConflict, + + // There is a conflict with an unresolvable attendee or an attendee that is + // not a user, group, or contact. + /** + * The Unknown attendee conflict. + */ + UnknownAttendeeConflict + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/DefaultExtendedPropertySet.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/DefaultExtendedPropertySet.java new file mode 100644 index 000000000..1ad22dc2e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/DefaultExtendedPropertySet.java @@ -0,0 +1,85 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +/** + * Defines the default sets of extended property. + */ +public enum DefaultExtendedPropertySet { + + // The Meeting extended property set. + /** + * The Meeting. + */ + Meeting, + + // The Appointment extended property set. + /** + * The Appointment. + */ + Appointment, + + // The Common extended property set. + /** + * The Common. + */ + Common, + + // The PublicStrings extended property set. + /** + * The Public strings. + */ + PublicStrings, + + // The Address extended property set. + /** + * The Address. + */ + Address, + + // The InternetHeaders extended property set. + /** + * The Internet headers. + */ + InternetHeaders, + + // The CalendarAssistants extended property set. + /** + * The Calendar assistant. + */ + CalendarAssistant, + + // The UnifiedMessaging extended property set. + /** + * The Unified messaging. + */ + UnifiedMessaging, + + // The Task extended property set. + /** + * The Task. + */ + Task + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/EmailAddressKey.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/EmailAddressKey.java similarity index 78% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/EmailAddressKey.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/EmailAddressKey.java index 71c770e7e..81772870f 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/EmailAddressKey.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/EmailAddressKey.java @@ -21,29 +21,29 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.property; +package com.eischet.ews.api.core.enumeration.property; /** * Defines e-mail address entries for a contact. */ public enum EmailAddressKey { - // The first e-mail address. - /** - * The Email address1. - */ - EmailAddress1, + // The first e-mail address. + /** + * The Email address1. + */ + EmailAddress1, - // The second e-mail address. - /** - * The Email address2. - */ - EmailAddress2, + // The second e-mail address. + /** + * The Email address2. + */ + EmailAddress2, - // The third e-mail address. - /** - * The Email address3. - */ - EmailAddress3 + // The third e-mail address. + /** + * The Email address3. + */ + EmailAddress3 } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/ImAddressKey.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/ImAddressKey.java similarity index 77% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/ImAddressKey.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/ImAddressKey.java index a118cc7a5..c508ee867 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/ImAddressKey.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/ImAddressKey.java @@ -21,28 +21,28 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.property; +package com.eischet.ews.api.core.enumeration.property; /** * Defines Instant Messaging address entries for a contact. */ public enum ImAddressKey { - // The first Instant Messaging address. - /** - * The Im address1. - */ - ImAddress1, + // The first Instant Messaging address. + /** + * The Im address1. + */ + ImAddress1, - // The second Instant Messaging address. - /** - * The Im address2. - */ - ImAddress2, + // The second Instant Messaging address. + /** + * The Im address2. + */ + ImAddress2, - // The third Instant Messaging address. - /** - * The Im address3. - */ - ImAddress3 + // The third Instant Messaging address. + /** + * The Im address3. + */ + ImAddress3 } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/Importance.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/Importance.java similarity index 82% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/Importance.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/Importance.java index e7f68b96d..87ad7905f 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/Importance.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/Importance.java @@ -21,28 +21,28 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.property; +package com.eischet.ews.api.core.enumeration.property; /** * Defines the importance of an item. */ public enum Importance { - // Low importance. - /** - * The Low. - */ - Low, + // Low importance. + /** + * The Low. + */ + Low, - // Normal importance. - /** - * The Normal. - */ - Normal, + // Normal importance. + /** + * The Normal. + */ + Normal, - // High importance. - /** - * The High. - */ - High + // High importance. + /** + * The High. + */ + High } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/LegacyFreeBusyStatus.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/LegacyFreeBusyStatus.java new file mode 100644 index 000000000..086543eeb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/LegacyFreeBusyStatus.java @@ -0,0 +1,79 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +/** + * Defines the legacy free/busy status associated with an appointment. + */ +public enum LegacyFreeBusyStatus { + + // The time slot associated with the appointment appears as free. + /** + * The Free. + */ + Free(0), + + // The time slot associated with the appointment appears as tentative. + /** + * The Tentative. + */ + Tentative(1), + + // The time slot associated with the appointment appears as busy. + /** + * The Busy. + */ + Busy(2), + + // The time slot associated with the appointment appears as Out of Office. + /** + * The OOF. + */ + OOF(3), + + // No free/busy status is associated with the appointment. + /** + * The No data. + */ + NoData(4); + + /** + * The busy status. + */ + private final int busyStatus; + + /** + * Instantiates a new legacy free busy status. + * + * @param busyStatus the busy status + */ + LegacyFreeBusyStatus(int busyStatus) { + this.busyStatus = busyStatus; + } + + public int getBusyStatus() { + return busyStatus; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/MailboxType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/MailboxType.java new file mode 100644 index 000000000..282b54a46 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/MailboxType.java @@ -0,0 +1,82 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +import com.eischet.ews.api.attribute.EwsEnum; +import com.eischet.ews.api.attribute.RequiredServerVersion; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; + +/** + * Defines the type of an EmailAddress object. + */ +public enum MailboxType { + + // Unknown mailbox type (Exchange 2010 or later). + /** + * The Unknown. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010) + Unknown, + + // The EmailAddress represents a one-off contact (Exchange 2010 or later). + /** + * The One off. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010) + OneOff, + + // The EmailAddress represents a mailbox. + /** + * The Mailbox. + */ + Mailbox, + + // The EmailAddress represents a public folder. + /** + * The Public folder. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2007_SP1) + PublicFolder, + + // The EmailAddress represents a Public Group. + /** + * The Public group. + */ + @EwsEnum(schemaName = "PublicDL") + PublicGroup, + + // The EmailAddress represents a Contact Group. + /** + * The Contact group. + */ + @EwsEnum(schemaName = "PrivateDL") + ContactGroup, + + // The EmailAddress represents a store contact or AD mail contact. + /** + * The Contact. + */ + Contact, + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/MapiPropertyType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/MapiPropertyType.java new file mode 100644 index 000000000..aadfd3dd5 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/MapiPropertyType.java @@ -0,0 +1,192 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +/** + * Defines the MAPI type of an extended property. + */ +public enum MapiPropertyType { + + // The property is of type ApplicationTime. + /** + * The Application time. + */ + ApplicationTime, + + // The property is of type ApplicationTimeArray. + /** + * The Application time array. + */ + ApplicationTimeArray, + + // The property is of type Binary. + /** + * The Binary. + */ + Binary, + + // The property is of type BinaryArray. + /** + * The Binary array. + */ + BinaryArray, + + // The property is of type Boolean. + /** + * The Boolean. + */ + Boolean, + + // The property is of type CLSID. + /** + * The CLSID. + */ + CLSID, + + // The property is of type CLSIDArray. + /** + * The CLSID array. + */ + CLSIDArray, + + // The property is of type Currency. + /** + * The Currency. + */ + Currency, + + // The property is of type CurrencyArray. + /** + * The Currency array. + */ + CurrencyArray, + + // The property is of type Double. + /** + * The Double. + */ + Double, + + // The property is of type DoubleArray. + /** + * The Double array. + */ + DoubleArray, + + // The property is of type Error. + /** + * The Error. + */ + Error, + + // The property is of type Float. + /** + * The Float. + */ + Float, + + // The property is of type FloatArray. + /** + * The Float array. + */ + FloatArray, + + // The property is of type Integer. + /** + * The Integer. + */ + Integer, + + // The property is of type IntegerArray. + /** + * The Integer array. + */ + IntegerArray, + + // The property is of type Long. + /** + * The Long. + */ + Long, + + // The property is of type LongArray. + /** + * The Long array. + */ + LongArray, + + // The property is of type Null. + /** + * The Null. + */ + Null, + + // The property is of type Object. + /** + * The Object. + */ + Object, + + // The property is of type ObjectArray. + /** + * The Object array. + */ + ObjectArray, + + // The property is of type Short. + /** + * The Short. + */ + Short, + + // The property is of type ShortArray. + /** + * The Short array. + */ + ShortArray, + + // The property is of type SystemTime. + /** + * The System time. + */ + SystemTime, + + // The property is of type SystemTimeArray. + /** + * The System time array. + */ + SystemTimeArray, + + // The property is of type String. + /** + * The String. + */ + String, + + // The property is of type StringArray. + /** + * The String array. + */ + StringArray +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/MeetingResponseType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/MeetingResponseType.java new file mode 100644 index 000000000..a085dae09 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/MeetingResponseType.java @@ -0,0 +1,67 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +/** + * Defines the types of response given to a meeting request. + */ +public enum MeetingResponseType { + + // The response type is inknown. + /** + * The Unknown. + */ + Unknown, + + // There was no response. The authenticated is the organizer of the meeting. + /** + * The Organizer. + */ + Organizer, + + // The meeting was tentatively accepted. + /** + * The Tentative. + */ + Tentative, + + // The meeting was accepted. + /** + * The Accept. + */ + Accept, + + // The meeting was declined. + /** + * The Decline. + */ + Decline, + + // No response was received for the meeting. + /** + * The No response received. + */ + NoResponseReceived + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/MemberStatus.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/MemberStatus.java similarity index 80% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/MemberStatus.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/MemberStatus.java index 981ef506d..38c415455 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/MemberStatus.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/MemberStatus.java @@ -21,29 +21,29 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.property; +package com.eischet.ews.api.core.enumeration.property; /** * Defines the status of group members. */ public enum MemberStatus { - // The member is unrecognized. - /** - * The Unrecognized. - */ - Unrecognized, + // The member is unrecognized. + /** + * The Unrecognized. + */ + Unrecognized, - // The member is normal. - /** - * The Normal. - */ - Normal, + // The member is normal. + /** + * The Normal. + */ + Normal, - // The member is demoted. - /** - * The Demoted. - */ - Demoted + // The member is demoted. + /** + * The Demoted. + */ + Demoted } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/OofExternalAudience.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/OofExternalAudience.java new file mode 100644 index 000000000..8664f825c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/OofExternalAudience.java @@ -0,0 +1,49 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +/** + * Defines the external audience of an Out of Office notification. + */ +public enum OofExternalAudience { + + // No external recipients should receive Out of Office notification. + /** + * The None. + */ + None, + + // Only recipients that are in the user's Contacts frolder should receive + // Out of Office notification. + /** + * The Known. + */ + Known, + + // All recipients should receive Out of Office notification. + /** + * The All. + */ + All +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/OofState.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/OofState.java similarity index 80% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/OofState.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/OofState.java index 9f26c13d0..88cfbc0d3 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/OofState.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/OofState.java @@ -21,28 +21,28 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.property; +package com.eischet.ews.api.core.enumeration.property; /** * Defines a user's Out of Office Assistant status. */ public enum OofState { - // The assistant is diabled. - /** - * The Disabled. - */ - Disabled, + // The assistant is diabled. + /** + * The Disabled. + */ + Disabled, - // The assistant is enabled. - /** - * The Enabled. - */ - Enabled, + // The assistant is enabled. + /** + * The Enabled. + */ + Enabled, - // The assistant is scheduled. - /** - * The Scheduled. - */ - Scheduled + // The assistant is scheduled. + /** + * The Scheduled. + */ + Scheduled } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/PhoneNumberKey.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/PhoneNumberKey.java new file mode 100644 index 000000000..c196b9d1e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/PhoneNumberKey.java @@ -0,0 +1,144 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +/** + * Defines phone number entries for a contact. + */ +public enum PhoneNumberKey { + + // The assistant's phone number. + /** + * The Assistant phone. + */ + AssistantPhone, + + // The business fax number. + /** + * The Business fax. + */ + BusinessFax, + + // The business phone number. + /** + * The Business phone. + */ + BusinessPhone, + + // The second business phone number. + /** + * The Business phone2. + */ + BusinessPhone2, + + // The callback number. + /** + * The Callback. + */ + Callback, + + // The car phone number. + /** + * The Car phone. + */ + CarPhone, + + // The company's main phone number. + /** + * The Company main phone. + */ + CompanyMainPhone, + + // The home fax number. + /** + * The Home fax. + */ + HomeFax, + + // The home phone number. + /** + * The Home phone. + */ + HomePhone, + + // The second home phone number. + /** + * The Home phone2. + */ + HomePhone2, + + // The ISDN number. + /** + * The Isdn. + */ + Isdn, + + // The mobile phone number. + /** + * The Mobile phone. + */ + MobilePhone, + + // An alternate fax number. + /** + * The Other fax. + */ + OtherFax, + + // An alternate phone number. + /** + * The Other telephone. + */ + OtherTelephone, + + // The pager number. + /** + * The Pager. + */ + Pager, + + // The primary phone number. + /** + * The Primary phone. + */ + PrimaryPhone, + + // The radio phone number. + /** + * The Radio phone. + */ + RadioPhone, + + // The Telex number. + /** + * The Telex. + */ + Telex, + + // The TTY/TTD phone number. + /** + * The Tty tdd phone. + */ + TtyTddPhone +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/PhysicalAddressIndex.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/PhysicalAddressIndex.java similarity index 78% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/PhysicalAddressIndex.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/PhysicalAddressIndex.java index de6295453..51bbb5a1c 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/PhysicalAddressIndex.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/PhysicalAddressIndex.java @@ -21,34 +21,34 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.property; +package com.eischet.ews.api.core.enumeration.property; /** * Defines a physical address index. */ public enum PhysicalAddressIndex { - // None. - /** - * The None. - */ - None, + // None. + /** + * The None. + */ + None, - // The business address. - /** - * The Business. - */ - Business, + // The business address. + /** + * The Business. + */ + Business, - // The home address. - /** - * The Home. - */ - Home, + // The home address. + /** + * The Home. + */ + Home, - // The alternate address. - /** - * The Other. - */ - Other + // The alternate address. + /** + * The Other. + */ + Other } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/PhysicalAddressKey.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/PhysicalAddressKey.java similarity index 81% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/PhysicalAddressKey.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/PhysicalAddressKey.java index 84e8a7000..5cd19b365 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/PhysicalAddressKey.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/PhysicalAddressKey.java @@ -21,29 +21,29 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.property; +package com.eischet.ews.api.core.enumeration.property; /** * Defines physical address entries for a contact. */ public enum PhysicalAddressKey { - // The business address. - /** - * The Business. - */ - Business, + // The business address. + /** + * The Business. + */ + Business, - // The home address. - /** - * The Home. - */ - Home, + // The home address. + /** + * The Home. + */ + Home, - // An alternate address. - /** - * The Other. - */ - Other + // An alternate address. + /** + * The Other. + */ + Other } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/PropertyDefinitionFlags.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/PropertyDefinitionFlags.java new file mode 100644 index 000000000..fa522c2f5 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/PropertyDefinitionFlags.java @@ -0,0 +1,80 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +/** + * defines how a complex property behaves. + */ +public enum PropertyDefinitionFlags { + + /** + * No specific behavior. + */ + None, + + /** + * The property is automatically instantiated when it is read. + */ + AutoInstantiateOnRead, + + /** + * The existing instance of the property is reusable. + */ + ReuseInstance, + + /** + * The property can be set. + */ + CanSet, + + /** + * The property can be updated. + */ + CanUpdate, + + /** + * The property can be deleted. + */ + CanDelete, + + /** + * The property can be searched. + */ + CanFind, + + /** + * The property must be loaded explicitly. + */ + MustBeExplicitlyLoaded, + + /** + * Only meaningful for "collection" property. With this flag, the item in the collection gets updated, + * instead of creating and adding new item to the collection. + * Should be used together with the ReuseInstance flag. + */ + + UpdateCollectionItems + +} + diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/RuleProperty.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/RuleProperty.java new file mode 100644 index 000000000..e36cfe785 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/RuleProperty.java @@ -0,0 +1,577 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +import com.eischet.ews.api.attribute.EwsEnum; + +public enum RuleProperty { + /** + * The RuleId property of a rule. + */ + @EwsEnum(schemaName = "RuleId") + RuleId, + + + /** + * The DisplayName property of a rule. + */ + @EwsEnum(schemaName = "DisplayName") + DisplayName, + + /** + * The Priority property of a rule. + */ + @EwsEnum(schemaName = "Priority") + Priority, + + /** + * The IsNotSupported property of a rule. + */ + @EwsEnum(schemaName = "IsNotSupported") + IsNotSupported, + + /** + * The Actions property of a rule. + */ + @EwsEnum(schemaName = "Actions") + Actions, + + /** + * The Categories property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:Categories") + ConditionCategories, + + /** + * The ContainsBodyStrings property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:ContainsBodyStrings") + ConditionContainsBodyStrings, + + /** + * The ContainsHeaderStrings property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:ContainsHeaderStrings") + ConditionContainsHeaderStrings, + + /** + * The ContainsRecipientStrings property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:ContainsRecipientStrings") + ConditionContainsRecipientStrings, + + /** + * The ContainsSenderStrings property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:ContainsSenderStrings") + ConditionContainsSenderStrings, + + /** + * The ContainsSubjectOrBodyStrings property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:ContainsSubjectOrBodyStrings") + ConditionContainsSubjectOrBodyStrings, + + /** + * The ContainsSubjectStrings property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:ContainsSubjectStrings") + ConditionContainsSubjectStrings, + + /** + * The FlaggedForAction property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:FlaggedForAction") + ConditionFlaggedForAction, + + /** + * The FromAddresses property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:FromAddresses") + ConditionFromAddresses, + + /** + * The FromConnectedAccounts property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:FromConnectedAccounts") + ConditionFromConnectedAccounts, + + /** + * The HasAttachments property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:HasAttachments") + ConditionHasAttachments, + + /** + * The Importance property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:Importance") + ConditionImportance, + + /** + * The IsApprovalRequest property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:IsApprovalRequest") + ConditionIsApprovalRequest, + + + /** + * The IsAutomaticForward property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:IsAutomaticForward") + ConditionIsAutomaticForward, + + /** + * The IsAutomaticForward property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:IsAutomaticReply") + ConditionIsAutomaticReply, + + /** + * The IsEncrypted property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:IsEncrypted") + ConditionIsEncrypted, + + /** + * The IsMeetingRequest property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:IsMeetingRequest") + ConditionIsMeetingRequest, + + /** + * The IsMeetingResponse property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:IsMeetingResponse") + ConditionIsMeetingResponse, + + /** + * The IsNonDeliveryReport property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:IsNDR") + ConditionIsNonDeliveryReport, + + /** + * The IsPermissionControlled property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:IsPermissionControlled") + ConditionIsPermissionControlled, + + /** + * The IsRead property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:IsRead") + ConditionIsRead, + + /** + * The IsSigned property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:IsSigned") + ConditionIsSigned, + + /** + * The IsVoicemail property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:IsVoicemail") + ConditionIsVoicemail, + + /** + * The IsReadReceipt property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:IsReadReceipt") + ConditionIsReadReceipt, + + /** + * The ItemClasses property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:ItemClasses") + ConditionItemClasses, + + /** + * The MessageClassifications property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:MessageClassifications") + ConditionMessageClassifications, + + /** + * The NotSentToMe property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:NotSentToMe") + ConditionNotSentToMe, + + /** + * The SentCcMe property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:SentCcMe") + ConditionSentCcMe, + + /** + * The SentOnlyToMe property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:SentOnlyToMe") + ConditionSentOnlyToMe, + + /** + * The SentToAddresses property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:SentToAddresses") + ConditionSentToAddresses, + + /** + * The SentToMe property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:SentToMe") + ConditionSentToMe, + + /** + * The SentToOrCcMe property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:SentToOrCcMe") + ConditionSentToOrCcMe, + + /** + * The Sensitivity property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:Sensitivity") + ConditionSensitivity, + + /** + * The WithinDateRange property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:WithinDateRange") + ConditionWithinDateRange, + + /** + * The WithinSizeRange property of a rule's set of conditions. + */ + @EwsEnum(schemaName = "Condition:WithinSizeRange") + ConditionWithinSizeRange, + + /** + * The Categories property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:Categories") + ExceptionCategories, + + /** + * The ContainsBodyStrings property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:ContainsBodyStrings") + ExceptionContainsBodyStrings, + + /** + * The ContainsHeaderStrings property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:ContainsHeaderStrings") + ExceptionContainsHeaderStrings, + + /** + * The ContainsRecipientStrings property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:ContainsRecipientStrings") + ExceptionContainsRecipientStrings, + + /** + * The ContainsSenderStrings property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:ContainsSenderStrings") + ExceptionContainsSenderStrings, + + /** + * The ContainsSubjectOrBodyStrings property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:ContainsSubjectOrBodyStrings") + ExceptionContainsSubjectOrBodyStrings, + + /** + * The ContainsSubjectStrings property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:ContainsSubjectStrings") + ExceptionContainsSubjectStrings, + + /** + * The FlaggedForAction property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:FlaggedForAction") + ExceptionFlaggedForAction, + + /** + * The FromAddresses property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:FromAddresses") + ExceptionFromAddresses, + + /** + * The FromConnectedAccounts property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:FromConnectedAccounts") + ExceptionFromConnectedAccounts, + + /** + * The HasAttachments property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:HasAttachments") + ExceptionHasAttachments, + + /** + * The Importance property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:Importance") + ExceptionImportance, + + /** + * The IsApprovalRequest property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:IsApprovalRequest") + ExceptionIsApprovalRequest, + + /** + * The IsAutomaticForward property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:IsAutomaticForward") + ExceptionIsAutomaticForward, + + /** + * The IsAutomaticReply property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:IsAutomaticReply") + ExceptionIsAutomaticReply, + + /** + * The IsEncrypted property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:IsEncrypted") + ExceptionIsEncrypted, + + /** + * The IsMeetingRequest property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:IsMeetingRequest") + ExceptionIsMeetingRequest, + + /** + * The IsMeetingResponse property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:IsMeetingResponse") + ExceptionIsMeetingResponse, + + /** + * The IsNonDeliveryReport property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:IsNDR") + ExceptionIsNonDeliveryReport, + + /** + * The IsPermissionControlled property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:IsPermissionControlled") + ExceptionIsPermissionControlled, + + /** + * The IsRead property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:IsRead") + ExceptionIsRead, + + /** + * The IsSigned property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:IsSigned") + ExceptionIsSigned, + + /** + * The IsVoicemail property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:IsVoicemail") + ExceptionIsVoicemail, + + /** + * The ItemClasses property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:ItemClasses") + ExceptionItemClasses, + + /** + * The MessageClassifications property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:MessageClassifications") + ExceptionMessageClassifications, + + /** + * The NotSentToMe property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:NotSentToMe") + ExceptionNotSentToMe, + + /** + * The SentCcMe property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:SentCcMe") + ExceptionSentCcMe, + + /** + * The SentOnlyToMe property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:SentOnlyToMe") + ExceptionSentOnlyToMe, + + /** + * The SentToAddresses property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:SentToAddresses") + ExceptionSentToAddresses, + + /** + * The SentToMe property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:SentToMe") + ExceptionSentToMe, + + /** + * The SentToOrCcMe property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:SentToOrCcMe") + ExceptionSentToOrCcMe, + + /** + * The Sensitivity property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:Sensitivity") + ExceptionSensitivity, + + /** + * The WithinDateRange property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:WithinDateRange") + ExceptionWithinDateRange, + + /** + * The WithinSizeRange property of a rule's set of exception. + */ + @EwsEnum(schemaName = "Exception:WithinSizeRange") + ExceptionWithinSizeRange, + + /** + * The Categories property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:Categories") + ActionCategories, + + /** + * The CopyToFolder property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:CopyToFolder") + ActionCopyToFolder, + + /** + * The Delete property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:Delete") + ActionDelete, + + /** + * The ForwardAsAttachmentToRecipients property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:ForwardAsAttachmentToRecipients") + ActionForwardAsAttachmentToRecipients, + + /** + * The ForwardToRecipients property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:ForwardToRecipients") + ActionForwardToRecipients, + + /** + * The Importance property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:Importance") + ActionImportance, + + /** + * The MarkAsRead property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:MarkAsRead") + ActionMarkAsRead, + + /** + * The MoveToFolder property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:MoveToFolder") + ActionMoveToFolder, + + /** + * The PermanentDelete property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:PermanentDelete") + ActionPermanentDelete, + + /** + * The RedirectToRecipients property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:RedirectToRecipients") + ActionRedirectToRecipients, + + /** + * The SendSMSAlertToRecipients property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:SendSMSAlertToRecipients") + ActionSendSMSAlertToRecipients, + + /** + * The ServerReplyWithMessage property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:ServerReplyWithMessage") + ActionServerReplyWithMessage, + + /** + * The StopProcessingRules property in a rule's set of actions. + */ + @EwsEnum(schemaName = "Action:StopProcessingRules") + ActionStopProcessingRules, + + /** + * The IsEnabled property of a rule, indicating if the rule is enabled. + */ + @EwsEnum(schemaName = "IsEnabled") + IsEnabled, + + /** + * The IsInError property of a rule, indicating if the rule is in error. + */ + @EwsEnum(schemaName = "IsInError") + IsInError, + + /** + * The Conditions property of a rule, contains all conditions of the rule. + */ + @EwsEnum(schemaName = "Conditions") + Conditions, + + /** + * The Exceptions property of a rule, contains all exception of the rule. + */ + @EwsEnum(schemaName = "Exceptions") + Exceptions + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/Sensitivity.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/Sensitivity.java similarity index 75% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/Sensitivity.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/Sensitivity.java index bb67b2761..a608a67d3 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/Sensitivity.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/Sensitivity.java @@ -21,35 +21,35 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.property; +package com.eischet.ews.api.core.enumeration.property; /** * Defines the sensitivity of an item. */ public enum Sensitivity { - // The item has a normal sensitivity. - /** - * The Normal. - */ - Normal, + // The item has a normal sensitivity. + /** + * The Normal. + */ + Normal, - // The item is personal. - /** - * The Personal. - */ - Personal, + // The item is personal. + /** + * The Personal. + */ + Personal, - // The item is private. - /** - * The Private. - */ - Private, + // The item is private. + /** + * The Private. + */ + Private, - // The item is confidential. - /** - * The Confidential. - */ - Confidential + // The item is confidential. + /** + * The Confidential. + */ + Confidential } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/StandardUser.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/StandardUser.java similarity index 78% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/StandardUser.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/StandardUser.java index c233134d4..aeec65cc3 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/StandardUser.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/StandardUser.java @@ -21,24 +21,24 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.property; +package com.eischet.ews.api.core.enumeration.property; /** * Defines a standard delegate user. */ public enum StandardUser { - // The Default delegate user, used to define default delegation permissions. - /** - * The Default. - */ - Default, + // The Default delegate user, used to define default delegation permissions. + /** + * The Default. + */ + Default, - // The Anonymous delegate user, used to define delegate permissions for - // unauthenticated users. - /** - * The Anonymous. - */ - Anonymous + // The Anonymous delegate user, used to define delegate permissions for + // unauthenticated users. + /** + * The Anonymous. + */ + Anonymous } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/TaskDelegationState.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/TaskDelegationState.java new file mode 100644 index 000000000..ce7cb29bd --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/TaskDelegationState.java @@ -0,0 +1,67 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +/** + * This maps to the bogus TaskDelegationState in the EWS schema. + * The schema enum has 6 values, but XSO should never return anything but + * values between 0 and 3, so we should be safe without mappings for + * EWS's Declined and Max values + */ + + +/** + * Defines the delegation state of a task. + */ +public enum TaskDelegationState { + + // The task is not delegated + /** + * The No delegation. + */ + NoDelegation, // Maps to NoMatch + + // The task's delegation state is unknown. + /** + * The Unknown. + */ + Unknown, // Maps to OwnNew + + // The task was delegated and the delegation was accepted. + /** + * The Accepted. + */ + Accepted, // Maps to Owned + + // The task was delegated but the delegation was declined. + /** + * The Declined. + */ + Declined + // Maps to Accepted + + // The original Declined value has no mapping + // The original Max value has no mapping + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/UserConfigurationDictionaryObjectType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/UserConfigurationDictionaryObjectType.java new file mode 100644 index 000000000..4fe822990 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/UserConfigurationDictionaryObjectType.java @@ -0,0 +1,91 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +/** + * Identifies the user configuration dictionary key and value types. + */ +public enum UserConfigurationDictionaryObjectType { + + // DateTime type. + /** + * The Date time. + */ + DateTime, + + // Boolean type. + /** + * The Boolean. + */ + Boolean, + + // Byte type. + /** + * The Byte. + */ + Byte, + + // String type. + /** + * The String. + */ + String, + + // 32-bit integer type. + /** + * The Integer32. + */ + Integer32, + + // 32-bit unsigned integer type. + /** + * The Unsigned integer32. + */ + UnsignedInteger32, + + // 64-bit integer type. + /** + * The Integer64. + */ + Integer64, + + // 64-bit unsigned integer type. + /** + * The Unsigned integer64. + */ + UnsignedInteger64, + + // String array type. + /** + * The String array. + */ + StringArray, + + // Byte array type + /** + * The Byte array. + */ + ByteArray, + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/WellKnownFolderName.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/WellKnownFolderName.java new file mode 100644 index 000000000..d57daacfc --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/WellKnownFolderName.java @@ -0,0 +1,187 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property; + +import com.eischet.ews.api.attribute.RequiredServerVersion; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; + +/** + * Defines well known folder names. + */ +public enum WellKnownFolderName { + + /** + * The Calendar folder. + */ + Calendar, + + /** + * The Contacts folder. + */ + Contacts, + + /** + * The Deleted Items folder. + */ + DeletedItems, + + /** + * The Drafts folder. + */ + Drafts, + + /** + * The Inbox folder. + */ + Inbox, + + /** + * The Journal folder. + */ + Journal, + + /** + * The Notes folder. + */ + Notes, + + /** + * The Outbox folder. + */ + Outbox, + + /** + * The Sent Items folder. + */ + SentItems, + + /** + * The Tasks folder. + */ + Tasks, + + /** + * The message folder root. + */ + MsgFolderRoot, + + /** + * The root of the Public Folders hierarchy. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2007_SP1) + PublicFoldersRoot, + + /** + * The root of the mailbox. + */ + Root, + + /** + * The Junk E-mail folder. + */ + JunkEmail, + + /** + * The Search Folders folder, also known as the Finder folder. + */ + SearchFolders, + + /** + * The Voicemail folder. + */ + VoiceMail, + + /** + * The Dumpster 2.0 root folder. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + RecoverableItemsRoot, + + /** + * The Dumpster 2.0 soft deletions folder. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + RecoverableItemsDeletions, + + /** + * The Dumpster 2.0 versions folder. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + RecoverableItemsVersions, + + /** + * The Dumpster 2.0 hard deletions folder. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + RecoverableItemsPurges, + + /** + * The root of the archive mailbox. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + ArchiveRoot, + + /** + * The message folder root in the archive mailbox. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + ArchiveMsgFolderRoot, + + /** + * The Deleted Items folder in the archive mailbox. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + ArchiveDeletedItems, + + /** + * The Dumpster 2.0 root folder in the archive mailbox. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + ArchiveRecoverableItemsRoot, + + /** + * The Dumpster 2.0 soft deletions folder in the archive mailbox. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + ArchiveRecoverableItemsDeletions, + + /** + * The Dumpster 2.0 versions folder in the archive mailbox. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + ArchiveRecoverableItemsVersions, + + /** + * The Dumpster 2.0 hard deletions folder in the archive mailbox. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + ArchiveRecoverableItemsPurges, + + + // Original pull request: https://github.com/OfficeDev/ews-java-api/pull/527/commits/70add8c4a2d910b87e1770cf732b0e079e4800b0 + SyncIssues, Conflicts, LocalFailures, ServerFailures, RecipientCache, QuickContacts, ConversationHistory, ToDoSearch + + + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/error/RuleErrorCode.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/error/RuleErrorCode.java new file mode 100644 index 000000000..e22463b3f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/error/RuleErrorCode.java @@ -0,0 +1,155 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property.error; + +/** + * Defines the error codes identifying why a rule failed validation. + */ +public enum RuleErrorCode { + + /** + * Active Directory operation failed. + */ + ADOperationFailure, + + /** + * The e-mail account specified in the + * FromConnectedAccounts predicate was not found. + */ + ConnectedAccountNotFound, + + /** + * The Rule object in a CreateInboxRuleOperation has an Id. The Ids of new + * rules are generated server side and + * should not be provided by the client. + */ + CreateWithRuleId, + + /** + * The value is empty. An empty value is not allowed for the property. + */ + EmptyValueFound, + + /** + * There already is a rule with the same priority. + */ + DuplicatedPriority, + + /** + * There are multiple operations against the same rule. + * Only one operation per rule is allowed. + */ + DuplicatedOperationOnTheSameRule, + + /** + * The folder does not exist in the user's mailbox. + */ + FolderDoesNotExist, + + /** + * The e-mail address is invalid. + */ + InvalidAddress, + + /** + * The date range is invalid. + */ + InvalidDateRange, + + /** + * The folder Id is invalid. + */ + InvalidFolderId, + + /** + * The size range is invalid. + */ + InvalidSizeRange, + + /** + * The value is invalid. + */ + InvalidValue, + + /** + * The message classification was not found. + */ + MessageClassificationNotFound, + + /** + * No action was specified. At least one action must be specified. + */ + MissingAction, + + /** + * The required parameter is missing. + */ + MissingParameter, + + /** + * The range value is missing. + */ + MissingRangeValue, + + /** + * The property cannot be modified. + */ + NotSettable, + + /** + * The recipient does not exist. + */ + RecipientDoesNotExist, + + /** + * The rule was not found. + */ + RuleNotFound, + + /** + * The size is less than zero. + */ + SizeLessThanZero, + + /** + * The string value is too big. + */ + StringValueTooBig, + + /** + * The address is unsupported. + */ + UnsupportedAddress, + + /** + * An unexpected error occured. + */ + UnexpectedError, + + /** + * The rule is not supported. + */ + UnsupportedRule +} + diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/time/DayOfTheWeek.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/time/DayOfTheWeek.java new file mode 100644 index 000000000..a2fd26a93 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/time/DayOfTheWeek.java @@ -0,0 +1,117 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property.time; + +import java.util.Calendar; + +/** + * Specifies the day of the week. For the standard days of the week (Sunday, + * Monday...) the DayOfTheWeek enum value is the same as the System.DayOfWeek + * enum type. These values can be safely cast between the two enum types. The + * special days of the week (Day, Weekday and WeekendDay) are used for monthly + * and yearly recurrences and cannot be cast to System.DayOfWeek values. + */ +public enum DayOfTheWeek { + + // Sunday + /** + * The Sunday. + */ + Sunday(Calendar.SUNDAY), + + // Monday + /** + * The Monday. + */ + Monday(Calendar.MONDAY), + + // Tuesday + /** + * The Tuesday. + */ + Tuesday(Calendar.TUESDAY), + + // Wednesday + /** + * The Wednesday. + */ + Wednesday(Calendar.WEDNESDAY), + + // Thursday + /** + * The Thursday. + */ + Thursday(Calendar.THURSDAY), + + // Friday + /** + * The Friday. + */ + Friday(Calendar.FRIDAY), + + // Saturday + /** + * The Saturday. + */ + Saturday(Calendar.SATURDAY), + + // Any day of the week + /** + * The Day. + */ + Day(), + + // Any day of the usual business week (Monday-Friday) + /** + * The Weekday. + */ + Weekday(), + + // Any weekend day (Saturday or Sunday) + /** + * The Weekend day. + */ + WeekendDay; + + /** + * The day of week. + */ + private int dayOfWeek = 0; + + /** + * Instantiates a new day of the week. + * + * @param dayOfWeek the day of week + */ + DayOfTheWeek(int dayOfWeek) { + this.dayOfWeek = dayOfWeek; + } + + /** + * Instantiates a new day of the week. + */ + DayOfTheWeek() { + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/time/DayOfTheWeekIndex.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/time/DayOfTheWeekIndex.java new file mode 100644 index 000000000..447194be4 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/time/DayOfTheWeekIndex.java @@ -0,0 +1,65 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property.time; + +/** + * Defines the index of a week day within a month. + */ +public enum DayOfTheWeekIndex { + + // The first specific day of the week in the month. For example, the first + // Tuesday of the month. + /** + * The First. + */ + First, + + // The second specific day of the week in the month. For example, the second + // Tuesday of the month. + /** + * The Second. + */ + Second, + + // The third specific day of the week in the month. For example, the third + // Tuesday of the month. + /** + * The Third. + */ + Third, + + // The fourth specific day of the week in the month. For example, the fourth + // Tuesday of the month. + /** + * The Fourth. + */ + Fourth, + + // The last specific day of the week in the month. For example, the last + // Tuesday of the month. + /** + * The Last. + */ + Last +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/time/Month.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/time/Month.java new file mode 100644 index 000000000..b19767be1 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/property/time/Month.java @@ -0,0 +1,116 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.property.time; + +/** + * Defines months of the year. + */ +public enum Month { + + // January. + /** + * The January. + */ + January(1), + + // February. + /** + * The February. + */ + February(2), + + // March. + /** + * The March. + */ + March(3), + + // April. + /** + * The April. + */ + April(4), + + // May. + /** + * The May. + */ + May(5), + + // June. + /** + * The June. + */ + June(6), + + // July. + /** + * The July. + */ + July(7), + + // August. + /** + * The August. + */ + August(8), + + // September. + /** + * The September. + */ + September(9), + + // October. + /** + * The October. + */ + October(10), + + // November. + /** + * The November. + */ + November(11), + + // December. + /** + * The December. + */ + December(12); + + /** + * The month. + */ + private final int month; + + /** + * Instantiates a new month. + * + * @param month the month + */ + Month(int month) { + this.month = month; + } +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/AggregateType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/AggregateType.java similarity index 84% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/AggregateType.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/AggregateType.java index e4b90b2c5..3c5bf7c95 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/AggregateType.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/AggregateType.java @@ -21,22 +21,22 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.search; +package com.eischet.ews.api.core.enumeration.search; /** * Defines the type of aggregation to perform. */ public enum AggregateType { - // The maximum value is calculated. - /** - * The Minimum. - */ - Minimum, + // The maximum value is calculated. + /** + * The Minimum. + */ + Minimum, - // The minimum value is calculated. - /** - * The Maximum. - */ - Maximum + // The minimum value is calculated. + /** + * The Maximum. + */ + Maximum } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/ComparisonMode.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/ComparisonMode.java new file mode 100644 index 000000000..db340b058 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/ComparisonMode.java @@ -0,0 +1,69 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.search; + +/** + * Defines the way values are compared in search filter. + */ +public enum ComparisonMode { + + // The comparison is exact. + /** + * The Exact. + */ + Exact, + + // The comparison ignores casing. + /** + * The Ignore case. + */ + IgnoreCase, + + // The comparison ignores spacing characters. + /** + * The Ignore non spacing characters. + */ + IgnoreNonSpacingCharacters, + + // The comparison ignores casing and spacing characters. + /** + * The Ignore case and non spacing characters. + */ + IgnoreCaseAndNonSpacingCharacters + + // From bug E12:113326 + // + // Although the following four values are defined in + // the EWS schema, they are useless + // as they are all thechnically equivalent to Loose. + // We are not exposing those values + // in this API. When we encounter one of these + // values on an existing search folder + // restriction, we map it to IgnoreCaseAndNonSpacingCharacters. + // + // Loose, + // LooseAndIgnoreCase, + // LooseAndIgnoreNonSpace, + // LooseAndIgnoreCaseAndIgnoreNonSpace +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/ContainmentMode.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/ContainmentMode.java new file mode 100644 index 000000000..2ff703558 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/ContainmentMode.java @@ -0,0 +1,62 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.search; + +/** + * Defines the containment mode for Contains search filter. + */ +public enum ContainmentMode { + + // The comparison is between the full string and the constant. The property + // value and the supplied constant are precisely the same. + /** + * The Full string. + */ + FullString, + + // The comparison is between the string prefix and the constant. + /** + * The Prefixed. + */ + Prefixed, + + // The comparison is between a substring of the string and the constant. + /** + * The Substring. + */ + Substring, + + // The comparison is between a prefix on individual words in the string and + // the constant. + /** + * The Prefix on words. + */ + PrefixOnWords, + + // The comparison is between an exact phrase in the string and the constant. + /** + * The Exact phrase. + */ + ExactPhrase +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/FolderTraversal.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/FolderTraversal.java similarity index 79% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/FolderTraversal.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/FolderTraversal.java index 1c8aa8ae3..31a4a9c9d 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/FolderTraversal.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/FolderTraversal.java @@ -21,29 +21,29 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.search; +package com.eischet.ews.api.core.enumeration.search; /** * Defines the scope of FindFolders operations. */ public enum FolderTraversal { - // Only direct sub-folder are retrieved. - /** - * The Shallow. - */ - Shallow, + // Only direct sub-folder are retrieved. + /** + * The Shallow. + */ + Shallow, - // The entire hierarchy of sub-folder is retrieved. - /** - * The Deep. - */ - Deep, + // The entire hierarchy of sub-folder is retrieved. + /** + * The Deep. + */ + Deep, - // Only soft deleted folder are retrieved. - /** - * The Soft deleted. - */ - SoftDeleted + // Only soft deleted folder are retrieved. + /** + * The Soft deleted. + */ + SoftDeleted } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/ItemTraversal.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/ItemTraversal.java new file mode 100644 index 000000000..3a2ca0625 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/ItemTraversal.java @@ -0,0 +1,52 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.search; + +import com.eischet.ews.api.attribute.RequiredServerVersion; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; + +/** + * Defines the scope of FindItems operations. + */ +public enum ItemTraversal { + + // All non deleted item in the specified folder are retrieved. + /** + * The Shallow. + */ + Shallow, + + // Only soft-deleted item are retrieved. + /** + * The Soft deleted. + */ + SoftDeleted, + + // Only associated item are retrieved (Exchange 2010 or later). + /** + * The Associated. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010) + Associated +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/LogicalOperator.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/LogicalOperator.java similarity index 87% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/LogicalOperator.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/LogicalOperator.java index 5405a9dbd..5145489d7 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/LogicalOperator.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/LogicalOperator.java @@ -21,23 +21,23 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.search; +package com.eischet.ews.api.core.enumeration.search; /** * Defines a logical operator as used by search filter collections. */ public enum LogicalOperator { - // The AND operator. - /** - * The And. - */ - And, + // The AND operator. + /** + * The And. + */ + And, - // The OR operator. - /** - * The Or. - */ - Or + // The OR operator. + /** + * The Or. + */ + Or } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/OffsetBasePoint.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/OffsetBasePoint.java similarity index 83% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/OffsetBasePoint.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/OffsetBasePoint.java index 56f47ea25..c4789c552 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/OffsetBasePoint.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/OffsetBasePoint.java @@ -21,23 +21,23 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.search; +package com.eischet.ews.api.core.enumeration.search; /** * Defines the offset's base point in a paged view. */ public enum OffsetBasePoint { - // The offset is from the beginning of the view. - /** - * The Beginning. - */ - Beginning, + // The offset is from the beginning of the view. + /** + * The Beginning. + */ + Beginning, - // The offset is from the end of the view. - /** - * The End. - */ - End + // The offset is from the end of the view. + /** + * The End. + */ + End } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/ResolveNameSearchLocation.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/ResolveNameSearchLocation.java new file mode 100644 index 000000000..f18c0b44a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/ResolveNameSearchLocation.java @@ -0,0 +1,56 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.search; + +/** + * Defines the location where a ResolveName operation searches for contacts. + */ +public enum ResolveNameSearchLocation { + + // The name is resolved against the Global Address List. + /** + * The Directory only. + */ + DirectoryOnly, + + // The name is resolved against the Global Address List and then against the + // Contacts folder if no match was found. + /** + * The Directory then contacts. + */ + DirectoryThenContacts, + + // The name is resolved against the Contacts folder. + /** + * The Contacts only. + */ + ContactsOnly, + + // The name is resolved against the Contacts folder and then against the + // Global Address List if no match was found. + /** + * The Contacts then directory. + */ + ContactsThenDirectory +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/SearchFolderTraversal.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/SearchFolderTraversal.java similarity index 82% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/SearchFolderTraversal.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/SearchFolderTraversal.java index 17d681a6d..a76921789 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/SearchFolderTraversal.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/SearchFolderTraversal.java @@ -21,23 +21,23 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.search; +package com.eischet.ews.api.core.enumeration.search; /** * Defines the scope of a search folder. */ public enum SearchFolderTraversal { - // Items belonging to the root folder are retrieved. - /** - * The Shallow. - */ - Shallow, + // Items belonging to the root folder are retrieved. + /** + * The Shallow. + */ + Shallow, - // Items belonging to the root folder and its sub-folder are retrieved. - /** - * The Deep. - */ - Deep + // Items belonging to the root folder and its sub-folder are retrieved. + /** + * The Deep. + */ + Deep } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/SortDirection.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/SortDirection.java similarity index 82% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/SortDirection.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/SortDirection.java index 3f561adfb..91171503e 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/SortDirection.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/search/SortDirection.java @@ -21,22 +21,22 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.search; +package com.eischet.ews.api.core.enumeration.search; /** * Defines a sort direction. */ public enum SortDirection { - // The sort is performed in ascending order. - /** - * The Ascending. - */ - Ascending, + // The sort is performed in ascending order. + /** + * The Ascending. + */ + Ascending, - // The sort is performed in descending order. - /** - * The Descending. - */ - Descending + // The sort is performed in descending order. + /** + * The Descending. + */ + Descending } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ConflictResolutionMode.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ConflictResolutionMode.java new file mode 100644 index 000000000..34753bace --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ConflictResolutionMode.java @@ -0,0 +1,50 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + +/** + * Defines how conflict resolutions are handled in update operations. + */ +public enum ConflictResolutionMode { + + // Local property changes are discarded. + /** + * The Never overwrite. + */ + NeverOverwrite, + + // Local property changes are applied to the server unless the server-side + // copy is more recent than the local copy. + /** + * The Auto resolve. + */ + AutoResolve, + + // Local property changes overwrite server-side changes. + /** + * The Always overwrite. + */ + AlwaysOverwrite + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ContactSource.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ContactSource.java similarity index 81% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ContactSource.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ContactSource.java index c665e8347..023a1f18d 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ContactSource.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ContactSource.java @@ -21,22 +21,22 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.service; +package com.eischet.ews.api.core.enumeration.service; /** * Defines the source of a contact or group. */ public enum ContactSource { - // The contact or group is stored in the Global Address List - /** - * The Active directory. - */ - ActiveDirectory, + // The contact or group is stored in the Global Address List + /** + * The Active directory. + */ + ActiveDirectory, - // The contact or group is stored in Exchange. - /** - * The Store. - */ - Store + // The contact or group is stored in Exchange. + /** + * The Store. + */ + Store } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ConversationFlagStatus.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ConversationFlagStatus.java similarity index 86% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ConversationFlagStatus.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ConversationFlagStatus.java index ac4700c9a..cb24aee3e 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ConversationFlagStatus.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ConversationFlagStatus.java @@ -21,26 +21,26 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.service; +package com.eischet.ews.api.core.enumeration.service; /** * Defines the flag status of a Conversation. */ public enum ConversationFlagStatus { - /** - * Not Flagged. - */ - NotFlagged, + /** + * Not Flagged. + */ + NotFlagged, - /** - * Flagged. - */ - Flagged, + /** + * Flagged. + */ + Flagged, - /** - * Complete. - */ - Complete + /** + * Complete. + */ + Complete } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/DeleteMode.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/DeleteMode.java new file mode 100644 index 000000000..d7e955275 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/DeleteMode.java @@ -0,0 +1,50 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + +/** + * Represents deletion modes. + */ +public enum DeleteMode { + + // The item or folder will be permanently deleted. + /** + * The Hard delete. + */ + HardDelete, + + // The item or folder will be moved to the dumpster. Items and folder in + // the dumpster can be recovered. + /** + * The Soft delete. + */ + SoftDelete, + + // The item or folder will be moved to the mailbox' Deleted Items folder. + /** + * The Move to deleted item. + */ + MoveToDeletedItems + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/EffectiveRights.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/EffectiveRights.java new file mode 100644 index 000000000..6db13b6bf --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/EffectiveRights.java @@ -0,0 +1,95 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + +/** + * Defines the effective user rights associated with an item or folder. + */ +public enum EffectiveRights { + + // The user has no acces right on the item or folder. + /** + * The None. + */ + None(0), + + // The user can create associated item (FAI) + /** + * The Create associated. + */ + CreateAssociated(1), + + // The user can create item. + /** + * The Create contents. + */ + CreateContents(2), + + // The user can create sub-folder. + + /** + * The Create hierarchy. + */ + CreateHierarchy(4), + + // The user can delete item and/or folder. + /** + * The Delete. + */ + Delete(8), + + // The user can modify the property of item and/or folder. + /** + * The Modify. + */ + Modify(16), + + // The user can read the contents of item. + /** + * The Read. + */ + Read(32), + + /// The user can view private item. + /** + * The View Private Items. + */ + ViewPrivateItems(64); + + + /** + * The effective rights. + */ + private final int effectiveRights; + + /** + * Instantiates a new effective rights. + * + * @param effectiveRights the effective rights + */ + EffectiveRights(int effectiveRights) { + this.effectiveRights = effectiveRights; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/FileAsMapping.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/FileAsMapping.java new file mode 100644 index 000000000..7356d6d83 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/FileAsMapping.java @@ -0,0 +1,160 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + +import com.eischet.ews.api.attribute.EwsEnum; +import com.eischet.ews.api.attribute.RequiredServerVersion; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; + +/** + * Defines the way the FileAs property of a contact is automatically formatted. + */ +public enum FileAsMapping { + // No automatic formatting is used. + /** + * The None. + */ + None, + + // Surname, GivenName + /** + * The Surname comma given name. + */ + @EwsEnum(schemaName = "LastCommaFirst") + SurnameCommaGivenName, + + // GivenName Surname + /** + * The Given name space surname. + */ + @EwsEnum(schemaName = "FirstSpaceLast") + GivenNameSpaceSurname, + + // Company + /** + * The Company. + */ + Company, + + // Surname, GivenName (Company) + /** + * The Surname comma given name company. + */ + @EwsEnum(schemaName = "LastCommaFirstCompany") + SurnameCommaGivenNameCompany, + + // Company (SurnameGivenName) + /** + * The Company surname given name. + */ + @EwsEnum(schemaName = "CompanyLastFirst") + CompanySurnameGivenName, + + // SurnameGivenName + /** + * The Surname given name. + */ + @EwsEnum(schemaName = "LastFirst") + SurnameGivenName, + + // SurnameGivenName (Company) + /** + * The Surname given name company. + */ + @EwsEnum(schemaName = "LastFirstCompany") + SurnameGivenNameCompany, + + // Company (Surname, GivenName) + /** + * The Company surname comma given name. + */ + @EwsEnum(schemaName = "CompanyLastCommaFirst") + CompanySurnameCommaGivenName, + + // SurnameGivenName Suffix + /** + * The Surname given name suffix. + */ + @EwsEnum(schemaName = "LastFirstSuffix") + SurnameGivenNameSuffix, + + // Surname GivenName (Company) + /** + * The Surname space given name company. + */ + @EwsEnum(schemaName = "LastSpaceFirstCompany") + SurnameSpaceGivenNameCompany, + + // Company (Surname GivenName) + /** + * The Company surname space given name. + */ + @EwsEnum(schemaName = "CompanyLastSpaceFirst") + CompanySurnameSpaceGivenName, + + // Surname GivenName + /** + * The Surname space given name. + */ + @EwsEnum(schemaName = "LastSpaceFirst") + SurnameSpaceGivenName, + + // Display Name (Exchange 2010 or later). + /** + * The Display name. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010) + DisplayName, + + // GivenName (Exchange 2010 or later). + /** + * The Given name. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010) + @EwsEnum(schemaName = "FirstName") + GivenName, + + // Surname GivenName Middle Suffix (Exchange 2010 or later). + /** + * The Surname given name middle suffix. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010) + @EwsEnum(schemaName = "LastFirstMiddleSuffix") + SurnameGivenNameMiddleSuffix, + + // Surname (Exchange 2010 or later). + /** + * The Surname. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010) + @EwsEnum(schemaName = "LastName") + Surname, + + // Empty (Exchange 2010 or later). + /** + * The Empty. + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010) + Empty +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/MeetingRequestType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/MeetingRequestType.java new file mode 100644 index 000000000..02af539d6 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/MeetingRequestType.java @@ -0,0 +1,74 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + +/** + * Defines the type of a meeting request. + */ +public enum MeetingRequestType { + + // Undefined meeting request type. + /** + * The None. + */ + None, + + // The meeting request is an update to the original meeting. + /** + * The Full update. + */ + FullUpdate, + + // The meeting request is an information update. + /** + * The Informational update. + */ + InformationalUpdate, + + // The meeting request is for a new meeting. + /** + * The New meeting request. + */ + NewMeetingRequest, + + // The meeting request is outdated. + /** + * The Outdated. + */ + Outdated, + + // The meeting update is a silent update to an existing meeting. + /** + * The Silent update. + */ + SilentUpdate, + + // The meeting update was forwarded to a delegate, and this copy is + // informational. + /** + * The Principal wants copy. + */ + PrincipalWantsCopy + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/MeetingRequestsDeliveryScope.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/MeetingRequestsDeliveryScope.java new file mode 100644 index 000000000..cc0f20bb8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/MeetingRequestsDeliveryScope.java @@ -0,0 +1,58 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + +import com.eischet.ews.api.attribute.RequiredServerVersion; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; + +/** + * Defines how meeting request are sent to delegates. + */ +public enum MeetingRequestsDeliveryScope { + + // Meeting request are sent to delegates only. + /** + * The Delegates only. + */ + DelegatesOnly, + + // Meeting request are sent to delegates and to the owner of the mailbox. + /** + * The Delegates and me. + */ + DelegatesAndMe, + + // Meeting request are sent to delegates and informational messages are + // sent to the owner of the mailbox. + /** + * The Delegates and send information to me. + */ + DelegatesAndSendInformationToMe, + + //Meeting request are not sent to delegates. This value is + //supported only for Exchange 2010 SP1 or later + //server versions. + @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) + NoForward +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/MessageDisposition.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/MessageDisposition.java similarity index 75% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/MessageDisposition.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/MessageDisposition.java index 5b7e63af8..8a5d7cba2 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/MessageDisposition.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/MessageDisposition.java @@ -21,31 +21,31 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.service; +package com.eischet.ews.api.core.enumeration.service; /** * Defines how messages are disposed of in CreateItem and UpdateItem operations. */ public enum MessageDisposition { - /* - * Messages are saved but not sent. - */ - /** - * The Save only. - */ - SaveOnly, - /* - * Messages are sent and a copy is saved. - */ - /** - * The Send and save copy. - */ - SendAndSaveCopy, - /* - * Messages are sent but no copy is saved. - */ - /** - * The Send only. - */ - SendOnly + /* + * Messages are saved but not sent. + */ + /** + * The Save only. + */ + SaveOnly, + /* + * Messages are sent and a copy is saved. + */ + /** + * The Send and save copy. + */ + SendAndSaveCopy, + /* + * Messages are sent but no copy is saved. + */ + /** + * The Send only. + */ + SendOnly } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/PhoneCallState.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/PhoneCallState.java new file mode 100644 index 000000000..4be0e4314 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/PhoneCallState.java @@ -0,0 +1,79 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + +/** + * The PhoneCallState enumeration. + */ +public enum PhoneCallState { + + // Idle + /** + * The Idle. + */ + Idle, + + // Connecting + /** + * The Connecting. + */ + Connecting, + + // Alerted + /** + * The Alerted. + */ + Alerted, + + // Connected + /** + * The Connected. + */ + Connected, + + // Disconnected + /** + * The Disconnected. + */ + Disconnected, + + // Incoming + /** + * The Incoming. + */ + Incoming, + + // Transferring + /** + * The Transferring. + */ + Transferring, + + // Forwarding + /** + * The Forwarding. + */ + Forwarding + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ResponseActions.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ResponseActions.java new file mode 100644 index 000000000..f7e389e88 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ResponseActions.java @@ -0,0 +1,115 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + + +import com.eischet.ews.api.attribute.Flags; + +/** + * Defines the response actions that can be taken on an item. + */ +@Flags +public enum ResponseActions { + + // No action can be taken. + /** + * The None. + */ + None(0), + + // The item can be accepted. + /** + * The Accept. + */ + Accept(1), + + // The item can be tentatively accepted. + /** + * The Tentatively accept. + */ + TentativelyAccept(2), + + // The item can be declined. + /** + * The Decline. + */ + Decline(4), + + // The item can be replied to. + + /** + * The Reply. + */ + Reply(8), + + // The item can be replied to. + /** + * The Reply all. + */ + ReplyAll(16), + + // The item can be forwarded. + /** + * The Forward. + */ + Forward(32), + + // The item can be cancelled. + /** + * The Cancel. + */ + Cancel(64), + + // The item can be removed from the calendar. + /** + * The Remove from calendar. + */ + RemoveFromCalendar(128), + + // The item's read receipt can be suppressed. + /** + * The Suppress read receipt. + */ + SuppressReadReceipt(256), + + // A reply to the item can be posted. + /** + * The Post reply. + */ + PostReply(512); + + /** + * The response act. + */ + private final int responseAct; + + /** + * Instantiates a new response actions. + * + * @param responseAct the response act + */ + ResponseActions(int responseAct) { + this.responseAct = responseAct; + } +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ResponseMessageType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ResponseMessageType.java similarity index 75% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ResponseMessageType.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ResponseMessageType.java index 9ee088813..e5b66fd0a 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ResponseMessageType.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ResponseMessageType.java @@ -21,30 +21,30 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.service; +package com.eischet.ews.api.core.enumeration.service; /** * Defines the type of a ResponseMessage object. */ public enum ResponseMessageType { - // The ResponseMessage is a reply to the sender of a message. - /** - * The Reply. - */ - Reply, + // The ResponseMessage is a reply to the sender of a message. + /** + * The Reply. + */ + Reply, - // The ResponseMessage is a reply to the sender and all the recipients of a - // message. - /** - * The Reply all. - */ - ReplyAll, + // The ResponseMessage is a reply to the sender and all the recipients of a + // message. + /** + * The Reply all. + */ + ReplyAll, - // The ResponseMessage is a forward. - /** - * The Forward. - */ - Forward + // The ResponseMessage is a forward. + /** + * The Forward. + */ + Forward } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/SendCancellationsMode.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/SendCancellationsMode.java new file mode 100644 index 000000000..a9152477e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/SendCancellationsMode.java @@ -0,0 +1,51 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + +/** + * Defines how meeting cancellations should be sent to attendees when an + * appointment is deleted. + */ +public enum SendCancellationsMode { + + // No meeting cancellation is sent. + /** + * The Send to none. + */ + SendToNone, + + // Meeting cancellations are sent to all attendees. + /** + * The Send only to all. + */ + SendOnlyToAll, + + // Meeting cancellations are sent to all attendees and a copy of the meeting + // is saved in the organizer's Sent Items folder. + /** + * The Send to all and save copy. + */ + SendToAllAndSaveCopy, + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/SendInvitationsMode.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/SendInvitationsMode.java new file mode 100644 index 000000000..033b8c82a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/SendInvitationsMode.java @@ -0,0 +1,50 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + +/** + * Defines if/how meeting invitations are sent. + */ +public enum SendInvitationsMode { + + // No meeting invitation is sent. + /** + * The Send to none. + */ + SendToNone, + + // Meeting invitations are sent to all attendees. + /** + * The Send only to all. + */ + SendOnlyToAll, + + // Meeting invitations are sent to all attendees and a copy of the + // invitation message is saved. + /** + * The Send to all and save copy. + */ + SendToAllAndSaveCopy + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/SendInvitationsOrCancellationsMode.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/SendInvitationsOrCancellationsMode.java new file mode 100644 index 000000000..17af18003 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/SendInvitationsOrCancellationsMode.java @@ -0,0 +1,66 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + +/** + * Defines if/how meeting invitations or cancellations should be sent to + * attendees when an appointment is updated. + */ +public enum SendInvitationsOrCancellationsMode { + + // No meeting invitation/cancellation is sent. + /** + * The Send to none. + */ + SendToNone, + + // Meeting invitations/cancellations are sent to all attendees. + /** + * The Send only to all. + */ + SendOnlyToAll, + + // Meeting invitations/cancellations are sent only to attendees that have + // been added or modified. + /** + * The Send only to changed. + */ + SendOnlyToChanged, + + // Meeting invitations/cancellations are sent to all attendees and a copy is + // saved in the organizer's Sent Items folder. + /** + * The Send to all and save copy. + */ + SendToAllAndSaveCopy, + + // Meeting invitations/cancellations are sent only to attendees that have + // been added or modified and a copy is saved in the organizer's Sent Items + // folder. + /** + * The Send to changed and save copy. + */ + SendToChangedAndSaveCopy + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ServiceObjectType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ServiceObjectType.java similarity index 80% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ServiceObjectType.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ServiceObjectType.java index b1127b2ab..ef0efc0a1 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ServiceObjectType.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ServiceObjectType.java @@ -21,28 +21,28 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.service; +package com.eischet.ews.api.core.enumeration.service; /** * Defines the type of a service object. */ public enum ServiceObjectType { - // The object is a folder. - /** - * The Folder. - */ - Folder, + // The object is a folder. + /** + * The Folder. + */ + Folder, - // The object is an item. - /** - * The Item. - */ - Item, + // The object is an item. + /** + * The Item. + */ + Item, - /// Data represents a conversation - /** - * The Conversation. - */ - Conversation + /// Data represents a conversation + /** + * The Conversation. + */ + Conversation } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ServiceResult.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ServiceResult.java similarity index 80% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ServiceResult.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ServiceResult.java index 5ba4571b4..577caec10 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ServiceResult.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/ServiceResult.java @@ -21,28 +21,28 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.service; +package com.eischet.ews.api.core.enumeration.service; /** * Defines the result of a call to an EWS method. Values in this enumeration * have to be ordered from lowest to highest severity. */ public enum ServiceResult { - // The call was successful - /** - * The Success. - */ - Success, + // The call was successful + /** + * The Success. + */ + Success, - // The call triggered at least one warning - /** - * The Warning. - */ - Warning, + // The call triggered at least one warning + /** + * The Warning. + */ + Warning, - // The call triggered at least one error - /** - * The Error. - */ - Error + // The call triggered at least one error + /** + * The Error. + */ + Error } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/SyncFolderItemsScope.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/SyncFolderItemsScope.java similarity index 80% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/SyncFolderItemsScope.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/SyncFolderItemsScope.java index 78986b2d5..d19a1b4b6 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/SyncFolderItemsScope.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/SyncFolderItemsScope.java @@ -21,22 +21,22 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.service; +package com.eischet.ews.api.core.enumeration.service; /** * Determines item to be included in a SyncFolderItems response. */ public enum SyncFolderItemsScope { - // Include only normal item in the response. - /** - * The Normal item. - */ - NormalItems, + // Include only normal item in the response. + /** + * The Normal item. + */ + NormalItems, - // Include normal and associated item in the response. - /** - * The Normal and associated item. - */ - NormalAndAssociatedItems + // Include normal and associated item in the response. + /** + * The Normal and associated item. + */ + NormalAndAssociatedItems } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/TaskMode.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/TaskMode.java new file mode 100644 index 000000000..7b20a62ba --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/TaskMode.java @@ -0,0 +1,80 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + +/** + * Defines the modes of a Task. + */ +public enum TaskMode { + + // The task is normal + /** + * The Normal. + */ + Normal(0), + + // The task is a task assignment request + /** + * The Request. + */ + Request(1), + + // The task assignment request was accepted + /** + * The Request accepted. + */ + RequestAccepted(2), + + // The task assignment request was declined + /** + * The Request declined. + */ + RequestDeclined(3), + + // The task has been updated + /** + * The Update. + */ + Update(4), + + // The task is self delegated + /** + * The Self delegated. + */ + SelfDelegated(5); + + /** + * The task mode. + */ + private final int taskMode; + + /** + * Instantiates a new task mode. + * + * @param taskMode the task mode + */ + TaskMode(int taskMode) { + this.taskMode = taskMode; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/TaskStatus.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/TaskStatus.java new file mode 100644 index 000000000..26043eaaa --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/TaskStatus.java @@ -0,0 +1,61 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service; + +/** + * Defines the execution status of a task. + */ +public enum TaskStatus { + + // The execution of the task is not started. + /** + * The Not started. + */ + NotStarted, + + // The execution of the task is in progress. + /** + * The In progress. + */ + InProgress, + + // The execution of the task is completed. + /** + * The Completed. + */ + Completed, + + // The execution of the task is waiting on others. + /** + * The Waiting on others. + */ + WaitingOnOthers, + + // The execution of the task is deferred. + /** + * The Deferred. + */ + Deferred + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/calendar/AffectedTaskOccurrence.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/calendar/AffectedTaskOccurrence.java similarity index 78% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/calendar/AffectedTaskOccurrence.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/calendar/AffectedTaskOccurrence.java index 1cdccd3cb..3012c2366 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/calendar/AffectedTaskOccurrence.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/calendar/AffectedTaskOccurrence.java @@ -21,22 +21,22 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.service.calendar; +package com.eischet.ews.api.core.enumeration.service.calendar; /** * Indicates which occurrence of a recurring task should be deleted. */ public enum AffectedTaskOccurrence { - // All occurrences of the recurring task will be deleted. - /** - * The All occurrences. - */ - AllOccurrences, + // All occurrences of the recurring task will be deleted. + /** + * The All occurrences. + */ + AllOccurrences, - // Only the current occurrence of the recurring task will be deleted. - /** - * The Specified occurrence only. - */ - SpecifiedOccurrenceOnly + // Only the current occurrence of the recurring task will be deleted. + /** + * The Specified occurrence only. + */ + SpecifiedOccurrenceOnly } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/calendar/AppointmentType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/calendar/AppointmentType.java new file mode 100644 index 000000000..a6f0ccba9 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/calendar/AppointmentType.java @@ -0,0 +1,53 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.enumeration.service.calendar; + +/** + * Defines the type of an appointment. + */ +public enum AppointmentType { + // The appointment is non-recurring. + /** + * The Single. + */ + Single, + + // The appointment is an occurrence of a recurring appointment. + /** + * The Occurrence. + */ + Occurrence, + + // The appointment is an exception of a recurring appointment. + /** + * The Exception. + */ + Exception, + + // The appointment is the recurring master of a series. + /** + * The Recurring master. + */ + RecurringMaster +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/error/ConnectionFailureCause.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/error/ConnectionFailureCause.java similarity index 76% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/error/ConnectionFailureCause.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/error/ConnectionFailureCause.java index b9fee7170..8a7493b98 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/error/ConnectionFailureCause.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/error/ConnectionFailureCause.java @@ -21,41 +21,41 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.service.error; +package com.eischet.ews.api.core.enumeration.service.error; /** * The ConnectionFailureCause enumeration. */ public enum ConnectionFailureCause { - // None - /** - * The None. - */ - None, - - // UserBusy - /** - * The User busy. - */ - UserBusy, - - // NoAnswer - /** - * The No answer. - */ - NoAnswer, - - // Unavailable - /** - * The Unavailable. - */ - Unavailable, - - // Other - /** - * The Other. - */ - Other + // None + /** + * The None. + */ + None, + + // UserBusy + /** + * The User busy. + */ + UserBusy, + + // NoAnswer + /** + * The No answer. + */ + NoAnswer, + + // Unavailable + /** + * The Unavailable. + */ + Unavailable, + + // Other + /** + * The Other. + */ + Other } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/error/ServiceErrorHandling.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/error/ServiceErrorHandling.java similarity index 81% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/error/ServiceErrorHandling.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/error/ServiceErrorHandling.java index c78d024fb..639540802 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/error/ServiceErrorHandling.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/service/error/ServiceErrorHandling.java @@ -21,22 +21,22 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.service.error; +package com.eischet.ews.api.core.enumeration.service.error; /** * Defines the type of error handling used for service method calls. */ public enum ServiceErrorHandling { - // Service method should return the error(s). - /** - * The Return errors. - */ - ReturnErrors, + // Service method should return the error(s). + /** + * The Return errors. + */ + ReturnErrors, - // Service method should throw exception when error occurs. - /** - * The Throw on error. - */ - ThrowOnError + // Service method should throw exception when error occurs. + /** + * The Throw on error. + */ + ThrowOnError } diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/sync/ChangeType.java b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/sync/ChangeType.java similarity index 75% rename from src/main/java/microsoft/exchange/webservices/data/core/enumeration/sync/ChangeType.java rename to ews-api/src/main/java/com/eischet/ews/api/core/enumeration/sync/ChangeType.java index 98fc13f2c..29dd5d8cd 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/sync/ChangeType.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/enumeration/sync/ChangeType.java @@ -21,34 +21,34 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.enumeration.sync; +package com.eischet.ews.api.core.enumeration.sync; /** * Defines the type of change of a synchronization event. */ public enum ChangeType { - // An item or folder was created. - /** - * The Create. - */ - Create, + // An item or folder was created. + /** + * The Create. + */ + Create, - // An item or folder was modified. - /** - * The Update. - */ - Update, + // An item or folder was modified. + /** + * The Update. + */ + Update, - // An item or folder was deleted. - /** - * The Delete. - */ - Delete, + // An item or folder was deleted. + /** + * The Delete. + */ + Delete, - // An item's IsRead flag was changed. - /** - * The Read flag change. - */ - ReadFlagChange, + // An item's IsRead flag was changed. + /** + * The Read flag change. + */ + ReadFlagChange, } diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/ExchangeException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/ExchangeException.java new file mode 100644 index 000000000..9ca588ad6 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/ExchangeException.java @@ -0,0 +1,27 @@ +package com.eischet.ews.api.core.exception; + +/** + * Represents a general exception from the Exchange Web Services. + *

+ * The original EWS code had "throws Exception" in over 8000 places (!) and defined a handful of + * exception classes that directly extend Exception. I assume that this code has been generated from the equivalent + * C# code, where checked exceptions don't exist. + * This has been changed so that any exception thrown by EWS code derives from this class. + *

+ *

grep -ri "throws exception" * | wc -l # result: 8241

+ */ +public class ExchangeException extends Exception { + public ExchangeException() { + } + public ExchangeException(final String message) { + super(message); + } + + public ExchangeException(final String message, final Throwable cause) { + super(message, cause); + } + + public ExchangeException(final Throwable cause) { + super(cause); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/dns/DnsException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/dns/DnsException.java new file mode 100644 index 000000000..df35d89a6 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/dns/DnsException.java @@ -0,0 +1,46 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.dns; + +import com.eischet.ews.api.core.exception.ExchangeException; + +/** + * Defines DnsException class. + */ +public class DnsException extends ExchangeException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * Instantiates a new dns exception. + * + * @param exceptionMessage the exception message + */ + public DnsException(String exceptionMessage) { + super(exceptionMessage); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/http/EWSHttpException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/http/EWSHttpException.java new file mode 100644 index 000000000..d775ca218 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/http/EWSHttpException.java @@ -0,0 +1,47 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.http; + +import com.eischet.ews.api.core.exception.ExchangeException; + +public class EWSHttpException extends ExchangeException { + + public EWSHttpException() { + super(); + } + + public EWSHttpException(String message, Throwable cause) { + super(message, cause); + } + + public EWSHttpException(String message) { + super(message); + + } + + public EWSHttpException(Throwable cause) { + super(cause); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/http/HttpErrorException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/http/HttpErrorException.java new file mode 100644 index 000000000..7c9eebb98 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/http/HttpErrorException.java @@ -0,0 +1,54 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.http; + + +import com.eischet.ews.api.core.exception.ExchangeException; + +/** + * User: nwoodham Date: 3/8/11 Time: 5:30 PM + */ +public class HttpErrorException extends ExchangeException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + private final int code; + + public HttpErrorException() { + super(); + this.code = 0; + } + + public HttpErrorException(String message, int code) { + super(message); + this.code = code; + } + + public int getHttpErrorCode() { + return this.code; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/ArgumentException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/ArgumentException.java new file mode 100644 index 000000000..28ecba3bc --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/ArgumentException.java @@ -0,0 +1,140 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.misc; + +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; + +import java.security.PrivilegedActionException; + +/** + * The Class ArgumentException. + */ +public class ArgumentException extends ExchangeValidationException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 2L; + + /** + * ParamName that causes the Exception + */ + private String paramName = null; + + + /** + * Constructs an IllegalArgumentException with the specified detail message. + * + * @param message the detail message. + */ + public ArgumentException(String message) { + super(message); + } + + /** + * Constructs an IllegalArgumentException with the specified detail message. + * + * @param s the detail message. + * @param paramName the Name of the Param that causes the exception + */ + public ArgumentException(String s, String paramName) { + super(s); + this.paramName = paramName; + } + + /** + * Constructs a new exception with the specified detail message and cause. + *

+ *

Note that the detail message associated with cause is not automatically + * incorporated in this exception's detail message. + * + * @param message the detail message (which is saved for later retrieval by the {@link + * Throwable#getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method). + * (A null value is permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public ArgumentException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new exception with the specified cause and a detail message of (cause==null ? null : + * cause.toString()) (which typically contains the class and detail message of cause). This + * constructor is useful for exceptions that are little more than wrappers for other throwables (for + * example, {@link PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method). + * (A null value is permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public ArgumentException(Throwable cause) { + // TODO: remove this constructor, as it omits any detail helpful to users + super("unspecified argument exception", cause); + } + + /** + * Constructs a new exception with the specified cause and a detail message of (cause==null ? null : + * cause.toString()) (which typically contains the class and detail message of cause). This + * constructor is useful for exceptions that are little more than wrappers for other throwables (for + * example, {@link PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} + * method). (A null value is permitted, and indicates that the cause is + * nonexistent or unknown.) + * @param paramName the Name of the Param that causes the exception + */ + public ArgumentException(Throwable cause, String paramName) { + // TODO: remove this constructor, as it omits any detail helpful to users + super("unspecified argument exception", cause); + this.paramName = paramName; + } + + /** + * Initializes a new instance of the System. ArgumentException class with a specified error message and the + * name of the parameter that causes this exception. + * + * @param message The error message that explains the reason for the exception. + * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} + * method). (A null value is permitted, and indicates that the cause is + * nonexistent or unknown.) + * @param paramName the Name of the Param that causes the exception + */ + public ArgumentException(String message, Throwable cause, String paramName) { + super(message + " Parameter that caused the current exception :" + paramName, cause); + this.paramName = paramName; + } + + /** + * Get the Name of the Param that causes the exception + * + * @return the ParamName (or null if not set) + */ + public String getParamName() { + return paramName; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/ArgumentNullException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/ArgumentNullException.java new file mode 100644 index 000000000..0eff77fad --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/ArgumentNullException.java @@ -0,0 +1,107 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.misc; + +public class ArgumentNullException extends ArgumentException { + + /** + * Constructs an IllegalArgumentException with the specified detail message. + * + * @param message the detail message. + */ + public ArgumentNullException(String message) { + super(message); + } + + /** + * Constructs an IllegalArgumentException with the specified detail message. + * + * @param s the detail message. + * @param paramName the Name of the Param that causes the exception + */ + public ArgumentNullException(String s, String paramName) { + super(s, paramName); + } + + /** + * Constructs a new exception with the specified detail message and cause. + *

+ *

Note that the detail message associated with cause is not automatically + * incorporated in this exception's detail message. + * + * @param message the detail message (which is saved for later retrieval by the {@link + * Throwable#getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method). + * (A null value is permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public ArgumentNullException(String message, Throwable cause) { + super(message, cause); + } + + /** + * Constructs a new exception with the specified cause and a detail message of (cause==null ? null : + * cause.toString()) (which typically contains the class and detail message of cause). This + * constructor is useful for exceptions that are little more than wrappers for other throwables (for + * example, {@link java.security.PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method). + * (A null value is permitted, and indicates that the cause is nonexistent or + * unknown.) + * @since 1.5 + */ + public ArgumentNullException(Throwable cause) { + super(cause); + } + + /** + * Constructs a new exception with the specified cause and a detail message of (cause==null ? null : + * cause.toString()) (which typically contains the class and detail message of cause). This + * constructor is useful for exceptions that are little more than wrappers for other throwables (for + * example, {@link java.security.PrivilegedActionException}). + * + * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} + * method). (A null value is permitted, and indicates that the cause is + * nonexistent or unknown.) + * @param paramName the Name of the Param that causes the exception + */ + public ArgumentNullException(Throwable cause, String paramName) { + super(cause, paramName); + } + + /** + * Initializes a new instance of the System. ArgumentException class with a specified error message and the + * name of the parameter that causes this exception. + * + * @param message The error message that explains the reason for the exception. + * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} + * method). (A null value is permitted, and indicates that the cause is + * nonexistent or unknown.) + * @param paramName the Name of the Param that causes the exception + */ + public ArgumentNullException(String message, Throwable cause, String paramName) { + super(message, cause, paramName); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/ArgumentOutOfRangeException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/ArgumentOutOfRangeException.java new file mode 100644 index 000000000..bdbabdafc --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/ArgumentOutOfRangeException.java @@ -0,0 +1,56 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.misc; + +/** + * The Class ArgumentOutOfRangeException. + */ +public class ArgumentOutOfRangeException extends ArgumentException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * Instantiates a new argument out of range exception. + * + * @param arg0 the arg0 + */ + public ArgumentOutOfRangeException(final String arg0) { + super(arg0); + + } + + /** + * Instantiates a new argument out of range exception. + * + * @param arg0 the arg0 + * @param arg1 the arg1 + */ + public ArgumentOutOfRangeException(final String arg0, final String arg1) { + super(arg0, arg1); + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/FormatException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/FormatException.java new file mode 100644 index 000000000..c0f6a510d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/FormatException.java @@ -0,0 +1,46 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.misc; + +/** + * The Class FormatException. + */ +public class FormatException extends ArgumentException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * Instantiates a new format exception. + * + * @param arg0 the arg0 + */ + public FormatException(final String arg0) { + super(arg0); + + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/InvalidOperationException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/InvalidOperationException.java new file mode 100644 index 000000000..6d32d6b6c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/misc/InvalidOperationException.java @@ -0,0 +1,53 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.misc; + +import com.eischet.ews.api.core.exception.ExchangeException; + +/** + * The Class InvalidOperationException. + */ +public class InvalidOperationException extends ExchangeException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * Instantiates a new invalid operation exception. + */ + public InvalidOperationException() { + + } + + /** + * Instantiates a new invalid operation exception. + * + * @param strMessage the str message + */ + public InvalidOperationException(String strMessage) { + super(strMessage); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ExchangeValidationException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ExchangeValidationException.java new file mode 100644 index 000000000..abf3b584b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ExchangeValidationException.java @@ -0,0 +1,47 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.local; + +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents an error that occurs when a validation check fails. + */ +public class ExchangeValidationException extends ExchangeXmlException { + + private static final long serialVersionUID = 1L; + + public ExchangeValidationException(final String message, final Throwable cause) { + super(message, cause); + } + + public ExchangeValidationException(String message) { + super(message); + } + + + public ExchangeValidationException() { + // TODO: remove this. We should never throw an exception that gives the user no clue at all about what went wrong. + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/InvalidOrUnsupportedTimeZoneDefinitionException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/InvalidOrUnsupportedTimeZoneDefinitionException.java new file mode 100644 index 000000000..7dd4dd615 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/InvalidOrUnsupportedTimeZoneDefinitionException.java @@ -0,0 +1,62 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.local; + +/** + * The Class InvalidOrUnsupportedTimeZoneDefinitionException. + *

+ * Thrown when time zone definition is not valid. + * + * @see com.eischet.ews.api.property.complex.time.TimeZoneDefinition + * @see com.eischet.ews.api.property.complex.time.TimeZoneTransitionGroup + */ +public class InvalidOrUnsupportedTimeZoneDefinitionException extends ExchangeValidationException { + + /** + * Constructs an InvalidOrUnsupportedTimeZoneDefinitionException with the specified detail message. + * + * @param message the detail message. + */ + public InvalidOrUnsupportedTimeZoneDefinitionException(String message) { + super(message); + } + + /** + * Constructs a new exception with the specified detail message and cause. + * + * @param message the detail message (which is saved for later retrieval by the {@link + * Throwable#getMessage()} method). + * @param innerException the cause (which is saved for later retrieval by the {@link Throwable#getCause()} + * method). (A null value is permitted, and indicates that the cause is nonexistent + * or unknown.) + */ + public InvalidOrUnsupportedTimeZoneDefinitionException(String message, Exception innerException) { + super(message, innerException); + } + + public InvalidOrUnsupportedTimeZoneDefinitionException() { + + super(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/PropertyException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/PropertyException.java new file mode 100644 index 000000000..5b570f077 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/PropertyException.java @@ -0,0 +1,86 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.local; + +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents an error that occurs when an operation on a property fails. + */ +public class PropertyException extends ExchangeXmlException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * The name. + */ + private String name; + + /** + * Instantiates a new property exception. + * + * @param name the name + */ + public PropertyException(String name) { + super(); + this.name = name; + } + + /** + * Instantiates a new property exception. + * + * @param message the message + * @param name the name + */ + public PropertyException(String message, String name) { + super(message); + this.name = name; + } + + /** + * Instantiates a new property exception. + * + * @param message the message + * @param name the name + * @param innerException the inner exception + */ + public PropertyException(String message, String name, + Exception innerException) { + super(message, innerException); + this.name = name; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return name; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceLocalException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceLocalException.java new file mode 100644 index 000000000..fb0f35e3b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceLocalException.java @@ -0,0 +1,49 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.local; + +import com.eischet.ews.api.core.exception.ExchangeException; + +/** + * Represents an error that occurs when a service operation fails locally (e.g. + * validation error). + */ +public class ServiceLocalException extends ExchangeException { + + public ServiceLocalException() { + super(); + } + + public ServiceLocalException(String message) { + super(message); + } + + public ServiceLocalException(String message, Throwable cause) { + super(message, cause); + } + + public ServiceLocalException(final Throwable cause) { + super(cause); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceObjectPropertyException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceObjectPropertyException.java new file mode 100644 index 000000000..a415fbce7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceObjectPropertyException.java @@ -0,0 +1,91 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.local; + +import com.eischet.ews.api.property.definition.PropertyDefinitionBase; + +/** + * Represents an error that occurs when an operation on a property fails. + */ +public class ServiceObjectPropertyException extends PropertyException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * The property definition. + */ + private final PropertyDefinitionBase propertyDefinition; + + /** + * ServiceObjectPropertyException constructor. + * + * @param propertyDefinition The definition of the property that is at the origin of the + * exception. + */ + public ServiceObjectPropertyException( + PropertyDefinitionBase propertyDefinition) { + super(propertyDefinition.getPrintableName()); + this.propertyDefinition = propertyDefinition; + } + + /** + * ServiceObjectPropertyException constructor. + * + * @param message Error message text. + * @param propertyDefinition The definition of the property that is at the origin of the + * exception. + */ + public ServiceObjectPropertyException(String message, PropertyDefinitionBase propertyDefinition) { + super(message, propertyDefinition.getPrintableName()); + this.propertyDefinition = propertyDefinition; + } + + /** + * ServiceObjectPropertyException constructor. + * + * @param message Error message text. + * @param propertyDefinition The definition of the property that is at the origin of the + * exception. + * @param innerException the inner exception + */ + public ServiceObjectPropertyException(String message, + PropertyDefinitionBase propertyDefinition, + Exception innerException) { + super(message, propertyDefinition.getPrintableName(), innerException); + this.propertyDefinition = propertyDefinition; + } + + /** + * The definition of the property that is at the origin of the exception. + * + * @return The definition of the property. + */ + public PropertyDefinitionBase getPropertyDefinition() { + return propertyDefinition; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceVersionException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceVersionException.java new file mode 100644 index 000000000..80c98ea37 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceVersionException.java @@ -0,0 +1,65 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.local; + +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents an error that occurs when a request cannot be handled due to a + * service version mismatch. + */ +public final class ServiceVersionException extends ExchangeXmlException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * Initializes a new instance of the class. + */ + public ServiceVersionException() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param message the message + */ + public ServiceVersionException(String message) { + super(message); + } + + /** + * Instantiates a new service version exception. + * + * @param message the message + * @param innerException the inner exception + */ + public ServiceVersionException(String message, Exception innerException) { + super(message, innerException); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceXmlDeserializationException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceXmlDeserializationException.java new file mode 100644 index 000000000..18b929265 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceXmlDeserializationException.java @@ -0,0 +1,64 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.local; + +/** + * Represents an error that occurs when the XML for a response cannot be + * deserialized. + */ +public final class ServiceXmlDeserializationException extends ServiceLocalException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * ServiceXmlDeserializationException Constructor. + */ + public ServiceXmlDeserializationException() { + super(); + } + + /** + * ServiceXmlDeserializationException Constructor. + * + * @param message the message + */ + public ServiceXmlDeserializationException(String message) { + super(message); + } + + /** + * ServiceXmlDeserializationException Constructor. + * + * @param message the message + * @param innerException the inner exception + */ + public ServiceXmlDeserializationException(String message, + Exception innerException) { + super(message, innerException); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceXmlSerializationException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceXmlSerializationException.java new file mode 100644 index 000000000..9e7da3719 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/ServiceXmlSerializationException.java @@ -0,0 +1,65 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.local; + +/** + * Represents an error that occurs when the XML for a request cannot be + * serialized. + */ +public class ServiceXmlSerializationException extends ServiceLocalException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * ServiceXmlSerializationException Constructor. + */ + public ServiceXmlSerializationException() { + super(); + } + + /** + * Instantiates a new service xml serialization exception. + * + * @param message the message + */ + public ServiceXmlSerializationException(String message) { + super(message); + + } + + /** + * Instantiates a new service xml serialization exception. + * + * @param message the message + * @param innerException the inner exception + */ + public ServiceXmlSerializationException(String message, + Exception innerException) { + super(message, innerException); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/TimeZoneConversionException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/TimeZoneConversionException.java new file mode 100644 index 000000000..e0e6dd2fe --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/local/TimeZoneConversionException.java @@ -0,0 +1,64 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.local; + +/** + * Represents an error that occurs when a date and time cannot be converted from + * one time zone to another. + */ +public class TimeZoneConversionException extends ServiceLocalException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * ServiceLocalException Constructor. + */ + public TimeZoneConversionException() { + super(); + } + + /** + * ServiceLocalException Constructor. + * + * @param message the message + */ + public TimeZoneConversionException(String message) { + super(message); + } + + /** + * ServiceLocalException Constructor. + * + * @param message the message + * @param innerException the inner exception + */ + public TimeZoneConversionException(String message, + Exception innerException) { + super(message, innerException); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/AccountIsLockedException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/AccountIsLockedException.java new file mode 100644 index 000000000..911262057 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/AccountIsLockedException.java @@ -0,0 +1,71 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.remote; + +import java.net.URI; + +/** + * Represents an error that occurs when the account that is + * being accessed is locked and requires user interaction to be unlocked. + */ +public class AccountIsLockedException extends ServiceRemoteException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + private URI accountUnlockUrl; + + + /** + * Initializes a new instance of the AccountIsLockedException class. + * + * @param message Error message text. + * @param accountUnlockUrl URL for client to visit to unlock account. + */ + public AccountIsLockedException(String message, URI accountUnlockUrl, + Exception innerException) { + + super(message, innerException); + this.setAccountUnlockUrl(accountUnlockUrl); + } + + /** + * Gets the URL of a web page where the user + * can navigate to unlock his or her account. + */ + public URI getAccountUnlockUrl() { + return accountUnlockUrl; + } + + + /** + * Sets the URL of a web page where the + * user can navigate to unlock his or her account. + */ + private void setAccountUnlockUrl(URI value) { + this.accountUnlockUrl = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/CreateAttachmentException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/CreateAttachmentException.java new file mode 100644 index 000000000..419a1d5c9 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/CreateAttachmentException.java @@ -0,0 +1,77 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.remote; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.response.CreateAttachmentResponse; +import com.eischet.ews.api.core.response.ServiceResponseCollection; + +/** + * Represents an error that occurs when a call to the CreateAttachment web + * method fails. + */ +public final class CreateAttachmentException extends ServiceRemoteException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * The response. + */ + private final ServiceResponseCollection responses; + + /** + * Initializes a new instance of CreateAttachmentException. + * + * @param serviceResponses the service response + * @param message the message + */ + public CreateAttachmentException(ServiceResponseCollection serviceResponses, + String message) { + super(message); + EwsUtilities.ewsAssert(serviceResponses != null, + "MultiServiceResponseException.ctor", "serviceResponses is null"); + + this.responses = serviceResponses; + } + + /** + * Initializes a new instance of CreateAttachmentException. + * + * @param serviceResponses the service response + * @param message the message + * @param innerException the inner exception + */ + protected CreateAttachmentException( + ServiceResponseCollection serviceResponses, + String message, Exception innerException) { + super(message, innerException); + EwsUtilities.ewsAssert(serviceResponses != null, + "MultiServiceResponseException.ctor", "serviceResponses is null"); + + this.responses = serviceResponses; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/DeleteAttachmentException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/DeleteAttachmentException.java new file mode 100644 index 000000000..d5afa39c5 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/DeleteAttachmentException.java @@ -0,0 +1,77 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.remote; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.response.DeleteAttachmentResponse; +import com.eischet.ews.api.core.response.ServiceResponseCollection; + +/** + * Represents an error that occurs when a call to the DeleteAttachment web + * method fails. + */ +public final class DeleteAttachmentException extends ServiceRemoteException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * The response. + */ + private final ServiceResponseCollection responses; + + /** + * Initializes a new instance of DeleteAttachmentException. + * + * @param serviceResponses The list of response to be associated with this exception. + * @param message The message that describes the error. + */ + public DeleteAttachmentException(ServiceResponseCollection serviceResponses, + String message) { + super(message); + EwsUtilities.ewsAssert(serviceResponses != null, + "MultiServiceResponseException.ctor", "serviceResponses is null"); + + this.responses = serviceResponses; + } + + /** + * Initializes a new instance of DeleteAttachmentException. + * + * @param serviceResponses The list of response to be associated with this exception. + * @param message The message that describes the error. + * @param innerException The exception that is the cause of the current exception. + */ + protected DeleteAttachmentException( + ServiceResponseCollection serviceResponses, + String message, Exception innerException) { + super(message, innerException); + EwsUtilities.ewsAssert(serviceResponses != null, + "MultiServiceResponseException.ctor", "serviceResponses is null"); + + this.responses = serviceResponses; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/ServiceRemoteException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/ServiceRemoteException.java new file mode 100644 index 000000000..01331ee90 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/ServiceRemoteException.java @@ -0,0 +1,63 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.remote; + +import com.eischet.ews.api.core.exception.ExchangeException; + +/** + * Represents an error that occurs when a service operation fails remotely. + */ +public class ServiceRemoteException extends ExchangeException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * ServiceRemoteException Constructor. + */ + public ServiceRemoteException() { + super(); + } + + /** + * ServiceRemoteException Constructor. + * + * @param message the message + */ + public ServiceRemoteException(String message) { + super(message); + } + + /** + * ServiceRemoteException Constructor. + * + * @param message the message + * @param innerException the inner exception + */ + public ServiceRemoteException(String message, Exception innerException) { + super(message, innerException); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/ServiceRequestException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/ServiceRequestException.java new file mode 100644 index 000000000..fda350824 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/ServiceRequestException.java @@ -0,0 +1,61 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.remote; + +/** + * The Class ServiceRequestException. + */ +public class ServiceRequestException extends ServiceRemoteException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * ServiceRequestException Constructor. + */ + public ServiceRequestException() { + super(); + } + + /** + * ServiceRequestException Constructor. + * + * @param message the message + */ + public ServiceRequestException(String message) { + super(message); + } + + /** + * ServiceRequestException Constructor. + * + * @param message the message + * @param innerException the inner exception + */ + public ServiceRequestException(String message, Exception innerException) { + super(message, innerException); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/ServiceResponseException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/ServiceResponseException.java new file mode 100644 index 000000000..d153b0bad --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/ServiceResponseException.java @@ -0,0 +1,122 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.remote; + +import com.eischet.ews.api.core.enumeration.misc.error.ServiceError; +import com.eischet.ews.api.core.response.ServiceResponse; + +/** + * Represents a remote service exception that has a single response. + */ +public class ServiceResponseException extends ServiceRemoteException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * Error details Value keys. + */ + private static final String ExceptionClassKey = "ExceptionClass"; + + /** + * The Exception message key. + */ + private static final String ExceptionMessageKey = "ExceptionMessage"; + + /** + * The Stack trace key. + */ + private static final String StackTraceKey = "StackTrace"; + + /** + * ServiceResponse when service operation failed remotely. + */ + private final ServiceResponse response; + + /** + * Initializes a new instance. + * + * @param response the response + */ + public ServiceResponseException(ServiceResponse response) { + this.response = response; + } + + /** + * Gets the ServiceResponse for the exception. + * + * @return the response + */ + public ServiceResponse getResponse() { + return response; + } + + /** + * Gets the service error code. + * + * @return the error code + */ + public ServiceError getErrorCode() { + return this.response.getErrorCode(); + } + + /** + * Gets a message that describes the current exception. + * + * @return The error message that explains the reason for the exception. + */ + + public String getMessage() { + + // Bug E14:134792 -- Special case for Internal Server Error. If the + // server returned + // stack trace information, include it in the exception message. + if (this.response.getErrorCode() == ServiceError.ErrorInternalServerError) { + String exceptionClass; + String exceptionMessage; + String stackTrace; + + if (this.response.getErrorDetails().containsKey(ExceptionClassKey) && + this.response.getErrorDetails().containsKey( + ExceptionMessageKey) && + this.response.getErrorDetails().containsKey( + StackTraceKey)) { + exceptionClass = this.response.getErrorDetails().get( + ExceptionClassKey); + exceptionMessage = this.response.getErrorDetails().get( + ExceptionMessageKey); + stackTrace = this.response.getErrorDetails().get(StackTraceKey); + + // return + return String.format("%s -- Server Error: %s: %s %s", this.response + .getErrorMessage(), exceptionClass, + exceptionMessage, stackTrace); + } + } + + return this.response.getErrorMessage(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/UpdateInboxRulesException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/UpdateInboxRulesException.java new file mode 100644 index 000000000..7557936a4 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/service/remote/UpdateInboxRulesException.java @@ -0,0 +1,98 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.service.remote; + +import com.eischet.ews.api.core.enumeration.misc.error.ServiceError; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.response.UpdateInboxRulesResponse; +import com.eischet.ews.api.property.complex.RuleOperation; +import com.eischet.ews.api.property.complex.RuleOperationError; +import com.eischet.ews.api.property.complex.RuleOperationErrorCollection; + +/** + * Represents an exception thrown when an error occurs as a result of calling + * the UpdateInboxRules operation. + */ +public class UpdateInboxRulesException extends ServiceRemoteException { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * ServiceResponse when service operation failed remotely. + */ + private final ServiceResponse serviceResponse; + + /** + * Rule operation error collection. + */ + private final RuleOperationErrorCollection errors; + + /** + * Initializes a new instance of the UpdateInboxRulesException class. + * + * @param serviceResponse The rule operation service response. + * @param ruleOperations The original operations. + */ + public UpdateInboxRulesException(UpdateInboxRulesResponse serviceResponse, + Iterable ruleOperations) { + super(); + this.serviceResponse = serviceResponse; + this.errors = serviceResponse.getErrors(); + for (RuleOperationError error : this.errors) { + error.setOperationByIndex(ruleOperations.iterator()); + } + } + + /** + * Gets the ServiceResponse for the exception. + */ + public ServiceResponse getServiceResponse() { + return this.serviceResponse; + } + + /** + * Gets the rule operation error collection. + */ + public RuleOperationErrorCollection getErrors() { + return this.errors; + } + + /** + * Gets the rule operation error code. + */ + public ServiceError getErrorCode() { + return this.serviceResponse.getErrorCode(); + } + + /** + * Gets the rule operation error message. + */ + public String getErrorMessage() { + return this.serviceResponse.getErrorMessage(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/exception/xml/ExchangeXmlException.java b/ews-api/src/main/java/com/eischet/ews/api/core/exception/xml/ExchangeXmlException.java new file mode 100644 index 000000000..3241a47f9 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/exception/xml/ExchangeXmlException.java @@ -0,0 +1,42 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.exception.xml; + +import com.eischet.ews.api.core.exception.ExchangeException; + +public class ExchangeXmlException extends ExchangeException { + + public ExchangeXmlException() { + super(); + } + + public ExchangeXmlException(final String message) { + super(message); + + } + + public ExchangeXmlException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/AddDelegateRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/AddDelegateRequest.java new file mode 100644 index 000000000..dd1e233d7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/AddDelegateRequest.java @@ -0,0 +1,182 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.MeetingRequestsDeliveryScope; +import com.eischet.ews.api.core.response.DelegateManagementResponse; +import com.eischet.ews.api.property.complex.DelegateUser; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents an AddDelegate request. + */ +public class AddDelegateRequest extends + DelegateManagementRequestBase { + + /** + * The delegate users. + */ + private final List delegateUsers = new ArrayList(); + + /** + * The meeting request delivery scope. + */ + private MeetingRequestsDeliveryScope meetingRequestsDeliveryScope; + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception + */ + public AddDelegateRequest(ExchangeService service) + throws Exception { + super(service); + } + + /** + * Initializes a new instance of the class. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParamCollection(this.getDelegateUsers().iterator(), "DelegateUsers"); + for (DelegateUser delegateUser : this.getDelegateUsers()) { + delegateUser.validateUpdateDelegate(); + } + + if (this.meetingRequestsDeliveryScope != null) { + EwsUtilities.validateEnumVersionValue(this. + getMeetingRequestsDeliveryScope(), + this.getService().getRequestedServerVersion()); + } + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + super.writeElementsToXml(writer); + + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.DelegateUsers); + + for (DelegateUser delegateUser : this.getDelegateUsers()) { + delegateUser.writeToXml(writer, XmlElementNames.DelegateUser); + } + + writer.writeEndElement(); // DelegateUsers + + if (this.getMeetingRequestsDeliveryScope() != null) { + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.DeliverMeetingRequests, this + .getMeetingRequestsDeliveryScope()); + } + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.AddDelegate; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.AddDelegateResponse; + } + + /** + * Creates the response. + * + * @return Service response. + */ + @Override + protected DelegateManagementResponse createResponse() { + return new DelegateManagementResponse(true, this.delegateUsers); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the meeting request delivery scope. The meeting + * request delivery scope. + * + * @return the meeting request delivery scope + */ + public MeetingRequestsDeliveryScope getMeetingRequestsDeliveryScope() { + return this.meetingRequestsDeliveryScope; + } + + /** + * Sets the meeting request delivery scope. + * + * @param meetingRequestsDeliveryScope the new meeting request delivery scope + */ + public void setMeetingRequestsDeliveryScope( + MeetingRequestsDeliveryScope meetingRequestsDeliveryScope) { + this.meetingRequestsDeliveryScope = meetingRequestsDeliveryScope; + } + + /** + * Gets the delegate users. The delegate users. + * + * @return the delegate users + */ + public List getDelegateUsers() { + return this.delegateUsers; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/ConvertIdRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/ConvertIdRequest.java new file mode 100644 index 000000000..d3f27ec21 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/ConvertIdRequest.java @@ -0,0 +1,187 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.IdFormat; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.ConvertIdResponse; +import com.eischet.ews.api.misc.id.AlternateIdBase; + +import javax.xml.stream.XMLStreamException; +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a ConvertId request. + */ +public final class ConvertIdRequest extends MultiResponseServiceRequest { + + /** + * The destination format. + */ + private IdFormat destinationFormat = IdFormat.EwsId; + + /** + * The ids. + */ + private final List ids = new ArrayList<>(); + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception on errors + */ + public ConvertIdRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param responseIndex the response index + * @return the convert id response + */ + @Override + protected ConvertIdResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new ConvertIdResponse(); + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.ConvertIdResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.ConvertIdResponseMessage; + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.ids.size(); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.ConvertId; + } + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParamCollection(this.ids.iterator(), "Ids"); + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.DestinationFormat, + this.destinationFormat); + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.SourceIds); + for (AlternateIdBase alternateId : this.ids) { + alternateId.writeToXml(writer); + } + + writer.writeEndElement(); // SourceIds + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the destination format. + * + * @return the destination format + */ + public IdFormat getDestinationFormat() { + return this.destinationFormat; + } + + /** + * Sets the destination format. + * + * @param destinationFormat the new destination format + */ + public void setDestinationFormat(IdFormat destinationFormat) { + this.destinationFormat = destinationFormat; + } + + /** + * Gets the ids. + * + * @return the ids + */ + public List getIds() { + return this.ids; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/CopyFolderRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/CopyFolderRequest.java new file mode 100644 index 000000000..7c8b5b036 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/CopyFolderRequest.java @@ -0,0 +1,100 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.MoveCopyFolderResponse; + +/** + * Represents a CopyFolder request. + */ +public class CopyFolderRequest extends MoveCopyFolderRequest { + + /** + * Initializes a new instance of the CopyFolderRequest class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + */ + public CopyFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) throws Exception { + super(service, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param service The Service + * @param responseIndex Index of the response. + * @return Service response. + */ + @Override + protected MoveCopyFolderResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new MoveCopyFolderResponse(); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.CopyFolder; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.CopyFolderResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.CopyFolderResponseMessage; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/CopyItemRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/CopyItemRequest.java new file mode 100644 index 000000000..85ed30faf --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/CopyItemRequest.java @@ -0,0 +1,100 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.MoveCopyItemResponse; + +/** + * Represents a CopyItem request. + */ +public class CopyItemRequest extends MoveCopyItemRequest { + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception + */ + public CopyItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response. + */ + @Override + protected MoveCopyItemResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new MoveCopyItemResponse(); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.CopyItem; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.CopyItemResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name. + */ + protected String getResponseMessageXmlElementName() { + return XmlElementNames.CopyItemResponseMessage; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateAttachmentRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateAttachmentRequest.java new file mode 100644 index 000000000..8322908cc --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateAttachmentRequest.java @@ -0,0 +1,218 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.CreateAttachmentResponse; +import com.eischet.ews.api.property.complex.Attachment; +import com.eischet.ews.api.property.complex.ItemAttachment; + +import java.util.ArrayList; +import java.util.ListIterator; + +/** + * Represents a CreateAttachment request. + */ + +public final class CreateAttachmentRequest extends + MultiResponseServiceRequest { + + /** + * The parent item id. + */ + private String parentItemId; + + /** + * The attachments. + */ + private final ArrayList attachments = new ArrayList<>(); + + /** + * Gets the attachments. + * + * @return attachments + */ + public ArrayList getAttachments() { + return attachments; + } + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception on errors + */ + public CreateAttachmentRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Validate request.. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.parentItemId, "ParentItemId"); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.attachments.size(); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.CreateAttachment; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.CreateAttachmentResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.CreateAttachmentResponseMessage; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets a value indicating whether the TimeZoneContext SOAP header should be + * emitted. + */ + protected boolean emitTimeZoneHeader() throws Exception { + { + + ListIterator items = this.getAttachments() + .listIterator(); + + while (items.hasNext()) { + + ItemAttachment itemAttachment = (ItemAttachment) items.next(); + + if ((itemAttachment.getItem() != null) + && itemAttachment + .getItem() + .getIsTimeZoneHeaderRequired(false /* isUpdateOperation */)) { + return true; + } + } + + return false; + } + } + + /** + * Gets the parent item id. + * + * @return parentItemId + */ + public String getParentItemId() { + return parentItemId; + } + + /** + * Sets the parent item id. + * + * @param parentItemId the new parent item id + */ + public void setParentItemId(String parentItemId) { + this.parentItemId = parentItemId; + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.ParentItemId); + writer.writeAttributeValue(XmlAttributeNames.Id, this.parentItemId); + writer.writeEndElement(); + + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.Attachments); + for (Attachment attachment : this.attachments) { + attachment.writeToXml(writer, attachment.getXmlElementName()); + } + writer.writeEndElement(); + + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return the creates the attachment response + */ + @Override + protected CreateAttachmentResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new CreateAttachmentResponse( + this.attachments.get(responseIndex)); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateFolderRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateFolderRequest.java new file mode 100644 index 000000000..5605a44aa --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateFolderRequest.java @@ -0,0 +1,163 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.CreateFolderResponse; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.service.folder.Folder; + +import java.util.Collection; + +/** + * Represents a CreateFolder request. + */ +public final class CreateFolderRequest extends CreateRequest { + + /** + * Initializes a new instance of the CreateFolderRequest class. + * + * @param service The service + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + public CreateFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.getFolders(), "Folders"); + + // Validate each folder. + for (Folder folder : this.getFolders()) { + folder.validate(); + } + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex Index of the response. + * @return Service response. + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new CreateFolderResponse((Folder) EwsUtilities + .getEnumeratedObjectAt(this.getFolders(), responseIndex)); + } + + /** + * Gets the name of the XML element. + * + * @return Xml element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.CreateFolder; + } + + /** + * Gets the name of the response XML element. + * + * @return Xml element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.CreateFolderResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return Xml element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.CreateFolderResponseMessage; + } + + /** + * Gets the name of the parent folder XML element. + * + * @return Xml element name + */ + @Override + protected String getParentFolderXmlElementName() { + return XmlElementNames.ParentFolderId; + } + + /** + * Gets the name of the object collection XML element. + * + * @return Xml element name + */ + @Override + protected String getObjectCollectionXmlElementName() { + return XmlElementNames.Folders; + } + + /** + * Gets the request version. Earliest Exchange version in which this request + * is supported. + * + * @return the minimum required server version + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the folder. + * + * @return the folder + */ + public Iterable getFolders() { + return this.getObjects(); + } + + /** + * Sets the folder. + * + * @param folder the new folder + */ + public void setFolders(Iterable folder) { + this.setObjects((Collection) folder); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateItemRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateItemRequest.java new file mode 100644 index 000000000..b903fd8fd --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateItemRequest.java @@ -0,0 +1,94 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.response.CreateItemResponse; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.service.item.Item; + +/** + * Represents a CreateItem request. + */ +public final class CreateItemRequest extends + CreateItemRequestBase { + + /** + * Initializes a new instance. + * + * @param service The service. + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + public CreateItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return the service response + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new CreateItemResponse((Item) EwsUtilities + .getEnumeratedObjectAt(this.getItems(), responseIndex)); + } + + /** + * Validate request.. + * + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + @Override + protected void validate() throws ServiceLocalException, Exception { + super.validate(); + // Iterable item = this.getItems(); + // Validate each item. + for (Item item : this.getItems()) { + item.validate(); + } + } + + /** + * Gets the request version. Returns earliest Exchange version in which + * this request is supported. + * + * @return the minimum required server version + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateItemRequestBase.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateItemRequestBase.java new file mode 100644 index 000000000..2738e4b60 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateItemRequestBase.java @@ -0,0 +1,199 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.service.MessageDisposition; +import com.eischet.ews.api.core.enumeration.service.SendInvitationsMode; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.service.ServiceObject; + +import java.util.Collection; + +/** + * Represents an abstract CreateItem request. + * + * @param The type of the service object. + * @param The type of the response. + */ +abstract class CreateItemRequestBase + extends CreateRequest { + + /** + * The message disposition. + */ + private MessageDisposition messageDisposition = null; + + /** + * The send invitations mode. + */ + private SendInvitationsMode sendInvitationsMode = null; + + /** + * Initializes a new instance. + * + * @param service The service. + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception on errors + */ + protected CreateItemRequestBase(ExchangeService service, ServiceErrorHandling errorHandlingMode) throws Exception { + super(service, errorHandlingMode); + } + + /** + * Validate the request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.getItems(), "Items"); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.CreateItem; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.CreateItemResponse; + } + + /** + * Gets the name of the response message XML element. XML element name. + * + * @return the response message xml element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.CreateItemResponseMessage; + } + + /** + * Gets the name of the parent folder XML element. + * + * @return XML element name. + */ + @Override + protected String getParentFolderXmlElementName() { + return XmlElementNames.SavedItemFolderId; + } + + /** + * Gets the name of the object collection XML element. + * + * @return XML element name. + */ + @Override + protected String getObjectCollectionXmlElementName() { + return XmlElementNames.Items; + } + + /** + * Writes the attribute to XML. + * + * @param writer The writer. + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + if (this.messageDisposition != null) { + writer.writeAttributeValue(XmlAttributeNames.MessageDisposition, this.getMessageDisposition()); + } + if (this.sendInvitationsMode != null) { + writer.writeAttributeValue(XmlAttributeNames.SendMeetingInvitations, + this.sendInvitationsMode); + } + } + + /** + * Gets the message disposition. + * + * @return the message disposition + */ + public MessageDisposition getMessageDisposition() { + return messageDisposition; + } + + /** + * Sets the message disposition. + * + * @param value the new message disposition + */ + public void setMessageDisposition(MessageDisposition value) { + messageDisposition = value; + } + + /** + * Gets the send invitations mode. + * + * @return the send invitations mode + */ + public SendInvitationsMode getSendInvitationsMode() { + return sendInvitationsMode; + } + + /** + * Sets the send invitations mode. + * + * @param value the new send invitations mode + */ + public void setSendInvitationsMode(SendInvitationsMode value) { + sendInvitationsMode = value; + } + + /** + * Gets the item. + * + * @param value the new item + */ + public void setItems(Collection value) { + this.setObjects(value); + } + + /** + * Gets the item. + * + * @return the item + */ + public Iterable getItems() { + return this.getObjects(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateRequest.java new file mode 100644 index 000000000..36cd1666d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateRequest.java @@ -0,0 +1,170 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.property.complex.FolderId; + +import java.util.Collection; + +/** + * Represents an abstract Create request. + * + * @param The type of the service object. + * @param The type of the response. + */ +abstract class CreateRequest + extends MultiResponseServiceRequest { + + /** + * The parent folder id. + */ + private FolderId parentFolderId; + + /** + * The objects. + */ + private Collection objects; + + /** + * Initializes a new instance. + * + * @param service The service. + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + protected CreateRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Validates the request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + if (this.getParentFolderId() != null) { + this.getParentFolderId().validate( + this.getService().getRequestedServerVersion()); + } + } + + /** + * Gets the expected response message count. + * + * @return the expected response message count + */ + @Override + protected int getExpectedResponseMessageCount() { + return EwsUtilities.getEnumeratedObjectCount(this.objects.iterator()); + } + + /** + * Gets the name of the parent folder XML element. + * + * @return The name of the parent folder XML element. + */ + protected abstract String getParentFolderXmlElementName(); + + /** + * Gets the name of the object collection XML element. + * + * @return The name of the object collection XML element. + */ + protected abstract String getObjectCollectionXmlElementName(); + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.ServiceRequestBase#writeElementsToXml( + * microsoft.exchange.webservices.EwsServiceXmlWriter) + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + if (this.parentFolderId != null) { + writer.writeStartElement(XmlNamespace.Messages, this + .getParentFolderXmlElementName()); + this.getParentFolderId().writeToXml(writer); + writer.writeEndElement(); + } + + writer.writeStartElement(XmlNamespace.Messages, this + .getObjectCollectionXmlElementName()); + if (null != this.objects) { + for (ServiceObject obj : this.objects) { + obj.writeToXml(writer); + } + } + writer.writeEndElement(); + + } + + /** + * Gets the service objects. + * + * @return Iterator + */ + protected Iterable getObjects() { + return this.objects; + } + + /** + * Sets the service objects. + * + * @param value Iterator + */ + protected void setObjects(Collection value) { + this.objects = value; + } + + /** + * Gets the parent folder id. + * + * @return FolderId. + */ + public FolderId getParentFolderId() { + return this.parentFolderId; + } + + /** + * Sets the parent folder id. + * + * @param value FolderId. + */ + public void setParentFolderId(FolderId value) { + this.parentFolderId = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateResponseObjectRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateResponseObjectRequest.java new file mode 100644 index 000000000..fde4102cf --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateResponseObjectRequest.java @@ -0,0 +1,70 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.CreateResponseObjectResponse; +import com.eischet.ews.api.core.service.ServiceObject; + +/** + * Represents a CreateItem request for a response object. + */ +public final class CreateResponseObjectRequest extends + CreateItemRequestBase { + + /** + * Initializes a new instance of the CreateResponseObjectRequest class. + * + * @param service The Service + * @param errorHandlingMode Indicates how errors should be handled. + */ + public CreateResponseObjectRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) throws Exception { + super(service, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service object. + */ + @Override + protected CreateResponseObjectResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new CreateResponseObjectResponse(); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateUserConfigurationRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateUserConfigurationRequest.java new file mode 100644 index 000000000..c2b31b807 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/CreateUserConfigurationRequest.java @@ -0,0 +1,165 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.misc.UserConfiguration; + +/** + * Represents a CreateUserConfiguration request. + */ +public class CreateUserConfigurationRequest extends + MultiResponseServiceRequest { + + /** + * The user configuration. + */ + protected UserConfiguration userConfiguration; + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.userConfiguration, "userConfiguration"); + } + + /** + * Creates the service response. + * + * @param service The service. + * @param responseIndex Index of the response. + * @return Service response. + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new ServiceResponse(); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010; + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name, + */ + @Override + public String getXmlElementName() { + return XmlElementNames.CreateUserConfiguration; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name, + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.CreateUserConfigurationResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name, + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.CreateUserConfigurationResponseMessage; + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + // Write UserConfiguation element + this.userConfiguration.writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.UserConfiguration); + } + + /** + * Initializes a new instance of the class. + * + * @param service The service. + * @throws Exception + */ + public CreateUserConfigurationRequest(ExchangeService service) + throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + } + + /** + * Gets the user configuration. + * + * @return The userConfiguration. + */ + public UserConfiguration getUserConfiguration() { + return this.userConfiguration; + + } + + /** + * Sets the user configuration. + * + * @param value the new user configuration + */ + public void setUserConfiguration(UserConfiguration value) { + this.userConfiguration = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/DelegateManagementRequestBase.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/DelegateManagementRequestBase.java new file mode 100644 index 000000000..27419e49e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/DelegateManagementRequestBase.java @@ -0,0 +1,126 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.response.DelegateManagementResponse; +import com.eischet.ews.api.property.complex.Mailbox; + +/** + * Represents an abstract delegate management request. + * + * @param The type of the response. + */ +abstract class DelegateManagementRequestBase + extends SimpleServiceRequestBase { + + /** + * The mailbox. + */ + private Mailbox mailbox; + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception on errors + */ + protected DelegateManagementRequestBase(ExchangeService service) throws Exception { + super(service); + } + + /** + * Validate request. + * + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + @Override + protected void validate() throws ServiceLocalException, Exception { + super.validate(); + EwsUtilities.validateParam(this.getMailbox(), "Mailbox"); + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.getMailbox().writeToXml(writer, XmlNamespace.Messages, XmlElementNames.Mailbox); + } + + /** + * Creates the response. + * + * @return Response object. + */ + protected abstract TResponse createResponse(); + + /** + * {@inheritDoc} + */ + @Override + protected TResponse parseResponse(EwsServiceXmlReader reader) + throws Exception { + TResponse response = this.createResponse(); + response.loadFromXml(reader, this.getResponseXmlElementName()); + return response; + } + + /** + * Executes this request. + * + * @return Response object. + * @throws Exception the exception + */ + public TResponse execute() throws Exception { + TResponse serviceResponse = internalExecute(); + serviceResponse.throwIfNecessary(); + return serviceResponse; + } + + /** + * Gets the mailbox. The mailbox. + * + * @return the mailbox + */ + public Mailbox getMailbox() { + return this.mailbox; + } + + /** + * Sets the mailbox. + * + * @param mailbox the new mailbox + */ + public void setMailbox(Mailbox mailbox) { + this.mailbox = mailbox; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteAttachmentRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteAttachmentRequest.java new file mode 100644 index 000000000..f167913bb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteAttachmentRequest.java @@ -0,0 +1,176 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.DeleteAttachmentResponse; +import com.eischet.ews.api.property.complex.Attachment; + +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents a DeleteAttachment request. + */ +public final class DeleteAttachmentRequest extends + MultiResponseServiceRequest { + + private static final Logger LOG = Logger.getLogger(DeleteAttachmentRequest.class.getCanonicalName()); + + /** + * The attachments. + */ + private final List attachments = new ArrayList<>(); + + /** + * Initializes a new instance of the DeleteAttachmentRequest class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception + */ + public DeleteAttachmentRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Validate request. + */ + @Override + protected void validate() { + try { + super.validate(); + EwsUtilities.validateParamCollection(this.getAttachments().iterator(), "Attachments"); + for (int i = 0; i < this.attachments.size(); i++) { + EwsUtilities.validateParam(this.attachments.get(i).getId(), + String.format("Attachment[%d].Id ", i)); + } + } catch (Exception e) { + LOG.log(Level.SEVERE, "validation error", e); + } + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service object. + */ + @Override + protected DeleteAttachmentResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new DeleteAttachmentResponse( + this.attachments.get(responseIndex)); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.attachments.size(); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.DeleteAttachment; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.DeleteAttachmentResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.DeleteAttachmentResponseMessage; + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.AttachmentIds); + + for (Attachment attachment : this.attachments) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.AttachmentId); + writer + .writeAttributeValue(XmlAttributeNames.Id, attachment + .getId()); + writer.writeEndElement(); + } + + writer.writeEndElement(); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the attachments. + * + * @return the attachments + */ + public List getAttachments() { + return this.attachments; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteFolderRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteFolderRequest.java new file mode 100644 index 000000000..4405d08d4 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteFolderRequest.java @@ -0,0 +1,161 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.misc.FolderIdWrapperList; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents a DeleteFolder request. + */ +public final class DeleteFolderRequest extends DeleteRequest { + private static final Logger LOG = Logger.getLogger(DeleteFolderRequest.class.getCanonicalName()); + /** + * The folder ids. + */ + private final FolderIdWrapperList folderIds = new FolderIdWrapperList(); + + /** + * Initializes a new instance of the DeleteFolderRequest class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception + */ + public DeleteFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.getFolderIds(), "FolderIds"); + this.getFolderIds().validate( + this.getService().getRequestedServerVersion()); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.getFolderIds().getCount(); + } + + /** + * Creates the service response. + * + * @param service The service. + * @param responseIndex Index of the response. + * @return Service object. + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new ServiceResponse(); + } + + /** + * Gets the name of the XML element. + * + * @return Xml element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.DeleteFolder; + } + + /** + * Gets the name of the response XML element. + * + * @return Xml element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.DeleteFolderResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return Xml element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.DeleteFolderResponseMessage; + } + + /** + * Writes XML elements. + * + * @param writer The writer + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) { + try { + this.getFolderIds().writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.FolderIds); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error writing XML", e); + } + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the folder ids. + * + * @return The folder ids. + */ + public FolderIdWrapperList getFolderIds() { + return this.folderIds; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteItemRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteItemRequest.java new file mode 100644 index 000000000..82f9fcb1e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteItemRequest.java @@ -0,0 +1,223 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.SendCancellationsMode; +import com.eischet.ews.api.core.enumeration.service.calendar.AffectedTaskOccurrence; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.misc.ItemIdWrapperList; + +/** + * Represents a DeleteItem request. + */ +public final class DeleteItemRequest extends DeleteRequest { + + /** + * The item ids. + */ + private final ItemIdWrapperList itemIds = new ItemIdWrapperList(); + + /** + * The affected task occurrences. + */ + private AffectedTaskOccurrence affectedTaskOccurrences; + + /** + * The send cancellations mode. + */ + private SendCancellationsMode sendCancellationsMode; + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception on errors + */ + public DeleteItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) throws Exception { + super(service, errorHandlingMode); + } + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.itemIds, "ItemIds"); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.itemIds.getCount(); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response. + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new ServiceResponse(); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.DeleteItem; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.DeleteItemResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.DeleteItemResponseMessage; + } + + /** + * Writes XML attribute. + * + * @param writer the writer + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + + if (this.affectedTaskOccurrences != null) { + writer.writeAttributeValue( + XmlAttributeNames.AffectedTaskOccurrences, this + .getAffectedTaskOccurrences()); + } + + if (this.sendCancellationsMode != null) { + writer.writeAttributeValue( + XmlAttributeNames.SendMeetingCancellations, this + .getSendCancellationsMode()); + } + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.itemIds.writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.ItemIds); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the item ids. + * + * @return the item ids + */ + public ItemIdWrapperList getItemIds() { + return this.itemIds; + } + + /** + * Gets the affected task occurrences. + * + * @return the affected task occurrences + */ + AffectedTaskOccurrence getAffectedTaskOccurrences() { + return this.affectedTaskOccurrences; + } + + /** + * Sets the affected task occurrences. + * + * @param affectedTaskOccurrences the new affected task occurrences + */ + public void setAffectedTaskOccurrences(AffectedTaskOccurrence affectedTaskOccurrences) { + this.affectedTaskOccurrences = affectedTaskOccurrences; + } + + /** + * Gets the send cancellations. + * + * @return the send cancellations mode + */ + SendCancellationsMode getSendCancellationsMode() { + return this.sendCancellationsMode; + } + + /** + * Sets the send cancellations mode. + * + * @param sendCancellationsMode the new send cancellations mode + */ + public void setSendCancellationsMode(SendCancellationsMode sendCancellationsMode) { + this.sendCancellationsMode = sendCancellationsMode; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteRequest.java new file mode 100644 index 000000000..63f319ae0 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteRequest.java @@ -0,0 +1,97 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.enumeration.service.DeleteMode; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.ServiceResponse; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents an abstract Delete request. + * + * @param The type of the response. + */ +abstract class DeleteRequest extends + MultiResponseServiceRequest { + + private static final Logger LOG = Logger.getLogger(DeleteRequest.class.getCanonicalName()); + + /** + * Delete mode. Default is SoftDelete. + */ + private DeleteMode deleteMode = DeleteMode.SoftDelete; + + /** + * Initializes a new instance of the DeleteRequest class. + * + * @param service The Servcie + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + protected DeleteRequest(ExchangeService service, + ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Writes XML attribute. + * + * @param writer The writer. + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) + throws ExchangeXmlException { + super.writeAttributesToXml(writer); + writer.writeAttributeValue(XmlAttributeNames.DeleteType, this.getDeleteMode()); + } + + /** + * Gets the delete mode. + * + * @return the delete mode + */ + public DeleteMode getDeleteMode() { + return this.deleteMode; + } + + /** + * Gets the delete mode.e + * + * @param deleteMode the new delete mode + */ + public void setDeleteMode(DeleteMode deleteMode) { + this.deleteMode = deleteMode; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteUserConfigurationRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteUserConfigurationRequest.java new file mode 100644 index 000000000..e292fa8cd --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/DeleteUserConfigurationRequest.java @@ -0,0 +1,190 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.misc.UserConfiguration; +import com.eischet.ews.api.property.complex.FolderId; + +/** + * Represents a DeleteUserConfiguration request. + */ +public class DeleteUserConfigurationRequest extends + MultiResponseServiceRequest { + + /** + * The name. + */ + private String name; + + /** + * The parent folder id. + */ + private FolderId parentFolderId; + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.name, "name"); + EwsUtilities.validateParam(this.parentFolderId, "parentFolderId"); + this.getParentFolderId().validate( + this.getService().getRequestedServerVersion()); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response. + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new ServiceResponse(); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010; + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.DeleteUserConfiguration; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.DeleteUserConfigurationResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.DeleteUserConfigurationResponseMessage; + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + // Write UserConfiguationName element + UserConfiguration + .writeUserConfigurationNameToXml(writer, XmlNamespace.Messages, this.name, this.parentFolderId); + } + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception on error + */ + public DeleteUserConfigurationRequest(ExchangeService service) + throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + } + + /** + * Gets the name. + * + * @return the name + */ + protected String getName() { + return this.name; + } + + /** + * Sets the name. + * + * @param name the new name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Gets the parent folThe parent folder Id. + * + * @return the parent folder id + */ + protected FolderId getParentFolderId() { + return this.parentFolderId; + } + + /** + * Sets the parent folder id. + * + * @param parentFolderId the new parent folder id + */ + public void setParentFolderId(FolderId parentFolderId) { + this.parentFolderId = parentFolderId; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/DisconnectPhoneCallRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/DisconnectPhoneCallRequest.java new file mode 100644 index 000000000..d29339ae0 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/DisconnectPhoneCallRequest.java @@ -0,0 +1,141 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.messaging.PhoneCallId; + +/** + * Represents a DisconnectPhoneCall request. + */ +public final class DisconnectPhoneCallRequest extends SimpleServiceRequestBase { + + /** + * The id. + */ + private PhoneCallId id; + + /** + * Initializes a new instance of the DisconnectPhoneCallRequest class. + * + * @param service the service + * @throws Exception + */ + public DisconnectPhoneCallRequest(ExchangeService service) + throws Exception { + super(service); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.DisconnectPhoneCall; + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.id.writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.PhoneCallId); + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.DisconnectPhoneCallResponse; + } + + /** + * {@inheritDoc} + */ + @Override + protected ServiceResponse parseResponse(EwsServiceXmlReader reader) + throws Exception { + ServiceResponse serviceResponse = new ServiceResponse(); + serviceResponse.loadFromXml(reader, + XmlElementNames.DisconnectPhoneCallResponse); + return serviceResponse; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010; + } + + /** + * Executes this request. + * + * @return Service response. + * @throws Exception the exception + */ + public ServiceResponse execute() throws Exception { + ServiceResponse serviceResponse = internalExecute(); + serviceResponse.throwIfNecessary(); + return serviceResponse; + } + + /** + * Gets the Id of the phone call. + * + * @return the id + */ + protected PhoneCallId getId() { + return this.id; + } + + /** + * Sets the id. + * + * @param id the new id + */ + public void setId(PhoneCallId id) { + this.id = id; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/EmptyFolderRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/EmptyFolderRequest.java new file mode 100644 index 000000000..cafa30c0b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/EmptyFolderRequest.java @@ -0,0 +1,184 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.misc.FolderIdWrapperList; + +/** + * Represents an EmptyFolder request. + */ +public final class EmptyFolderRequest extends DeleteRequest { + + private final FolderIdWrapperList folderIds = new FolderIdWrapperList(); + private boolean deleteSubFolders; + + /** + * Initializes a new instance of the EmptyFolderRequest class. + * + * @param service The service. + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception on error + */ + public EmptyFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Validates request. + * + * @throws Exception on error + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.getFolderIds(), "FolderIds"); + this.getFolderIds().validate(this.getService(). + getRequestedServerVersion()); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.getFolderIds().getCount(); + } + + /** + * Creates the service response. + * + * @param service The service. + * @param responseIndex Index of the response. + * @return Service object + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new ServiceResponse(); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.EmptyFolder; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.EmptyFolderResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.EmptyFolderResponseMessage; + } + + /** + * Writes XML elements. + * + * @param writer The writer. + * @throws Exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.getFolderIds().writeToXml( + writer, + XmlNamespace.Messages, + XmlElementNames.FolderIds); + } + + /** + * Writes XML attribute. + * + * @param writer The writer. + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + writer.writeAttributeValue(XmlAttributeNames.DeleteSubFolders, this.deleteSubFolders); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010_SP1; + } + + /** + * Gets the folder ids. + * + * @return The folder ids. + */ + public FolderIdWrapperList getFolderIds() { + return this.folderIds; + } + + /** + * Gets a value indicating whether empty folder should also delete sub folder. + * + * @value true if empty folder should also delete sub folder, otherwise false. + */ + protected boolean getDeleteSubFolders() { + return deleteSubFolders; + } + + /** + * Sets a value indicating whether empty folder should also delete sub folder. + * + * @value true if empty folder should also delete sub folder, otherwise false. + */ + public void setDeleteSubFolders(boolean value) { + this.deleteSubFolders = value; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/ExecuteDiagnosticMethodRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/ExecuteDiagnosticMethodRequest.java new file mode 100644 index 000000000..22dd812d6 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/ExecuteDiagnosticMethodRequest.java @@ -0,0 +1,172 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.ExecuteDiagnosticMethodResponse; +import org.w3c.dom.Node; + +import javax.xml.stream.XMLStreamException; + +/** + * Defines the ExecuteDiagnosticMethodRequest class. + */ +public final class ExecuteDiagnosticMethodRequest extends + MultiResponseServiceRequest { + + private Node xmlNode; + private String verb; + + /** + * Initializes a new instance of the ExecuteDiagnosticMethodRequest class. + * + * @throws Exception + */ + public ExecuteDiagnosticMethodRequest(ExchangeService service) + throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + } + + /** + * Gets the name of the XML element. + * + * @return XmlElementNames + */ + @Override + public String getXmlElementName() { + return XmlElementNames.ExecuteDiagnosticMethod; + } + + /** + * Writes XML elements. + * + * @param writer The writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.Verb, this.getVerb()); + + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.Parameter); + writer.writeNode(this.getParameter()); + writer.writeEndElement(); + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.ExecuteDiagnosticMethodResponse; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + /** Set to 2007_SP1 because only test code + * will be using this method (it's marked internal. + * If it were marked for 2010_SP1, test cases + * would have to create new ExchangeService instances + * when using this method for tests running under older versions. + */ + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the verb of the method to execute. + */ + protected String getVerb() { + return verb; + } + + /** + * Sets the verb of the method to execute. + */ + public void setVerb(String value) { + this.verb = value; + } + + /** + * Gets the parameter to the executing method. + */ + protected Node getParameter() { + return xmlNode; + } + + /** + * Sets the parameter to the executing method. + */ + public void setParameter(Node value) { + this.xmlNode = value; + } + + /** + * Creates the service response. + * + * @param service The service + * @param responseIndex Index of the response + * @return Service response + */ + @Override + protected ExecuteDiagnosticMethodResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new ExecuteDiagnosticMethodResponse(service); + } + + /** + * Gets the name of the response message XML element. + * + * @return XmlElementNames + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.ExecuteDiagnosticMethodResponseMEssage; + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/ExpandGroupRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/ExpandGroupRequest.java new file mode 100644 index 000000000..dc29165a9 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/ExpandGroupRequest.java @@ -0,0 +1,164 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.ExpandGroupResponse; +import com.eischet.ews.api.property.complex.EmailAddress; + +/** + * Represents an ExpandGroup request. + */ +public class ExpandGroupRequest extends + MultiResponseServiceRequest { + + /** + * The email address. + */ + private EmailAddress emailAddress; + + /** + * Represents an ExpandGroup request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.getEmailAddress(), "EmailAddress"); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response. + */ + @Override + protected ExpandGroupResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new ExpandGroupResponse(); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.ExpandDL; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.ExpandDLResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.ExpandDLResponseMessage; + } + + /** + * writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + if (this.getEmailAddress() != null) { + this.getEmailAddress().writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.Mailbox); + } + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception on error + */ + public ExpandGroupRequest(ExchangeService service) + throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + } + + /** + * Gets the email address. + * + * @return the email address + */ + public EmailAddress getEmailAddress() { + return this.emailAddress; + } + + /** + * Sets the email address. + * + * @param emailAddress the new email address + */ + public void setEmailAddress(EmailAddress emailAddress) { + this.emailAddress = emailAddress; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/FindConversationRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/FindConversationRequest.java new file mode 100644 index 000000000..46b075f50 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/FindConversationRequest.java @@ -0,0 +1,202 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.FindConversationResponse; +import com.eischet.ews.api.misc.FolderIdWrapper; +import com.eischet.ews.api.search.ConversationIndexedItemView; +import com.eischet.ews.api.search.filter.SearchFilter; + +/** + * Represents a request to a Find Conversation operation + */ +public final class FindConversationRequest extends SimpleServiceRequestBase { + + + private ConversationIndexedItemView view; + private SearchFilter.IsEqualTo searchFilter; + private FolderIdWrapper folderId; + + /** + * @throws Exception + */ + public FindConversationRequest(ExchangeService service) + throws Exception { + super(service); + } + + + /** + * Gets or sets the view controlling the number of conversations returned. + */ + protected ConversationIndexedItemView getIndexedItemView() { + return this.view; + } + + public void setIndexedItemView(ConversationIndexedItemView value) { + this.view = value; + } + + + /** + * Gets or sets the search filter. + */ + protected SearchFilter.IsEqualTo getConversationViewFilter() { + + return this.searchFilter; + } + + public void setConversationViewFilter(SearchFilter.IsEqualTo value) { + this.searchFilter = value; + + } + + /** + * Gets or sets folder id + */ + protected FolderIdWrapper getFolderId() { + return this.folderId; + } + + public void setFolderId(FolderIdWrapper value) { + this.folderId = value; + } + + + /** + * Validate request. + * + * @throws Exception + * @throws ServiceLocalException + */ + @Override + protected void validate() throws ServiceLocalException, Exception { + super.validate(); + this.view.internalValidate(this); + } + + + /** + * Writes XML attribute. + * + * @param writer The writer. + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + } + + + /** + * Writes XML attribute. + * + * @param writer The writer. + * @throws Exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.getIndexedItemView().writeToXml(writer); + + if (this.getConversationViewFilter() != null) { + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.Restriction); + this.getConversationViewFilter().writeToXml(writer); + writer.writeEndElement(); // Restriction + } + + this.getIndexedItemView().writeOrderByToXml(writer); + + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.ParentFolderId); + this.getFolderId().writeToXml(writer); + writer.writeEndElement(); + } + + /** + * {@inheritDoc} + */ + @Override + protected FindConversationResponse parseResponse(EwsServiceXmlReader reader) + throws Exception { + FindConversationResponse response = new FindConversationResponse(); + response.loadFromXml(reader, + XmlElementNames.FindConversationResponse); + return response; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.FindConversation; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.FindConversationResponse; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010_SP1; + } + + /** + * Executes this request. + * + * @return Service response. + * @throws Exception + * @throws ServiceLocalException + */ + public FindConversationResponse execute() + throws ServiceLocalException, Exception { + FindConversationResponse serviceResponse = internalExecute(); + serviceResponse.throwIfNecessary(); + return serviceResponse; + } +} + diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/FindFolderRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/FindFolderRequest.java new file mode 100644 index 000000000..fa8a500e3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/FindFolderRequest.java @@ -0,0 +1,102 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.FindFolderResponse; + +/** + * Represents a FindFolder request. + */ +public final class FindFolderRequest extends FindRequest { + + /** + * Initializes a new instance of the FindFolderRequest class. + * + * @param exchangeService The Service + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + public FindFolderRequest(ExchangeService exchangeService, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(exchangeService, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param service The service + * @param responseIndex Index of the response. Service response. + * @return the find folder response + */ + @Override + protected FindFolderResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new FindFolderResponse(this.getView().getPropertySetOrDefault()); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.FindFolder; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.FindFolderResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.FindFolderResponseMessage; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/FindItemRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/FindItemRequest.java new file mode 100644 index 000000000..e851d3469 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/FindItemRequest.java @@ -0,0 +1,132 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.FindItemResponse; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.search.Grouping; + +/** + * Represents a FindItem request. + * + * @param The type of the item. + */ +public final class FindItemRequest extends + FindRequest> { + + /** + * The group by. + */ + private Grouping groupBy; + + /** + * Initializes a new instance of the FindItemRequest class. + * + * @param service The Service + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + public FindItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param service The service + * @param responseIndex Index of the response. + * @return Service response. + */ + @Override + protected FindItemResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new FindItemResponse(this.getGroupBy() != null, this + .getView().getPropertySetOrDefault()); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.FindItem; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.FindItemResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.FindItemResponseMessage; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the group by. + * + * @return the group by + */ + public Grouping getGroupBy() { + return this.groupBy; + } + + /** + * Sets the group by. + * + * @param value the new group by + */ + public void setGroupBy(Grouping value) { + this.groupBy = value; + + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/FindRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/FindRequest.java new file mode 100644 index 000000000..8948480ec --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/FindRequest.java @@ -0,0 +1,246 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.misc.FolderIdWrapperList; +import com.eischet.ews.api.search.Grouping; +import com.eischet.ews.api.search.ViewBase; +import com.eischet.ews.api.search.filter.SearchFilter; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents an abstract Find request. + * + * @param The type of the response. + */ +abstract class FindRequest extends MultiResponseServiceRequest { + + private static final Logger LOG = Logger.getLogger(FindRequest.class.getCanonicalName()); + + /** + * The parent folder ids. + */ + private final FolderIdWrapperList parentFolderIds = new FolderIdWrapperList(); + + /** + * The search filter. + */ + private SearchFilter searchFilter; + + /** + * The query string. + */ + private String queryString; + + /** + * The view. + */ + private ViewBase view; + + /** + * Initializes a new instance of the FindRequest class. + * + * @param service The service. + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + protected FindRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) throws ServiceVersionException { + super(service, errorHandlingMode); + } + + /** + * Validate request. + * + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + @Override + protected void validate() throws ServiceLocalException, Exception { + super.validate(); + + this.getView().internalValidate(this); + + // query string parameter is only valid for Exchange2010 or higher + // + if (!(this.queryString == null || this.queryString.isEmpty()) + && this.getService().getRequestedServerVersion().ordinal() < + ExchangeVersion.Exchange2010.ordinal()) { + throw new ServiceVersionException(String.format( + "The parameter %s is only valid for Exchange Server version %s or a later version.", + "queryString", ExchangeVersion.Exchange2010)); + } + + if ((!(this.queryString == null || this.queryString.isEmpty())) + && this.searchFilter != null) { + throw new ServiceLocalException( + "Both search filter and query string can't be specified. One of them must be null."); + } + } + + /** + * Gets the expected response message count. + * + * @return XML element name. + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.getParentFolderIds().getCount(); + } + + /** + * Gets the group by clause. + * + * @return The group by clause, null if the request does not have or support + * grouping. + */ + protected Grouping getGroupBy() { + return null; + } + + /** + * Writes XML attribute. + * + * @param writer The Writer + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + this.getView().writeAttributesToXml(writer); + } + + /** + * Writes XML elements. + * + * @param writer The Writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.getView().writeToXml(writer, this.getGroupBy()); + + if (this.getSearchFilter() != null) { + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.Restriction); + this.getSearchFilter().writeToXml(writer); + writer.writeEndElement(); // Restriction + } + + this.getView().writeOrderByToXml(writer); + + try { + this.getParentFolderIds().writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.ParentFolderIds); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error writing XML", e); + } + + if (!(this.queryString == null || this.queryString.isEmpty())) { + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.QueryString, this.queryString); + } + } + + /** + * Gets the parent folder ids. + * + * @return the parent folder ids + */ + public FolderIdWrapperList getParentFolderIds() { + return this.parentFolderIds; + } + + /** + * Gets the search filter. Available search filter classes include + * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection. If SearchFilter is null, no search + * filter are applied. + * + * @return the search filter + */ + public SearchFilter getSearchFilter() { + return searchFilter; + } + + /** + * Sets the search filter. Available search filter classes include + * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection. If SearchFilter is null, no search + * filter are applied. + * + * @param searchFilter the new search filter + */ + public void setSearchFilter(SearchFilter searchFilter) { + this.searchFilter = searchFilter; + } + + /** + * Gets the query string for indexed search. + * + * @return the query string + */ + public String getQueryString() { + return queryString; + } + + /** + * Sets the query string for indexed search. + * + * @param queryString the new query string + */ + public void setQueryString(String queryString) { + this.queryString = queryString; + } + + /** + * Gets the view controlling the number of item or folder returned. + * + * @return the view + */ + public ViewBase getView() { + return view; + } + + /** + * Sets the view controlling the number of item or folder returned. + * + * @param view the new view + */ + public void setView(ViewBase view) { + this.view = view; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetAttachmentRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetAttachmentRequest.java new file mode 100644 index 000000000..1386bf46d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetAttachmentRequest.java @@ -0,0 +1,213 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.BodyType; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.GetAttachmentResponse; +import com.eischet.ews.api.property.complex.Attachment; +import com.eischet.ews.api.property.definition.PropertyDefinitionBase; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a GetAttachment request. + */ +public final class GetAttachmentRequest extends MultiResponseServiceRequest { + + private final List attachments = new ArrayList<>(); + + private final List additionalProperties = new ArrayList<>(); + + private BodyType bodyType; + + /** + * Initializes a new instance of the GetAttachmentRequest class. + * + * @param service The service. + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception on errors + */ + public GetAttachmentRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParamCollection(this.getAttachments().iterator(), "Attachments"); + for (int i = 0; i < this.getAdditionalProperties().size(); i++) { + EwsUtilities.validateParam(this.getAdditionalProperties().get(i), + String.format("AdditionalProperties[%d]", i)); + } + } + + /** + * Creates the service response. + * + * @param service The service. + * @param responseIndex Index of the response. + * @return Service response. + */ + @Override + protected GetAttachmentResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new GetAttachmentResponse(this.getAttachments().get( + responseIndex)); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.getAttachments().size(); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.GetAttachment; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetAttachmentResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.GetAttachmentResponseMessage; + } + + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if ((this.getBodyType() != null) + || !this.getAdditionalProperties().isEmpty()) { + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.AttachmentShape); + + if (this.getBodyType() != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.BodyType, this.getBodyType()); + } + + if (!this.getAdditionalProperties().isEmpty()) { + PropertySet.writeAdditionalPropertiesToXml(writer, this.getAdditionalProperties().iterator()); + } + + writer.writeEndElement(); // AttachmentShape + } + + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.AttachmentIds); + + for (Attachment attachment : this.getAttachments()) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.AttachmentId); + writer + .writeAttributeValue(XmlAttributeNames.Id, attachment + .getId()); + writer.writeEndElement(); + } + + writer.writeEndElement(); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the attachments. + * + * @return the attachments + */ + public List getAttachments() { + return this.attachments; + } + + /** + * Gets the additional property. + * + * @return the additional property + */ + public List getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Gets the type of the body. + * + * @return the body type + */ + public BodyType getBodyType() { + + return this.bodyType; + + } + + /** + * Sets the body type. + * + * @param bodyType the new body type + */ + public void setBodyType(BodyType bodyType) { + this.bodyType = bodyType; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetDelegateRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetDelegateRequest.java new file mode 100644 index 000000000..98d144096 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetDelegateRequest.java @@ -0,0 +1,169 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.GetDelegateResponse; +import com.eischet.ews.api.property.complex.UserId; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a GetDelegate request. + */ +public class GetDelegateRequest extends + DelegateManagementRequestBase { + + /** + * The user ids. + */ + private final List userIds = new ArrayList(); + + /** + * The include permissions. + */ + private boolean includePermissions; + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception + */ + public GetDelegateRequest(ExchangeService service) + throws Exception { + super(service); + } + + /** + * Creates the response. + * + * @return Service response. + */ + @Override + protected GetDelegateResponse createResponse() { + return new GetDelegateResponse(true); + } + + /** + * Writes XML attribute. + * + * @param writer the writer + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + writer.writeAttributeValue(XmlAttributeNames.IncludePermissions, this + .getIncludePermissions()); + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + super.writeElementsToXml(writer); + + if (this.getUserIds().size() > 0) { + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.UserIds); + + for (UserId userId : this.getUserIds()) { + userId.writeToXml(writer, XmlElementNames.UserId); + } + + writer.writeEndElement(); // UserIds + } + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetDelegateResponse; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.GetDelegate; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the user ids. The user ids. + * + * @return the user ids + */ + public List getUserIds() { + return this.userIds; + } + + /** + * Gets a value indicating whether permissions are included. + * + * @return the include permissions + */ + public boolean getIncludePermissions() { + return this.includePermissions; + + } + + /** + * Sets the include permissions. + * + * @param includePermissions the new include permissions + */ + public void setIncludePermissions(boolean includePermissions) { + this.includePermissions = includePermissions; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetEventsRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetEventsRequest.java new file mode 100644 index 000000000..bdb6dcafb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetEventsRequest.java @@ -0,0 +1,189 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.GetEventsResponse; + +import javax.xml.stream.XMLStreamException; + +/** + * GetEvents request. + */ +public class GetEventsRequest extends MultiResponseServiceRequest { + + /** + * The subscription id. + */ + private String subscriptionId; + + /** + * The watermark. + */ + private String watermark; + + /** + * Initializes a new instance. + * + * @param service the service + * @throws Exception + */ + public GetEventsRequest(ExchangeService service) + throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response + */ + @Override + protected GetEventsResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new GetEventsResponse(); + } + + /** + * Gets the expected response message count. + * + * @return Response count + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.GetEvents; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetEventsResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.GetEventsResponseMessage; + } + + /** + * Validates the request. + * + * @throws Exception the exception + */ + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateNonBlankStringParam(this. + getSubscriptionId(), "SubscriptionId"); + EwsUtilities.validateNonBlankStringParam(this. + getWatermark(), "Watermark"); + } + + /** + * Writes the elements to XML writer. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeElementValue(XmlNamespace.Messages, XmlElementNames.SubscriptionId, this.getSubscriptionId()); + writer.writeElementValue(XmlNamespace.Messages, XmlElementNames.Watermark, this.getWatermark()); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * gets the subscriptionId. + * + * @return the subscriptionId. + */ + public String getSubscriptionId() { + return subscriptionId; + } + + /** + * Sets the subscriptionId. + * + * @param subscriptionId the subscriptionId. + */ + public void setSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + } + + /** + * gets the watermark. + * + * @return the watermark. + */ + public String getWatermark() { + return watermark; + } + + /** + * Sets the watermark. + * + * @param watermark the new watermark + */ + public void setWatermark(String watermark) { + this.watermark = watermark; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetFolderRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetFolderRequest.java new file mode 100644 index 000000000..7ab0a11ed --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetFolderRequest.java @@ -0,0 +1,64 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.GetFolderResponse; + +/** + * Represents a GetFolder request. + */ +public final class GetFolderRequest extends GetFolderRequestBase { + + // private FolderIdWrapperList folderIds = new FolderIdWrapperList(); + + /** + * Initializes a new instance of the GetFolderRequest class. + * + * @param service the service + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + public GetFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param service The service + * @param responseIndex Index of the response. + * @return Service response. + */ + @Override + protected GetFolderResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new GetFolderResponse(this.getFolderIds() + .getFolderIdWrapperList(responseIndex).getFolder(), this + .getPropertySet()); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetFolderRequestBase.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetFolderRequestBase.java new file mode 100644 index 000000000..a1c274c03 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetFolderRequestBase.java @@ -0,0 +1,151 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.ServiceObjectType; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.service.folder.Folder; +import com.eischet.ews.api.misc.FolderIdWrapperList; + +/** + * Represents an abstract GetFolder request. + * + * @param the generic type + */ +abstract class GetFolderRequestBase extends GetRequest { + + /** + * The folder ids. + */ + private final FolderIdWrapperList folderIds = new FolderIdWrapperList(); + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception + */ + protected GetFolderRequestBase(ExchangeService service, + ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Validate request. + * + * @throws Exception the exception + */ + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParamCollection(this.getFolderIds().iterator(), "FolderIds"); + this.getFolderIds().validate( + this.getService().getRequestedServerVersion()); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages + */ + protected int getExpectedResponseMessageCount() { + return this.getFolderIds().getCount(); + } + + /** + * Gets the type of the service object this request applies to. + * + * @return The type of service object the request applies to + */ + protected ServiceObjectType getServiceObjectType() { + return ServiceObjectType.Folder; + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + super.writeElementsToXml(writer); + this.getFolderIds().writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.FolderIds); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + public String getXmlElementName() { + return XmlElementNames.GetFolder; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + protected String getResponseXmlElementName() { + return XmlElementNames.GetFolderResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + protected String getResponseMessageXmlElementName() { + return XmlElementNames.GetFolderResponseMessage; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported + */ + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the folder ids. + * + * @return the folder ids + */ + public FolderIdWrapperList getFolderIds() { + return this.folderIds; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetFolderRequestForLoad.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetFolderRequestForLoad.java new file mode 100644 index 000000000..591f7a889 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetFolderRequestForLoad.java @@ -0,0 +1,63 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.GetFolderResponse; +import com.eischet.ews.api.core.response.ServiceResponse; + +/** + * Represents a GetFolder request specialized to return ServiceResponse. + */ +public final class GetFolderRequestForLoad extends + GetFolderRequestBase { + + /** + * Initializes a new instance of the GetFolderRequestForLoad class. + * + * @param exchangeService the exchange service + * @param throwonerror the throwonerror + * @throws Exception + */ + public GetFolderRequestForLoad(ExchangeService exchangeService, ServiceErrorHandling throwonerror) throws Exception { + super(exchangeService, throwonerror); + } + + /** + * Creates the service response. + * + * @param service The Service + * @param responseIndex the response index + * @return Service response. + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new GetFolderResponse(this.getFolderIds() + .getFolderIdWrapperList(responseIndex).getFolder(), this + .getPropertySet()); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetInboxRulesRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetInboxRulesRequest.java new file mode 100644 index 000000000..b7e35db68 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetInboxRulesRequest.java @@ -0,0 +1,148 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.GetInboxRulesResponse; + +import javax.xml.stream.XMLStreamException; + +/** + * Represents a GetInboxRules request. + */ +public final class GetInboxRulesRequest extends SimpleServiceRequestBase { + + /** + * The smtp address of the mailbox from which to get the inbox rules. + */ + private String mailboxSmtpAddress; + + /** + * Initializes a new instance of the GetInboxRulesRequest class. + * + * @param service The service. + * @throws Exception + */ + public GetInboxRulesRequest(ExchangeService service) throws Exception { + super(service); + } + + /** + * Gets or sets the address of the mailbox + * from which to get the inbox rules. + * + * @return the mailboxSmtpAddress + */ + protected String getmailboxSmtpAddress() { + return this.mailboxSmtpAddress; + } + + /** + * sets the address of the mailbox from which to get the inbox rules. + */ + public void setmailboxSmtpAddress(String value) { + this.mailboxSmtpAddress = value; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.GetInboxRules; + } + + /** + * Writes XML elements. + * + * @param writer The writer. + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (!(this.mailboxSmtpAddress == null || + this.mailboxSmtpAddress.isEmpty())) { + writer.writeElementValue( + XmlNamespace.Messages, + XmlElementNames.MailboxSmtpAddress, + this.mailboxSmtpAddress); + } + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetInboxRulesResponse; + } + + /** + * {@inheritDoc} + */ + @Override + protected GetInboxRulesResponse parseResponse(EwsServiceXmlReader reader) + throws Exception { + GetInboxRulesResponse response = new GetInboxRulesResponse(); + response.loadFromXml(reader, XmlElementNames.GetInboxRulesResponse); + return response; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010_SP1; + } + + /** + * Executes this request. + * + * @return Service response. + * @throws Exception + * @throws ServiceLocalException + */ + public GetInboxRulesResponse execute() + throws ServiceLocalException, Exception { + GetInboxRulesResponse serviceResponse = internalExecute(); + serviceResponse.throwIfNecessary(); + return serviceResponse; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetItemRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetItemRequest.java new file mode 100644 index 000000000..4cef8462e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetItemRequest.java @@ -0,0 +1,60 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.GetItemResponse; + +/** + * Represents an abstract GetItem request. + */ +public final class GetItemRequest extends GetItemRequestBase { + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception + */ + public GetItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response + */ + protected GetItemResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new GetItemResponse(this.getItemIds().getItemIdWrapperList( + responseIndex), this.getPropertySet()); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetItemRequestBase.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetItemRequestBase.java new file mode 100644 index 000000000..df155bc9f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetItemRequestBase.java @@ -0,0 +1,151 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.ServiceObjectType; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.misc.ItemIdWrapperList; + +/** + * Represents an abstract GetItem request. + * + * @param the generic type + */ +abstract class GetItemRequestBase extends GetRequest { + + /** + * The item ids. + */ + private final ItemIdWrapperList itemIds = new ItemIdWrapperList(); + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception + */ + protected GetItemRequestBase(ExchangeService service, + ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Validate request. + * + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + protected void validate() throws ServiceLocalException, Exception { + super.validate(); + EwsUtilities.validateParamCollection(this.getItemIds().iterator(), "ItemIds"); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages + */ + protected int getExpectedResponseMessageCount() { + return this.itemIds.getCount(); + } + + /** + * Gets the type of the service object this request applies to. + * + * @return The type of service object the request applies to + */ + protected ServiceObjectType getServiceObjectType() { + return ServiceObjectType.Item; + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + super.writeElementsToXml(writer); + + this.itemIds.writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.ItemIds); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + public String getXmlElementName() { + return XmlElementNames.GetItem; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + protected String getResponseXmlElementName() { + return XmlElementNames.GetItemResponse; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + protected String getResponseMessageXmlElementName() { + return XmlElementNames.GetItemResponseMessage; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported + */ + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the item ids. + * + * @return the item ids + */ + public ItemIdWrapperList getItemIds() { + return this.itemIds; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetItemRequestForLoad.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetItemRequestForLoad.java new file mode 100644 index 000000000..77d947981 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetItemRequestForLoad.java @@ -0,0 +1,62 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.GetItemResponse; +import com.eischet.ews.api.core.response.ServiceResponse; + +/** + * Represents a GetItem request specialized to return ServiceResponse. + */ +public final class GetItemRequestForLoad extends GetItemRequestBase { + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception + */ + public GetItemRequestForLoad(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response. + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new GetItemResponse(this.getItemIds().getItemIdWrapperList( + responseIndex), this.getPropertySet()); + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetPasswordExpirationDateRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetPasswordExpirationDateRequest.java new file mode 100644 index 000000000..024e4235f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetPasswordExpirationDateRequest.java @@ -0,0 +1,113 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.response.GetPasswordExpirationDateResponse; + +public final class GetPasswordExpirationDateRequest extends SimpleServiceRequestBase { + + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + // TODO Auto-generated method stub + return ExchangeVersion.Exchange2010_SP1; + } + + /** + * Initializes a new instance of the GetPasswordExpirationDateRequest class + * + * @throws Exception + */ + public GetPasswordExpirationDateRequest(ExchangeService service) throws Exception { + super(service); + } + + protected String getResponseXmlElementName() { + return XmlElementNames.GetPasswordExpirationDateResponse; + } + + /** + * Gets the name of the XML Element. + * returns XML element name + */ + public String getXmlElementName() { + return XmlElementNames.GetPasswordExpirationDateRequest; + } + + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) throws Exception { + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.MailboxSmtpAddress, + this.getMailboxSmtpAddress()); + } + + /** + * {@inheritDoc} + */ + @Override + protected GetPasswordExpirationDateResponse parseResponse(EwsServiceXmlReader reader) throws Exception { + GetPasswordExpirationDateResponse response = new GetPasswordExpirationDateResponse(); + response.loadFromXml(reader, XmlElementNames.GetPasswordExpirationDateResponse); + return response; + } + + /** + * Gets the request version + * @return Earliest Exchange version in which this request is supported. + *//* + protected ExchangeVersion getMinimumRequiredServerVersion(){ + return ExchangeVersion.Exchange2010_SP1; + }*/ + + /** + * Executes this request. + * + * @return Service response. + */ + public GetPasswordExpirationDateResponse execute() throws Exception { + GetPasswordExpirationDateResponse serviceResponse = internalExecute(); + serviceResponse.throwIfNecessary(); + return serviceResponse; + } + + /** + * Gets mailbox smtp address. + * + * @return The mailbox smtp address. + */ + protected String getMailboxSmtpAddress() { + return this.mailboxSmtpAddress; + } + + public void setMailboxSmtpAddress(String mailboxSmtpAddress) { + this.mailboxSmtpAddress = mailboxSmtpAddress; + } + + private String mailboxSmtpAddress; +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetPhoneCallRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetPhoneCallRequest.java new file mode 100644 index 000000000..524de497d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetPhoneCallRequest.java @@ -0,0 +1,140 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.response.GetPhoneCallResponse; +import com.eischet.ews.api.messaging.PhoneCallId; + +/** + * Represents a GetPhoneCall request. + */ +public final class GetPhoneCallRequest extends SimpleServiceRequestBase { + + /** + * The id. + */ + private PhoneCallId id; + + /** + * Initializes a new instance of the GetPhoneCallRequest class. + * + * @param service the service + * @throws Exception + */ + public GetPhoneCallRequest(ExchangeService service) + throws Exception { + super(service); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.GetPhoneCall; + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.id.writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.PhoneCallId); + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetPhoneCallResponse; + } + + /** + * {@inheritDoc} + */ + @Override + protected GetPhoneCallResponse parseResponse(EwsServiceXmlReader reader) + throws Exception { + GetPhoneCallResponse response = new GetPhoneCallResponse(getService()); + response.loadFromXml(reader, XmlElementNames.GetPhoneCallResponse); + return response; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010; + } + + /** + * Executes this request. + * + * @return Service response. + * @throws Exception the exception + */ + public GetPhoneCallResponse execute() throws Exception { + GetPhoneCallResponse serviceResponse = internalExecute(); + serviceResponse.throwIfNecessary(); + return serviceResponse; + } + + /** + * Gets the Id of the phone call. + * + * @return the id + */ + protected PhoneCallId getId() { + return id; + } + + /** + * Sets the id. + * + * @param id the new id + */ + public void setId(PhoneCallId id) { + this.id = id; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetRequest.java new file mode 100644 index 000000000..314751ce7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetRequest.java @@ -0,0 +1,112 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.enumeration.service.ServiceObjectType; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.service.ServiceObject; + +/** + * Represents an abstract Get request. + * + * @param the generic type + * @param the generic type + */ +abstract class GetRequest + extends MultiResponseServiceRequest { + + /** + * The property set. + */ + private PropertySet propertySet; + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception + */ + protected GetRequest(ExchangeService service, + ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Validate request. + * + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + protected void validate() throws ServiceLocalException, Exception { + super.validate(); + EwsUtilities.validateParam(this.propertySet, "PropertySet"); + this.propertySet + .validateForRequest(this, false /* summaryPropertiesOnly */); + } + + /** + * Gets the type of the service object this request applies to. + * + * @return The type of service object the request applies to + */ + protected abstract ServiceObjectType getServiceObjectType(); + + /** + * Gets the type of the service object this request applies to. + * + * @param writer the writer + * @throws Exception + */ + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.propertySet.writeToXml(writer, this.getServiceObjectType()); + } + + /** + * Gets the property set. + * + * @return the property set + */ + public PropertySet getPropertySet() { + return this.propertySet; + } + + /** + * Sets the property set. + * + * @param propertySet the new property set + */ + public void setPropertySet(PropertySet propertySet) { + this.propertySet = propertySet; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetRoomListsRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetRoomListsRequest.java new file mode 100644 index 000000000..f37820f67 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetRoomListsRequest.java @@ -0,0 +1,111 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.response.GetRoomListsResponse; + +/** + * Represents a GetRoomList request. + */ +public final class GetRoomListsRequest extends SimpleServiceRequestBase { + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception + */ + public GetRoomListsRequest(ExchangeService service) + throws Exception { + super(service); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.GetRoomListsRequest; + } + + /** + * Writes XML elements. + * + * @param writer the writer + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) { + // Don't have parameter in request + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetRoomListsResponse; + } + + /** + * {@inheritDoc} + */ + @Override + protected GetRoomListsResponse parseResponse(EwsServiceXmlReader reader) + throws Exception { + GetRoomListsResponse response = new GetRoomListsResponse(); + response.loadFromXml(reader, XmlElementNames.GetRoomListsResponse); + return response; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010; + } + + /** + * Executes this request. + * + * @return Service response + * @throws Exception the exception + */ + public GetRoomListsResponse execute() throws Exception { + GetRoomListsResponse serviceResponse = internalExecute(); + serviceResponse.throwIfNecessary(); + return serviceResponse; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetRoomsRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetRoomsRequest.java new file mode 100644 index 000000000..ef966d741 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetRoomsRequest.java @@ -0,0 +1,140 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.response.GetRoomsResponse; +import com.eischet.ews.api.property.complex.EmailAddress; + +/** + * Represents a GetRooms request. + */ +public final class GetRoomsRequest extends SimpleServiceRequestBase { + + /** + * Represents a GetRooms request. + * + * @param service the service + * @throws Exception + */ + public GetRoomsRequest(ExchangeService service) + throws Exception { + super(service); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.GetRoomsRequest; + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.getRoomList().writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.RoomList); + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetRoomsResponse; + } + + /** + * {@inheritDoc} + */ + @Override + protected GetRoomsResponse parseResponse(EwsServiceXmlReader reader) + throws Exception { + GetRoomsResponse response = new GetRoomsResponse(); + response.loadFromXml(reader, XmlElementNames.GetRoomsResponse); + return response; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010; + } + + /** + * Executes this request. + * + * @return Service response. + * @throws Exception the exception + */ + public GetRoomsResponse execute() throws Exception { + GetRoomsResponse serviceResponse = internalExecute(); + serviceResponse.throwIfNecessary(); + return serviceResponse; + } + + /** + * Gets the room list to retrieve rooms from. + * + * @return the room list + */ + protected EmailAddress getRoomList() { + return this.roomList; + } + + /** + * Sets the room list. + * + * @param value the new room list + */ + public void setRoomList(EmailAddress value) { + this.roomList = value; + } + + /** + * The room list. + */ + private EmailAddress roomList; + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetServerTimeZonesRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetServerTimeZonesRequest.java new file mode 100644 index 000000000..9555f650c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetServerTimeZonesRequest.java @@ -0,0 +1,174 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.GetServerTimeZonesResponse; + +import javax.xml.stream.XMLStreamException; + +/** + * Represents a GetServerTimeZones request. + */ +public final class GetServerTimeZonesRequest extends + MultiResponseServiceRequest { + + /** + * The ids. + */ + private Iterable ids; + + /** + * Gets the XML element name associated with the transition. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + if (this.ids != null) { + EwsUtilities.validateParamCollection(this.getIds().iterator(), "Ids"); + } + } + + /** + * Initializes a new instance of the "GetServerTimeZonesRequest" class. + * + * @param service the service + * @throws Exception + */ + public GetServerTimeZonesRequest(ExchangeService service) + throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response. + */ + @Override + protected GetServerTimeZonesResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new GetServerTimeZonesResponse(); + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name, + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.GetServerTimeZonesResponseMessage; + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name, + */ + @Override + public String getXmlElementName() { + return XmlElementNames.GetServerTimeZones; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name, + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetServerTimeZonesResponse; + } + + /** + * Gets the minimum server version required to process this request. + * + * @return Exchange server version. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010; + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws ServiceXmlSerializationException the service xml serialization exception + * @throws XMLStreamException the XML stream exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws ServiceXmlSerializationException, XMLStreamException, ExchangeXmlException { + if (this.getIds() != null) { + writer.writeStartElement(XmlNamespace.Messages, XmlElementNames.Ids); + for (String id : this.getIds()) { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Id, id); + } + writer.writeEndElement(); // Ids + } + } + + /** + * Gets the ids of the time zones that should be returned by the + * server. + * + * @return the ids + */ + protected Iterable getIds() { + return this.ids; + } + + /** + * Sets the ids. + * + * @param ids the new ids + */ + protected void setIds(Iterable ids) { + this.ids = ids; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetStreamingEventsRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetStreamingEventsRequest.java new file mode 100644 index 000000000..bc544a0cd --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetStreamingEventsRequest.java @@ -0,0 +1,158 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.GetStreamingEventsResponse; +import com.eischet.ews.api.http.ExchangeHttpClient; + +import javax.xml.stream.XMLStreamException; + +/** + * Defines the GetStreamingEventsRequest class. + */ +public class GetStreamingEventsRequest extends HangingServiceRequestBase { + + protected final static int HeartbeatFrequencyDefault = 45000; ////45s in ms + private static int heartbeatFrequency = HeartbeatFrequencyDefault; + + private final Iterable subscriptionIds; + private final int connectionTimeout; + + /** + * Initializes a new instance of the GetStreamingEventsRequest class. + * + * @param service The service + * @param serviceObjectHandler The serviceObjectHandler + * @param subscriptionIds The subscriptionIds + * @param connectionTimeout The connectionTimeout + * @throws ServiceVersionException + */ + public GetStreamingEventsRequest(ExchangeService service, IHandleResponseObject serviceObjectHandler, + Iterable subscriptionIds, int connectionTimeout) + throws ServiceVersionException { + super(service, serviceObjectHandler, + GetStreamingEventsRequest.heartbeatFrequency); + this.subscriptionIds = subscriptionIds; + this.connectionTimeout = connectionTimeout; + } + + /** + * Gets the name of the XML element. + * + * @return XmlElementNames + */ + @Override + public String getXmlElementName() { + return XmlElementNames.GetStreamingEvents; + } + + /** + * Gets the name of the response XML element. + * + * @return XmlElementNames + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetStreamingEventsResponse; + } + + /** + * Writes the elements to XML writer. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.SubscriptionIds); + + for (String id : this.subscriptionIds) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.SubscriptionId, + id); + } + + writer.writeEndElement(); + + writer.writeElementValue( + XmlNamespace.Messages, + XmlElementNames.ConnectionTimeout, + this.connectionTimeout); + } + + /** + * Gets the request version. + * + * @return ExchangeVersion + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010_SP1; + } + + /** + * {@inheritDoc} + */ + @Override + protected GetStreamingEventsResponse parseResponse(EwsServiceXmlReader reader) + throws Exception { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.ResponseMessages); + + GetStreamingEventsResponse response = + new GetStreamingEventsResponse(this); + response.loadFromXml(reader, XmlElementNames. + GetStreamingEventsResponseMessage); + + reader.readEndElementIfNecessary(XmlNamespace.Messages, + XmlElementNames.ResponseMessages); + + return response; + } + + /** + * region Test hooks + * Allow test code to change heartbeat value + */ + protected static void setHeartbeatFrequency(int heartbeatFrequency) { + GetStreamingEventsRequest.heartbeatFrequency = heartbeatFrequency; + } + + @Override + protected ExchangeHttpClient.Request buildEwsHttpWebRequest() throws Exception { + return super.buildEwsHttpPoolingWebRequest(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetUserAvailabilityRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetUserAvailabilityRequest.java new file mode 100644 index 000000000..16ec33a6e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetUserAvailabilityRequest.java @@ -0,0 +1,320 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.availability.AvailabilityData; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.misc.error.ServiceError; +import com.eischet.ews.api.core.response.AttendeeAvailability; +import com.eischet.ews.api.core.response.ServiceResponseCollection; +import com.eischet.ews.api.core.response.SuggestionsResponse; +import com.eischet.ews.api.misc.availability.*; + +/** + * Represents a GetUserAvailability request. + */ +public final class GetUserAvailabilityRequest extends SimpleServiceRequestBase { + + /** + * The attendees. + */ + private Iterable attendees; + + /** + * The time window. + */ + private TimeWindow timeWindow; + + /** + * The requested data. + */ + private AvailabilityData requestedData = + AvailabilityData.FreeBusyAndSuggestions; + + /** + * The options. + */ + private AvailabilityOptions options; + + /** + * Initializes a new instance of the "GetUserAvailabilityRequest" class. + * + * @param service the service + * @throws Exception + */ + public GetUserAvailabilityRequest(ExchangeService service) + throws Exception { + super(service); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.GetUserAvailabilityRequest; + } + + /** + * Gets a value indicating whether free/busy data is requested. + * + * @return true, if is free busy view requested + */ + public boolean isFreeBusyViewRequested() { + return this.requestedData == AvailabilityData.FreeBusy || + this.requestedData == AvailabilityData. + FreeBusyAndSuggestions; + } + + /** + * Gets a value indicating whether suggestions are requested. + * + * @return true, if is suggestions view requested + */ + public boolean isSuggestionsViewRequested() { + return this.requestedData == AvailabilityData.Suggestions || + this.requestedData == AvailabilityData. + FreeBusyAndSuggestions; + } + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + + this.options.validate(this.timeWindow.getDuration()); + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + // Only serialize the TimeZone property against an Exchange 2007 SP1 + // server. + // Against Exchange 2010, the time zone is emitted in the request's SOAP + // header. + //if (writer.getService().getRequestedServerVersion() == + //ExchangeVersion.Exchange2007_SP1) { + LegacyAvailabilityTimeZone legacyTimeZone = + new LegacyAvailabilityTimeZone(); + + legacyTimeZone.writeToXml(writer, XmlElementNames.TimeZone); + + + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.MailboxDataArray); + + for (AttendeeInfo attendee : this.attendees) { + attendee.writeToXml(writer); + } + + writer.writeEndElement(); // MailboxDataArray + + this.options.writeToXml(writer, this); + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetUserAvailabilityResponse; + } + + /** + * {@inheritDoc} + */ + @Override + protected GetUserAvailabilityResults parseResponse(EwsServiceXmlReader reader) + throws Exception { + GetUserAvailabilityResults serviceResponse = + new GetUserAvailabilityResults(); + + if (this.isFreeBusyViewRequested()) { + serviceResponse + .setAttendeesAvailability(new ServiceResponseCollection()); + + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.FreeBusyResponseArray); + + do { + reader.read(); + + if (reader.isStartElement(XmlNamespace.Messages, + XmlElementNames.FreeBusyResponse)) { + AttendeeAvailability freeBusyResponse = + new AttendeeAvailability(); + + freeBusyResponse.loadFromXml(reader, + XmlElementNames.ResponseMessage); + + if (freeBusyResponse.getErrorCode().equals( + ServiceError.NoError)) { + freeBusyResponse.loadFreeBusyViewFromXml(reader, + this.options.getRequestedFreeBusyView()); + } + + serviceResponse.getAttendeesAvailability().add( + freeBusyResponse); + } + } while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.FreeBusyResponseArray)); + } + + if (this.isSuggestionsViewRequested()) { + serviceResponse.setSuggestionsResponse(new SuggestionsResponse()); + + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.SuggestionsResponse); + + serviceResponse.getSuggestionsResponse().loadFromXml(reader, + XmlElementNames.ResponseMessage); + + if (serviceResponse.getSuggestionsResponse().getErrorCode().equals( + ServiceError.NoError)) { + serviceResponse.getSuggestionsResponse() + .loadSuggestedDaysFromXml(reader); + } + + reader.readEndElement(XmlNamespace.Messages, + XmlElementNames.SuggestionsResponse); + } + + return serviceResponse; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Executes this request. + * + * @return Service response. + * @throws Exception the exception + */ + public GetUserAvailabilityResults execute() throws Exception { + return internalExecute(); + } + + /** + * Gets the attendees. + * + * @return the attendees + */ + public Iterable getAttendees() { + return attendees; + } + + /** + * Sets the attendees. + * + * @param attendees the new attendees + */ + public void setAttendees(Iterable attendees) { + this.attendees = attendees; + } + + /** + * Gets the time window in which to retrieve user availability + * information. + * + * @return the time window + */ + public TimeWindow getTimeWindow() { + return timeWindow; + } + + /** + * Sets the time window. + * + * @param timeWindow the new time window + */ + public void setTimeWindow(TimeWindow timeWindow) { + this.timeWindow = timeWindow; + } + + /** + * Gets a value indicating what data is requested (free/busy and/or + * suggestions). + * + * @return the requested data + */ + public AvailabilityData getRequestedData() { + return requestedData; + } + + /** + * Sets the requested data. + * + * @param requestedData the new requested data + */ + public void setRequestedData(AvailabilityData requestedData) { + this.requestedData = requestedData; + } + + /** + * Gets an object that allows you to specify options controlling the + * information returned by the GetUserAvailability request. + * + * @return the options + */ + public AvailabilityOptions getOptions() { + return options; + } + + /** + * Sets the options. + * + * @param options the new options + */ + public void setOptions(AvailabilityOptions options) { + this.options = options; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetUserConfigurationRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetUserConfigurationRequest.java new file mode 100644 index 000000000..d7369daea --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetUserConfigurationRequest.java @@ -0,0 +1,264 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.UserConfigurationProperties; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.response.GetUserConfigurationResponse; +import com.eischet.ews.api.misc.UserConfiguration; +import com.eischet.ews.api.property.complex.FolderId; + +import java.util.EnumSet; + +/** + * The Class GetUserConfigurationRequest. + */ +public class GetUserConfigurationRequest extends + MultiResponseServiceRequest { + + /** + * The name. + */ + private String name; + + /** + * The parent folder id. + */ + private FolderId parentFolderId; + + /** + * The property. + */ + private EnumSet properties; + + /** + * The user configuration. + */ + private UserConfiguration userConfiguration; + + /** + * Validate request. + * + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + @Override + protected void validate() throws ServiceLocalException, Exception { + super.validate(); + + EwsUtilities.validateParam(this.name, "name"); + EwsUtilities.validateParam(this.parentFolderId, "parentFolderId"); + this.getParentFolderId().validate( + this.getService().getRequestedServerVersion()); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response. + * @throws Exception the exception + */ + @Override + protected GetUserConfigurationResponse createServiceResponse( + ExchangeService service, int responseIndex) throws Exception { + // In the case of UserConfiguration.Load(), this.userConfiguration is + // set. + if (this.userConfiguration == null) { + this.userConfiguration = new UserConfiguration(service, + this.properties); + this.userConfiguration.setName(this.name); + this.userConfiguration.setParentFolderId(this.parentFolderId); + } + + return new GetUserConfigurationResponse(this.userConfiguration); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010; + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.GetUserConfiguration; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetUserConfigurationResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.GetUserConfigurationResponseMessage; + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + final String EnumDelimiter = ","; + + // Write UserConfiguationName element + UserConfiguration.writeUserConfigurationNameToXml(writer, + XmlNamespace.Messages, this.name, this.parentFolderId); + + // Write UserConfigurationProperties element + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.UserConfigurationProperties, this.properties + .toString().replace(EnumDelimiter, ""). + replace("[", "").replace("]", "")); + } + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception + */ + public GetUserConfigurationRequest(ExchangeService service) + throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + } + + /** + * Gets the name. The name. + * + * @return the name + */ + protected String getName() { + return this.name; + } + + /** + * Sets the name. + * + * @param name the new name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Gets the parent folder Id. The parent folder Id. + * + * @return the parent folder id + */ + protected FolderId getParentFolderId() { + return this.parentFolderId; + } + + /** + * Sets the parent folder id. + * + * @param parentFolderId the new parent folder id + */ + public void setParentFolderId(FolderId parentFolderId) { + this.parentFolderId = parentFolderId; + } + + /** + * Gets the user configuration. The user + * configuration. + * + * @return the user configuration + */ + protected UserConfiguration getUserConfiguration() { + return this.userConfiguration; + } + + /** + * Sets the user configuration. + * + * @param userConfiguration the new user configuration + */ + public void setUserConfiguration(UserConfiguration userConfiguration) { + this.userConfiguration = userConfiguration; + this.name = this.userConfiguration.getName(); + this.parentFolderId = this.userConfiguration.getParentFolderId(); + } + + /** + * Gets the property. + * + * @return the property + */ + protected EnumSet getProperties() { + return this.properties; + } + + /** + * Sets the property. + * + * @param properties the new property + */ + public void setProperties(EnumSet properties) { + this.properties = properties; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/GetUserOofSettingsRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetUserOofSettingsRequest.java new file mode 100644 index 000000000..76a389781 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/GetUserOofSettingsRequest.java @@ -0,0 +1,173 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.misc.error.ServiceError; +import com.eischet.ews.api.core.enumeration.property.OofExternalAudience; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.GetUserOofSettingsResponse; +import com.eischet.ews.api.property.complex.availability.OofSettings; + +import javax.xml.stream.XMLStreamException; + +/** + * Represents a GetUserOofSettings request. + */ +public final class GetUserOofSettingsRequest extends SimpleServiceRequestBase { + + /** + * The smtp address. + */ + private String smtpAddress; + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.GetUserOofSettingsRequest; + } + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + + EwsUtilities.validateParam(this.getSmtpAddress(), "SmtpAddress"); + } + + /** + * Validate request. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Mailbox); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Address, + this.getSmtpAddress()); + writer.writeEndElement(); // Mailbox + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.GetUserOofSettingsResponse; + } + + /** + * {@inheritDoc} + */ + @Override + protected GetUserOofSettingsResponse parseResponse(EwsServiceXmlReader reader) + throws Exception { + GetUserOofSettingsResponse serviceResponse = + new GetUserOofSettingsResponse(); + + serviceResponse.loadFromXml(reader, XmlElementNames.ResponseMessage); + if (serviceResponse.getErrorCode() == ServiceError.NoError) { + reader.readStartElement(XmlNamespace.Types, + XmlElementNames.OofSettings); + + serviceResponse.setOofSettings(new OofSettings()); + serviceResponse.getOofSettings().loadFromXml(reader, + reader.getLocalName()); + + serviceResponse.getOofSettings().setAllowExternalOof( + reader.readElementValue(OofExternalAudience.class, + XmlNamespace.Messages, + XmlElementNames.AllowExternalOof)); + } + + return serviceResponse; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception on errors + */ + public GetUserOofSettingsRequest(ExchangeService service) throws Exception { + super(service); + } + + /** + * Executes this request. + * + * @return Service response. + * @throws Exception the exception + */ + public GetUserOofSettingsResponse execute() throws Exception { + GetUserOofSettingsResponse serviceResponse = internalExecute(); + serviceResponse.throwIfNecessary(); + return serviceResponse; + } + + /** + * Gets the SMTP address. + * + * @return the smtp address + */ + public String getSmtpAddress() { + return this.smtpAddress; + } + + /** + * Sets the smtp address. + * + * @param smtpAddress the new smtp address + */ + public void setSmtpAddress(String smtpAddress) { + this.smtpAddress = smtpAddress; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/HangingRequestDisconnectEventArgs.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/HangingRequestDisconnectEventArgs.java new file mode 100644 index 000000000..33149a715 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/HangingRequestDisconnectEventArgs.java @@ -0,0 +1,86 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.enumeration.misc.HangingRequestDisconnectReason; + +/** + * Represents a collection of arguments for the + * HangingServiceRequestBase.HangingRequestDisconnectHandler + * delegate method. + */ +public final class HangingRequestDisconnectEventArgs { + + /** + * Initializes a new instance of the + * HangingRequestDisconnectEventArgs class. + * + * @param reason The reason. + * @param exception The exception. + */ + public HangingRequestDisconnectEventArgs(HangingRequestDisconnectReason reason, Exception exception) { + this.reason = reason; + this.exception = exception; + } + + private HangingRequestDisconnectReason reason; + + /** + * Gets the reason that the user was disconnected. + * + * @return reason The reason. + */ + public HangingRequestDisconnectReason getReason() { + return reason; + } + + /** + * Sets the reason that the user was disconnected. + * + * @param value The reason. + */ + protected void setReason(HangingRequestDisconnectReason value) { + reason = value; + } + + private Exception exception; + + /** + * Gets the exception that caused the disconnection. Can be null. + * + * @return exception The Exception. + */ + public Exception getException() { + return exception; + } + + /** + * Sets the exception that caused the disconnection. Can be null. + * + * @param value The Exception. + */ + protected void setException(Exception value) { + exception = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/HangingServiceRequestBase.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/HangingServiceRequestBase.java new file mode 100644 index 000000000..4a0b0a22f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/HangingServiceRequestBase.java @@ -0,0 +1,355 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceMultiResponseXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.misc.HangingRequestDisconnectReason; +import com.eischet.ews.api.core.enumeration.misc.TraceFlags; +import com.eischet.ews.api.core.exception.http.EWSHttpException; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.service.remote.ServiceRequestException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.http.ExchangeHttpClient; +import com.eischet.ews.api.misc.HangingTraceStream; +import com.eischet.ews.api.security.XmlNodeType; +import com.eischet.ews.api.util.IOUtils; + +import javax.xml.stream.XMLStreamException; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectStreamException; +import java.net.SocketTimeoutException; +import java.net.UnknownServiceException; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; + + +/** + * Represents an abstract, hanging service request. + */ +public abstract class HangingServiceRequestBase extends ServiceRequestBase { + + private static final Logger LOG = Logger.getLogger(HangingServiceRequestBase.class.getCanonicalName()); + + + public interface IHandleResponseObject { + + /** + * Callback delegate to handle asynchronous response. + * + * @param response Response received from the server + * @throws ArgumentException + */ + void handleResponseObject(Object response) throws ArgumentException; + } + + + public static final int BUFFER_SIZE = 4096; + + /** + * Test switch to log all bytes that come across the wire. + * Helpful when parsing fails before certain bytes hit the trace logs. + */ + private static volatile boolean logAllWireBytes = false; + + /** + * Callback delegate to handle response objects + */ + private final IHandleResponseObject responseHandler; + + /** + * Response from the server. + */ + private ExchangeHttpClient.Request response; + + /** + * Expected minimum frequency in response, in milliseconds. + */ + protected int heartbeatFrequencyMilliseconds; + + + public interface IHangingRequestDisconnectHandler { + + /** + * Delegate method to handle a hanging request disconnection. + * + * @param sender the object invoking the delegate + * @param args event data + */ + void hangingRequestDisconnectHandler(Object sender, + HangingRequestDisconnectEventArgs args); + + } + + + public static boolean isLogAllWireBytes() { + return logAllWireBytes; + } + + public static void setLogAllWireBytes(final boolean logAllWireBytes) { + HangingServiceRequestBase.logAllWireBytes = logAllWireBytes; + } + + /** + * Disconnect events Occur when the hanging request is disconnected. + */ + private final List onDisconnectList = + new ArrayList(); + + /** + * Set event to happen when property disconnect. + * + * @param disconnect disconnect event + */ + public void addOnDisconnectEvent(IHangingRequestDisconnectHandler disconnect) { + onDisconnectList.add(disconnect); + } + + /** + * Remove the event from happening when property disconnect. + * + * @param disconnect disconnect event + */ + protected void removeDisconnectEvent( + IHangingRequestDisconnectHandler disconnect) { + onDisconnectList.remove(disconnect); + } + + /** + * Clears disconnect events list. + */ + protected void clearDisconnectEvents() { + onDisconnectList.clear(); + } + + /** + * Initializes a new instance of the HangingServiceRequestBase class. + * + * @param service The service. + * @param handler Callback delegate to handle response objects + * @param heartbeatFrequency Frequency at which we expect heartbeats, in milliseconds. + */ + protected HangingServiceRequestBase(ExchangeService service, + IHandleResponseObject handler, int heartbeatFrequency) + throws ServiceVersionException { + super(service); + this.responseHandler = handler; + this.heartbeatFrequencyMilliseconds = heartbeatFrequency; + } + + /** + * Exectures the request. + */ + public void internalExecute() throws Exception { + synchronized (this) { + this.response = this.validateAndEmitRequest(); + this.internalOnConnect(); + } + } + + /** + * Parses the response. + */ + private void parseResponses() { + HangingTraceStream tracingStream = null; + ByteArrayOutputStream responseCopy = null; + + + try { + boolean traceEWSResponse = this.getService().isTraceEnabledFor(TraceFlags.EwsResponse); + InputStream responseStream = this.response.getInputStream(); + tracingStream = new HangingTraceStream(responseStream, + this.getService()); + //EWSServiceMultiResponseXmlReader. Create causes a read. + + if (traceEWSResponse) { + responseCopy = new ByteArrayOutputStream(); + tracingStream.setResponseCopy(responseCopy); + } + + while (this.isConnected()) { + T responseObject; + if (traceEWSResponse) { + EwsServiceMultiResponseXmlReader ewsXmlReader = + EwsServiceMultiResponseXmlReader.create(tracingStream, getService()); + responseObject = this.readResponse(ewsXmlReader); + this.responseHandler.handleResponseObject(responseObject); + + // reset the stream collector. + responseCopy.close(); + responseCopy = new ByteArrayOutputStream(); + tracingStream.setResponseCopy(responseCopy); + + } else { + EwsServiceMultiResponseXmlReader ewsXmlReader = + EwsServiceMultiResponseXmlReader.create(tracingStream, getService()); + responseObject = this.readResponse(ewsXmlReader); + this.responseHandler.handleResponseObject(responseObject); + } + } + } catch (SocketTimeoutException ex) { + // The connection timed out. + this.disconnect(HangingRequestDisconnectReason.Timeout, ex); + } catch (UnknownServiceException ex) { + // Stream is closed, so disconnect. + this.disconnect(HangingRequestDisconnectReason.Exception, ex); + } catch (ObjectStreamException ex) { + // Stream is closed, so disconnect. + this.disconnect(HangingRequestDisconnectReason.Exception, ex); + } catch (IOException ex) { + // Stream is closed, so disconnect. + this.disconnect(HangingRequestDisconnectReason.Exception, ex); + } catch (UnsupportedOperationException ex) { + LOG.log(Level.SEVERE, "unsuppored operation", ex); + // This is thrown if we close the stream during a + //read operation due to a user method call. + // Trying to delay closing until the read finishes + //simply results in a long-running connection. + this.disconnect(HangingRequestDisconnectReason.UserInitiated, null); + } catch (Exception ex) { + // Stream is closed, so disconnect. + this.disconnect(HangingRequestDisconnectReason.Exception, ex); + } finally { + IOUtils.closeQuietly(responseCopy); + } + } + + private boolean isConnected; + + /** + * Gets a value indicating whether this instance is connected. + * + * @return true, if this instance is connected; otherwise, false + */ + public boolean isConnected() { + return this.isConnected; + } + + private void setIsConnected(boolean value) { + this.isConnected = value; + } + + /** + * Disconnects the request. + */ + public void disconnect() { + synchronized (this) { + try { + response.close(); + } catch (IOException ignored) { + } + this.disconnect(HangingRequestDisconnectReason.UserInitiated, null); + } + } + + /** + * Disconnects the request with the specified reason and exception. + * + * @param reason The reason. + * @param exception The exception. + */ + public void disconnect(HangingRequestDisconnectReason reason, Exception exception) { + if (this.isConnected()) { + try { + response.close(); + } catch (IOException ignored) { + } + this.internalOnDisconnect(reason, exception); + } + } + + /** + * Perform any bookkeeping needed when we connect + * + * @throws XMLStreamException the XML stream exception + */ + private void internalOnConnect() throws XMLStreamException, + IOException, EWSHttpException { + if (!this.isConnected()) { + this.isConnected = true; + + if (this.getService().isTraceEnabledFor(TraceFlags.EwsResponseHttpHeaders)) { + // Trace Http headers + this.getService().processHttpResponseHeaders( + TraceFlags.EwsResponseHttpHeaders, + this.response); + } + int poolSize = 1; + + int maxPoolSize = 1; + + long keepAliveTime = 10; + + final ArrayBlockingQueue queue = new ArrayBlockingQueue<>(1); + ThreadPoolExecutor threadPool = new ThreadPoolExecutor(poolSize, + maxPoolSize, + keepAliveTime, TimeUnit.SECONDS, queue); + threadPool.execute(this::parseResponses); + threadPool.shutdown(); + } + } + + /** + * Perform any bookkeeping needed when we disconnect (cleanly or forcefully) + * + * @param reason The reason. + * @param exception The exception. + */ + private void internalOnDisconnect(HangingRequestDisconnectReason reason, + Exception exception) { + if (this.isConnected()) { + this.isConnected = false; + for (IHangingRequestDisconnectHandler disconnect : onDisconnectList) { + disconnect.hangingRequestDisconnectHandler(this, + new HangingRequestDisconnectEventArgs(reason, exception)); + } + } + } + + /** + * Reads any preamble data not part of the core response. + * + * @param ewsXmlReader The EwsServiceXmlReader. + * @throws Exception on various occasions + */ + @Override + protected void readPreamble(EwsServiceXmlReader ewsXmlReader) + throws Exception { + // Do nothing. + try { + ewsXmlReader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT)); + } catch (ExchangeXmlException ex) { + throw new ServiceRequestException("The response received from the service didn't contain valid XML.", ex); + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/HttpWebRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/HttpWebRequest.java new file mode 100644 index 000000000..985835a87 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/HttpWebRequest.java @@ -0,0 +1,571 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.EWSConstants; +import com.eischet.ews.api.core.WebProxy; +import com.eischet.ews.api.core.exception.http.EWSHttpException; + +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.util.Map; + +/** + * The Class HttpWebRequest. + */ +public abstract class HttpWebRequest implements Closeable { + + /** + * The url. + */ + private URL url; + + /** + * The pre authenticate. + */ + private boolean preAuthenticate; + + /** + * The timeout. I guess this is in milliseconds + */ + private int timeout; + + /** + * The content type. + */ + private String contentType = "text/xml; charset=utf-8"; + + /** + * The accept. + */ + private String accept = "text/xml"; + + /** + * The user agent. + */ + private String userAgent = "EWS SDK"; + + /** + * The allow auto redirect. + */ + private boolean allowAutoRedirect; + + /** + * The keep alive. + */ + private boolean keepAlive = true; + + /** + * The accept gzip encoding. + */ + private boolean acceptGzipEncoding; + + /** + * The use default credential. + */ + private boolean useDefaultCredentials; + + private boolean allowAuthentication = true; + + /** + * The user name. + */ + private String username; + + /** + * The password. + */ + private String password; + + /** + * The domain. + */ + private String domain; + + /** + * The request Method. + */ + private String requestMethod = "POST"; + + /** + * The request headers. + */ + private Map headers; + + /** + * The Web Proxy. + */ + private WebProxy proxy; + + /** + * Gets the Web Proxy. + * + * @return the proxy + */ + public WebProxy getProxy() { + return proxy; + } + + /** + * Sets the Web Proxy. + * + * @param proxy The Web Proxy + */ + public void setProxy(WebProxy proxy) { + this.proxy = proxy; + } + + /** + * Checks if is http scheme. + * + * @return true, if is http scheme + */ + public boolean isHttpScheme() { + return getUrl().getProtocol().equalsIgnoreCase(EWSConstants.HTTP_SCHEME); + } + + /** + * Checks if is https scheme. + * + * @return true, if is https scheme + */ + public boolean isHttpsScheme() { + return getUrl().getProtocol().equalsIgnoreCase(EWSConstants.HTTPS_SCHEME); + } + + /** + * Gets the user name. + * + * @return the user name + */ + public String getUsername() { + return username; + } + + /** + * Sets the user name. + * + * @param username the new user name + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * Gets the password. + * + * @return the password + */ + public String getPassword() { + return password; + } + + /** + * Sets the password. + * + * @param password the new password + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * Gets the domain. + * + * @return the domain + */ + public String getDomain() { + return domain; + } + + /** + * Sets the domain. + * + * @param domain the new domain + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * Gets the url. + * + * @return the url + */ + public URL getUrl() { + + return url; + } + + /** + * Sets the url. + * + * @param url the new url + */ + public void setUrl(URL url) { + this.url = url; + } + + /** + * Whether to use preemptive authentication. Currently not implemented, though. + */ + public boolean isPreAuthenticate() { + return preAuthenticate; + } + + /** + * Whether to use preemptive authentication. Currently not implemented, though. + */ + public void setPreAuthenticate(boolean preAuthenticate) { + this.preAuthenticate = preAuthenticate; + } + + /** + * Gets the timeout. + * + * @return the timeout + */ + public int getTimeout() { + return timeout; + } + + /** + * Sets the timeout. + * + * @param timeout the new timeout + */ + public void setTimeout(int timeout) { + this.timeout = timeout; + } + + /** + * Gets the content type. + * + * @return the content type + */ + public String getContentType() { + return contentType; + } + + /** + * Sets the content type. + * + * @param contentType the new content type + */ + public void setContentType(String contentType) { + this.contentType = contentType; + } + + /** + * Gets the accept. + * + * @return the accept + */ + public String getAccept() { + return accept; + } + + /** + * Sets the accept. + * + * @param accept the new accept + */ + public void setAccept(String accept) { + this.accept = accept; + } + + /** + * Gets the user agent. + * + * @return the user agent + */ + public String getUserAgent() { + return userAgent; + } + + /** + * Sets the user agent. + * + * @param userAgent the new user agent + */ + public void setUserAgent(String userAgent) { + this.userAgent = userAgent; + } + + /** + * Checks if is allow auto redirect. + * + * @return true, if is allow auto redirect + */ + public boolean isAllowAutoRedirect() { + return allowAutoRedirect; + } + + /** + * Sets the allow auto redirect. + * + * @param allowAutoRedirect the new allow auto redirect + */ + public void setAllowAutoRedirect(boolean allowAutoRedirect) { + this.allowAutoRedirect = allowAutoRedirect; + } + + /** + * Checks if is keep alive. + * + * @return true, if is keep alive + */ + public boolean isKeepAlive() { + return keepAlive; + } + + /** + * Sets the keep alive. + * + * @param keepAlive the new keep alive + */ + public void setKeepAlive(boolean keepAlive) { + this.keepAlive = keepAlive; + } + + /** + * Checks if is accept gzip encoding. + * + * @return true, if is accept gzip encoding + */ + public boolean isAcceptGzipEncoding() { + return acceptGzipEncoding; + } + + /** + * Sets the accept gzip encoding. + * + * @param acceptGzipEncoding the new accept gzip encoding + */ + public void setAcceptGzipEncoding(boolean acceptGzipEncoding) { + this.acceptGzipEncoding = acceptGzipEncoding; + } + + /** + * Checks if is use default credential. + * + * @return true, if is use default credential + */ + public boolean isUseDefaultCredentials() { + return useDefaultCredentials; + } + + /** + * Sets the use default credential. + * + * @param useDefaultCredentials the new use default credential + */ + public void setUseDefaultCredentials(boolean useDefaultCredentials) { + this.useDefaultCredentials = useDefaultCredentials; + } + + /** + * Whether web service authentication is allowed. + * This can be set to {@code false} to disallow sending credential with this request. + *

+ * This is useful for the autodiscover request to the legacy HTTP url, because this single request doesn't + * require authentication and we don't want to send credential over HTTP. + * + * @return {@code true} if authentication is allowed. + */ + public boolean isAllowAuthentication() { + return allowAuthentication; + } + + /** + * Whether web service authentication is allowed. + * This can be set to {@code false} to disallow sending credential with this request. + *

+ * This is useful for the autodiscover request to the legacy HTTP url, because this single request doesn't + * require authentication and we don't want to send credential over HTTP. + *

+ * Default is {@code true}. + * + * @param allowAuthentication {@code true} if authentication is allowed. + */ + public void setAllowAuthentication(boolean allowAuthentication) { + this.allowAuthentication = allowAuthentication; + } + + /** + * Gets the request method type. + * + * @return the request method type. + */ + public String getRequestMethod() { + return requestMethod; + } + + /** + * Sets the request method type. + * + * @param requestMethod the request method type. + */ + public void setRequestMethod(String requestMethod) { + this.requestMethod = requestMethod; + } + + /** + * Gets the Headers. + * + * @return the content type + */ + public Map getHeaders() { + return headers; + } + + /** + * Sets the Headers. + * + * @param headers The headers + */ + public void setHeaders(Map headers) { + this.headers = headers; + } + + /** + * Sets the credential. + * + * @param domain user domain + * @param user user name + * @param pwd password + */ + public void setCredentials(String domain, String user, String pwd) { + this.domain = domain; + this.username = user; + this.password = pwd; + } + + /** + * Gets the input stream. + * + * @return the input stream + * @throws EWSHttpException the eWS http exception + * @throws IOException the IO exception + */ + public abstract InputStream getInputStream() throws EWSHttpException, IOException; + + /** + * Gets the error stream. + * + * @return the error stream + * @throws EWSHttpException the eWS http exception + */ + public abstract InputStream getErrorStream() throws EWSHttpException; + + /** + * Gets the output stream. + * + * @return the output stream + * @throws EWSHttpException the eWS http exception + */ + public abstract OutputStream getOutputStream() throws EWSHttpException; + + /** + * Close. + */ + public abstract void close() throws IOException; + + /** + * Prepare connection. + */ + public abstract void prepareConnection(); + + /** + * Gets the response headers. + * + * @return the response headers + * @throws EWSHttpException the eWS http exception + */ + public abstract Map getResponseHeaders() + throws EWSHttpException; + + /** + * Gets the content encoding. + * + * @return the content encoding + * @throws EWSHttpException the EWS http exception + */ + public abstract String getContentEncoding() throws EWSHttpException; + + /** + * Gets the response content type. + * + * @return the response content type + * @throws EWSHttpException the EWS http exception + */ + public abstract String getResponseContentType() throws EWSHttpException; + + /** + * Gets the response code. + * + * @return the response code + * @throws EWSHttpException the EWS http exception + */ + public abstract int getResponseCode() throws EWSHttpException; + + /** + * Gets the response message. + * + * @return the response message + * @throws EWSHttpException the EWS http exception + */ + public abstract String getResponseText() throws EWSHttpException; + + /** + * Gets the response header field. + * + * @param headerName the header name + * @return the response header field + * @throws EWSHttpException the EWS http exception + */ + public abstract String getResponseHeaderField(String headerName) + throws EWSHttpException; + + /** + * Gets the request property. + * + * @return the request property + * @throws EWSHttpException the EWS http exception + */ + public abstract Map getRequestProperty() + throws EWSHttpException; + + /** + * Executes Request by sending request xml data to server. + * + * @throws EWSHttpException the EWS http exception + * @throws java.io.IOException the IO Exception + */ + public abstract int executeRequest() throws EWSHttpException, IOException; + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveCopyFolderRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveCopyFolderRequest.java new file mode 100644 index 000000000..01597bfb6 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveCopyFolderRequest.java @@ -0,0 +1,114 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.service.folder.Folder; +import com.eischet.ews.api.misc.FolderIdWrapperList; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents an abstract Move/Copy Folder request. + * + * @param The type of response + */ +abstract class MoveCopyFolderRequest extends + MoveCopyRequest { + + private static final Logger LOG = Logger.getLogger(MoveCopyFolderRequest.class.getCanonicalName()); + + /** + * The folder ids. + */ + private final FolderIdWrapperList folderIds = new FolderIdWrapperList(); + + /** + * Validates request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParamCollection(this.getFolderIds().iterator(), "FolderIds"); + this.getFolderIds().validate( + this.getService().getRequestedServerVersion()); + } + + /** + * Initializes a new instance of the class. + * + * @param service The service. + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + protected MoveCopyFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) throws ServiceVersionException { + super(service, errorHandlingMode); + } + + /** + * Writes the ids as XML. + * + * @param writer the writer + */ + @Override + protected void writeIdsToXml(EwsServiceXmlWriter writer) { + try { + this.folderIds.writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.FolderIds); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error writing IDs to XML", e); + } + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.getFolderIds().getCount(); + } + + /** + * Gets the folder ids. + * + * @return The folder ids. + */ + public FolderIdWrapperList getFolderIds() { + return this.folderIds; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveCopyItemRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveCopyItemRequest.java new file mode 100644 index 000000000..ec337ac66 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveCopyItemRequest.java @@ -0,0 +1,114 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.misc.ItemIdWrapperList; + +/** + * Represents an abstract Move/Copy Item request. + * + * @param The type of the response. + */ +public abstract class MoveCopyItemRequest + extends MoveCopyRequest { + private final ItemIdWrapperList itemIds = new ItemIdWrapperList(); + private Boolean newItemIds; + + /** + * Validates request. + * + * @throws Exception the exception + */ + @Override + public void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.getItemIds(), "ItemIds"); + } + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception on error + */ + protected MoveCopyItemRequest(ExchangeService service, + ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Writes the ids as XML. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeIdsToXml(EwsServiceXmlWriter writer) throws Exception { + this.getItemIds().writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.ItemIds); + if (this.getReturnNewItemIds() != null) { + writer.writeElementValue( + XmlNamespace.Messages, + XmlElementNames.ReturnNewItemIds, + this.getReturnNewItemIds()); + } + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.getItemIds().getCount(); + } + + /** + * Gets the item ids. + * + * @return the item ids + */ + public ItemIdWrapperList getItemIds() { + return this.itemIds; + } + + protected Boolean getReturnNewItemIds() { + return this.newItemIds; + } + + public void setReturnNewItemIds(Boolean value) { + this.newItemIds = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveCopyRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveCopyRequest.java new file mode 100644 index 000000000..55bcee6ff --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveCopyRequest.java @@ -0,0 +1,120 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.property.complex.FolderId; + +/** + * Represents an abstract Move/Copy request. + * + * @param The type of the service object. + * @param The type of the response. + */ +abstract class MoveCopyRequest extends + MultiResponseServiceRequest { + + /** + * The destination folder id. + */ + private FolderId destinationFolderId; + + /** + * Validates request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + EwsUtilities.validateParam(this.getDestinationFolderId(), "DestinationFolderId"); + this.getDestinationFolderId().validate( + this.getService().getRequestedServerVersion()); + } + + /** + * Initializes a new instance of the MoveCopyRequest class. + * + * @param service The Service + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + protected MoveCopyRequest(ExchangeService service, + ServiceErrorHandling errorHandlingMode) throws ServiceVersionException { + super(service, errorHandlingMode); + } + + /** + * Writes the ids as XML. + * + * @param writer The Writer + * @throws Exception the exception + */ + protected abstract void writeIdsToXml(EwsServiceXmlWriter writer) + throws Exception; + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.ToFolderId); + this.getDestinationFolderId().writeToXml(writer); + writer.writeEndElement(); + + this.writeIdsToXml(writer); + } + + /** + * Gets the destination folder id. + * + * @return the destination folder id + */ + public FolderId getDestinationFolderId() { + return this.destinationFolderId; + } + + /** + * Sets the destination folder id. + * + * @param destinationFolderId the new destination folder id + */ + public void setDestinationFolderId(FolderId destinationFolderId) { + this.destinationFolderId = destinationFolderId; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveFolderRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveFolderRequest.java new file mode 100644 index 000000000..49b1f3975 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveFolderRequest.java @@ -0,0 +1,102 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.MoveCopyFolderResponse; + +/** + * Represents a MoveFolder request. + */ +public class MoveFolderRequest extends MoveCopyFolderRequest { + + /** + * Initializes a new instance of the MoveFolderRequest class. + * + * @param service The service. + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + public MoveFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param service The service. + * @param responseIndex Index of the response. + * @return Service response. + */ + @Override + protected MoveCopyFolderResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new MoveCopyFolderResponse(); + } + + /** + * Gets the name of the XML element. + * + * @return Xml element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.MoveFolder; + } + + /** + * Gets the name of the response XML element. + * + * @return Xml element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.MoveFolderResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return Xml element name. + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.MoveFolderResponseMessage; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveItemRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveItemRequest.java new file mode 100644 index 000000000..6d59ef145 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/MoveItemRequest.java @@ -0,0 +1,101 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.MoveCopyItemResponse; + +/** + * The Class MoveItemRequest. + */ +public class MoveItemRequest extends MoveCopyItemRequest { + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception + */ + public MoveItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response. + */ + @Override + protected MoveCopyItemResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new MoveCopyItemResponse(); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name, + */ + @Override + public String getXmlElementName() { + return XmlElementNames.MoveItem; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name, + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.MoveItemResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name, + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.MoveItemResponseMessage; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/MultiResponseServiceRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/MultiResponseServiceRequest.java new file mode 100644 index 000000000..dfdb8b73b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/MultiResponseServiceRequest.java @@ -0,0 +1,199 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.ServiceResult; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.core.exception.service.remote.ServiceResponseException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.response.ServiceResponseCollection; +import com.eischet.ews.api.misc.IAsyncResult; + +/** + * Represents a service request that can have multiple response. + * + * @param The type of the response. + */ +public abstract class MultiResponseServiceRequest + extends SimpleServiceRequestBase> { + + /** + * The error handling mode. + */ + private final ServiceErrorHandling errorHandlingMode; + + /** + * {@inheritDoc} + */ + @Override + protected ServiceResponseCollection parseResponse(EwsServiceXmlReader reader) + throws Exception { + ServiceResponseCollection serviceResponses = + new ServiceResponseCollection(); + + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.ResponseMessages); + + for (int i = 0; i < this.getExpectedResponseMessageCount(); i++) { + // Read ahead to see if we've reached the end of the response + // messages early. + reader.read(); + if (reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.ResponseMessages)) { + break; + } + + TResponse response = this.createServiceResponse( + reader.getService(), i); + + response.loadFromXml(reader, this + .getResponseMessageXmlElementName()); + + // Add the response to the list after it has been deserialized + // because the response list updates an overall result as individual + // response are added + // to it. + serviceResponses.add(response); + } + // Bug E14:131334 -- if there's a general error in batch processing, + // the server will return a single response message containing the error + // (for example, if the SavedItemFolderId is bogus in a batch CreateItem + // call). In this case, throw a ServiceResponsException. Otherwise this + // is an unexpected server error. + if (serviceResponses.getCount() < this + .getExpectedResponseMessageCount()) { + if ((serviceResponses.getCount() == 1) && + (serviceResponses.getResponseAtIndex(0).getResult() == + ServiceResult.Error)) { + throw new ServiceResponseException(serviceResponses + .getResponseAtIndex(0)); + } else { + throw new ServiceXmlDeserializationException(String.format( + "The service was expected to return %s response of type '%d', but %d response were received.", this + .getResponseMessageXmlElementName(), this + .getExpectedResponseMessageCount(), + serviceResponses.getCount())); + } + } + + reader.readEndElementIfNecessary(XmlNamespace.Messages, + XmlElementNames.ResponseMessages); + + return serviceResponses; + } + + /** + * Creates the service response. + * + * @param service The service. + * @param responseIndex Index of the response. + * @return Service response. + * @throws Exception the exception + */ + protected abstract TResponse createServiceResponse(ExchangeService service, + int responseIndex) throws Exception; + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + protected abstract String getResponseMessageXmlElementName(); + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + protected abstract int getExpectedResponseMessageCount(); + + /** + * Initializes a new instance. + * + * @param service The service. + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + protected MultiResponseServiceRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) throws ServiceVersionException { + super(service); + this.errorHandlingMode = errorHandlingMode; + } + + /** + * Executes this request. + * + * @return Service response collection. + * @throws Exception the exception + */ + public ServiceResponseCollection execute() throws Exception { + ServiceResponseCollection serviceResponses = internalExecute(); + + if (this.errorHandlingMode == ServiceErrorHandling.ThrowOnError) { + EwsUtilities.ewsAssert(serviceResponses.getCount() == 1, "MultiResponseServiceRequest.Execute", + "ServiceErrorHandling.ThrowOnError " + "error handling " + + "is only valid for singleton request"); + + serviceResponses.getResponseAtIndex(0).throwIfNecessary(); + } + + return serviceResponses; + } + + /** + * Ends executing this async request. + * + * @param asyncResult The async result + * @return Service response collection. + * @throws Exception on error + */ + public ServiceResponseCollection endExecute(IAsyncResult asyncResult) throws Exception { + ServiceResponseCollection serviceResponses = endInternalExecute(asyncResult); + + if (this.errorHandlingMode == ServiceErrorHandling.ThrowOnError) { + EwsUtilities.ewsAssert(serviceResponses.getCount() == 1, "MultiResponseServiceRequest.Execute", + "ServiceErrorHandling.ThrowOnError error handling is only valid for singleton request"); + + serviceResponses.getResponseAtIndex(0).throwIfNecessary(); + } + + return serviceResponses; + } + + /** + * Gets a value indicating how errors should be handled. + * + * @return A value indicating how errors should be handled. + */ + protected ServiceErrorHandling getErrorHandlingMode() { + return this.errorHandlingMode; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/PlayOnPhoneRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/PlayOnPhoneRequest.java new file mode 100644 index 000000000..a33e97c91 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/PlayOnPhoneRequest.java @@ -0,0 +1,167 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.response.PlayOnPhoneResponse; +import com.eischet.ews.api.property.complex.ItemId; + +/** + * Represents a PlayOnPhone request. + */ +public final class PlayOnPhoneRequest extends SimpleServiceRequestBase { + + /** + * The item id. + */ + private ItemId itemId; + + /** + * The dial string. + */ + private String dialString; + + /** + * Initializes a new instance of the PlayOnPhoneRequest class. + * + * @param service the service + * @throws Exception + */ + public PlayOnPhoneRequest(ExchangeService service) + throws Exception { + super(service); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.PlayOnPhone; + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.itemId.writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.ItemId); + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.DialString, dialString); + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name, + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.PlayOnPhoneResponse; + } + + /** + * {@inheritDoc} + */ + @Override + protected PlayOnPhoneResponse parseResponse(EwsServiceXmlReader reader) + throws Exception { + PlayOnPhoneResponse serviceResponse = new PlayOnPhoneResponse(this + .getService()); + serviceResponse + .loadFromXml(reader, XmlElementNames.PlayOnPhoneResponse); + return serviceResponse; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010; + } + + /** + * Executes this request. + * + * @return Service response. + * @throws Exception the exception + */ + public PlayOnPhoneResponse execute() throws Exception { + PlayOnPhoneResponse serviceResponse = internalExecute(); + serviceResponse.throwIfNecessary(); + return serviceResponse; + } + + /** + * Gets the item id of the message to play. + * + * @return the item id + */ + protected ItemId getItemId() { + return this.itemId; + } + + /** + * Sets the item id. + * + * @param itemId the new item id + */ + public void setItemId(ItemId itemId) { + this.itemId = itemId; + } + + /** + * Gets the dial string. + * + * @return the dial string + */ + protected String getDialString() { + return this.dialString; + } + + /** + * Sets the dial string. + * + * @param dialString the new dial string + */ + public void setDialString(String dialString) { + this.dialString = dialString; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/RemoveDelegateRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/RemoveDelegateRequest.java new file mode 100644 index 000000000..9f1718f8e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/RemoveDelegateRequest.java @@ -0,0 +1,140 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.response.DelegateManagementResponse; +import com.eischet.ews.api.property.complex.UserId; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a RemoveDelete request. + */ +public class RemoveDelegateRequest extends + DelegateManagementRequestBase { + + /** + * The user ids. + */ + private final List userIds = new ArrayList(); + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception + */ + public RemoveDelegateRequest(ExchangeService service) + throws Exception { + super(service); + } + + /** + * Asserts the valid. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParamCollection(this.getUserIds().iterator(), "UserIds"); + } + + /** + * Asserts the valid. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + super.writeElementsToXml(writer); + writer + .writeStartElement(XmlNamespace.Messages, + XmlElementNames.UserIds); + + for (UserId userId : this.getUserIds()) { + userId.writeToXml(writer, XmlElementNames.UserId); + } + + writer.writeEndElement(); // UserIds + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.RemoveDelegateResponse; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.RemoveDelegate; + } + + /** + * Creates the response. + * + * @return Service response + */ + @Override + protected DelegateManagementResponse createResponse() { + return new DelegateManagementResponse(false, null); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the user ids. + * + * @return the user ids + */ + public List getUserIds() { + return this.userIds; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/ResolveNamesRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/ResolveNamesRequest.java new file mode 100644 index 000000000..c32215d7f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/ResolveNamesRequest.java @@ -0,0 +1,321 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.search.ResolveNameSearchLocation; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.ResolveNamesResponse; +import com.eischet.ews.api.misc.FolderIdWrapperList; + +import java.util.HashMap; +import java.util.Map; + +/** + * Represents a ResolveNames request. + */ +public final class ResolveNamesRequest extends + MultiResponseServiceRequest { + + /** + * The Search scope map. + */ + private static final LazyMember> searchScopeMap = + new LazyMember>( + new ILazyMember>() { + @Override + public Map + createInstance() { + + Map map = new HashMap<>(); + + map.put(ResolveNameSearchLocation.DirectoryOnly, + "ActiveDirectory"); + map.put(ResolveNameSearchLocation.DirectoryThenContacts, + "ActiveDirectoryContacts"); + map.put(ResolveNameSearchLocation.ContactsOnly, + "Contacts"); + map.put(ResolveNameSearchLocation.ContactsThenDirectory, + "ContactsActiveDirectory"); + + return map; + } + + }); + + /** + * The name to resolve. + */ + private String nameToResolve; + + /** + * The return full contact data. + */ + private boolean returnFullContactData; + + /** + * The search location. + */ + private ResolveNameSearchLocation searchLocation; + + /** + * The Contact PropertySet. * + */ + private PropertySet contactDataPropertySet; + + /** + * The parent folder ids. + */ + private final FolderIdWrapperList parentFolderIds = new FolderIdWrapperList(); + + + /** + * Asserts the valid. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateNonBlankStringParam(this. + getNameToResolve(), "NameToResolve"); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response + */ + @Override + protected ResolveNamesResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new ResolveNamesResponse(service); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.ResolveNames; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.ResolveNamesResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.ResolveNamesResponseMessage; + } + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception on errors + */ + public ResolveNamesRequest(ExchangeService service) throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.ReturnFullContactData, + this.returnFullContactData); + + String searchScope = null; + if (searchScopeMap.getMember().containsKey(searchLocation)) { + searchScope = searchScopeMap.getMember().get(searchLocation); + } + + EwsUtilities + .ewsAssert((!(searchScope == null || searchScope.isEmpty())), + "ResolveNameRequest.WriteAttributesToXml", + "The specified search location cannot be mapped to an EWS search scope."); + + String propertySet = null; + if (this.getContactDataPropertySet() != null) { + //((PropertyBag)PropertySet.getDefaultPropertySetDictionary( ).getMember()).tryGetValue(this.contactDataPropertySet.getBasePropertySet(), propertySet); + if (PropertySet.getDefaultPropertySetMap().getMember() + .containsKey(this.getContactDataPropertySet().getBasePropertySet())) { + propertySet = PropertySet.getDefaultPropertySetMap().getMember() + .get(this.getContactDataPropertySet().getBasePropertySet()); + } + } + + if (!this.getService().getExchange2007CompatibilityMode()) { + writer.writeAttributeValue(XmlAttributeNames. + SearchScope, searchScope); + } + if (!(propertySet == null)) { + writer.writeAttributeValue(XmlAttributeNames.ContactDataShape, propertySet); + } + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.getParentFolderIds().writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.ParentFolderIds); + + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.UnresolvedEntry, this.getNameToResolve()); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the name to resolve. + * + * @return the name to resolve + */ + public String getNameToResolve() { + return this.nameToResolve; + } + + /** + * Sets the name to resolve. + * + * @param nameToResolve the new name to resolve + */ + public void setNameToResolve(String nameToResolve) { + this.nameToResolve = nameToResolve; + } + + /** + * Gets a value indicating whether to return full contact data or not. + * "true" if should return full contact data; otherwise, "false". + * + * @return the return full contact data + */ + public boolean getReturnFullContactData() { + return this.returnFullContactData; + } + + /** + * Sets the return full contact data. + * + * @param returnFullContactData the new return full contact data + */ + public void setReturnFullContactData(boolean returnFullContactData) { + this.returnFullContactData = returnFullContactData; + } + + /** + * Gets the search location. + * + * @return the search location + */ + public ResolveNameSearchLocation getSearchLocation() { + return this.searchLocation; + } + + /** + * Sets the search location. + * + * @param searchLocation the new search location + */ + public void setSearchLocation(ResolveNameSearchLocation searchLocation) { + this.searchLocation = searchLocation; + } + + /** + * Gets the parent folder ids. + * + * @return the parent folder ids + */ + public FolderIdWrapperList getParentFolderIds() { + return this.parentFolderIds; + } + + /** + * Gets or sets the PropertySet for Contact Data + *

+ * The PropertySet + */ + public void setContactDataPropertySet(PropertySet propertySet) { + + + this.contactDataPropertySet = propertySet; + } + + /** + * Gets or sets the PropertySet for Contact Data + * + * @return The PropertySet + */ + public PropertySet getContactDataPropertySet() { + return this.contactDataPropertySet; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/SendItemRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/SendItemRequest.java new file mode 100644 index 000000000..2370349aa --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/SendItemRequest.java @@ -0,0 +1,217 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.property.complex.FolderId; + +/** + * Represents a SendItem request. + */ +public final class SendItemRequest extends MultiResponseServiceRequest { + + /** + * The item. + */ + private Iterable items; + + /** + * The saved copy destination folder id. + */ + private FolderId savedCopyDestinationFolderId; + + /** + * Asserts the valid. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.items, "Items"); + + if (this.savedCopyDestinationFolderId != null) { + this.savedCopyDestinationFolderId.validate(this.getService() + .getRequestedServerVersion()); + } + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response. + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new ServiceResponse(); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return EwsUtilities.getEnumeratedObjectCount(this.items.iterator()); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.SendItem; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.SendItemResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.SendItemResponseMessage; + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + + writer.writeAttributeValue(XmlAttributeNames.SaveItemToFolder, + this.savedCopyDestinationFolderId != null); + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) throws Exception { + writer + .writeStartElement(XmlNamespace.Messages, + XmlElementNames.ItemIds); + + for (Item item : this.getItems()) { + item.getId().writeToXml(writer, XmlElementNames.ItemId); + } + + writer.writeEndElement(); // ItemIds + + if (this.savedCopyDestinationFolderId != null) { + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.SavedItemFolderId); + this.savedCopyDestinationFolderId.writeToXml(writer); + writer.writeEndElement(); + } + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception on errors + */ + public SendItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) throws Exception { + super(service, errorHandlingMode); + } + + /** + * Gets the item. The item. + * + * @return the item + */ + public Iterable getItems() { + return this.items; + } + + /** + * Sets the item. + * + * @param items the new item + */ + public void setItems(Iterable items) { + this.items = items; + } + + /** + * Gets the saved copy destination folder id. + * + * @return the saved copy destination folder id + */ + public FolderId getSavedCopyDestinationFolderId() { + return this.savedCopyDestinationFolderId; + } + + /** + * Sets the saved copy destination folder id. + * + * @param savedCopyDestinationFolderId the new saved copy destination folder id + */ + public void setSavedCopyDestinationFolderId( + FolderId savedCopyDestinationFolderId) { + this.savedCopyDestinationFolderId = savedCopyDestinationFolderId; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/ServiceRequestBase.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/ServiceRequestBase.java new file mode 100644 index 000000000..fa5ab5ef7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/ServiceRequestBase.java @@ -0,0 +1,759 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.DateTimePrecision; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.TraceFlags; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.http.EWSHttpException; +import com.eischet.ews.api.core.exception.http.HttpErrorException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.service.remote.ServiceRequestException; +import com.eischet.ews.api.core.exception.service.remote.ServiceResponseException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.http.ExchangeHttpClient; +import com.eischet.ews.api.misc.SoapFaultDetails; +import com.eischet.ews.api.security.XmlNodeType; + +import javax.xml.stream.XMLStreamException; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.zip.GZIPInputStream; +import java.util.zip.InflaterInputStream; + +/** + * Represents an abstract service request. + */ +public abstract class ServiceRequestBase { + + private static final Logger LOG = Logger.getLogger(ServiceRequestBase.class.getCanonicalName()); + + /** + * The service. + */ + private final ExchangeService service; + + // Methods for subclasses to override + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + public abstract String getXmlElementName(); + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + protected abstract String getResponseXmlElementName(); + + /** + * Gets the minimum server version required to process this request. + * + * @return Exchange server version. + */ + protected abstract ExchangeVersion getMinimumRequiredServerVersion(); + + /** + * Parses the response. + * + * @param reader The reader. + * @return the Response Object. + * @throws Exception the exception + */ + protected abstract T parseResponse(EwsServiceXmlReader reader) throws Exception; + + /** + * Writes XML elements. + * + * @param writer The writer. + * @throws Exception the exception + */ + protected abstract void writeElementsToXml(EwsServiceXmlWriter writer) throws Exception; + + /** + * Validate request. + * + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + protected void validate() throws Exception { + this.service.validate(); + } + + /** + * Writes XML body. + * + * @param writer The writer. + * @throws Exception the exception + */ + protected void writeBodyToXml(EwsServiceXmlWriter writer) throws Exception { + writer.writeStartElement(XmlNamespace.Messages, this.getXmlElementName()); + + this.writeAttributesToXml(writer); + this.writeElementsToXml(writer); + + writer.writeEndElement(); // m:this.GetXmlElementName() + } + + /** + * Writes XML attribute. Subclass will override if it has XML attribute. + * + * @param writer The writer. + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + } + + /** + * Initializes a new instance. + * + * @param service The service. + * @throws ServiceVersionException the service version exception + */ + protected ServiceRequestBase(ExchangeService service) throws ServiceVersionException { + this.service = service; + this.throwIfNotSupportedByRequestedServerVersion(); + } + + /** + * Gets the service. + * + * @return The service. + */ + public ExchangeService getService() { + return service; + } + + /** + * Throw exception if request is not supported in requested server version. + * + * @throws ServiceVersionException the service version exception + */ + protected void throwIfNotSupportedByRequestedServerVersion() throws ServiceVersionException { + if (this.service.getRequestedServerVersion().ordinal() < this.getMinimumRequiredServerVersion().ordinal()) { + throw new ServiceVersionException(String.format( + "The service request %s is only valid for Exchange version %s or later.", this.getXmlElementName(), + this.getMinimumRequiredServerVersion())); + } + } + + // HttpWebRequest-based implementation + + /** + * Writes XML. + * + * @param writer The writer. + * @throws Exception the exception + */ + protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { + writer.writeStartDocument(); + writer.writeStartElement(XmlNamespace.Soap, XmlElementNames.SOAPEnvelopeElementName); + writer.writeAttributeValue("xmlns", EwsUtilities.getNamespacePrefix(XmlNamespace.Soap), + EwsUtilities.getNamespaceUri(XmlNamespace.Soap)); + writer.writeAttributeValue("xmlns", EwsUtilities.EwsXmlSchemaInstanceNamespacePrefix, + EwsUtilities.EwsXmlSchemaInstanceNamespace); + writer.writeAttributeValue("xmlns", EwsUtilities.EwsMessagesNamespacePrefix, + EwsUtilities.EwsMessagesNamespace); + writer.writeAttributeValue("xmlns", EwsUtilities.EwsTypesNamespacePrefix, EwsUtilities.EwsTypesNamespace); + if (writer.isRequireWSSecurityUtilityNamespace()) { + writer.writeAttributeValue("xmlns", EwsUtilities.WSSecurityUtilityNamespacePrefix, + EwsUtilities.WSSecurityUtilityNamespace); + } + + writer.writeStartElement(XmlNamespace.Soap, XmlElementNames.SOAPHeaderElementName); + + if (this.service.getCredentials() != null) { + this.service.getCredentials().emitExtraSoapHeaderNamespaceAliases(writer.getInternalWriter()); + } + + // Emit the RequestServerVersion header + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.RequestServerVersion); + writer.writeAttributeValue(XmlAttributeNames.Version, this.getRequestedServiceVersionString()); + writer.writeEndElement(); // RequestServerVersion + + /* + * if ((this.getService().getRequestedServerVersion().ordinal() == + * ExchangeVersion.Exchange2007_SP1.ordinal() || + * this.EmitTimeZoneHeader()) && + * (!this.getService().getExchange2007CompatibilityMode())) { + * writer.writeStartElement(XmlNamespace.Types, + * XmlElementNames.TimeZoneContext); + * + * this.getService().TimeZoneDefinition().WriteToXml(writer); + * + * writer.WriteEndElement(); // TimeZoneContext + * + * writer.IsTimeZoneHeaderEmitted = true; } + */ + + if (this.service.getPreferredCulture() != null) { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.MailboxCulture, + this.service.getPreferredCulture().getDisplayName()); + } + + /* Emit the DateTimePrecision header */ + + if (this.getService().getDateTimePrecision().ordinal() != DateTimePrecision.Default.ordinal()) { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.DateTimePrecision, + this.getService().getDateTimePrecision().toString()); + } + if (this.service.getImpersonatedUserId() != null) { + this.service.getImpersonatedUserId().writeToXml(writer); + } + + if (this.service.getCredentials() != null) { + this.service.getCredentials() + .serializeExtraSoapHeaders(writer.getInternalWriter(), this.getXmlElementName()); + } + this.service.doOnSerializeCustomSoapHeaders(writer.getInternalWriter()); + + writer.writeEndElement(); // soap:Header + + writer.writeStartElement(XmlNamespace.Soap, XmlElementNames.SOAPBodyElementName); + + this.writeBodyToXml(writer); + + writer.writeEndElement(); // soap:Body + writer.writeEndElement(); // soap:Envelope + writer.flush(); + } + + /** + * Gets st ring representation of requested server version. In order to support E12 RTM servers, + * ExchangeService has another flag indicating that we should use "Exchange2007" as the server version + * string rather than Exchange2007_SP1. + * + * @return String representation of requested server version. + */ + private String getRequestedServiceVersionString() { + if (this.service.getRequestedServerVersion() == ExchangeVersion.Exchange2007_SP1 && this.service + .getExchange2007CompatibilityMode()) { + return "Exchange2007"; + } else { + return this.service.getRequestedServerVersion().toString(); + } + } + + /** + * Gets the response stream (may be wrapped with GZip/Deflate stream to decompress content). + * + * @param request HttpWebRequest object from which response stream can be read. + * @return ResponseStream + * @throws java.io.IOException Signals that an I/O exception has occurred. + * @throws EWSHttpException the EWS http exception + */ + protected static InputStream getResponseStream(ExchangeHttpClient.Request request) throws IOException, EWSHttpException { + String contentEncoding = ""; + + if (null != request.getContentEncoding()) { + contentEncoding = request.getContentEncoding().toLowerCase(); + } + + InputStream responseStream; + + if (contentEncoding.contains("gzip")) { + responseStream = new GZIPInputStream(request.getInputStream()); + } else if (contentEncoding.contains("deflate")) { + responseStream = new InflaterInputStream(request.getInputStream()); + } else { + responseStream = request.getInputStream(); + } + return responseStream; + } + + /** + * Traces the response. + * + * @param request the response + * @param memoryStream the response content in a MemoryStream + * @throws XMLStreamException the XML stream exception + * @throws IOException signals that an I/O exception has occurred + * @throws EWSHttpException the EWS http exception + */ + protected void traceResponse(ExchangeHttpClient.Request request, ByteArrayOutputStream memoryStream) + throws XMLStreamException, IOException, EWSHttpException { + + this.service.processHttpResponseHeaders(TraceFlags.EwsResponseHttpHeaders, request); + String contentType = request.getResponseContentType(); + + if (!isNullOrEmpty(contentType) && (contentType.startsWith("text/") || contentType + .startsWith("application/soap"))) { + this.service.traceXml(TraceFlags.EwsResponse, memoryStream); + } else { + this.service.traceMessage(TraceFlags.EwsResponse, "Non-textual response"); + } + + } + + /** + * Gets the response error stream. + * + * @param request the request + * @return the response error stream + * @throws EWSHttpException the EWS http exception + * @throws java.io.IOException Signals that an I/O exception has occurred. + */ + private static InputStream getResponseErrorStream(ExchangeHttpClient.Request request) + throws EWSHttpException, IOException { + String contentEncoding = ""; + + if (null != request.getContentEncoding()) { + contentEncoding = request.getContentEncoding().toLowerCase(); + } + + InputStream responseStream; + + if (contentEncoding.contains("gzip")) { + responseStream = new GZIPInputStream(request.getErrorStream()); + } else if (contentEncoding.contains("deflate")) { + responseStream = new InflaterInputStream(request.getErrorStream()); + } else { + responseStream = request.getErrorStream(); + } + return responseStream; + } + + /** + * Reads the response. + * + * @param response HTTP web request + * @return response response object + * @throws Exception on error + */ + protected T readResponse(ExchangeHttpClient.Request response) throws Exception { + T serviceResponse; + + if (!response.getResponseContentType().startsWith("text/xml")) { + throw new ServiceRequestException("The response received from the service didn't contain valid XML."); + } + + /* + * If tracing is enabled, we read the entire response into a + * MemoryStream so that we can pass it along to the ITraceListener. Then + * we parse the response from the MemoryStream. + */ + + try { + this.getService().processHttpResponseHeaders(TraceFlags.EwsResponseHttpHeaders, response); + + if (this.getService().isTraceEnabledFor(TraceFlags.EwsResponse)) { + ByteArrayOutputStream memoryStream = new ByteArrayOutputStream(); + InputStream serviceResponseStream = ServiceRequestBase.getResponseStream(response); + + int data = serviceResponseStream.read(); + while (data != -1) { + memoryStream.write(data); + data = serviceResponseStream.read(); + } + + this.traceResponse(response, memoryStream); + ByteArrayInputStream memoryStreamIn = new ByteArrayInputStream(memoryStream.toByteArray()); + EwsServiceXmlReader ewsXmlReader = new EwsServiceXmlReader(memoryStreamIn, this.getService()); + serviceResponse = this.readResponse(ewsXmlReader); + serviceResponseStream.close(); + memoryStream.flush(); + } else { + InputStream responseStream = ServiceRequestBase.getResponseStream(response); + EwsServiceXmlReader ewsXmlReader = new EwsServiceXmlReader(responseStream, this.getService()); + serviceResponse = this.readResponse(ewsXmlReader); + } + + return serviceResponse; + // + // Used to import: import javax.xml.ws.http.HTTPException; + // I have no Idea why this was thrown here or where the class is supposed to be right now. + //} catch (HTTPException e) { + // if (e.getMessage() != null) { + // this.getService().processHttpResponseHeaders(TraceFlags.EwsResponseHttpHeaders, response); + // } + // throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e); + } catch (IOException e) { + throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e); + } finally { // close the underlying response + response.close(); + } + } + + /** + * Reads the response. + * + * @param ewsXmlReader The XML reader. + * @return Service response. + * @throws Exception the exception + */ + protected T readResponse(EwsServiceXmlReader ewsXmlReader) throws Exception { + T serviceResponse; + this.readPreamble(ewsXmlReader); + ewsXmlReader.readStartElement(XmlNamespace.Soap, XmlElementNames.SOAPEnvelopeElementName); + this.readSoapHeader(ewsXmlReader); + ewsXmlReader.readStartElement(XmlNamespace.Soap, XmlElementNames.SOAPBodyElementName); + + ewsXmlReader.readStartElement(XmlNamespace.Messages, this.getResponseXmlElementName()); + + serviceResponse = this.parseResponse(ewsXmlReader); + + ewsXmlReader.readEndElementIfNecessary(XmlNamespace.Messages, this.getResponseXmlElementName()); + + ewsXmlReader.readEndElement(XmlNamespace.Soap, XmlElementNames.SOAPBodyElementName); + ewsXmlReader.readEndElement(XmlNamespace.Soap, XmlElementNames.SOAPEnvelopeElementName); + return serviceResponse; + } + + /** + * Reads any preamble data not part of the core response. + * + * @param ewsXmlReader The EwsServiceXmlReader. + * @throws Exception on error + */ + protected void readPreamble(EwsServiceXmlReader ewsXmlReader) throws Exception { + this.readXmlDeclaration(ewsXmlReader); + } + + /** + * Read SOAP header and extract server version. + * + * @param reader EwsServiceXmlReader + * @throws Exception the exception + */ + private void readSoapHeader(EwsServiceXmlReader reader) throws Exception { + reader.readStartElement(XmlNamespace.Soap, XmlElementNames.SOAPHeaderElementName); + do { + reader.read(); + + // Is this the ServerVersionInfo? + if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.ServerVersionInfo)) { + this.service.setServerInfo(ExchangeServerInfo.parse(reader)); + } + + // Ignore anything else inside the SOAP header + } while (!reader.isEndElement(XmlNamespace.Soap, XmlElementNames.SOAPHeaderElementName)); + } + + /** + * Processes the web exception. + * + * @param webException the web exception + * @param req HTTP Request object used to send the http request + * @throws Exception on error + */ + protected void processWebException(Exception webException, ExchangeHttpClient.Request req) throws Exception { + SoapFaultDetails soapFaultDetails; + if (null != req) { + this.getService().processHttpResponseHeaders(TraceFlags.EwsResponseHttpHeaders, req); + if (500 == req.getResponseCode()) { + if (this.service.isTraceEnabledFor(TraceFlags.EwsResponse)) { + ByteArrayOutputStream memoryStream = new ByteArrayOutputStream(); + InputStream serviceResponseStream = ServiceRequestBase.getResponseErrorStream(req); + while (true) { + int data = serviceResponseStream.read(); + if (-1 == data) { + break; + } else { + memoryStream.write(data); + } + } + memoryStream.flush(); + serviceResponseStream.close(); + this.traceResponse(req, memoryStream); + ByteArrayInputStream memoryStreamIn = new ByteArrayInputStream(memoryStream.toByteArray()); + EwsServiceXmlReader reader = new EwsServiceXmlReader(memoryStreamIn, this.service); + soapFaultDetails = this.readSoapFault(reader); + memoryStream.close(); + } else { + InputStream serviceResponseStream = ServiceRequestBase.getResponseStream(req); + EwsServiceXmlReader reader = new EwsServiceXmlReader(serviceResponseStream, this.service); + soapFaultDetails = this.readSoapFault(reader); + serviceResponseStream.close(); + + } + + if (soapFaultDetails != null) { + switch (soapFaultDetails.getResponseCode()) { + case ErrorInvalidServerVersion: + throw new ServiceVersionException("Exchange Server doesn't support the requested version."); + + case ErrorSchemaValidation: + // If we're talking to an E12 server + // (8.00.xxxx.xxx), a schema + // validation error is the same as + // a version mismatch error. + // (Which only will happen if we + // send a request that's not valid + // for E12). + if ((this.service.getServerInfo() != null) && (this.service.getServerInfo().getMajorVersion() + == 8) && ( + this.service.getServerInfo().getMinorVersion() == 0)) { + throw new ServiceVersionException("Exchange Server doesn't support the requested version."); + } + + break; + + case ErrorIncorrectSchemaVersion: + // This shouldn't happen. It + // indicates that a request wasn't + // valid for the version that was specified. + EwsUtilities.ewsAssert(false, "ServiceRequestBase.ProcessWebException", + "Exchange server supports " + "requested version " + + "but request was invalid for that version"); + break; + + default: + // Other error codes will + // be reported as remote error + break; + } + + // General fall-through case: + // throw a ServiceResponseException + throw new ServiceResponseException(new ServiceResponse(soapFaultDetails)); + } + } else { + this.service.processHttpErrorResponse(req, webException); + } + } + + } + + /** + * Reads the SOAP fault. + * + * @param reader The reader. + * @return SOAP fault details. + */ + protected SoapFaultDetails readSoapFault(EwsServiceXmlReader reader) { + SoapFaultDetails soapFaultDetails = null; + + try { + this.readXmlDeclaration(reader); + + reader.read(); + if (!reader.isStartElement() || (!reader.getLocalName() + .equals(XmlElementNames.SOAPEnvelopeElementName))) { + return soapFaultDetails; + } + + // EWS can sometimes return SOAP faults using the SOAP 1.2 + // namespace. Get the + // namespace URI from the envelope element and use it for the rest + // of the parsing. + // If it's not 1.1 or 1.2, we can't continue. + XmlNamespace soapNamespace = EwsUtilities.getNamespaceFromUri(reader.getNamespaceUri()); + if (soapNamespace == XmlNamespace.NotSpecified) { + return soapFaultDetails; + } + + reader.read(); + + // EWS doesn't always return a SOAP header. If this response + // contains a header element, + // read the server version information contained in the header. + if (reader.isStartElement(soapNamespace, XmlElementNames.SOAPHeaderElementName)) { + do { + reader.read(); + + if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.ServerVersionInfo)) { + this.service.setServerInfo(ExchangeServerInfo.parse(reader)); + } + } while (!reader.isEndElement(soapNamespace, XmlElementNames.SOAPHeaderElementName)); + + // Queue up the next read + reader.read(); + } + + // Parse the fault element contained within the SOAP body. + if (reader.isStartElement(soapNamespace, XmlElementNames.SOAPBodyElementName)) { + do { + reader.read(); + + // Parse Fault element + if (reader.isStartElement(soapNamespace, XmlElementNames.SOAPFaultElementName)) { + soapFaultDetails = SoapFaultDetails.parse(reader, soapNamespace); + } + } while (!reader.isEndElement(soapNamespace, XmlElementNames.SOAPBodyElementName)); + } + + reader.readEndElement(soapNamespace, XmlElementNames.SOAPEnvelopeElementName); + } catch (Exception e) { + // If response doesn't contain a valid SOAP fault, just ignore + // exception and + // return null for SOAP fault details. + LOG.log(Level.SEVERE, "error reading SOAP fault", e); + } + + return soapFaultDetails; + } + + /** + * Validates request parameters, and emits the request to the server. + * + * @return The response returned by the server. + * @throws Exception on error + */ + protected ExchangeHttpClient.Request validateAndEmitRequest() throws Exception { + this.validate(); + + ExchangeHttpClient.Request request; + + + /* TODO: find out where the pooling logic should go, probably move into httpClient... + if (service.getMaximumPoolingConnections() > 1) { + request = buildEwsHttpPoolingWebRequest(); + } else { + request = buildEwsHttpWebRequest(); + } + + */ + request = buildEwsHttpWebRequest(); + + try { + try { + return this.getEwsHttpWebResponse(request); + } catch (HttpErrorException e) { + processWebException(e, request); + + // Wrap exception if the above code block didn't throw + throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e); + } + } catch (Exception e) { + request.close(); + throw e; + } + } + + /** + * Builds the HttpWebRequest object for current service request with exception handling. + * + * @return An HttpWebRequest instance + * @throws Exception on error + */ + protected ExchangeHttpClient.Request buildEwsHttpWebRequest() throws Exception { + ExchangeHttpClient.Request request = service.prepareHttpWebRequest(); + return buildEwsHttpWebRequest(request); + } + + /** + * Builds a HttpWebRequest object from a pooling connection manager for current service request + * with exception handling. + *

+ * Used for subscriptions. + *

+ * + * @return A HttpWebRequest instance + * @throws Exception on error + */ + protected ExchangeHttpClient.Request buildEwsHttpPoolingWebRequest() throws Exception { + ExchangeHttpClient.Request request = service.prepareHttpPoolingWebRequest(); + return buildEwsHttpWebRequest(request); + } + + private ExchangeHttpClient.Request buildEwsHttpWebRequest(ExchangeHttpClient.Request request) throws Exception { + try { + + service.traceHttpRequestHeaders(TraceFlags.EwsRequestHttpHeaders, request); + + ByteArrayOutputStream requestStream = (ByteArrayOutputStream) request.getOutputStream(); + + EwsServiceXmlWriter writer = new EwsServiceXmlWriter(service, requestStream); + + boolean needSignature = + service.getCredentials() != null && service.getCredentials().isNeedSignature(); + writer.setRequireWSSecurityUtilityNamespace(needSignature); + + writeToXml(writer); + + if (needSignature) { + service.getCredentials().sign(requestStream); + } + + service.traceXml(TraceFlags.EwsRequest, requestStream); + + return request; + } catch (IOException e) { + // Wrap exception. + throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e); + } + } + + /** + * Gets the IEwsHttpWebRequest object from the specifiedHttpWebRequest object with exception handling + * + * @param request The specified HttpWebRequest + * @return An HttpWebResponse instance + * @throws Exception on error + */ + protected ExchangeHttpClient.Request getEwsHttpWebResponse(ExchangeHttpClient.Request request) throws Exception { + try { + request.executeRequest(); + + if (request.getResponseCode() >= 400) { + throw new HttpErrorException( + "The remote server returned an error: (" + request.getResponseCode() + ")" + + request.getResponseText(), request.getResponseCode()); + } + } catch (IOException e) { + // Wrap exception. + throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e); + } + + return request; + } + + /** + * Checks whether input string is null or empty. + * + * @param str The input string. + * @return true if input string is null or empty, otherwise false + */ + private boolean isNullOrEmpty(String str) { + return null == str || str.isEmpty(); + } + + /** + * Try to read the XML declaration. If it's not there, the server didn't return XML. + * + * @param reader The reader. + */ + private void readXmlDeclaration(EwsServiceXmlReader reader) throws Exception { + try { + reader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT)); + } catch (ExchangeXmlException ex) { + throw new ServiceRequestException("The response received from the service didn't contain valid XML.", + ex); + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/SetUserOofSettingsRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/SetUserOofSettingsRequest.java new file mode 100644 index 000000000..3c44aa85c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/SetUserOofSettingsRequest.java @@ -0,0 +1,177 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.property.complex.availability.OofSettings; + +/** + * Represents a SetUserOofSettings request. + */ +public final class SetUserOofSettingsRequest extends SimpleServiceRequestBase { + + /** + * The smtp address. + */ + private String smtpAddress; + + /** + * The oof settings. + */ + private OofSettings oofSettings; + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.SetUserOofSettingsRequest; + } + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + + EwsUtilities.validateParam(this.getSmtpAddress(), "SmtpAddress"); + EwsUtilities.validateParam(this.getOofSettings(), "OofSettings"); + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Mailbox); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Address, + this.getSmtpAddress()); + writer.writeEndElement(); // Mailbox + + this.getOofSettings().writeToXml(writer, + XmlElementNames.UserOofSettings); + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.SetUserOofSettingsResponse; + } + + /** + * {@inheritDoc} + */ + @Override + protected ServiceResponse parseResponse(EwsServiceXmlReader reader) + throws Exception { + ServiceResponse serviceResponse = new ServiceResponse(); + serviceResponse.loadFromXml(reader, XmlElementNames.ResponseMessage); + return serviceResponse; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception on errors + */ + public SetUserOofSettingsRequest(ExchangeService service) throws Exception { + super(service); + } + + /** + * Executes this request. + * + * @return Service response + * @throws Exception the exception + */ + public ServiceResponse execute() throws Exception { + ServiceResponse serviceResponse = internalExecute(); + serviceResponse.throwIfNecessary(); + return serviceResponse; + } + + /** + * Gets the SMTP address. + * + * @return the smtp address + */ + public String getSmtpAddress() { + return this.smtpAddress; + } + + /** + * Sets the smtp address. + * + * @param smtpAddress the new smtp address + */ + public void setSmtpAddress(String smtpAddress) { + this.smtpAddress = smtpAddress; + } + + /** + * Gets the oof settings. + * + * @return the oof settings + */ + public OofSettings getOofSettings() { + return this.oofSettings; + } + + /** + * Sets the oof settings. + * + * @param oofSettings the new oof settings + */ + public void setOofSettings(OofSettings oofSettings) { + this.oofSettings = oofSettings; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/SimpleServiceRequestBase.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/SimpleServiceRequestBase.java new file mode 100644 index 000000000..b72611902 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/SimpleServiceRequestBase.java @@ -0,0 +1,106 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.misc.TraceFlags; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.service.remote.ServiceRequestException; +import com.eischet.ews.api.http.ExchangeHttpClient; +import com.eischet.ews.api.misc.*; + +import java.io.IOException; +import java.util.concurrent.Callable; +import java.util.concurrent.Future; + +/** + * Defines the SimpleServiceRequestBase class. + */ +public abstract class SimpleServiceRequestBase extends ServiceRequestBase { + + /** + * Initializes a new instance of the SimpleServiceRequestBase class. + */ + protected SimpleServiceRequestBase(ExchangeService service) throws ServiceVersionException { + super(service); + } + + /** + * Executes this request. + * + * @return response object + * @throws Exception on error + */ + protected T internalExecute() throws Exception { + ExchangeHttpClient.Request response = null; + + try { + response = this.validateAndEmitRequest(); + return this.readResponse(response); + } catch (IOException ex) { + // Wrap exception. + throw new ServiceRequestException(String. + format("The request failed. %s", ex.getMessage()), ex); + } catch (Exception e) { + if (response != null) { + this.getService().processHttpResponseHeaders(TraceFlags. + EwsResponseHttpHeaders, response); + } + + throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e); + } + } + + /** + * Ends executing this async request. + * + * @param asyncResult The async result + * @return Service response object + * @throws Exception on error + */ + protected T endInternalExecute(IAsyncResult asyncResult) throws Exception { + ExchangeHttpClient.Request response = (ExchangeHttpClient.Request) asyncResult.get(); + return this.readResponse(response); + } + + /** + * Begins executing this async request. + * + * @param callback The AsyncCallback delegate. + * @return An IAsyncResult that references the asynchronous request. + * @throws Exception on error + */ + public AsyncRequestResult beginExecute(AsyncCallback callback) throws Exception { + this.validate(); + + ExchangeHttpClient.Request request = this.buildEwsHttpWebRequest(); + AsyncExecutor es = new AsyncExecutor(); + Callable cl = new CallableMethod(request); + Future task = es.submit(cl, callback); + es.shutdown(); + + return new AsyncRequestResult(this, request, task, null); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/SubscribeRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/SubscribeRequest.java new file mode 100644 index 000000000..b20575706 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/SubscribeRequest.java @@ -0,0 +1,259 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.notification.EventType; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.SubscribeResponse; +import com.eischet.ews.api.http.ExchangeHttpClient; +import com.eischet.ews.api.misc.FolderIdWrapperList; +import com.eischet.ews.api.notification.SubscriptionBase; + +import javax.xml.stream.XMLStreamException; +import java.util.ArrayList; +import java.util.List; + +/** + * The Class SubscribeRequest. + * + * @param the generic type + */ +abstract class SubscribeRequest extends + MultiResponseServiceRequest> { + + /** + * The folder ids. + */ + private FolderIdWrapperList folderIds = new FolderIdWrapperList(); + + /** + * The event types. + */ + private List eventTypes = new ArrayList<>(); + + /** + * The watermark. + */ + private String watermark; + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.getFolderIds(), "FolderIds"); + EwsUtilities.validateParamCollection(this.getEventTypes().iterator(), + "EventTypes"); + this.getFolderIds().validate( + this.getService().getRequestedServerVersion()); + // Check that caller isn't trying + //to subscribe to Status events. + if (this.getEventTypes().contains(EventType.Status)) { + throw new ExchangeValidationException("Status events can't be subscribed to."); + } + + // If Watermark was specified, make sure it's not a blank string. + if (!(this.getWatermark() == null || + this.getWatermark().isEmpty())) { + EwsUtilities.validateNonBlankStringParam(this. + getWatermark(), "Watermark"); + } + + for (EventType eventType : this.getEventTypes()) { + EwsUtilities.validateEnumVersionValue(eventType, + this.getService().getRequestedServerVersion()); + } + + } + + /** + * Gets the name of the subscription XML element. + * + * @return XML element name + */ + protected abstract String getSubscriptionXmlElementName(); + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.Subscribe; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.SubscribeResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.SubscribeResponseMessage; + } + + /** + * Internal method to write XML elements. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + protected abstract void internalWriteElementsToXml(EwsServiceXmlWriter writer) throws XMLStreamException, ServiceXmlSerializationException, ExchangeXmlException; + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + writer.writeStartElement(XmlNamespace.Messages, this + .getSubscriptionXmlElementName()); + + if (this.getFolderIds().getCount() == 0) { + writer.writeAttributeValue(XmlAttributeNames.SubscribeToAllFolders, true); + } + + this.getFolderIds().writeToXml(writer, XmlNamespace.Types, + XmlElementNames.FolderIds); + + writer + .writeStartElement(XmlNamespace.Types, + XmlElementNames.EventTypes); + for (EventType eventType : this.getEventTypes()) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.EventType, eventType); + } + writer.writeEndElement(); + + if (!(this.getWatermark() == null || this.getWatermark().isEmpty())) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.Watermark, this.getWatermark()); + } + + this.internalWriteElementsToXml(writer); + + writer.writeEndElement(); + } + + /** + * Instantiates a new subscribe request. + * + * @param service the service + * @throws Exception on errors + */ + protected SubscribeRequest(ExchangeService service) + throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + this.setFolderIds(new FolderIdWrapperList()); + this.setEventTypes(new ArrayList<>()); + } + + /** + * Gets the folder ids. + * + * @return the folder ids + */ + public FolderIdWrapperList getFolderIds() { + return this.folderIds; + } + + /** + * Sets the folder ids. + */ + private void setFolderIds(FolderIdWrapperList value) { + this.folderIds = value; + } + + /** + * Gets the event types. + * + * @return the event types + */ + public List getEventTypes() { + return this.eventTypes; + } + + /** + * set the EventTypes + */ + private void setEventTypes(List value) { + this.eventTypes = value; + } + + /** + * Gets the watermark. + * + * @return the watermark + */ + public String getWatermark() { + return this.watermark; + } + + /** + * Sets the watermark. + * + * @param watermark the new watermark + */ + public void setWatermark(String watermark) { + this.watermark = watermark; + } + + @Override + protected ExchangeHttpClient.Request buildEwsHttpWebRequest() throws Exception { + return super.buildEwsHttpPoolingWebRequest(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/SubscribeToPullNotificationsRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/SubscribeToPullNotificationsRequest.java new file mode 100644 index 000000000..a87e79eb2 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/SubscribeToPullNotificationsRequest.java @@ -0,0 +1,136 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.SubscribeResponse; +import com.eischet.ews.api.notification.PullSubscription; + +/** + * Represents a "pull" Subscribe request. + */ +public class SubscribeToPullNotificationsRequest extends + SubscribeRequest { + + /** + * The timeout. + */ + private int timeout = 30; + + /** + * Instantiates a new subscribe to pull notification request. + * + * @param service the service + * @throws Exception the exception + */ + public SubscribeToPullNotificationsRequest(ExchangeService service) + throws Exception { + + super(service); + + } + + /** + * Gets the timeout. + * + * @return the timeout + */ + public int getTimeout() { + return this.timeout; + } + + /** + * Sets the time out. + * + * @param timeout the new time out + */ + public void setTimeOut(int timeout) { + this.timeout = timeout; + } + + /** + * Validate request. + * + * @throws Exception the exception + */ + protected void validate() throws Exception { + super.validate(); + if ((this.getTimeout() < 1) || (this.getTimeout() > 1440)) { + throw new ArgumentException(String.format( + "%d is not a valid timeout value. Valid values range from 1 to 1440.", this.getTimeout())); + } + } + + /** + * Creates the service response. + * + * @param service The service. + * @param responseIndex Index of the response. + * @return Service response. + * @throws Exception the exception + */ + @Override + protected SubscribeResponse createServiceResponse( + ExchangeService service, int responseIndex) throws Exception { + return new SubscribeResponse(new PullSubscription( + service)); + } + + /** + * Gets the minimum server version required to process this request. + * + * @return Exchange server version. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the name of the subscription XML element. + * + * @return XML element name + */ + @Override + protected String getSubscriptionXmlElementName() { + return XmlElementNames.PullSubscriptionRequest; + } + + /** + * Reads response elements from XML. + * + * @param writer the writer + */ + @Override + protected void internalWriteElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Timeout, this.getTimeout()); + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/SubscribeToPushNotificationsRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/SubscribeToPushNotificationsRequest.java new file mode 100644 index 000000000..57b1576a8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/SubscribeToPushNotificationsRequest.java @@ -0,0 +1,171 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.SubscribeResponse; +import com.eischet.ews.api.notification.PushSubscription; + +import java.net.URI; + +/** + * The Class SubscribeToPushNotificationsRequest. + */ +public class SubscribeToPushNotificationsRequest extends + SubscribeRequest { + + /** + * The frequency. + */ + private int frequency = 30; + + /** + * The url. + */ + private URI url; + + /** + * Instantiates a new subscribe to push notification request. + * + * @param service the service + * @throws Exception + */ + public SubscribeToPushNotificationsRequest(ExchangeService service) + throws Exception { + super(service); + } + + /* + * (non-Javadoc) + * + * @see microsoft.exchange.webservices.SubscribeRequest#validate() + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.getUrl(), "Url"); + if ((this.getFrequency() < 1) || (this.getFrequency() > 1440)) { + throw new ArgumentException(String.format( + "%d is not a valid frequency value. Valid values range from 1 to 1440.", this.getFrequency())); + } + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.SubscribeRequest + * #getSubscriptionXmlElementName + * () + */ + @Override + protected String getSubscriptionXmlElementName() { + return XmlElementNames.PushSubscriptionRequest; + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.SubscribeRequest + * #internalWriteElementsToXml + * (microsoft.exchange.webservices.EwsServiceXmlWriter) + */ + @Override + protected void internalWriteElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.StatusFrequency, this.getFrequency()); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.URL, this + .getUrl().toString()); + } + + /* + * (non-Javadoc) + * + * @seemicrosoft.exchange.webservices.MultiResponseServiceRequest# + * createServiceResponse(microsoft.exchange.webservices.ExchangeService, + * int) + */ + @Override + protected SubscribeResponse createServiceResponse( + ExchangeService service, int responseIndex) throws Exception { + return new SubscribeResponse<>(new PushSubscription( + service)); + } + + /* + * (non-Javadoc) + * + * @seemicrosoft.exchange.webservices.ServiceRequestBase# + * getMinimumRequiredServerVersion() + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the frequency. + * + * @return the frequency + */ + public int getFrequency() { + return this.frequency; + } + + /** + * Sets the frequency. + * + * @param frequency the new frequency + */ + public void setFrequency(int frequency) { + this.frequency = frequency; + } + + /** + * Gets the url. + * + * @return the url + */ + public URI getUrl() { + return this.url; + } + + /** + * Sets the url. + * + * @param url the new url + */ + public void setUrl(URI url) { + this.url = url; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/SubscribeToStreamingNotificationsRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/SubscribeToStreamingNotificationsRequest.java new file mode 100644 index 000000000..3813bd0f0 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/SubscribeToStreamingNotificationsRequest.java @@ -0,0 +1,111 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.response.SubscribeResponse; +import com.eischet.ews.api.notification.StreamingSubscription; + +/** + * Defines the SubscribeToStreamingNotificationsRequest class. + */ +public class SubscribeToStreamingNotificationsRequest extends + SubscribeRequest { + + /** + * Initializes a new instance of the + * SubscribeToStreamingNotificationsRequest class. + * + * @param service The service + * @throws Exception + */ + public SubscribeToStreamingNotificationsRequest(ExchangeService service) + throws Exception { + super(service); + } + + /** + * Validate request. + * + * @throws Exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + + if (!(this.getWatermark() == null || this.getWatermark().isEmpty())) { + throw new ArgumentException( + "Watermarks cannot be used with StreamingSubscriptions."); + } + } + + + /** + * Gets the name of the subscription XML element. + * + * @return XmlElementsNames + */ + @Override + protected String getSubscriptionXmlElementName() { + return XmlElementNames.StreamingSubscriptionRequest; + } + + /** + * Internals the write elements to XML. + * + * @param writer The writer + */ + @Override + protected void internalWriteElementsToXml(EwsServiceXmlWriter writer) { + } + + /** + * Creates the service response. + * + * @param service The service + * @param responseIndex The responseIndex + * @return SubscribeResponse + * @throws Exception + */ + @Override + protected SubscribeResponse createServiceResponse(ExchangeService service, + int responseIndex) throws Exception { + return new SubscribeResponse( + new StreamingSubscription(service)); + } + + /** + * Gets the request version. + * + * @return ExchangeVersion + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010_SP1; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/SyncFolderHierarchyRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/SyncFolderHierarchyRequest.java new file mode 100644 index 000000000..9a742d2d8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/SyncFolderHierarchyRequest.java @@ -0,0 +1,224 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.ServiceObjectType; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.SyncFolderHierarchyResponse; +import com.eischet.ews.api.property.complex.FolderId; + +/** + * Represents a SyncFolderHierarchy request. + */ +public class SyncFolderHierarchyRequest extends + MultiResponseServiceRequest { + + /** + * The property set. + */ + private PropertySet propertySet; + + /** + * The sync folder id. + */ + private FolderId syncFolderId; + + /** + * The sync state. + */ + private String syncState; + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception + */ + public SyncFolderHierarchyRequest(ExchangeService service) + throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response. + */ + @Override + protected SyncFolderHierarchyResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new SyncFolderHierarchyResponse(this.getPropertySet()); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.SyncFolderHierarchy; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.SyncFolderHierarchyResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.SyncFolderHierarchyResponseMessage; + } + + /** + * Validates request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.getPropertySet(), "PropertySet"); + if (this.getSyncFolderId() != null) { + this.getSyncFolderId().validate( + this.getService().getRequestedServerVersion()); + } + + this.getPropertySet() + .validateForRequest(this, false /* summaryPropertiesOnly */); + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.getPropertySet().writeToXml(writer, ServiceObjectType.Folder); + + if (this.getSyncFolderId() != null) { + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.SyncFolderId); + this.getSyncFolderId().writeToXml(writer); + writer.writeEndElement(); + } + + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.SyncState, this.getSyncState()); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets or sets the property set. The property set. + * + * @return the property set + */ + public PropertySet getPropertySet() { + return this.propertySet; + } + + /** + * Sets the property set. + * + * @param value the new property set + */ + public void setPropertySet(PropertySet value) { + this.propertySet = value; + } + + /** + * Gets or sets the property set. The property set. + * + * @return the sync folder id + */ + public FolderId getSyncFolderId() { + return this.syncFolderId; + } + + /** + * Sets the sync folder id. + * + * @param value the new sync folder id + */ + public void setSyncFolderId(FolderId value) { + this.syncFolderId = value; + } + + /** + * Gets or sets the state of the sync. The state of the + * sync. + * + * @return the sync state + */ + public String getSyncState() { + return this.syncState; + } + + /** + * Sets the sync state. + * + * @param value the new sync state + */ + public void setSyncState(String value) { + this.syncState = value; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/SyncFolderItemsRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/SyncFolderItemsRequest.java new file mode 100644 index 000000000..4cf79690e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/SyncFolderItemsRequest.java @@ -0,0 +1,319 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.ServiceObjectType; +import com.eischet.ews.api.core.enumeration.service.SyncFolderItemsScope; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.response.SyncFolderItemsResponse; +import com.eischet.ews.api.misc.ItemIdWrapperList; +import com.eischet.ews.api.property.complex.FolderId; + +/** + * Represents a SyncFolderItems request. + */ +public class SyncFolderItemsRequest extends + MultiResponseServiceRequest { + + /** + * The property set. + */ + private PropertySet propertySet; + + /** + * The sync folder id. + */ + private FolderId syncFolderId; + + /** + * The sync scope. + */ + private SyncFolderItemsScope syncScope; + + /** + * The sync state. + */ + private String syncState; + + /** + * The ignored item ids. + */ + private final ItemIdWrapperList ignoredItemIds = new ItemIdWrapperList(); + + /** + * The max changes returned. + */ + private int maxChangesReturned = 100; + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception + */ + public SyncFolderItemsRequest(ExchangeService service) + throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + } + + /** + * Creates service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response + */ + @Override + protected SyncFolderItemsResponse createServiceResponse( + ExchangeService service, int responseIndex) { + return new SyncFolderItemsResponse(this.getPropertySet()); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.SyncFolderItems; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.SyncFolderItemsResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.SyncFolderItemsResponseMessage; + } + + /** + * Validates request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.getPropertySet(), "PropertySet"); + EwsUtilities.validateParam(this.getSyncFolderId(), "SyncFolderId"); + this.getSyncFolderId().validate( + this.getService().getRequestedServerVersion()); + + // SyncFolderItemsScope enum was introduced with Exchange2010. Only + // value NormalItems is valid with previous server versions. + if (this.getService().getRequestedServerVersion().compareTo( + ExchangeVersion.Exchange2010) < 0 && + this.syncScope != SyncFolderItemsScope.NormalItems) { + throw new ServiceVersionException(String.format( + "Enumeration value %s in enumeration type %s is only valid for Exchange version %s or later.", this + .getSyncScope().toString(), this.getSyncScope() + .name(), ExchangeVersion.Exchange2010)); + } + + // SyncFolderItems can only handle summary property + this.getPropertySet() + .validateForRequest(this, true /* summaryPropertiesOnly */); + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + this.getPropertySet().writeToXml(writer, ServiceObjectType.Item); + + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.SyncFolderId); + this.getSyncFolderId().writeToXml(writer); + writer.writeEndElement(); + + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.SyncState, this.getSyncState()); + + this.getIgnoredItemIds().writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.Ignore); + + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.MaxChangesReturned, this + .getMaxChangesReturned()); + + if (this.getService().getRequestedServerVersion().compareTo( + ExchangeVersion.Exchange2010) >= 0) { + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.SyncScope, this.syncScope); + } + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets or sets the property set. The property set. + * + * @return the property set + */ + public PropertySet getPropertySet() { + return this.propertySet; + } + + /** + * Sets the property set. + * + * @param propertySet the new property set + */ + public void setPropertySet(PropertySet propertySet) { + this.propertySet = propertySet; + } + + /** + * Gets the sync folder id. The sync folder id. + * + * @return the sync folder id + */ + public FolderId getSyncFolderId() { + return this.syncFolderId; + } + + /** + * Sets the sync folder id. + * + * @param syncFolderId the new sync folder id + */ + public void setSyncFolderId(FolderId syncFolderId) { + this.syncFolderId = syncFolderId; + } + + /** + * Gets the scope of the sync. The scope of the + * sync. + * + * @return the sync scope + */ + public SyncFolderItemsScope getSyncScope() { + return this.syncScope; + } + + /** + * Sets the sync scope. + * + * @param syncScope the new sync scope + */ + public void setSyncScope(SyncFolderItemsScope syncScope) { + this.syncScope = syncScope; + } + + /** + * Gets the state of the sync. The state of the + * sync. + * + * @return the sync state + */ + public String getSyncState() { + return this.syncState; + } + + /** + * Sets the sync state. + * + * @param syncState the new sync state + */ + public void setSyncState(String syncState) { + this.syncState = syncState; + } + + /** + * Gets the list of ignored item ids. The ignored item ids. + * + * @return the ignored item ids + */ + public ItemIdWrapperList getIgnoredItemIds() { + return this.ignoredItemIds; + } + + /** + * Gets the maximum number of changes returned by SyncFolderItems. + * Values must be between 1 and 512. Default is 100. + * + * @return the max changes returned + */ + public int getMaxChangesReturned() { + + return this.maxChangesReturned; + } + + /** + * Sets the max changes returned. + * + * @param maxChangesReturned the new max changes returned + * @throws ArgumentException the argument exception + */ + public void setMaxChangesReturned(int maxChangesReturned) + throws ArgumentException { + if (maxChangesReturned >= 1 && maxChangesReturned <= 512) { + this.maxChangesReturned = maxChangesReturned; + } else { + throw new ArgumentException("MaxChangesReturned must be between 1 and 512."); + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/UnsubscribeRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/UnsubscribeRequest.java new file mode 100644 index 000000000..ec2d5f97e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/UnsubscribeRequest.java @@ -0,0 +1,164 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.http.ExchangeHttpClient; + +/** + * The Class UnsubscribeRequest. + */ +public class UnsubscribeRequest extends MultiResponseServiceRequest { + + /** + * The subscription id. + */ + private String subscriptionId; + + /** + * Instantiates a new unsubscribe request. + * + * @param service the service + * @throws Exception + */ + public UnsubscribeRequest(ExchangeService service) + throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + } + + /** + * Creates service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response. + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new ServiceResponse(); + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } + + /** + * Gets the name of the XML element. + * + * @return Xml element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.Unsubscribe; + } + + /** + * Gets the name of the response XML element. + * + * @return Xml element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.UnsubscribeResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return Xml element name. + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.UnsubscribeResponseMessage; + } + + /** + * Validate the request. + * + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + @Override + protected void validate() throws ServiceLocalException, Exception { + super.validate(); + EwsUtilities.validateNonBlankStringParam(this. + getSubscriptionId(), "SubscriptionId"); + + } + + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.SubscriptionId, this.getSubscriptionId()); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the subscription id. + * + * @return the subscription id + */ + public String getSubscriptionId() { + return this.subscriptionId; + } + + /** + * Sets the subscription id. + * + * @param subscriptionId the new subscription id + */ + public void setSubscriptionId(String subscriptionId) { + this.subscriptionId = subscriptionId; + } + + @Override + protected ExchangeHttpClient.Request buildEwsHttpWebRequest() throws Exception { + return super.buildEwsHttpPoolingWebRequest(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateDelegateRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateDelegateRequest.java new file mode 100644 index 000000000..c5c8f2231 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateDelegateRequest.java @@ -0,0 +1,175 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.MeetingRequestsDeliveryScope; +import com.eischet.ews.api.core.response.DelegateManagementResponse; +import com.eischet.ews.api.property.complex.DelegateUser; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents an UpdateDelegate request. + */ +public class UpdateDelegateRequest extends + DelegateManagementRequestBase { + + /** + * The delegate users. + */ + private final List delegateUsers = new ArrayList(); + + /** + * The meeting request delivery scope. + */ + private MeetingRequestsDeliveryScope meetingRequestsDeliveryScope; + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception + */ + public UpdateDelegateRequest(ExchangeService service) + throws Exception { + super(service); + } + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParamCollection(this.getDelegateUsers().iterator(), "DelegateUsers"); + for (DelegateUser delegateUser : this.getDelegateUsers()) { + delegateUser.validateUpdateDelegate(); + } + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + super.writeElementsToXml(writer); + + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.DelegateUsers); + + for (DelegateUser delegateUser : this.getDelegateUsers()) { + delegateUser.writeToXml(writer, XmlElementNames.DelegateUser); + } + + writer.writeEndElement(); // DelegateUsers + + if (this.getMeetingRequestsDeliveryScope() != null) { + writer.writeElementValue(XmlNamespace.Messages, + XmlElementNames.DeliverMeetingRequests, this + .getMeetingRequestsDeliveryScope()); + } + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.UpdateDelegateResponse; + } + + /** + * Creates the response. + * + * @return Response object. + */ + @Override + protected DelegateManagementResponse createResponse() { + return new DelegateManagementResponse(true, this.delegateUsers); + } + + /** + * Gets the name of the XML element. + * + * @return Xml element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.UpdateDelegate; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the meeting request delivery scope. + * + * @return the meeting request delivery scope + */ + public MeetingRequestsDeliveryScope getMeetingRequestsDeliveryScope() { + return this.meetingRequestsDeliveryScope; + } + + /** + * Sets the meeting request delivery scope. + * + * @param value the new meeting request delivery scope + */ + public void setMeetingRequestsDeliveryScope( + MeetingRequestsDeliveryScope value) { + this.meetingRequestsDeliveryScope = value; + } + + /** + * Gets the delegate users. + * + * @return the delegate users + */ + public List getDelegateUsers() { + return this.delegateUsers; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateFolderRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateFolderRequest.java new file mode 100644 index 000000000..9207f02a2 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateFolderRequest.java @@ -0,0 +1,174 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.core.response.UpdateFolderResponse; +import com.eischet.ews.api.core.service.folder.Folder; + +import java.util.ArrayList; + +/** + * Represents an UpdateFolder request. + */ +public final class UpdateFolderRequest extends + MultiResponseServiceRequest { + + /** + * The folder. + */ + private final ArrayList folders = new ArrayList(); + + /** + * Initializes a new instance of the UpdateFolderRequest class. + * + * @param service The Servcie + * @param errorHandlingMode Indicates how errors should be handled. + * @throws Exception + */ + public UpdateFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /** + * validates request. + * + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + @Override + protected void validate() throws ServiceLocalException, Exception { + super.validate(); + EwsUtilities.validateParamCollection(this.getFolders().iterator(), "Folders"); + for (int i = 0; i < this.getFolders().size(); i++) { + Folder folder = this.getFolders().get(i); + + if ((folder == null) || folder.isNew()) { + throw new IllegalArgumentException(String.format("Folders[%d] is either null or does not have an Id.", i)); + } + + folder.validate(); + } + } + + /** + * Creates the service response. + * + * @param session The session + * @param responseIndex Index of the response. + * @return Service response. + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService session, + int responseIndex) { + return new UpdateFolderResponse(this.getFolders().get(responseIndex)); + } + + /** + * Gets the name of the XML element. + * + * @return Xml element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.UpdateFolder; + } + + /** + * Gets the name of the response XML element. + * + * @return Xml element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.UpdateFolderResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return Xml element name. + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.UpdateFolderResponseMessage; + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.getFolders().size(); + } + + /** + * Writes to xml. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.FolderChanges); + + for (Folder folder : this.folders) { + folder.writeToXmlForUpdate(writer); + } + + writer.writeEndElement(); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the folder. + * + * @return the folder + */ + public ArrayList getFolders() { + return this.folders; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateInboxRulesRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateInboxRulesRequest.java new file mode 100644 index 000000000..d25bb235e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateInboxRulesRequest.java @@ -0,0 +1,215 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.ServiceResult; +import com.eischet.ews.api.core.exception.service.remote.UpdateInboxRulesException; +import com.eischet.ews.api.core.response.UpdateInboxRulesResponse; +import com.eischet.ews.api.property.complex.RuleOperation; + +/** + * Represents a UpdateInboxRulesRequest request. + */ +public final class UpdateInboxRulesRequest extends SimpleServiceRequestBase { + /** + * The smtp address of the mailbox from which to get the inbox rules. + */ + private String mailboxSmtpAddress; + + /** + * Remove OutlookRuleBlob or not. + */ + private boolean removeOutlookRuleBlob; + + /** + * InboxRule operation collection. + */ + private Iterable inboxRuleOperations; + + /** + * Initializes a new instance of the + * class. + * + * @param service The service. + */ + public UpdateInboxRulesRequest(ExchangeService service) throws Exception { + super(service); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.UpdateInboxRules; + } + + /** + * Writes XML elements. + * + * @param writer The writer. + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + if (!(mailboxSmtpAddress == null || mailboxSmtpAddress.isEmpty())) { + writer.writeElementValue( + XmlNamespace.Messages, + XmlElementNames.MailboxSmtpAddress, + this.mailboxSmtpAddress); + } + + writer.writeElementValue( + XmlNamespace.Messages, + XmlElementNames.RemoveOutlookRuleBlob, + this.removeOutlookRuleBlob); + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.Operations); + for (RuleOperation operation : this.inboxRuleOperations) { + operation.writeToXml(writer, operation.getXmlElementName()); + } + writer.writeEndElement(); + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name. + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.UpdateInboxRulesResponse; + } + + /** + * {@inheritDoc} + */ + @Override + protected UpdateInboxRulesResponse parseResponse(EwsServiceXmlReader reader) + throws Exception { + UpdateInboxRulesResponse response = new UpdateInboxRulesResponse(); + response.loadFromXml(reader, XmlElementNames.UpdateInboxRulesResponse); + return response; + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010_SP1; + } + + /** + * Validate request. + */ + @Override + protected void validate() throws Exception { + if (this.inboxRuleOperations == null) { + throw new IllegalArgumentException( + "RuleOperations cannot be null." + "Operations"); + } + + int operationCount = 0; + for (RuleOperation operation : this.inboxRuleOperations) { + EwsUtilities.validateParam(operation, "RuleOperation"); + operationCount++; + } + + if (operationCount == 0) { + throw new IllegalArgumentException( + "RuleOperations cannot be empty." + "Operations"); + } + + this.getService().validate(); + } + + /** + * Executes this request. + * + * @return Service response. + * @throws Exception on error + */ + public UpdateInboxRulesResponse execute() throws Exception { + UpdateInboxRulesResponse serviceResponse = internalExecute(); + if (serviceResponse.getResult() == ServiceResult.Error) { + throw new UpdateInboxRulesException(serviceResponse, + this.inboxRuleOperations); + } + return serviceResponse; + } + + /** + * Gets the address of the mailbox in which to update the inbox rules. + */ + public String getMailboxSmtpAddress() { + return this.mailboxSmtpAddress; + } + + /** + * Sets the address of the mailbox in which to update the inbox rules. + */ + public void setMailboxSmtpAddress(String value) { + this.mailboxSmtpAddress = value; + } + + /** + * Gets a value indicating whether or not to + * remove OutlookRuleBlob from the rule collection. + */ + public boolean getRemoveOutlookRuleBlob() { + return this.removeOutlookRuleBlob; + } + + /** + * Sets a value indicating whether or not to + * remove OutlookRuleBlob from the rule collection. + */ + public void setRemoveOutlookRuleBlob(boolean value) { + this.removeOutlookRuleBlob = value; + } + + + /** + * Gets the RuleOperation collection. + */ + public Iterable getInboxRuleOperations() { + return this.inboxRuleOperations; + } + + /** + * Sets the RuleOperation collection. + */ + public void setInboxRuleOperations(Iterable value) { + this.inboxRuleOperations = value; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateItemRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateItemRequest.java new file mode 100644 index 000000000..ee22ce075 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateItemRequest.java @@ -0,0 +1,320 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.ConflictResolutionMode; +import com.eischet.ews.api.core.enumeration.service.MessageDisposition; +import com.eischet.ews.api.core.enumeration.service.SendInvitationsOrCancellationsMode; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.UpdateItemResponse; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.property.complex.FolderId; + +import java.util.ArrayList; +import java.util.List; + +/** + * The Class UpdateItemRequest. + */ +public final class UpdateItemRequest extends + MultiResponseServiceRequest { + + /** + * The item. + */ + private final List items = new ArrayList<>(); + + /** + * The saved item destination folder. + */ + private FolderId savedItemsDestinationFolder; + + /** + * The conflict resolution mode. + */ + private ConflictResolutionMode conflictResolutionMode; + + /** + * The message disposition. + */ + private MessageDisposition messageDisposition; + + /** + * The send invitations or cancellations mode. + */ + private SendInvitationsOrCancellationsMode + sendInvitationsOrCancellationsMode; + + /** + * Instantiates a new update item request. + * + * @param service the service + * @param errorHandlingMode the error handling mode + * @throws Exception on errors + */ + public UpdateItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) + throws Exception { + super(service, errorHandlingMode); + } + + /* + * (non-Javadoc) + * + * @see microsoft.exchange.webservices.ServiceRequestBase#validate() + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParamCollection(this.getItems().iterator(), "Items"); + for (int i = 0; i < this.getItems().size(); i++) { + if ((this.getItems().get(i) == null) || + this.getItems().get(i).isNew()) { + throw new ArgumentException(String.format("Items[%d] is either null or does not have an Id.", i)); + } + } + + if (this.savedItemsDestinationFolder != null) { + this.savedItemsDestinationFolder.validate(this.getService() + .getRequestedServerVersion()); + } + + // Validate each item. + for (Item item : this.getItems()) { + item.validate(); + } + } + + /* + * (non-Javadoc) + * + * @seemicrosoft.exchange.webservices.MultiResponseServiceRequest# + * createServiceResponse(microsoft.exchange.webservices.ExchangeService, + * int) + */ + @Override + protected UpdateItemResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new UpdateItemResponse(this.getItems().get(responseIndex)); + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.ServiceRequestBase#getXmlElementName() + */ + @Override + public String getXmlElementName() { + return XmlElementNames.UpdateItem; + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.ServiceRequestBase + * #getResponseXmlElementName + * () + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.UpdateItemResponse; + } + + /* + * (non-Javadoc) + * + * @seemicrosoft.exchange.webservices.MultiResponseServiceRequest# + * getResponseMessageXmlElementName() + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.UpdateItemResponseMessage; + } + + /* + * (non-Javadoc) + * + * @seemicrosoft.exchange.webservices.MultiResponseServiceRequest# + * getExpectedResponseMessageCount() + */ + @Override + protected int getExpectedResponseMessageCount() { + return this.items.size(); + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.ServiceRequestBase#writeAttributesToXml + * (microsoft.exchange.webservices.EwsServiceXmlWriter) + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + + if (this.messageDisposition != null) { + writer.writeAttributeValue(XmlAttributeNames.MessageDisposition, + this.messageDisposition); + } + + writer.writeAttributeValue(XmlAttributeNames.ConflictResolution, + this.conflictResolutionMode); + + if (this.sendInvitationsOrCancellationsMode != null) { + writer.writeAttributeValue( + XmlAttributeNames.SendMeetingInvitationsOrCancellations, + this.sendInvitationsOrCancellationsMode); + } + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.ServiceRequestBase#writeElementsToXml( + * microsoft.exchange.webservices.EwsServiceXmlWriter) + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + if (this.savedItemsDestinationFolder != null) { + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.SavedItemFolderId); + this.savedItemsDestinationFolder.writeToXml(writer); + writer.writeEndElement(); + } + + writer.writeStartElement(XmlNamespace.Messages, + XmlElementNames.ItemChanges); + + for (Item item : this.items) { + item.writeToXmlForUpdate(writer); + } + + writer.writeEndElement(); + } + + /* + * (non-Javadoc) + * + * @seemicrosoft.exchange.webservices.ServiceRequestBase# + * getMinimumRequiredServerVersion() + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the message disposition. + * + * @return the message disposition + */ + public MessageDisposition getMessageDisposition() { + return this.messageDisposition; + } + + /** + * Sets the message disposition. + * + * @param value the new message disposition + */ + public void setMessageDisposition(MessageDisposition value) { + this.messageDisposition = value; + } + + /** + * Gets the conflict resolution mode. + * + * @return the conflict resolution mode + */ + public ConflictResolutionMode getConflictResolutionMode() { + return this.conflictResolutionMode; + } + + /** + * Sets the conflict resolution mode. + * + * @param value the new conflict resolution mode + */ + public void setConflictResolutionMode(ConflictResolutionMode value) { + this.conflictResolutionMode = value; + } + + /** + * Gets the send invitations or cancellations mode. + * + * @return the send invitations or cancellations mode + */ + public SendInvitationsOrCancellationsMode + getSendInvitationsOrCancellationsMode() { + return this.sendInvitationsOrCancellationsMode; + } + + /** + * Sets the send invitations or cancellations mode. + * + * @param value the new send invitations or cancellations mode + */ + public void setSendInvitationsOrCancellationsMode( + SendInvitationsOrCancellationsMode value) { + this.sendInvitationsOrCancellationsMode = value; + } + + /** + * Gets the item. + * + * @return the item + */ + public List getItems() { + return this.items; + } + + /** + * Gets the saved item destination folder. + * + * @return the saved item destination folder + */ + public FolderId getSavedItemsDestinationFolder() { + return this.savedItemsDestinationFolder; + } + + /** + * Sets the saved item destination folder. + * + * @param value the new saved item destination folder + */ + public void setSavedItemsDestinationFolder(FolderId value) { + this.savedItemsDestinationFolder = value; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateUserConfigurationRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateUserConfigurationRequest.java new file mode 100644 index 000000000..c808799c8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/UpdateUserConfigurationRequest.java @@ -0,0 +1,163 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.request; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.response.ServiceResponse; +import com.eischet.ews.api.misc.UserConfiguration; + +/** + * Represents a UpdateUserConfiguration request. + */ +public class UpdateUserConfigurationRequest extends + MultiResponseServiceRequest { + + /** + * The user configuration. + */ + protected UserConfiguration userConfiguration; + + /** + * Validate request. + * + * @throws Exception the exception + */ + @Override + protected void validate() throws Exception { + super.validate(); + EwsUtilities.validateParam(this.userConfiguration, "userConfiguration"); + } + + /** + * Creates the service response. + * + * @param service the service + * @param responseIndex the response index + * @return Service response. + */ + @Override + protected ServiceResponse createServiceResponse(ExchangeService service, + int responseIndex) { + return new ServiceResponse(); + } + + /** + * Gets the request version. + * + * @return Earliest Exchange version in which this request is supported. + */ + @Override + protected ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010; + } + + /** + * Gets the expected response message count. + * + * @return Number of expected response messages. + */ + @Override + protected int getExpectedResponseMessageCount() { + return 1; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.UpdateUserConfiguration; + } + + /** + * Gets the name of the response XML element. + * + * @return XML element name + */ + @Override + protected String getResponseXmlElementName() { + return XmlElementNames.UpdateUserConfigurationResponse; + } + + /** + * Gets the name of the response message XML element. + * + * @return XML element name + */ + @Override + protected String getResponseMessageXmlElementName() { + return XmlElementNames.UpdateUserConfigurationResponseMessage; + } + + /** + * Writes XML elements. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + // Write UserConfiguation element + this.userConfiguration.writeToXml(writer, XmlNamespace.Messages, + XmlElementNames.UserConfiguration); + } + + /** + * Initializes a new instance of the class. + * + * @param service the service + * @throws Exception on error + */ + public UpdateUserConfigurationRequest(ExchangeService service) + throws Exception { + super(service, ServiceErrorHandling.ThrowOnError); + } + + /** + * Gets the user configuration. + * + * @return the user configuration + */ + public UserConfiguration getUserConfiguration() { + return this.userConfiguration; + } + + /** + * Sets the user configuration. + * + * @param userConfiguration the new user configuration + */ + public void setUserConfiguration(UserConfiguration userConfiguration) { + this.userConfiguration = userConfiguration; + } +} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/WaitHandle.java b/ews-api/src/main/java/com/eischet/ews/api/core/request/WaitHandle.java similarity index 95% rename from src/main/java/microsoft/exchange/webservices/data/core/request/WaitHandle.java rename to ews-api/src/main/java/com/eischet/ews/api/core/request/WaitHandle.java index ba9bb9925..65dff6781 100644 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/WaitHandle.java +++ b/ews-api/src/main/java/com/eischet/ews/api/core/request/WaitHandle.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.request; +package com.eischet.ews.api.core.request; public class WaitHandle { diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/AttendeeAvailability.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/AttendeeAvailability.java new file mode 100644 index 000000000..98d5d342d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/AttendeeAvailability.java @@ -0,0 +1,177 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.availability.FreeBusyViewType; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.LegacyFreeBusyStatus; +import com.eischet.ews.api.property.complex.availability.CalendarEvent; +import com.eischet.ews.api.property.complex.availability.WorkingHours; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * Represents the availability of an individual attendee. + */ +public final class AttendeeAvailability extends ServiceResponse { + + /** + * The calendar events. + */ + private final Collection calendarEvents = + new ArrayList(); + + /** + * The merged free busy status. + */ + private final Collection mergedFreeBusyStatus = + new ArrayList(); + + /** + * The view type. + */ + private FreeBusyViewType viewType; + + /** + * The working hours. + */ + private WorkingHours workingHours; + + /** + * Initializes a new instance of the AttendeeAvailability class. + */ + public AttendeeAvailability() { + super(); + } + + /** + * Loads the free busy view from XML. + * + * @param reader the reader + * @param viewType the view type + * @throws Exception the exception + */ + public void loadFreeBusyViewFromXml(EwsServiceXmlReader reader, FreeBusyViewType viewType) throws Exception { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.FreeBusyView); + + String viewTypeString = reader.readElementValue(XmlNamespace.Types, + XmlElementNames.FreeBusyViewType); + + for (Object o : FreeBusyViewType.class.getEnumConstants()) { + if (o.toString().equals(viewTypeString)) { + this.viewType = (FreeBusyViewType) o; + break; + } + } + do { + reader.read(); + + if (reader.isStartElement()) { + if (reader.getLocalName() + .equals(XmlElementNames.MergedFreeBusy)) { + String mergedFreeBusy = reader.readElementValue(); + + for (int i = 0; i < mergedFreeBusy.length(); i++) { + + Byte b = Byte.parseByte(mergedFreeBusy.charAt(i) + ""); + for (LegacyFreeBusyStatus legacyStatus : LegacyFreeBusyStatus.values()) { + if (b == legacyStatus.getBusyStatus()) { + this.mergedFreeBusyStatus.add(legacyStatus); + break; + } + } + + } + + } else if (reader.getLocalName().equals( + XmlElementNames.CalendarEventArray)) { + do { + reader.read(); + + if (reader.isStartElement(XmlNamespace.Types, + XmlElementNames.CalendarEvent)) { + CalendarEvent calendarEvent = new CalendarEvent(); + + calendarEvent.loadFromXml(reader, + XmlElementNames.CalendarEvent); + + this.calendarEvents.add(calendarEvent); + } + } while (!reader.isEndElement(XmlNamespace.Types, + XmlElementNames.CalendarEventArray)); + + } else if (reader.getLocalName().equals( + XmlElementNames.WorkingHours)) { + this.workingHours = new WorkingHours(); + this.workingHours + .loadFromXml(reader, reader.getLocalName()); + + break; + } + } + } while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.FreeBusyView)); + } + + /** + * Gets a collection of calendar events for the attendee. + * + * @return the calendar events + */ + public Collection getCalendarEvents() { + return this.calendarEvents; + } + + /** + * Gets a collection of merged free/busy status for the attendee. + * + * @return the merged free busy status + */ + public Collection getMergedFreeBusyStatus() { + return mergedFreeBusyStatus; + } + + /** + * Gets the free/busy view type that wes retrieved for the attendee. + * + * @return the view type + */ + public FreeBusyViewType getViewType() { + return viewType; + } + + /** + * Gets the working hours of the attendee. + * + * @return the working hours + */ + public WorkingHours getWorkingHours() { + return workingHours; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/ConvertIdResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/ConvertIdResponse.java new file mode 100644 index 000000000..5a541f331 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/ConvertIdResponse.java @@ -0,0 +1,109 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.misc.id.AlternateId; +import com.eischet.ews.api.misc.id.AlternateIdBase; +import com.eischet.ews.api.misc.id.AlternatePublicFolderId; +import com.eischet.ews.api.misc.id.AlternatePublicFolderItemId; + +/** + * Represents the response to an individual Id conversion operation. + */ +public final class ConvertIdResponse extends ServiceResponse { + + /** + * The converted id. + */ + private AlternateIdBase convertedId; + + /** + * Initializes a new instance of the class. + */ + public ConvertIdResponse() { + super(); + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws InstantiationException the instantiation exception + * @throws IllegalAccessException the illegal access exception + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws InstantiationException, IllegalAccessException, ServiceLocalException, Exception { + super.readElementsFromXml(reader); + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.AlternateId); + String alternateIdClass = reader.readAttributeValue( + XmlNamespace.XmlSchemaInstance, XmlAttributeNames.Type); + + int aliasSeparatorIndex = alternateIdClass.indexOf(':'); + + if (aliasSeparatorIndex > -1) { + alternateIdClass = alternateIdClass + .substring(aliasSeparatorIndex + 1); + } + + // Alternate Id classes are responsible fro reading the AlternateId end + // element when necessary + if (alternateIdClass.equals(AlternateId.SchemaTypeName)) { + this.convertedId = new AlternateId(); + } else if (alternateIdClass + .equals(AlternatePublicFolderId.SchemaTypeName)) { + this.convertedId = new AlternatePublicFolderId(); + } else if (alternateIdClass + .equals(AlternatePublicFolderItemId.SchemaTypeName)) { + this.convertedId = new AlternatePublicFolderItemId(); + } else { + EwsUtilities + .ewsAssert(false, "ConvertIdResponse.ReadElementsFromXml", + String.format("Unknown alternate Id class: %s", alternateIdClass)); + } + + this.convertedId.loadAttributesFromXml(reader); + reader.readEndElement(XmlNamespace.Messages, + XmlElementNames.AlternateId); + } + + /** + * Reads response elements from XML. + * + * @return the converted id + */ + public AlternateIdBase getConvertedId() { + return this.convertedId; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateAttachmentResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateAttachmentResponse.java new file mode 100644 index 000000000..444bb19ca --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateAttachmentResponse.java @@ -0,0 +1,87 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.property.complex.Attachment; +import com.eischet.ews.api.security.XmlNodeType; + +/** + * Represents the response to an individual attachment creation operation. + */ +public final class CreateAttachmentResponse extends ServiceResponse { + + /** + * The attachment. + */ + private final Attachment attachment; + + /** + * Initializes a new instance of the CreateAttachmentResponse class. + * + * @param attachment the attachment + */ + public CreateAttachmentResponse(Attachment attachment) { + super(); + EwsUtilities.ewsAssert(attachment != null, "CreateAttachmentResponse.ctor", "attachment is null"); + + this.attachment = attachment; + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + super.readElementsFromXml(reader); + + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.Attachments); + + // reader.read(XmlNodeType.START_ELEMENT); + XmlNodeType x = new XmlNodeType(XmlNodeType.START_ELEMENT); + reader.read(x); + this.attachment.loadFromXml(reader, reader.getLocalName()); + + reader.readEndElement(XmlNamespace.Messages, + XmlElementNames.Attachments); + } + + /** + * Gets the attachment that was created. + * + * @return the attachment + */ + public Attachment getAttachment() { + return this.attachment; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateFolderResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateFolderResponse.java new file mode 100644 index 000000000..20c39f831 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateFolderResponse.java @@ -0,0 +1,94 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.service.ServiceResult; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.folder.Folder; + +import java.util.List; + +/** + * Represents the response to an individual folder creation operation. + */ +public final class CreateFolderResponse extends ServiceResponse implements + IGetObjectInstanceDelegate { + + /** + * The folder. + */ + private Folder folder; + + /** + * Initializes a new instance of the CreateFolderResponse class. + * + * @param folder The folder. + */ + public CreateFolderResponse(Folder folder) { + super(); + this.folder = folder; + } + + private Folder getObjectInstance(ExchangeService service, String xmlElementName) throws ExchangeXmlException { + if (this.folder != null) { + return this.folder; + } else { + return EwsUtilities.createEwsObjectFromXmlElementName(Folder.class, service, xmlElementName); + } + } + + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + super.readElementsFromXml(reader); + + List folders = reader.readServiceObjectsCollectionFromXml( + XmlElementNames.Folders, this, false, /* clearPropertyBag */ + null, /* requestedPropertySet */ + false); /* summaryPropertiesOnly */ + + this.folder = folders.get(0); + } + + @Override + public ServiceObject getObjectInstanceDelegate(ExchangeService service, String xmlElementName) throws ExchangeXmlException { + return this.getObjectInstance(service, xmlElementName); + } + + /** + * Clears the change log of the created folder if the creation succeeded. + */ + @Override + protected void loaded() { + if (this.getResult() == ServiceResult.Success) { + this.folder.clearChangeLog(); + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateItemResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateItemResponse.java new file mode 100644 index 000000000..5555ec5fb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateItemResponse.java @@ -0,0 +1,72 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.service.ServiceResult; +import com.eischet.ews.api.core.service.item.Item; + +/** + * Represents the response to an individual item creation operation. + */ +public final class CreateItemResponse extends CreateItemResponseBase { + + /** + * The item. + */ + private final Item item; + + /** + * Gets Item instance. + * + * @param service The service. + * @param xmlElementName Name of the XML element. + * @return the object instance + */ + @Override + protected Item getObjectInstance(ExchangeService service, + String xmlElementName) { + return this.item; + } + + /** + * Initializes a new instance. + * + * @param item The item. + */ + public CreateItemResponse(Item item) { + super(); + this.item = item; + } + + /** + * Clears the change log of the created folder if the creation succeeded. + */ + @Override + protected void loaded() { + if (this.getResult() == ServiceResult.Success) { + this.item.clearChangeLog(); + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateItemResponseBase.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateItemResponseBase.java new file mode 100644 index 000000000..22e6dd279 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateItemResponseBase.java @@ -0,0 +1,101 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Item; + +import java.util.List; + +/** + * Represents the base response class for item creation operations. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +abstract class CreateItemResponseBase extends ServiceResponse implements IGetObjectInstanceDelegate { + + /** + * The item. + */ + private List items; + + /** + * Gets Item instance. + * + * @param service The service. + * @param xmlElementName Name of the XML element. + * @return Item. + */ + protected abstract Item getObjectInstance(ExchangeService service, String xmlElementName) throws ExchangeXmlException; + + /** + * Gets the object instance delegate. + * + * @param service accepts ExchangeService + * @param xmlElementName accepts String + * @return object + */ + public ServiceObject getObjectInstanceDelegate(ExchangeService service, + String xmlElementName) throws ExchangeXmlException { + return this.getObjectInstance(service, xmlElementName); + } + + /** + * Initializes a new instance. + */ + protected CreateItemResponseBase() { + super(); + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + super.readElementsFromXml(reader); + this.items = reader.readServiceObjectsCollectionFromXml( + XmlElementNames.Items, this, false, /* clearPropertyBag */ + null, /* requestedPropertySet */ + false); /* summaryPropertiesOnly */ + } + + /** + * Gets the item. + * + * @return List of item. + */ + public List getItems() { + return items; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateResponseObjectResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateResponseObjectResponse.java new file mode 100644 index 000000000..ae6555cf9 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/CreateResponseObjectResponse.java @@ -0,0 +1,62 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.item.Item; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents response to generic Create request. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class CreateResponseObjectResponse extends CreateItemResponseBase { + + /** + * Gets Item instance. + * + * @param service The service. + * @param xmlElementName Name of the XML element. + * @return Item. + * @throws Exception the exception + */ + @Override + protected Item getObjectInstance(ExchangeService service, String xmlElementName) throws ExchangeXmlException { + return EwsUtilities.createEwsObjectFromXmlElementName(Item.class, service, xmlElementName); + } + + /** + * Initializes a new instance of the CreateResponseObjectResponse class. + */ + public CreateResponseObjectResponse() { + super(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/DelegateManagementResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/DelegateManagementResponse.java new file mode 100644 index 000000000..fb65ad8fb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/DelegateManagementResponse.java @@ -0,0 +1,123 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.misc.error.ServiceError; +import com.eischet.ews.api.property.complex.DelegateUser; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Represents the response to a delegate managent-related operation. + */ +public class DelegateManagementResponse extends ServiceResponse { + + /** + * The read delegate users. + */ + private final boolean readDelegateUsers; + + /** + * The delegate users. + */ + private final List delegateUsers; + + /** + * The delegate user response. + */ + private Collection delegateUserResponses; + + /** + * Initializes a new instance of the class. + * + * @param readDelegateUsers the read delegate users + * @param delegateUsers the delegate users + */ + public DelegateManagementResponse(boolean readDelegateUsers, List delegateUsers) { + super(); + this.readDelegateUsers = readDelegateUsers; + this.delegateUsers = delegateUsers; + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + if (this.getErrorCode() == ServiceError.NoError) { + this.delegateUserResponses = new ArrayList(); + + reader.read(); + + if (reader.isStartElement(XmlNamespace.Messages, + XmlElementNames.ResponseMessages)) { + int delegateUserIndex = 0; + do { + reader.read(); + if (reader.isStartElement(XmlNamespace.Messages, + XmlElementNames.DelegateUserResponseMessageType)) { + DelegateUser delegateUser = null; + if (this.readDelegateUsers && + (this.delegateUsers != null)) { + delegateUser = this.delegateUsers + .get(delegateUserIndex); + } + + DelegateUserResponse delegateUserResponse = + new DelegateUserResponse( + readDelegateUsers, delegateUser); + delegateUserResponse + .loadFromXml( + reader, + XmlElementNames. + DelegateUserResponseMessageType); + this.delegateUserResponses.add(delegateUserResponse); + + delegateUserIndex++; + } + } while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.ResponseMessages)); + } + } + } + + /** + * Gets a collection of response for each of the delegate users concerned + * by the operation. + * + * @return the delegate user response + */ + public Collection getDelegateUserResponses() { + return this.delegateUserResponses; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/DelegateUserResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/DelegateUserResponse.java new file mode 100644 index 000000000..b3f74638e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/DelegateUserResponse.java @@ -0,0 +1,90 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.property.complex.DelegateUser; + +/** + * Represents the response to an individual delegate user manipulation (add, + * remove, update) operation. + */ +public final class DelegateUserResponse extends ServiceResponse { + + /** + * The read delegate user. + */ + private final boolean readDelegateUser; + + /** + * The delegate user. + */ + private DelegateUser delegateUser; + + /** + * Initializes a new instance of the class. + * + * @param readDelegateUser the read delegate user + * @param delegateUser the delegate user + */ + protected DelegateUserResponse(boolean readDelegateUser, + DelegateUser delegateUser) { + super(); + this.readDelegateUser = readDelegateUser; + this.delegateUser = delegateUser; + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + if (this.readDelegateUser) { + if (this.delegateUser == null) { + this.delegateUser = new DelegateUser(); + } + + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.DelegateUser); + + this.delegateUser.loadFromXml(reader, XmlNamespace.Messages, reader + .getLocalName()); + } + } + + /** + * The delegate user that was involved in the operation. + * + * @return the delegate user + */ + public DelegateUser getDelegateUser() { + return this.delegateUser; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/DeleteAttachmentResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/DeleteAttachmentResponse.java new file mode 100644 index 000000000..ae01ee8f4 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/DeleteAttachmentResponse.java @@ -0,0 +1,88 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.property.complex.Attachment; + +/** + * Represents the response to an individual attachment deletion operation. + */ +public final class DeleteAttachmentResponse extends ServiceResponse { + + /** + * The attachment. + */ + private final Attachment attachment; + + /** + * Initializes a new instance of the DeleteAttachmentResponse class. + * + * @param attachment the attachment + */ + public DeleteAttachmentResponse(Attachment attachment) { + super(); + EwsUtilities.ewsAssert(attachment != null, "DeleteAttachmentResponse.ctor", "attachment is null"); + + this.attachment = attachment; + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws ServiceLocalException, Exception { + super.readElementsFromXml(reader); + + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.RootItemId); + + String changeKey = reader + .readAttributeValue(XmlAttributeNames.RootItemChangeKey); + if (!(null == changeKey || changeKey.isEmpty())) { + this.attachment.getOwner().getRootItemId().setChangeKey(changeKey); + } + reader.readEndElement(XmlNamespace.Messages, + XmlElementNames.RootItemId); + } + + /** + * Gets the attachment that was deleted. + * + * @return the attachment + */ + public Attachment getAttachment() { + return this.attachment; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/ExecuteDiagnosticMethodResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/ExecuteDiagnosticMethodResponse.java new file mode 100644 index 000000000..57cb14d59 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/ExecuteDiagnosticMethodResponse.java @@ -0,0 +1,168 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.events.Attribute; +import javax.xml.stream.events.Namespace; +import javax.xml.stream.events.StartElement; +import javax.xml.stream.events.XMLEvent; +import java.util.Iterator; + + +/** + * Represents the response to a ExecuteDiagnosticMethod operation + */ +public final class ExecuteDiagnosticMethodResponse extends ServiceResponse { + + + /** + * Initializes a new instance of the ExecuteDiagnosticMethodResponse class. + * + * @param service The service + */ + public ExecuteDiagnosticMethodResponse(ExchangeService service) { + super(); + EwsUtilities.ewsAssert(service != null, "ExecuteDiagnosticMethodResponse.ctor", "service is null"); + } + + /** + * Reads response elements from XML. + * + * @throws Exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.ReturnValue); + + XMLEventReader returnValueReader = reader.getXmlReaderForNode(); + //this.returnValue = (Document) new SafeXmlDocument(); + { + this.returnValue = retriveDocument(returnValueReader); + } + + reader.skipCurrentElement(); + reader.readEndElementIfNecessary(XmlNamespace.Messages, + XmlElementNames.ReturnValue); + } + + + /** + * @return document + * @throws javax.xml.parsers.ParserConfigurationException + */ + public Document retriveDocument(XMLEventReader xmlEventReader) + throws ParserConfigurationException { + DocumentBuilderFactory dbfInstance = DocumentBuilderFactory + .newInstance(); + DocumentBuilder documentBuilder = dbfInstance.newDocumentBuilder(); + Document document = documentBuilder.newDocument(); + + Element currentElement = document.getDocumentElement(); + + while (xmlEventReader.hasNext()) { + XMLEvent xmleve = (XMLEvent) xmlEventReader.next(); + + if (xmleve.getEventType() == XmlNodeType.END_ELEMENT) { + Node node = currentElement.getParentNode(); + if (node instanceof Document) { + currentElement = ((Document) node).getDocumentElement(); + } else { + currentElement = (Element) currentElement.getParentNode(); + } + } + + if (xmleve.getEventType() == XmlNodeType.START_ELEMENT) { + // startElement((StartElement) xmleve,doc); + StartElement ele = (StartElement) xmleve; + Element element = null; + element = document.createElementNS(ele.getName() + .getNamespaceURI(), ele.getName().getLocalPart()); + + + Iterator ite = ele.getAttributes(); + + while (ite.hasNext()) { + Attribute attr = ite.next(); + element.setAttribute(attr.getName().getLocalPart(), + attr.getValue()); + } + + String xmlns = EwsUtilities.WSTrustFebruary2005Namespace;//"http://schemas.xmlsoap.org/wsdl/"; + final Iterator iteNS = ele.getNamespaces(); + while (iteNS.hasNext()) { + Namespace ns = iteNS.next(); + String name = ns.getPrefix(); + if (!name.isEmpty()) { + element.setAttributeNS(xmlns, name, + ns.getNamespaceURI()); + } else { + xmlns = ns.getNamespaceURI(); + } + } + + if (currentElement == null) { + document.appendChild(element); + } else { + currentElement.appendChild(element); + } + + currentElement = element; + element.setUserData("location", ele.getLocation(), null); + } + } + return document; + } + + private Document returnValue; + + /** + * Gets the return value. + */ + public Document getReturnValue() { + return returnValue; + } + + /** + * Sets the return value. + */ + private void setReturnValue(Document value) { + returnValue = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/ExpandGroupResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/ExpandGroupResponse.java new file mode 100644 index 000000000..2916138fb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/ExpandGroupResponse.java @@ -0,0 +1,68 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.misc.ExpandGroupResults; + +/** + * Represents the response to a group expansion operation. + */ +public final class ExpandGroupResponse extends ServiceResponse { + + /** + * AD or store group members. + */ + private final ExpandGroupResults members = new ExpandGroupResults(); + + /** + * Initializes a new instance of the class. + */ + public ExpandGroupResponse() { + super(); + } + + /** + * Gets a list of the group's members. + * + * @return the members + */ + public ExpandGroupResults getMembers() { + return this.members; + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + super.readElementsFromXml(reader); + this.getMembers().loadFromXml(reader); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/FindConversationResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/FindConversationResponse.java new file mode 100644 index 000000000..b2aa26ab3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/FindConversationResponse.java @@ -0,0 +1,99 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.service.item.Conversation; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Represents the response to a Conversation search operation. + */ +public final class FindConversationResponse extends ServiceResponse { + List conversations = new ArrayList(); + + /** + * Initializes a new instance of the FindConversationResponse class. + */ + public FindConversationResponse() { + super(); + } + + /** + * Gets the results of the operation. + */ + public Collection getConversations() { + + return this.conversations; + + } + + /** + * Read Conversations from XML. + * + * @param reader The reader. + * @throws Exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + EwsUtilities.ewsAssert(conversations != null, "FindConversationResponse.ReadElementsFromXml", + "conversations is null."); + + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.Conversations); + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + Conversation item = EwsUtilities. + createEwsObjectFromXmlElementName(Conversation.class, + reader.getService(), reader.getLocalName()); + + if (item == null) { + reader.skipCurrentElement(); + } else { + item.loadFromXml( + reader, + true, /* clearPropertyBag */ + null, + false /* summaryPropertiesOnly */); + + conversations.add(item); + } + } + } + while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.Conversations)); + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/FindFolderResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/FindFolderResponse.java new file mode 100644 index 000000000..6823c3a30 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/FindFolderResponse.java @@ -0,0 +1,120 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.service.folder.Folder; +import com.eischet.ews.api.search.FindFoldersResults; +import com.eischet.ews.api.security.XmlNodeType; + +/** + * Represents the response to a folder search operation. + */ +public final class FindFolderResponse extends ServiceResponse { + + /** + * The results. + */ + private final FindFoldersResults results = new FindFoldersResults(); + + /** + * The property set. + */ + private final PropertySet propertySet; + + /** + * Reads response elements from XML. + * + * @param reader The reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.RootFolder); + + this.results.setTotalCount(reader.readAttributeValue(Integer.class, + XmlAttributeNames.TotalItemsInView)); + this.results.setMoreAvailable(!reader.readAttributeValue(Boolean.class, + XmlAttributeNames.IncludesLastItemInRange)); + + // Ignore IndexedPagingOffset attribute if MoreAvailable is false. + this.results.setNextPageOffset(results.isMoreAvailable() ? reader + .readNullableAttributeValue(Integer.class, + XmlAttributeNames.IndexedPagingOffset) : null); + + reader.readStartElement(XmlNamespace.Types, XmlElementNames.Folders); + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) { + Folder folder = EwsUtilities + .createEwsObjectFromXmlElementName(Folder.class, reader.getService(), reader.getLocalName()); + + if (folder == null) { + reader.skipCurrentElement(); + } else { + folder.loadFromXml(reader, true, /* clearPropertyBag */ + this.propertySet, true /* summaryPropertiesOnly */); + + this.results.getFolders().add(folder); + } + } + } while (!reader.isEndElement(XmlNamespace.Types, + XmlElementNames.Folders)); + } else { + reader.read(); + } + + reader + .readEndElement(XmlNamespace.Messages, + XmlElementNames.RootFolder); + } + + /** + * Initializes a new instance of the FindFolderResponse class. + * + * @param propertySet The property set from, the request. + */ + public FindFolderResponse(PropertySet propertySet) { + super(); + this.propertySet = propertySet; + + EwsUtilities.ewsAssert(this.propertySet != null, "FindFolderResponse.ctor", + "PropertySet should not be null"); + } + + /** + * Gets the results of the search operation. + * + * @return the results + */ + public FindFoldersResults getResults() { + return this.results; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/FindItemResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/FindItemResponse.java new file mode 100644 index 000000000..4b6a63e9f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/FindItemResponse.java @@ -0,0 +1,214 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.search.FindItemsResults; +import com.eischet.ews.api.search.GroupedFindItemsResults; +import com.eischet.ews.api.search.ItemGroup; +import com.eischet.ews.api.security.XmlNodeType; + +import javax.xml.stream.XMLStreamException; +import java.util.ArrayList; +import java.util.List; + +/** + * Represents the response to a item search operation. + * + * @param The type of item that the opeartion returned. + */ +public final class FindItemResponse + extends ServiceResponse { + + /** + * The results. + */ + private FindItemsResults results; + + /** + * The is grouped. + */ + private final boolean isGrouped; + + /** + * The grouped find results. + */ + private GroupedFindItemsResults groupedFindResults; + + /** + * The property set. + */ + private final PropertySet propertySet; + + /** + * Initializes a new instance of the FindItemResponse class. + * + * @param isGrouped if set to true if grouped. + * @param propertySet The property Set + */ + public FindItemResponse(boolean isGrouped, PropertySet propertySet) { + super(); + this.isGrouped = isGrouped; + this.propertySet = propertySet; + + EwsUtilities + .ewsAssert(this.propertySet != null, "FindItemResponse.ctor", "PropertySet should not be null"); + } + + /** + * Reads response elements from XML. + * + * @param reader ,The reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.RootFolder); + + int totalItemsInView = reader.readAttributeValue(Integer.class, + XmlAttributeNames.TotalItemsInView); + boolean moreItemsAvailable = !reader.readAttributeValue(Boolean.class, + XmlAttributeNames.IncludesLastItemInRange); + + // Ignore IndexedPagingOffset attribute if moreItemsAvailable is false. + Integer nextPageOffset = moreItemsAvailable ? reader + .readNullableAttributeValue(Integer.class, + XmlAttributeNames.IndexedPagingOffset) : null; + + if (!this.isGrouped) { + this.results = new FindItemsResults<>(); + this.results.setTotalCount(totalItemsInView); + this.results.setNextPageOffset(nextPageOffset); + this.results.setMoreAvailable(moreItemsAvailable); + internalReadItemsFromXml(reader, this.propertySet, this.results + .getItems()); + } else { + this.groupedFindResults = new GroupedFindItemsResults<>(); + this.groupedFindResults.setTotalCount(totalItemsInView); + this.groupedFindResults.setNextPageOffset(nextPageOffset); + this.groupedFindResults.setMoreAvailable(moreItemsAvailable); + + reader.readStartElement(XmlNamespace.Types, XmlElementNames.Groups); + + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.isStartElement(XmlNamespace.Types, + XmlElementNames.GroupedItems)) { + String groupIndex = reader.readElementValue( + XmlNamespace.Types, XmlElementNames.GroupIndex); + + ArrayList itemList = new ArrayList<>(); + internalReadItemsFromXml(reader, this.propertySet, + itemList); + + reader.readEndElement(XmlNamespace.Types, + XmlElementNames.GroupedItems); + + this.groupedFindResults.getItemGroups().add( + new ItemGroup<>(groupIndex, itemList)); + } + } while (!reader.isEndElement(XmlNamespace.Types, + XmlElementNames.Groups)); + } else { + reader.read(); + } + } + + reader + .readEndElement(XmlNamespace.Messages, + XmlElementNames.RootFolder); + } + + /** + * Read item from XML. + * + * @param reader the reader + * @param propertySet the property set + * @param destinationList the list in which to add the read item + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlDeserializationException the service xml deserialization exception + * @throws Exception the exception + */ + private void internalReadItemsFromXml(EwsServiceXmlReader reader, + PropertySet propertySet, List destinationList) + throws XMLStreamException, ServiceXmlDeserializationException, + Exception { + EwsUtilities.ewsAssert(destinationList != null, "FindItemResponse.InternalReadItemsFromXml", + "destinationList is null."); + + reader.readStartElement(XmlNamespace.Types, XmlElementNames.Items); + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) { + Item item = EwsUtilities.createEwsObjectFromXmlElementName( + Item.class, reader.getService(), reader + .getLocalName()); + + if (item == null) { + reader.skipCurrentElement(); + } else { + item.loadFromXml(reader, true, /* clearPropertyBag */ + propertySet, true /* summaryPropertiesOnly */); + + destinationList.add((TItem) item); + } + } + } while (!reader.isEndElement(XmlNamespace.Types, + XmlElementNames.Items)); + } else { + reader.read(); + } + + } + + /** + * Gets a grouped list of item matching the specified search criteria that + * were found in Exchange. ItemGroups is null if the search operation did + * not specify grouping options. + * + * @return the grouped find results + */ + public GroupedFindItemsResults getGroupedFindResults() { + return groupedFindResults; + } + + /** + * Gets the results of the search operation. + * + * @return the results + */ + public FindItemsResults getResults() { + return results; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetAttachmentResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetAttachmentResponse.java new file mode 100644 index 000000000..6f975042d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetAttachmentResponse.java @@ -0,0 +1,90 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.property.complex.Attachment; +import com.eischet.ews.api.security.XmlNodeType; + +/** + * Represents the response to an individual attachment retrieval request. + */ +public final class GetAttachmentResponse extends ServiceResponse { + + /** + * The attachment. + */ + private final Attachment attachment; + + /** + * Initializes a new instance of the GetAttachmentResponse class. + * + * @param attachment the attachment + */ + public GetAttachmentResponse(Attachment attachment) { + super(); + EwsUtilities.ewsAssert(attachment != null, "GetAttachmentResponse.ctor", "attachment is null"); + + this.attachment = attachment; + } + + /** + * Reads response elements from XML. + * + * @param reader The reader. + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + super.readElementsFromXml(reader); + + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.Attachments); + if (!reader.isEmptyElement()) { + XmlNodeType x = new XmlNodeType(XmlNodeType.START_ELEMENT); + reader.read(x); + + this.attachment.loadFromXml(reader, reader.getLocalName()); + + reader.readEndElement(XmlNamespace.Messages, + XmlElementNames.Attachments); + } else { + reader.read(); + } + } + + /** + * Gets the attachment that was retrieved. + * + * @return the attachment + */ + protected Attachment getAttachment() { + return this.attachment; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetDelegateResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetDelegateResponse.java new file mode 100644 index 000000000..7b196cc44 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetDelegateResponse.java @@ -0,0 +1,87 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.misc.error.ServiceError; +import com.eischet.ews.api.core.enumeration.service.MeetingRequestsDeliveryScope; + +/** + * The Class GetDelegateResponse. + */ +public final class GetDelegateResponse extends DelegateManagementResponse { + + /** + * Represents the response to a delegate user retrieval operation. + */ + private MeetingRequestsDeliveryScope meetingRequestsDeliveryScope = + MeetingRequestsDeliveryScope.NoForward; + + /** + * Initializes a new instance of the class. + * + * @param readDelegateUsers the read delegate users + */ + public GetDelegateResponse(boolean readDelegateUsers) { + super(readDelegateUsers, null); + } + + /** + * Reads response elements from XML + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + super.readElementsFromXml(reader); + + if (this.getErrorCode() == ServiceError.NoError) { + // This is a hack. If there were no response messages, the reader + // will already be on the + // DeliverMeetingRequests start element, so we don't need to read + // it. + if (this.getDelegateUserResponses().size() > 0) { + reader.read(); + } + if (reader.isStartElement(XmlNamespace.Messages, XmlElementNames.DeliverMeetingRequests)) { + this.meetingRequestsDeliveryScope = reader + .readElementValue(MeetingRequestsDeliveryScope.class); + } + } + } + + /** + * Gets a value indicating if and how meeting request are delivered to + * delegates. + * + * @return the meeting request delivery scope + */ + public MeetingRequestsDeliveryScope getMeetingRequestsDeliveryScope() { + return this.meetingRequestsDeliveryScope; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetEventsResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetEventsResponse.java new file mode 100644 index 000000000..ec97bb452 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetEventsResponse.java @@ -0,0 +1,67 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.notification.GetEventsResults; + +/** + * Represents the response to a subscription event retrieval operation. + */ +public final class GetEventsResponse extends ServiceResponse { + + /** + * The results. + */ + private final GetEventsResults results = new GetEventsResults(); + + /** + * Initializes a new instance. + */ + public GetEventsResponse() { + super(); + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + super.readElementsFromXml(reader); + this.results.loadFromXml(reader); + } + + /** + * gets the results. + * + * @return the results. + */ + public GetEventsResults getResults() { + return results; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetFolderResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetFolderResponse.java new file mode 100644 index 000000000..c3c53c956 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetFolderResponse.java @@ -0,0 +1,118 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.folder.Folder; + +import java.util.List; + +/** + * Represents the response to an individual folder retrieval operation. + */ +public final class GetFolderResponse extends ServiceResponse implements + IGetObjectInstanceDelegate { + + /** + * The folder. + */ + private Folder folder; + + /** + * The property set. + */ + private final PropertySet propertySet; + + /** + * Initializes a new instance of the GetFolderResponse class. + * + * @param folder The folder. + * @param propertySet The property set from the request. + */ + public GetFolderResponse(Folder folder, PropertySet propertySet) { + super(); + this.folder = folder; + this.propertySet = propertySet; + EwsUtilities + .ewsAssert(this.propertySet != null, "GetFolderResponse.ctor", "PropertySet should not be null"); + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + super.readElementsFromXml(reader); + List folders = reader.readServiceObjectsCollectionFromXml( + XmlElementNames.Folders, this, true, /* clearPropertyBag */ + this.propertySet, /* requestedPropertySet */ + false); /* summaryPropertiesOnly */ + this.folder = folders.get(0); + } + + /** + * Gets the object instance delegate. + * + * @param service the service + * @param xmlElementName the xml element name + * @return the object instance delegate + */ + @Override + public ServiceObject getObjectInstanceDelegate(ExchangeService service, String xmlElementName) throws ExchangeXmlException { + return this.getObjectInstance(service, xmlElementName); + } + + /** + * Gets the folder instance. + * + * @param service The service. + * @param xmlElementName Name of the XML element. + * @return folder + */ + private Folder getObjectInstance(ExchangeService service, + String xmlElementName) throws ExchangeXmlException { + if (this.getFolder() != null) { + return this.getFolder(); + } else { + return EwsUtilities.createEwsObjectFromXmlElementName(Folder.class, + service, xmlElementName); + } + } + + /** + * Gets the folder that was retrieved. + * + * @return folder + */ + public Folder getFolder() { + return this.folder; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetInboxRulesResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetInboxRulesResponse.java new file mode 100644 index 000000000..ccceefc9d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetInboxRulesResponse.java @@ -0,0 +1,76 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.property.complex.RuleCollection; + +/** + * Represents the response to a GetInboxRules operation. + */ +public final class GetInboxRulesResponse extends ServiceResponse { + /** + * Rule collection. + */ + private final RuleCollection ruleCollection; + + /** + * Initializes a new instance of the {@link GetInboxRulesResponse} class. + */ + public GetInboxRulesResponse() { + super(); + this.ruleCollection = new RuleCollection(); + } + + /** + * Reads response elements from XML. + * + * @param reader The reader. + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + reader.read(); + this.ruleCollection.setOutlookRuleBlobExists(reader. + readElementValue(Boolean.class, + XmlNamespace.Messages, + XmlElementNames.OutlookRuleBlobExists)); + reader.read(); + if (reader.isStartElement(XmlNamespace.NotSpecified, XmlElementNames.InboxRules)) { + this.ruleCollection.loadFromXml(reader, + XmlNamespace.NotSpecified, + XmlElementNames.InboxRules); + } + } + + /** + * Gets the rule collection in the response. + */ + public RuleCollection getRules() { + return this.ruleCollection; + } +} + diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetItemResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetItemResponse.java new file mode 100644 index 000000000..7ae466565 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetItemResponse.java @@ -0,0 +1,119 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Item; + +import java.util.List; + +/** + * Represents a response to an individual item retrieval operation. + */ +public final class GetItemResponse extends ServiceResponse implements + IGetObjectInstanceDelegate { + + /** + * The item. + */ + private Item item; + + /** + * The property set. + */ + private final PropertySet propertySet; + + /** + * Initializes a new instance of the class. + * + * @param item the item + * @param propertySet the property set + */ + public GetItemResponse(Item item, PropertySet propertySet) { + super(); + this.item = item; + this.propertySet = propertySet; + EwsUtilities.ewsAssert(this.propertySet != null, "GetItemResponse.ctor", "PropertySet should not be null"); + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws InstantiationException the instantiation exception + * @throws IllegalAccessException the illegal access exception + * @throws Exception the exception + */ + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws InstantiationException, IllegalAccessException, Exception { + super.readElementsFromXml(reader); + + List items = reader.readServiceObjectsCollectionFromXml( + XmlElementNames.Items, this, + true, /* clearPropertyBag */ + this.propertySet, /* requestedPropertySet */ + false); /* summaryPropertiesOnly */ + + this.item = items.get(0); + } + + /** + * Gets Item instance. + * + * @param service the service + * @param xmlElementName the xml element name + * @return Item + */ + private Item getObjectInstance(ExchangeService service, String xmlElementName) throws ExchangeXmlException { + if (this.getItem() != null) { + return this.getItem(); + } else { + return EwsUtilities.createEwsObjectFromXmlElementName(Item.class, service, xmlElementName); + + } + } + + /** + * Gets the item that was retrieved. + * + * @return the item + */ + public Item getItem() { + return this.item; + } + + /** + * Gets the object instance delegate. + * + * @param service accepts ExchangeService + * @param xmlElementName accepts String + * @return Name + */ + @Override + public ServiceObject getObjectInstanceDelegate(ExchangeService service, String xmlElementName) throws ExchangeXmlException { + return getObjectInstance(service, xmlElementName); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetPasswordExpirationDateResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetPasswordExpirationDateResponse.java new file mode 100644 index 000000000..dd64b79ac --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetPasswordExpirationDateResponse.java @@ -0,0 +1,63 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; + +import java.time.LocalDateTime; + +public class GetPasswordExpirationDateResponse extends ServiceResponse { + private LocalDateTime passwordExpirationDate; + + /** + * Initializes a new instance of the GetPasswordExpirationDateResponse class. + */ + public GetPasswordExpirationDateResponse() { + super(); + } + + /** + * Reads response elements from XML + * + * @param reader The Reader + */ + protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { + super.readElementsFromXml(reader); + this.passwordExpirationDate = reader.readElementValueAsDateTime( + XmlNamespace.NotSpecified, + XmlElementNames.PasswordExpirationDate); + + } + + /** + * Get password expiration date. + * + * @return Password expiration date. + */ + public LocalDateTime getPasswordExpirationDate() { + return this.passwordExpirationDate; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetPhoneCallResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetPhoneCallResponse.java new file mode 100644 index 000000000..2d60e28ed --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetPhoneCallResponse.java @@ -0,0 +1,81 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.messaging.PhoneCall; + +/** + * Represents the response to a GetPhoneCall operation. + */ +public final class GetPhoneCallResponse extends ServiceResponse { + + /** + * The phone call. + */ + private final PhoneCall phoneCall; + + /** + * Initializes a new instance of the GetPhoneCallResponse class. + * + * @param service the service + */ + public GetPhoneCallResponse(ExchangeService service) { + super(); + EwsUtilities.ewsAssert(service != null, "GetPhoneCallResponse.ctor", "service is null"); + + this.phoneCall = new PhoneCall(service); + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.PhoneCallInformation); + this.phoneCall.loadFromXml(reader, XmlNamespace.Messages, + XmlElementNames.PhoneCallInformation); + reader.readEndElementIfNecessary(XmlNamespace.Messages, + XmlElementNames.PhoneCallInformation); + } + + /** + * Gets the phone call. + * + * @return the phone call + */ + public PhoneCall getPhoneCall() { + return phoneCall; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetRoomListsResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetRoomListsResponse.java new file mode 100644 index 000000000..03782a4cd --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetRoomListsResponse.java @@ -0,0 +1,93 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.property.complex.EmailAddress; +import com.eischet.ews.api.property.complex.EmailAddressCollection; + +/** + * Represents the response to a GetRoomLists operation. + */ +public final class GetRoomListsResponse extends ServiceResponse { + + /** + * The room lists. + */ + private final EmailAddressCollection roomLists = new EmailAddressCollection(); + + /** + * Represents the response to a GetRoomLists operation. + */ + public GetRoomListsResponse() { + super(); + } + + /** + * Gets all room list returned. + * + * @return the room lists + */ + public EmailAddressCollection getRoomLists() { + return this.roomLists; + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + this.roomLists.clear(); + super.readElementsFromXml(reader); + + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.RoomLists); + + if (!reader.isEmptyElement()) { + // Because we don't have an element for count of returned object, + // we have to test the element to determine if it is return object + // or EndElement + reader.read(); + while (reader.isStartElement(XmlNamespace.Types, + XmlElementNames.Address)) { + EmailAddress emailAddress = new EmailAddress(); + emailAddress.loadFromXml(reader, XmlElementNames.Address); + this.roomLists.add(emailAddress); + reader.read(); + } + reader.ensureCurrentNodeIsEndElement(XmlNamespace.Messages, + XmlElementNames.RoomLists); + } else { + reader.read(); + } + return; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetRoomsResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetRoomsResponse.java new file mode 100644 index 000000000..cc75d0018 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetRoomsResponse.java @@ -0,0 +1,97 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.property.complex.EmailAddress; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * Represents the response to a GetRooms operation. + */ +public final class GetRoomsResponse extends ServiceResponse { + + /** + * The rooms. + */ + private final Collection rooms = new ArrayList(); + + /** + * Initializes a new instance of the class. + */ + public GetRoomsResponse() { + super(); + } + + /** + * Gets collection for all rooms returned. + * + * @return the rooms + */ + public Collection getRooms() { + return this.rooms; + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + this.rooms.clear(); + super.readElementsFromXml(reader); + + reader.readStartElement(XmlNamespace.Messages, XmlElementNames.Rooms); + + if (!reader.isEmptyElement()) { + // Because we don't have an element for count of returned object, + // we have to test the element to determine if it is StartElement of + // return object or EndElement + reader.read(); + while (reader.isStartElement(XmlNamespace.Types, + XmlElementNames.Room)) { + reader.read(); // skip the start + + EmailAddress emailAddress = new EmailAddress(); + emailAddress.loadFromXml(reader, XmlElementNames.RoomId); + this.rooms.add(emailAddress); + + reader.readEndElement(XmlNamespace.Types, XmlElementNames.Room); + reader.read(); + } + + reader.ensureCurrentNodeIsEndElement(XmlNamespace.Messages, + XmlElementNames.Rooms); + } else { + reader.read(); + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetServerTimeZonesResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetServerTimeZonesResponse.java new file mode 100644 index 000000000..f72c77f8f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetServerTimeZonesResponse.java @@ -0,0 +1,93 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.property.complex.time.TimeZoneDefinition; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * Represents the response to a GetServerTimeZones request. + */ +public class GetServerTimeZonesResponse extends ServiceResponse { + + /** + * The time zones. + */ + private final Collection timeZones = + new ArrayList(); + + /** + * Initializes a new instance of the class. + */ + public GetServerTimeZonesResponse() { + super(); + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { + super.readElementsFromXml(reader); + + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.TimeZoneDefinitions); + + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.isStartElement(XmlNamespace.Types, + XmlElementNames.TimeZoneDefinition)) { + TimeZoneDefinition timeZoneDefinition = + new TimeZoneDefinition(); + timeZoneDefinition.loadFromXml(reader); + + this.timeZones.add(timeZoneDefinition); + } + } while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.TimeZoneDefinitions)); + } else { + reader.read(); + } + } + + /** + * Reads response elements from XML. + * + * @return the time zones + */ + public Collection getTimeZones() { + return this.timeZones; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetStreamingEventsResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetStreamingEventsResponse.java new file mode 100644 index 000000000..2d6f400fd --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetStreamingEventsResponse.java @@ -0,0 +1,154 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.HangingRequestDisconnectReason; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.request.HangingServiceRequestBase; +import com.eischet.ews.api.notification.GetStreamingEventsResults; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents the response to a subscription event retrieval operation. + */ +public final class GetStreamingEventsResponse extends ServiceResponse { + + private final GetStreamingEventsResults results = new GetStreamingEventsResults(); + private final HangingServiceRequestBase request; + + + /** + * Enumeration of ConnectionStatus that can be returned by the server. + */ + private enum ConnectionStatus { + /** + * Simple heartbeat + */ + OK, + + /** + * Server is closing the connection. + */ + Closed + } + + /** + * Initializes a new instance of the GetStreamingEventsResponse class. + * + * @param request The request + * Request to disconnect when we get a close message. + */ + public GetStreamingEventsResponse(HangingServiceRequestBase request) { + super(); + List string = new ArrayList(); + this.setErrorSubscriptionIds(string); + this.request = request; + } + + /** + * Reads response elements from XML. + * + * @throws Exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + super.readElementsFromXml(reader); + + reader.read(); + + if (reader.getLocalName().equals(XmlElementNames.Notifications)) { + this.results.loadFromXml(reader); + } else if (reader.getLocalName().equals(XmlElementNames.ConnectionStatus)) { + String connectionStatus = reader.readElementValue(XmlNamespace. + Messages, XmlElementNames.ConnectionStatus); + + if (connectionStatus.equals(ConnectionStatus.Closed.toString())) { + this.request.disconnect( + HangingRequestDisconnectReason.Clean, null); + } + } + } + + /** + * Loads extra error details from XML + * + * @throws Exception + */ + @Override + protected boolean loadExtraErrorDetailsFromXml(EwsServiceXmlReader reader, + String xmlElementName) throws Exception { + boolean baseReturnVal = super. + loadExtraErrorDetailsFromXml(reader, xmlElementName); + + if (reader.isStartElement(XmlNamespace.Messages, XmlElementNames.ErrorSubscriptionIds)) { + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT && + reader.getLocalName().equals(XmlElementNames.SubscriptionId)) { + this.getErrorSubscriptionIds().add( + reader.readElementValue(XmlNamespace.Messages, + XmlElementNames.SubscriptionId)); + } + } + while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.ErrorSubscriptionIds)); + + return true; + } else { + return baseReturnVal; + } + } + + /** + * Gets event results from subscription. + */ + public GetStreamingEventsResults getResults() { + return this.results; + } + + private List errorSubscriptionIds; + + /** + * Gets the error subscription ids. + */ + public List getErrorSubscriptionIds() { + return this.errorSubscriptionIds; + } + + /** + * Sets the error subscription ids. + */ + private void setErrorSubscriptionIds(List value) { + this.errorSubscriptionIds = value; + } + + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetUserConfigurationResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetUserConfigurationResponse.java new file mode 100644 index 000000000..c1478795b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetUserConfigurationResponse.java @@ -0,0 +1,73 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.misc.UserConfiguration; + +/** + * Represents a response to a GetUserConfiguration request. + */ +public final class GetUserConfigurationResponse extends ServiceResponse { + + /** + * The user configuration. + */ + private final UserConfiguration userConfiguration; + + /** + * Initializes a new instance of the class. + * + * @param userConfiguration the user configuration + */ + public GetUserConfigurationResponse(UserConfiguration userConfiguration) { + super(); + EwsUtilities.ewsAssert(userConfiguration != null, "GetUserConfigurationResponse.ctor", + "userConfiguration is null"); + + this.userConfiguration = userConfiguration; + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { + super.readElementsFromXml(reader); + this.userConfiguration.loadFromXml(reader); + } + + /** + * Gets the user configuration that was created. + * + * @return the user configuration + */ + public UserConfiguration getUserConfiguration() { + return this.userConfiguration; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/GetUserOofSettingsResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetUserOofSettingsResponse.java new file mode 100644 index 000000000..7b2b3398b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/GetUserOofSettingsResponse.java @@ -0,0 +1,63 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.property.complex.availability.OofSettings; + +/** + * Represents response to GetUserOofSettings request. + */ +public class GetUserOofSettingsResponse extends ServiceResponse { + + /** + * The oof settings. + */ + private OofSettings oofSettings; + + /** + * Initializes a new instance of the class. + */ + public GetUserOofSettingsResponse() { + super(); + } + + /** + * Gets the OOF settings. + * + * @return the oof settings + */ + public OofSettings getOofSettings() { + return this.oofSettings; + } + + /** + * Sets the oof settings. + * + * @param value the new oof settings + */ + public void setOofSettings(OofSettings value) { + this.oofSettings = value; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/IGetObjectInstanceDelegate.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/IGetObjectInstanceDelegate.java new file mode 100644 index 000000000..2e9ab2cc7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/IGetObjectInstanceDelegate.java @@ -0,0 +1,46 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; + +/** + * The Interface GetObjectInstanceDelegateInterface. + * + * @param the generic type + */ +@FunctionalInterface +public interface IGetObjectInstanceDelegate { + + /** + * Gets the object instance delegate. + * + * @param service the service + * @param xmlElementName the xml element name + * @return the object instance delegate + */ + T getObjectInstanceDelegate(ExchangeService service, String xmlElementName) throws ExchangeXmlException; +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/MoveCopyFolderResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/MoveCopyFolderResponse.java new file mode 100644 index 000000000..0270cd218 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/MoveCopyFolderResponse.java @@ -0,0 +1,111 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.folder.Folder; + +import java.util.List; +import java.util.logging.Logger; + +/** + * Represents the base response class for individual folder move and copy + * operations. + */ +public final class MoveCopyFolderResponse extends ServiceResponse implements IGetObjectInstanceDelegate { + + private static final Logger LOG = Logger.getLogger(MoveCopyFolderResponse.class.getCanonicalName()); + + /** + * The folder. + */ + private Folder folder; + + /** + * Initializes a new instance of the MoveCopyFolderResponse class. + */ + public MoveCopyFolderResponse() { + super(); + } + + /** + * Gets Folder instance. + * + * @param service The service. + * @param xmlElementName Name of the XML element. + * @return folder + * @throws Exception the exception + */ + private Folder getObjectInstance(ExchangeService service, String xmlElementName) throws ExchangeXmlException { + return EwsUtilities.createEwsObjectFromXmlElementName(Folder.class, service, xmlElementName); + } + + /** + * Reads response elements from XML. + * + * @param reader The reader. + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { + super.readElementsFromXml(reader); + + List folders; + folders = reader.readServiceObjectsCollectionFromXml( + + XmlElementNames.Folders, this, false,/* clearPropertyBag */ + null, /* requestedPropertySet */ + false); /* summaryPropertiesOnly */ + + this.folder = folders.get(0); + + } + + /** + * Gets the new (moved or copied) folder. + * + * @return the folder + */ + public Folder getFolder() { + return folder; + } + + /** + * Gets the object instance delegate. + * + * @param service accepts ExchangeService + * @param xmlElementName accepts String + * @return Object + */ + @Override + public ServiceObject getObjectInstanceDelegate(ExchangeService service, String xmlElementName) throws ExchangeXmlException { + return this.getObjectInstance(service, xmlElementName); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/MoveCopyItemResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/MoveCopyItemResponse.java new file mode 100644 index 000000000..d8373339b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/MoveCopyItemResponse.java @@ -0,0 +1,115 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Item; + +import java.util.List; + +/** + * Represents a response to a Move or Copy operation. + */ +public final class MoveCopyItemResponse extends ServiceResponse implements + IGetObjectInstanceDelegate { + + /** + * The item. + */ + private Item item; + + /** + * Represents a response to a Move or Copy operation. + */ + public MoveCopyItemResponse() { + super(); + } + + /** + * Gets Item instance. + * + * @param service the service + * @param xmlElementName the xml element name + * @return the object instance + */ + private Item getObjectInstance(ExchangeService service, + String xmlElementName) throws ExchangeXmlException { + return EwsUtilities.createEwsObjectFromXmlElementName(Item.class, service, xmlElementName); + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + super.readElementsFromXml(reader); + List items = reader.readServiceObjectsCollectionFromXml( + XmlElementNames.Items, this, false, /* clearPropertyBag */ + null, /* requestedPropertySet */ + false); /* summaryPropertiesOnly */ + + // We only receive the copied or moved item if the copy or move + // operation was within + // a single mailbox. No item is returned if the operation is + // cross-mailbox, from a + // mailbox to a public folder or from a public folder to a mailbox. + if (!items.isEmpty()) { + this.item = items.get(0); + } + } + + /** + * Gets the object instance delegate. + * + * @param service the service + * @param xmlElementName the xml element name + * @return the object instance delegate + */ + @Override + public ServiceObject getObjectInstanceDelegate(ExchangeService service, + String xmlElementName) throws ExchangeXmlException { + return this.getObjectInstance(service, xmlElementName); + } + + /** + * Gets the copied or moved item. Item is null if the copy or move + * operation was between two mailboxes or between a mailbox and a public + * folder. + * + * @return the item + */ + public Item getItem() { + return this.item; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/PlayOnPhoneResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/PlayOnPhoneResponse.java new file mode 100644 index 000000000..7b5154257 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/PlayOnPhoneResponse.java @@ -0,0 +1,81 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.messaging.PhoneCallId; + +/** + * Represents the response to a PlayOnPhone operation. + */ +public final class PlayOnPhoneResponse extends ServiceResponse { + + /** + * The phone call id. + */ + private final PhoneCallId phoneCallId; + + /** + * Initializes a new instance of the PlayOnPhoneResponse class. + * + * @param service the service + */ + public PlayOnPhoneResponse(ExchangeService service) { + super(); + EwsUtilities.ewsAssert(service != null, "PlayOnPhoneResponse.ctor", "service is null"); + + this.phoneCallId = new PhoneCallId(); + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.PhoneCallId); + this.phoneCallId.loadFromXml(reader, XmlNamespace.Messages, + XmlElementNames.PhoneCallId); + reader.readEndElementIfNecessary(XmlNamespace.Messages, + XmlElementNames.PhoneCallId); + } + + /** + * Gets the Id of the phone call. + * + * @return the phone call id + */ + public PhoneCallId getPhoneCallId() { + return phoneCallId; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/ResolveNamesResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/ResolveNamesResponse.java new file mode 100644 index 000000000..d1436b792 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/ResolveNamesResponse.java @@ -0,0 +1,90 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.misc.error.ServiceError; +import com.eischet.ews.api.core.exception.service.remote.ServiceResponseException; +import com.eischet.ews.api.misc.NameResolutionCollection; + +/** + * Represents the response to a name resolution operation. + */ +public final class ResolveNamesResponse extends ServiceResponse { + + /** + * The resolutions. + */ + private final NameResolutionCollection resolutions; + + /** + * Initializes a new instance of the class. + * + * @param service the service + */ + public ResolveNamesResponse(ExchangeService service) { + super(); + EwsUtilities.ewsAssert(service != null, "ResolveNamesResponse.ctor", "service is null"); + + this.resolutions = new NameResolutionCollection(service); + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + super.readElementsFromXml(reader); + this.resolutions.loadFromXml(reader); + } + + /** + * Override base implementation so that API does not throw when name + * resolution fails to find a match. EWS returns an error in this case but + * the API will just return an empty NameResolutionCollection. + * + * @throws ServiceResponseException the service response exception + */ + @Override + protected void internalThrowIfNecessary() throws ServiceResponseException { + if (this.getErrorCode() != ServiceError.ErrorNameResolutionNoResults) { + super.internalThrowIfNecessary(); + } + } + + /** + * Gets a list of name resolution suggestions. + * + * @return the resolutions + */ + public NameResolutionCollection getResolutions() { + return this.resolutions; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/ServiceResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/ServiceResponse.java new file mode 100644 index 000000000..fbcb6d72a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/ServiceResponse.java @@ -0,0 +1,357 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.misc.error.ServiceError; +import com.eischet.ews.api.core.enumeration.service.ServiceResult; +import com.eischet.ews.api.core.exception.service.remote.ServiceResponseException; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.misc.SoapFaultDetails; +import com.eischet.ews.api.property.definition.ExtendedPropertyDefinition; +import com.eischet.ews.api.property.definition.IndexedPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinitionBase; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +/** + * Represents the standard response to an Exchange Web Services operation. + */ +public class ServiceResponse { + + /** + * The result. + */ + private ServiceResult result; + + /** + * The error code. + */ + private ServiceError errorCode; + + /** + * The error message. + */ + private String errorMessage; + + /** + * The error details. + */ + private Map errorDetails = new HashMap(); + + /** + * The error property. + */ + private final Collection errorProperties = + new ArrayList(); + + /** + * Initializes a new instance. + */ + public ServiceResponse() { + } + + /** + * Initializes a new instance. + * + * @param soapFaultDetails The SOAP fault details. + */ + public ServiceResponse(SoapFaultDetails soapFaultDetails) { + this.result = ServiceResult.Error; + this.errorCode = soapFaultDetails.getResponseCode(); + this.errorMessage = soapFaultDetails.getFaultString(); + this.errorDetails = soapFaultDetails.getErrorDetails(); + } + + /** + * Loads response from XML. + * + * @param reader the reader + * @param xmlElementName the xml element name + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader, String xmlElementName) + throws Exception { + if (!reader.isStartElement(XmlNamespace.Messages, xmlElementName)) { + reader.readStartElement(XmlNamespace.Messages, xmlElementName); + } + + this.result = reader.readAttributeValue(ServiceResult.class, + XmlAttributeNames.ResponseClass); + + if (this.result == ServiceResult.Success || + this.result == ServiceResult.Warning) { + if (this.result == ServiceResult.Warning) { + this.errorMessage = reader.readElementValue( + XmlNamespace.Messages, XmlElementNames.MessageText); + } + + this.errorCode = reader.readElementValue(ServiceError.class, + XmlNamespace.Messages, XmlElementNames.ResponseCode); + + if (this.result == ServiceResult.Warning) { + reader.readElementValue(int.class, XmlNamespace.Messages, + XmlElementNames.DescriptiveLinkKey); + } + + // Bug E14:212308 -- If batch processing stopped, EWS returns an + // empty element. Skip over it. + if (this.getBatchProcessingStopped()) { + do { + reader.read(); + } while (!reader.isEndElement(XmlNamespace.Messages, + xmlElementName)); + } else { + + this.readElementsFromXml(reader); + //read end tag if it is an empty element. + if (reader.isEmptyElement()) { + reader.read(); + } + reader.readEndElementIfNecessary(XmlNamespace. + Messages, xmlElementName); + } + } else { + this.errorMessage = reader.readElementValue(XmlNamespace.Messages, + XmlElementNames.MessageText); + this.errorCode = reader.readElementValue(ServiceError.class, + XmlNamespace.Messages, XmlElementNames.ResponseCode); + reader.readElementValue(int.class, XmlNamespace.Messages, + XmlElementNames.DescriptiveLinkKey); + + while (!reader.isEndElement(XmlNamespace. + Messages, xmlElementName)) { + reader.read(); + + if (reader.isStartElement()) { + if (!this.loadExtraErrorDetailsFromXml(reader, reader.getLocalName())) { + reader.skipCurrentElement(); + } + + } + } + } + + this.mapErrorCodeToErrorMessage(); + + this.loaded(); + } + + /** + * Parses the message XML. + * + * @param reader The reader. + * @throws Exception the exception + */ + protected void parseMessageXml(EwsServiceXmlReader reader) + throws Exception { + do { + reader.read(); + if (reader.isStartElement()) { + if (reader.getLocalName().equals(XmlElementNames.Value)) { + this.errorDetails.put(reader + .readAttributeValue(XmlAttributeNames.Name), reader + .readElementValue()); + } else if (reader.getLocalName().equals( + XmlElementNames.FieldURI)) { + this.errorProperties + .add(ServiceObjectSchema + .findPropertyDefinition(reader.readAttributeValue(XmlAttributeNames. + FieldURI))); + } else if (reader.getLocalName().equals( + XmlElementNames.IndexedFieldURI)) { + this.errorProperties + .add(new IndexedPropertyDefinition( + reader + .readAttributeValue(XmlAttributeNames. + FieldURI), + reader + .readAttributeValue(XmlAttributeNames. + FieldIndex))); + } else if (reader.getLocalName().equals( + XmlElementNames.ExtendedFieldURI)) { + ExtendedPropertyDefinition extendedPropDef = + new ExtendedPropertyDefinition(); + extendedPropDef.loadFromXml(reader); + this.errorProperties.add(extendedPropDef); + } + } + } while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.MessageXml)); + } + + + /** + * Called when the response has been loaded from XML. + */ + protected void loaded() { + } + + /** + * Called after the response has been loaded from XML in order to map error + * codes to "better" error messages. + */ + protected void mapErrorCodeToErrorMessage() { + // Bug E14:69560 -- Use a better error message when an item cannot be + // updated because its changeKey is old. + if (this.getErrorCode() == ServiceError.ErrorIrresolvableConflict) { + this.setErrorMessage( + "The operation can't be performed because the item is out of date. Reload the item and try again."); + } + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { + } + + /** + * Loads extra error details from XML + * + * @param reader The reader. + * @param xmlElementName The current element name of the extra error details. + * @return True if the expected extra details is loaded; + * False if the element name does not match the expected element. + */ + protected boolean loadExtraErrorDetailsFromXml(EwsServiceXmlReader reader, + String xmlElementName) throws Exception { + if (reader.isStartElement(XmlNamespace.Messages, XmlElementNames.MessageXml) && + !reader.isEmptyElement()) { + this.parseMessageXml(reader); + + return true; + } else { + return false; + } + } + + /** + * Throws a ServiceResponseException if this response has its Result + * property set to Error. + * + * @throws ServiceResponseException the service response exception + */ + public void throwIfNecessary() throws ServiceResponseException { + this.internalThrowIfNecessary(); + } + + /** + * Internal method that throws a ServiceResponseException if this response + * has its Result property set to Error. + * + * @throws ServiceResponseException the service response exception + */ + protected void internalThrowIfNecessary() throws ServiceResponseException { + if (this.result == ServiceResult.Error) { + throw new ServiceResponseException(this); + } + } + + /** + * Gets a value indicating whether a batch request stopped processing before + * the end. + * + * @return A value indicating whether a batch request stopped processing + * before the end. + */ + protected boolean getBatchProcessingStopped() { + return (this.result == ServiceResult.Warning) + && (this.errorCode == ServiceError.ErrorBatchProcessingStopped); + } + + /** + * Gets the result associated with this response. + * + * @return The result associated with this response. + */ + public ServiceResult getResult() { + return result; + } + + /** + * Gets the error code associated with this response. + * + * @return The error code associated with this response. + */ + public ServiceError getErrorCode() { + return errorCode; + } + + /** + * Gets a detailed error message associated with the response. If Result + * is set to Success, ErrorMessage returns null. ErrorMessage is localized + * according to the PreferredCulture property of the ExchangeService object + * that was used to call the method that generated the response. + * + * @return the error message + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Sets a detailed error message associated with the response. + * + * @param errorMessage The error message associated with the response. + */ + protected void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * Gets error details associated with the response. If Result is set to + * Success, ErrorDetailsDictionary returns null. Error details will only + * available for some error codes. For example, when error code is + * ErrorRecurrenceHasNoOccurrence, the ErrorDetailsDictionary will contain + * keys for EffectiveStartDate and EffectiveEndDate. + * + * @return The error details dictionary. + */ + public Map getErrorDetails() { + return errorDetails; + } + + /** + * Gets information about property errors associated with the response. If + * Result is set to Success, ErrorProperties returns null. ErrorProperties + * is only available for some error codes. For example, when the error code + * is ErrorInvalidPropertyForOperation, ErrorProperties will contain the + * definition of the property that was invalid for the request. + * + * @return the error property + */ + public Collection getErrorProperties() { + return this.errorProperties; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/ServiceResponseCollection.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/ServiceResponseCollection.java new file mode 100644 index 000000000..841a761ff --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/ServiceResponseCollection.java @@ -0,0 +1,128 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.enumeration.service.ServiceResult; + +import java.util.Enumeration; +import java.util.Iterator; +import java.util.Vector; + +/** + * Represents a strongly typed list of service response. + * + * @param The type of response stored in the list. + */ +public final class ServiceResponseCollection + implements Iterable { + + /** + * The response. + */ + private final Vector responses = new Vector(); + + /** + * The overall result. + */ + private ServiceResult overallResult = ServiceResult.Success; + + /** + * Initializes a new instance. + */ + public ServiceResponseCollection() { + + } + + /** + * Adds specified response. + * + * @param response The response. + */ + public void add(TResponse response) { + EwsUtilities.ewsAssert(response != null, "EwsResponseList.Add", "response is null"); + if (response.getResult().ordinal() > this.overallResult.ordinal()) { + this.overallResult = response.getResult(); + } + this.responses.add(response); + } + + /** + * Gets the total number of response in the list. + * + * @return total number of response in the list. + */ + public int getCount() { + return this.responses.size(); + } + + /** + * Gets the response at the specified index. + * + * @param index The zero-based index of the response to get. + * @return The response at the specified index. + * @throws IndexOutOfBoundsException the index out of bounds exception + */ + public TResponse getResponseAtIndex(int index) + throws IndexOutOfBoundsException { + if (index < 0 || index >= this.getCount()) { + throw new IndexOutOfBoundsException("Index out of Range"); + } + return this.responses.get(index); + } + + /** + * Gets a value indicating the overall result of the request that + * generated this response collection. If all of the response have their + * Result property set to Success, OverallResult returns Success. If at + * least one response has its Result property set to Warning and all other + * response have their Result property set to Success, OverallResult + * returns Warning. If at least one response has a its Result set to Error, + * OverallResult returns Error. + * + * @return the overall result + */ + public ServiceResult getOverallResult() { + return this.overallResult; + } + + /** + * Returns an iterator over a set of elements of type T. + * + * @return an Iterator. + */ + @Override + public Iterator iterator() { + return responses.iterator(); + } + + /** + * Gets the enumerator. + * + * @return the enumerator + */ + public Enumeration getEnumerator() { + return this.responses.elements(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/SubscribeResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/SubscribeResponse.java new file mode 100644 index 000000000..7728f5182 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/SubscribeResponse.java @@ -0,0 +1,74 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.notification.SubscriptionBase; + +/** + * Represents the base response class to subscription creation operations. + * + * @param Subscription type + */ +public final class SubscribeResponse extends ServiceResponse { + + /** + * The subscription. + */ + private final TSubscription subscription; + + /** + * Initializes a new instance of the SubscribeResponse<TSubscription + * class. + * + * @param subscription The Subscription + */ + public SubscribeResponse(TSubscription subscription) { + super(); + EwsUtilities.ewsAssert(subscription != null, "SubscribeResponse.ctor", "subscription is null"); + this.subscription = subscription; + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { + super.readElementsFromXml(reader); + this.subscription.loadFromXml(reader); + } + + /** + * Gets the subscription. + * + * @return the subscription + */ + public TSubscription getSubscription() { + return this.subscription; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/SuggestionsResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/SuggestionsResponse.java new file mode 100644 index 000000000..c430c8a4c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/SuggestionsResponse.java @@ -0,0 +1,85 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.property.complex.availability.Suggestion; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * Represents the base response class to subscription creation operations. + */ +public final class SuggestionsResponse extends ServiceResponse { + + /** + * The day suggestions. + */ + private final Collection daySuggestions = new ArrayList(); + + /** + * Initializes a new instance of the SuggestionsResponse class. + */ + public SuggestionsResponse() { + super(); + } + + /** + * Loads the suggested days from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + public void loadSuggestedDaysFromXml(EwsServiceXmlReader reader) + throws Exception { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.SuggestionDayResultArray); + + do { + reader.read(); + + if (reader.isStartElement(XmlNamespace.Types, + XmlElementNames.SuggestionDayResult)) { + Suggestion daySuggestion = new Suggestion(); + + daySuggestion.loadFromXml(reader, reader.getLocalName()); + + this.daySuggestions.add(daySuggestion); + } + } while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.SuggestionDayResultArray)); + } + + /** + * Gets a list of suggested days. + * + * @return the suggestions + */ + public Collection getSuggestions() { + return this.daySuggestions; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/SyncFolderHierarchyResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/SyncFolderHierarchyResponse.java new file mode 100644 index 000000000..dbda32236 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/SyncFolderHierarchyResponse.java @@ -0,0 +1,76 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.service.folder.Folder; +import com.eischet.ews.api.sync.FolderChange; + +/** + * Represents the response to a folder synchronization operation. + */ +public final class SyncFolderHierarchyResponse extends + SyncResponse { + + /** + * Represents the response to a folder synchronization operation. + * + * @param propertySet the property set + */ + public SyncFolderHierarchyResponse(PropertySet propertySet) { + super(propertySet); + } + + /** + * Gets the name of the includes last in range XML element. + * + * @return XML element name. + */ + @Override + protected String getIncludesLastInRangeXmlElementName() { + return XmlElementNames.IncludesLastFolderInRange; + } + + /** + * Creates a folder change instance. + * + * @return FolderChange instance + */ + @Override + protected FolderChange createChangeInstance() { + return new FolderChange(); + } + + /** + * Gets a value indicating whether this request returns full or summary property. + * "true" if summary property only; otherwise, "false". + * + * @return the summary property only + */ + @Override + protected boolean getSummaryPropertiesOnly() { + return false; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/SyncFolderItemsResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/SyncFolderItemsResponse.java new file mode 100644 index 000000000..0af417d62 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/SyncFolderItemsResponse.java @@ -0,0 +1,77 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.sync.ItemChange; + +/** + * Represents the response to a folder item synchronization operation. + */ +public final class SyncFolderItemsResponse extends + SyncResponse { + + /** + * Initializes a new instance of the class. + * + * @param propertySet the property set + */ + public SyncFolderItemsResponse(PropertySet propertySet) { + super(propertySet); + } + + /** + * Gets the name of the includes last in range XML element. + * + * @return XML element name. + */ + @Override + protected String getIncludesLastInRangeXmlElementName() { + return XmlElementNames.IncludesLastItemInRange; + } + + /** + * Creates an item change instance. + * + * @return ItemChange instance + */ + @Override + protected ItemChange createChangeInstance() { + return new ItemChange(); + } + + /** + * Gets a value indicating whether this request returns full or summary property. + * "true" if summary property only; otherwise, "false". + * + * @return the summary property only + */ + @Override + protected boolean getSummaryPropertiesOnly() { + return true; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/SyncResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/SyncResponse.java new file mode 100644 index 000000000..729c7cfaf --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/SyncResponse.java @@ -0,0 +1,193 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.sync.ChangeType; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.sync.Change; +import com.eischet.ews.api.sync.ChangeCollection; +import com.eischet.ews.api.sync.ItemChange; + +/** + * Represents the base response class for synchronuization operations. + * + * @param ServiceObject type. + * @param Change type. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class SyncResponse extends ServiceResponse { + + /** + * The changes. + */ + private final ChangeCollection changes = new ChangeCollection(); + + /** + * The property set. + */ + private final PropertySet propertySet; + + /** + * Initializes a new instance of the class. + * + * @param propertySet the property set + */ + protected SyncResponse(PropertySet propertySet) { + super(); + this.propertySet = propertySet; + EwsUtilities.ewsAssert(this.propertySet != null, "SyncResponse.ctor", "PropertySet should not be null"); + } + + /** + * Gets the name of the includes last in range XML element. + * + * @return XML element name. + */ + protected abstract String getIncludesLastInRangeXmlElementName(); + + /** + * Creates the change instance. + * + * @return TChange instance + */ + protected abstract TChange createChangeInstance(); + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws ServiceLocalException, Exception { + this.changes.setSyncState(reader.readElementValue( + XmlNamespace.Messages, XmlElementNames.SyncState)); + this.changes.setMoreChangesAvailable(!reader.readElementValue( + Boolean.class, XmlNamespace.Messages, this + .getIncludesLastInRangeXmlElementName())); + + reader.readStartElement(XmlNamespace.Messages, XmlElementNames.Changes); + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.isStartElement()) { + TChange change = this.createChangeInstance(); + + if (reader.getLocalName().equals(XmlElementNames.Create)) { + change.setChangeType(ChangeType.Create); + } else if (reader.getLocalName().equals( + XmlElementNames.Update)) { + change.setChangeType(ChangeType.Update); + } else if (reader.getLocalName().equals( + XmlElementNames.Delete)) { + change.setChangeType(ChangeType.Delete); + } else if (reader.getLocalName().equals( + XmlElementNames.ReadFlagChange)) { + change.setChangeType(ChangeType.ReadFlagChange); + } else { + reader.skipCurrentElement(); + } + + if (change != null) { + reader.read(); + reader.ensureCurrentNodeIsStartElement(); + + if (change.getChangeType().equals(ChangeType.Delete) + || change.getChangeType().equals( + ChangeType.ReadFlagChange)) { + change.setId(change.createId()); + change.getId().loadFromXml(reader, + change.getId().getXmlElementName()); + + if (change.getChangeType().equals( + ChangeType.ReadFlagChange)) { + reader.read(); + reader.ensureCurrentNodeIsStartElement(); + ItemChange itemChange = null; + if (change instanceof ItemChange) { + itemChange = (ItemChange) change; + } + EwsUtilities + .ewsAssert(itemChange != null, "SyncResponse." + "ReadElementsFromXml", + "ReadFlagChange is only " + "valid on ItemChange"); + + itemChange.setIsRead(reader.readElementValue( + Boolean.class, XmlNamespace.Types, + XmlElementNames.IsRead)); + } + } else { + + change.setServiceObject(EwsUtilities + .createEwsObjectFromXmlElementName(null, + reader.getService(), reader + .getLocalName())); + + change.getServiceObject().loadFromXml(reader, + true, /* clearPropertyBag */ + this.propertySet, this.getSummaryPropertiesOnly()); + } + + reader.readEndElementIfNecessary(XmlNamespace.Types, + change.getChangeType().toString()); + + this.changes.add(change); + } + } + } while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.Changes)); + } else { + reader.read(); + } + } + + /** + * Gets a list of changes that occurred on the synchronized folder. + * + * @return the changes + */ + public ChangeCollection getChanges() { + return this.changes; + } + + /** + * Gets a value indicating whether this request returns full or summary + * property. + * + * @return the summary property only + */ + protected abstract boolean getSummaryPropertiesOnly(); + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/UpdateFolderResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/UpdateFolderResponse.java new file mode 100644 index 000000000..18e19db3c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/UpdateFolderResponse.java @@ -0,0 +1,108 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.service.ServiceResult; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.folder.Folder; + +/** + * Represents response to UpdateFolder request. + */ +public final class UpdateFolderResponse extends ServiceResponse implements + IGetObjectInstanceDelegate { + + /** + * The folder. + */ + private final Folder folder; + + /** + * Initializes a new instance of the UpdateFolderResponse class. + * + * @param folder The folder + */ + public UpdateFolderResponse(Folder folder) { + super(); + EwsUtilities.ewsAssert(folder != null, "UpdateFolderResponse.ctor", "folder is null"); + + this.folder = folder; + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) + throws Exception { + super.readElementsFromXml(reader); + + reader.readServiceObjectsCollectionFromXml(XmlElementNames.Folders, + this, false, /* clearPropertyBag */ + null, /* requestedPropertySet */ + false); /* summaryPropertiesOnly */ + } + + /** + * Clears the change log of the updated folder if the update succeeded. + */ + @Override + protected void loaded() { + if (this.getResult() == ServiceResult.Success) { + this.folder.clearChangeLog(); + } + } + + /** + * Gets Folder instance. + * + * @param session The session + * @param xmlElementName Name of the XML element. + * @return Folder + */ + private Folder getObjectInstance(ExchangeService session, + String xmlElementName) { + return this.folder; + } + + /** + * Gets the object instance delegate. + * + * @param service accepts ExchangeService + * @param xmlElementName accepts String + * @return Object + */ + @Override + public ServiceObject getObjectInstanceDelegate(ExchangeService service, + String xmlElementName) { + return this.getObjectInstance(service, xmlElementName); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/UpdateInboxRulesResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/UpdateInboxRulesResponse.java new file mode 100644 index 000000000..4ab90a877 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/UpdateInboxRulesResponse.java @@ -0,0 +1,78 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.property.complex.RuleOperationErrorCollection; + +/** + * Represents the response to a UpdateInboxRulesResponse operation. + */ +public final class UpdateInboxRulesResponse extends ServiceResponse { + + /** + * Rule operation error collection. + */ + private final RuleOperationErrorCollection errors; + + /** + * Initializes a new instance of the UpdateInboxRulesResponse class. + */ + public UpdateInboxRulesResponse() { + super(); + this.errors = new RuleOperationErrorCollection(); + } + + /** + * Loads extra error details from XML + * + * @param reader The reader. + * @param xmlElementName The current element name of the extra error details. + * @return True if the expected extra details is loaded, + * False if the element name does not match the expected element. + * @throws Exception + */ + @Override + protected boolean loadExtraErrorDetailsFromXml(EwsServiceXmlReader reader, + String xmlElementName) throws Exception { + if (xmlElementName.equals(XmlElementNames.MessageXml)) { + return super.loadExtraErrorDetailsFromXml(reader, xmlElementName); + } else if (xmlElementName.equals(XmlElementNames.RuleOperationErrors)) { + this.getErrors().loadFromXml(reader, + XmlNamespace.Messages, xmlElementName); + return true; + } else { + return false; + } + } + + /** + * Gets the rule operation errors in the response. + */ + public RuleOperationErrorCollection getErrors() { + return this.errors; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/response/UpdateItemResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/response/UpdateItemResponse.java new file mode 100644 index 000000000..ad18322e8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/response/UpdateItemResponse.java @@ -0,0 +1,172 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.response; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.ServiceResult; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Item; + +/** + * The Class UpdateItemResponse. + */ +public final class UpdateItemResponse extends ServiceResponse implements + IGetObjectInstanceDelegate { + + /** + * Represents the response to an individual item update operation. + */ + private final Item item; + + /** + * The returned item. + */ + private Item returnedItem; + + /** + * The conflict count. + */ + private int conflictCount; + + /** + * Initializes a new instance of the class. + * + * @param item the item + */ + public UpdateItemResponse(Item item) { + super(); + EwsUtilities.ewsAssert(item != null, "UpdateItemResponse.ctor", "item is null"); + this.item = item; + } + + /** + * Reads response elements from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { + super.readElementsFromXml(reader); + + reader.readServiceObjectsCollectionFromXml(XmlElementNames.Items, this, + false, null, false); + + if (!reader.getService().getExchange2007CompatibilityMode()) { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.ConflictResults); + this.conflictCount = reader.readElementValue(Integer.class, + XmlNamespace.Types, XmlElementNames.Count); + reader.readEndElement(XmlNamespace.Messages, + XmlElementNames.ConflictResults); + } + + // If UpdateItem returned an item that has the same Id as the item that + // is being updated, this is a "normal" UpdateItem operation, and we + // need + // to update the ChangeKey of the item being updated with the one that + // was + // returned. Also set returnedItem to indicate that no new item was + // returned. + // + // Otherwise, this in a "special" UpdateItem operation, such as a + // recurring + // task marked as complete (the returned item in that case is the + // one-off + // task that represents the completed instance). + // + // Note that there can be no returned item at all, as in an UpdateItem + // call + // with MessageDisposition set to SendOnly or SendAndSaveCopy. + if (this.returnedItem != null) { + if (this.item.getId().getUniqueId().equals( + this.returnedItem.getId().getUniqueId())) { + this.item.getId().setChangeKey( + this.returnedItem.getId().getChangeKey()); + this.returnedItem = null; + } + } + } + + /* + * (non-Javadoc) + * + * @seemicrosoft.exchange.webservices.GetObjectInstanceDelegateInterface# + * getObjectInstanceDelegate(microsoft.exchange.webservices.ExchangeService, + * java.lang.String) + */ + public ServiceObject getObjectInstanceDelegate(ExchangeService service, String xmlElementName) throws ExchangeXmlException { + return this.getObjectInstance(service, xmlElementName); + } + + /** + * Clears the change log of the created folder if the creation succeeded. + */ + @Override + protected void loaded() { + if (this.getResult() == ServiceResult.Success) { + this.item.clearChangeLog(); + } + } + + /** + * Gets Item instance. + * + * @param service the service + * @param xmlElementName the xml element name + * @return Item + */ + private Item getObjectInstance(ExchangeService service, String xmlElementName) throws ExchangeXmlException { + this.returnedItem = EwsUtilities.createEwsObjectFromXmlElementName( + Item.class, service, xmlElementName); + return this.returnedItem; + } + + /** + * Gets the item that was returned by the update operation. ReturnedItem + * is set only when a recurring Task is marked as complete or when its + * recurrence pattern changes. + * + * @return the returned item + */ + public Item getReturnedItem() { + return this.returnedItem; + } + + /** + * Gets the number of property conflicts that were resolved during the + * update operation. + * + * @return the conflict count + */ + public int getConflictCount() { + return this.conflictCount; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/ICreateServiceObjectWithAttachmentParam.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/ICreateServiceObjectWithAttachmentParam.java new file mode 100644 index 000000000..6b5fd69a1 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/ICreateServiceObjectWithAttachmentParam.java @@ -0,0 +1,34 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service; + +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ItemAttachment; + +@FunctionalInterface +public interface ICreateServiceObjectWithAttachmentParam { + + Object createServiceObjectWithAttachmentParam(ItemAttachment itemAttachment, boolean isNew) throws ExchangeXmlException; + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/ICreateServiceObjectWithServiceParam.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/ICreateServiceObjectWithServiceParam.java new file mode 100644 index 000000000..26a5dbb27 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/ICreateServiceObjectWithServiceParam.java @@ -0,0 +1,42 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * The Interface ICreateServiceObjectWithServiceParam. + */ +public interface ICreateServiceObjectWithServiceParam { + + /** + * Creates the service object with service param. + * + * @param srv the srv + * @return the object + * @throws Exception the exception + */ + Object createServiceObjectWithServiceParam(ExchangeService srv) throws ExchangeXmlException; +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/ServiceObject.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/ServiceObject.java new file mode 100644 index 000000000..badaa8cfa --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/ServiceObject.java @@ -0,0 +1,620 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.DeleteMode; +import com.eischet.ews.api.core.enumeration.service.SendCancellationsMode; +import com.eischet.ews.api.core.enumeration.service.calendar.AffectedTaskOccurrence; +import com.eischet.ews.api.core.exception.misc.InvalidOperationException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.complex.ExtendedProperty; +import com.eischet.ews.api.property.complex.ExtendedPropertyCollection; +import com.eischet.ews.api.property.complex.IServiceObjectChangedDelegate; +import com.eischet.ews.api.property.complex.ServiceId; +import com.eischet.ews.api.property.definition.ExtendedPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinitionBase; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Represents the base abstract class for all item and folder types. + */ +public abstract class ServiceObject { + + /** + * The lock object. + */ + private final Object lockObject = new Object(); + + /** + * The service. + */ + private ExchangeService service; + + /** + * The property bag. + */ + private final PropertyBag propertyBag; + + /** + * The xml element name. + */ + private String xmlElementName; + + /** + * Triggers dispatch of the change event. + */ + public void changed() { + + for (IServiceObjectChangedDelegate change : this.onChange) { + change.serviceObjectChanged(this); + } + } + + /** + * Throws exception if this is a new service object. + * + * @throws InvalidOperationException the invalid operation exception + * @throws ServiceLocalException the service local exception + */ + public void throwIfThisIsNew() throws InvalidOperationException, + ServiceLocalException, ExchangeXmlException { + if (this.isNew()) { + throw new InvalidOperationException( + "This operation can't be performed because this service object doesn't have an Id."); + } + } + + /** + * Throws exception if this is not a new service object. + * + * @throws InvalidOperationException the invalid operation exception + * @throws ServiceLocalException the service local exception + */ + protected void throwIfThisIsNotNew() throws InvalidOperationException, + ServiceLocalException, ExchangeXmlException { + if (!this.isNew()) { + throw new InvalidOperationException( + "This operation can't be performed because this service object already has an ID. To update this service object, use the Update() method instead."); + } + } + + // / This methods lets subclasses of ServiceObject override the default + // mechanism + // / by which the XML element name associated with their type is retrieved. + + /** + * This methods lets subclasses of ServiceObject override the default + * mechanism by which the XML element name associated with their type is + * retrieved. + * + * @return String + */ + protected String getXmlElementNameOverride() { + return null; + } + + /** + * GetXmlElementName retrieves the XmlElementName of this type based on the + * EwsObjectDefinition attribute that decorates it, if present. + * + * @return The XML element name associated with this type. + */ + public String getXmlElementName() { + if (this.isNullOrEmpty(this.xmlElementName)) { + this.xmlElementName = this.getXmlElementNameOverride(); + if (this.isNullOrEmpty(this.xmlElementName)) { + synchronized (this.lockObject) { + + ServiceObjectDefinition annotation = this.getClass() + .getAnnotation(ServiceObjectDefinition.class); + if (null != annotation) { + this.xmlElementName = annotation.xmlElementName(); + } + } + } + } + EwsUtilities + .ewsAssert(!isNullOrEmpty(this.xmlElementName), "EwsObject.GetXmlElementName", String + .format("The class %s does not have an " + "associated XML element name.", + this.getClass().getName())); + + return this.xmlElementName; + } + + /** + * Gets the name of the change XML element. + * + * @return the change xml element name + */ + public String getChangeXmlElementName() { + return XmlElementNames.ItemChange; + } + + /** + * Gets the name of the set field XML element. + * + * @return String + */ + public String getSetFieldXmlElementName() { + return XmlElementNames.SetItemField; + } + + /** + * Gets the name of the delete field XML element. + * + * @return String + */ + public String getDeleteFieldXmlElementName() { + return XmlElementNames.DeleteItemField; + } + + /** + * Gets a value indicating whether a time zone SOAP header should be emitted + * in a CreateItem or UpdateItem request so this item can be property saved + * or updated. + * + * @param isUpdateOperation the is update operation + * @return boolean + */ + protected boolean getIsTimeZoneHeaderRequired(boolean isUpdateOperation) + throws ServiceLocalException, Exception { + return false; + } + + /** + * Determines whether property defined with + * ScopedDateTimePropertyDefinition require custom time zone scoping. + * + * @return boolean + */ + protected boolean getIsCustomDateTimeScopingRequired() { + return false; + } + + /** + * The property bag holding property values for this object. + * + * @return the property bag + */ + public PropertyBag getPropertyBag() { + return this.propertyBag; + } + + /** + * Internal constructor. + * + * @param service the service + * @throws Exception the exception + */ + protected ServiceObject(ExchangeService service) throws ExchangeXmlException { + try { + EwsUtilities.validateParam(service, "service"); + EwsUtilities.validateServiceObjectVersion(this, service.getRequestedServerVersion()); + } catch (ExchangeValidationException | ServiceVersionException e) { + throw new ExchangeXmlException("error validating " + this, e); + } + this.service = service; + this.propertyBag = new PropertyBag(this); + } + + /** + * Gets the schema associated with this type of object. + * + * @return ServiceObjectSchema + */ + public ServiceObjectSchema schema() { + return this.getSchema(); + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return the schema + */ + public abstract ServiceObjectSchema getSchema(); + + /** + * Gets the minimum required server version. + * + * @return the minimum required server version + */ + public abstract ExchangeVersion getMinimumRequiredServerVersion(); + + /** + * Loads service object from XML. + * + * @param reader the reader + * @param clearPropertyBag the clear property bag + */ + public void loadFromXml(EwsServiceXmlReader reader, boolean clearPropertyBag) throws ExchangeXmlException { + + this.getPropertyBag().loadFromXml(reader, clearPropertyBag, + null, // propertySet + false); // summaryPropertiesOnly + + } + + // / Validates this instance. + + /** + * Validate. + * + * @throws Exception the exception + */ + protected void validate() throws Exception { + this.getPropertyBag().validate(); + } + + // / Loads service object from XML. + + /** + * Load from xml. + * + * @param reader the reader + * @param clearPropertyBag the clear property bag + * @param requestedPropertySet the requested property set + * @param summaryPropertiesOnly the summary property only + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader, boolean clearPropertyBag, + PropertySet requestedPropertySet, boolean summaryPropertiesOnly) throws ExchangeXmlException { + + this.getPropertyBag().loadFromXml(reader, clearPropertyBag, + requestedPropertySet, summaryPropertiesOnly); + + } + + // Clears the object's change log. + + /** + * Clear change log. + */ + public void clearChangeLog() { + this.getPropertyBag().clearChangeLog(); + } + + // / Writes service object as XML. + + /** + * Write to xml. + * + * @param writer the writer + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer) throws Exception { + this.getPropertyBag().writeToXml(writer); + } + + // Writes service object for update as XML. + + /** + * Write to xml for update. + * + * @param writer the writer + * @throws Exception the exception + */ + public void writeToXmlForUpdate(EwsServiceXmlWriter writer) + throws Exception { + this.getPropertyBag().writeToXmlForUpdate(writer); + } + + // / Loads the specified set of property on the object. + + /** + * Internal load. + * + * @param propertySet the property set + * @throws Exception the exception + */ + protected abstract void internalLoad(PropertySet propertySet) + throws Exception; + + // / Deletes the object. + + /** + * Internal delete. + * + * @param deleteMode the delete mode + * @param sendCancellationsMode the send cancellations mode + * @param affectedTaskOccurrences the affected task occurrences + * @throws Exception the exception + */ + protected abstract void internalDelete(DeleteMode deleteMode, + SendCancellationsMode sendCancellationsMode, + AffectedTaskOccurrence affectedTaskOccurrences) throws Exception; + + // / Loads the specified set of property. Calling this method results in a + // call to EWS. + + /** + * Load. + * + * @param propertySet the property set + * @throws Exception the exception + */ + public void load(PropertySet propertySet) throws Exception { + this.internalLoad(propertySet); + } + + // Loads the first class property. Calling this method results in a call + // to EWS. + + /** + * Load. + * + * @throws Exception the exception + */ + public void load() throws Exception { + this.internalLoad(PropertySet.getFirstClassProperties()); + } + + /** + * Gets the value of specified property in this instance. + * + * @param propertyDefinition Definition of the property to get. + * @return The value of specified property in this instance. + * @throws Exception the exception + */ + public Object getObjectFromPropertyDefinition( + PropertyDefinitionBase propertyDefinition) throws Exception { + PropertyDefinition propDef = (PropertyDefinition) propertyDefinition; + + if (propDef != null) { + return this.getPropertyBag().getObjectFromPropertyDefinition(propDef); + } else { + // E14:226103 -- Other subclasses of PropertyDefinitionBase are not supported. + throw new UnsupportedOperationException(String.format( + "This operation isn't supported for property definition type %s.", + propertyDefinition.getType().getName())); + } + } + + /** + * Try to get the value of a specified extended property in this instance. + * + * @param propertyDefinition the property definition + * @param propertyValue the property value + * @return true, if successful + * @throws Exception the exception + */ + protected boolean tryGetExtendedProperty(Class cls, + ExtendedPropertyDefinition propertyDefinition, + OutParam propertyValue) throws Exception { + ExtendedPropertyCollection propertyCollection = this + .getExtendedProperties(); + + if ((propertyCollection != null) && + propertyCollection.tryGetValue(cls, propertyDefinition, propertyValue)) { + return true; + } else { + propertyValue.setParam(null); + return false; + } + } + + /** + * Try to get the value of a specified property in this instance. + * + * @param propertyDefinition The property definition. + * @param propertyValue The property value + * @return True if property retrieved, false otherwise. + * @throws Exception + */ + public boolean tryGetProperty(PropertyDefinitionBase propertyDefinition, OutParam propertyValue) + throws Exception { + return this.tryGetProperty(Object.class, propertyDefinition, propertyValue); + } + + /** + * Try to get the value of a specified property in this instance. + * + * @param propertyDefinition the property definition + * @param propertyValue the property value + * @return true, if successful + * @throws Exception the exception + */ + public boolean tryGetProperty(Class cls, PropertyDefinitionBase propertyDefinition, + OutParam propertyValue) throws Exception { + + PropertyDefinition propDef = (PropertyDefinition) propertyDefinition; + if (propDef != null) { + return this.getPropertyBag().tryGetPropertyType(cls, propDef, propertyValue); + } else { + // E14:226103 -- Other subclasses of PropertyDefinitionBase are not supported. + throw new UnsupportedOperationException(String.format( + "This operation isn't supported for property definition type %s.", + propertyDefinition.getType().getName())); + } + } + + /** + * Gets the collection of loaded property definitions. + * + * @return the loaded property definitions + * @throws Exception the exception + */ + public Collection getLoadedPropertyDefinitions() + throws Exception { + + Collection propDefs = + new ArrayList(); + for (PropertyDefinition propDef : this.getPropertyBag().getProperties() + .keySet()) { + propDefs.add(propDef); + } + + if (this.getExtendedProperties() != null) { + for (ExtendedProperty extProp : getExtendedProperties()) { + propDefs.add(extProp.getPropertyDefinition()); + } + } + + return propDefs; + } + + /** + * Gets the service. + * + * @return the service + */ + public ExchangeService getService() { + return service; + } + + /** + * Sets the service. + * + * @param service the new service + */ + protected void setService(ExchangeService service) { + this.service = service; + } + + // / The property definition for the Id of this object. + + /** + * Gets the id property definition. + * + * @return the id property definition + */ + public PropertyDefinition getIdPropertyDefinition() { + return null; + } + + // / The unique Id of this object. + + /** + * Gets the id. + * + * @return the id + */ + public ServiceId getId() throws ExchangeXmlException { + PropertyDefinition idPropertyDefinition = this.getIdPropertyDefinition(); + OutParam serviceId = new OutParam(); + if (idPropertyDefinition != null) { + this.getPropertyBag().tryGetValue(idPropertyDefinition, serviceId); + } + return (ServiceId) serviceId.getParam(); + } + + // / Indicates whether this object is a real store item, or if it's a local + // object + // / that has yet to be saved. + + /** + * Checks if is new. + * + * @return true, if is new + */ + public boolean isNew() throws ExchangeXmlException { + + ServiceId id = this.getId(); + + return id == null || !id.isValid(); + + } + + // / Gets a value indicating whether the object has been modified and should + // be saved. + + /** + * Checks if is dirty. + * + * @return true, if is dirty + */ + public boolean isDirty() { + return this.getPropertyBag().getIsDirty(); + + } + + // Gets the extended property collection. + + /** + * Gets the extended property. + * + * @return the extended property + * @throws Exception the exception + */ + protected ExtendedPropertyCollection getExtendedProperties() + throws Exception { + return null; + } + + /** + * Checks is the string is null or empty. + * + * @param namespacePrefix the namespace prefix + * @return true, if is null or empty + */ + private boolean isNullOrEmpty(String namespacePrefix) { + return (namespacePrefix == null || namespacePrefix.isEmpty()); + + } + + /** + * The on change. + */ + private final List onChange = + new ArrayList<>(); + + /** + * Adds the service object changed event. + * + * @param change the change + */ + public void addServiceObjectChangedEvent( + IServiceObjectChangedDelegate change) { + this.onChange.add(change); + } + + /** + * Removes the service object changed event. + * + * @param change the change + */ + public void removeServiceObjectChangedEvent( + IServiceObjectChangedDelegate change) { + this.onChange.remove(change); + } + + /** + * Clear service object changed event. + */ + public void clearServiceObjectChangedEvent() { + this.onChange.clear(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/ServiceObjectInfo.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/ServiceObjectInfo.java new file mode 100644 index 000000000..687cf579d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/ServiceObjectInfo.java @@ -0,0 +1,315 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.folder.*; +import com.eischet.ews.api.core.service.item.*; +import com.eischet.ews.api.property.complex.ItemAttachment; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * ServiceObjectInfo contains metadata on how to map from an element name to a + * ServiceObject type as well as how to map from a ServiceObject type to + * appropriate constructors. + */ +public class ServiceObjectInfo { + + /** + * The service object constructors with attachment param. + */ + private final Map, ICreateServiceObjectWithAttachmentParam> + serviceObjectConstructorsWithAttachmentParam; + + /** + * The service object constructors with service param. + */ + private final Map, ICreateServiceObjectWithServiceParam> + serviceObjectConstructorsWithServiceParam; + + /** + * The xml element name to service object class map. + */ + private final Map> xmlElementNameToServiceObjectClassMap; + + /** + * Default constructor. + */ + public ServiceObjectInfo() { + this.xmlElementNameToServiceObjectClassMap = new HashMap<>(); + this.serviceObjectConstructorsWithServiceParam = new HashMap<>(); + this.serviceObjectConstructorsWithAttachmentParam = new HashMap<>(); + + this.initializeServiceObjectClassMap(); + } + + /** + * Initializes the service object class map. If you add a new ServiceObject + * subclass that can be returned by the Server, add the type to the class + * map as well as associated delegate(s) to call the constructor(s). + */ + private void initializeServiceObjectClassMap() { + // Appointment + this.addServiceObjectType(XmlElementNames.CalendarItem, + Appointment.class, new ICreateServiceObjectWithServiceParam() { + public Object createServiceObjectWithServiceParam(ExchangeService srv) throws ExchangeXmlException { + return new Appointment(srv); + } + }, new ICreateServiceObjectWithAttachmentParam() { + public Object createServiceObjectWithAttachmentParam(ItemAttachment itemAttachment, boolean isNew) throws ExchangeXmlException { + return new Appointment(itemAttachment, isNew); + } + }); + + // CalendarFolder + this.addServiceObjectType(XmlElementNames.CalendarFolder, CalendarFolder.class, CalendarFolder::new, null); + + // Contact + this.addServiceObjectType(XmlElementNames.Contact, Contact.class, Contact::new, (itemAttachment, isNew) -> new Contact(itemAttachment)); + + // ContactsFolder + this.addServiceObjectType(XmlElementNames.ContactsFolder, ContactsFolder.class, ContactsFolder::new, null); + + // ContactGroup + this.addServiceObjectType(XmlElementNames.DistributionList, ContactGroup.class, ContactGroup::new, (itemAttachment, isNew) -> new ContactGroup(itemAttachment)); + + // Conversation + this.addServiceObjectType(XmlElementNames.Conversation, Conversation.class, Conversation::new, null); + + // EmailMessage + this.addServiceObjectType(XmlElementNames.Message, EmailMessage.class, EmailMessage::new, (itemAttachment, isNew) -> new EmailMessage(itemAttachment)); + + // Folder + this.addServiceObjectType(XmlElementNames.Folder, Folder.class, Folder::new, null); + + // Item + this.addServiceObjectType(XmlElementNames.Item, Item.class, Item::new, (itemAttachment, isNew) -> new Item(itemAttachment)); + + // MeetingCancellation + this.addServiceObjectType(XmlElementNames.MeetingCancellation, MeetingCancellation.class, MeetingCancellation::new, (itemAttachment, isNew) -> new MeetingCancellation(itemAttachment)); + + // MeetingMessage + this.addServiceObjectType(XmlElementNames.MeetingMessage, + MeetingMessage.class, + new ICreateServiceObjectWithServiceParam() { + public Object createServiceObjectWithServiceParam( + ExchangeService srv) throws ExchangeXmlException { + return new MeetingMessage(srv); + } + }, new ICreateServiceObjectWithAttachmentParam() { + public Object createServiceObjectWithAttachmentParam( + ItemAttachment itemAttachment, boolean isNew) + throws ExchangeXmlException { + return new MeetingMessage(itemAttachment); + } + }); + + // MeetingRequest + this.addServiceObjectType(XmlElementNames.MeetingRequest, + MeetingRequest.class, + new ICreateServiceObjectWithServiceParam() { + public Object createServiceObjectWithServiceParam( + ExchangeService srv) throws ExchangeXmlException { + return new MeetingRequest(srv); + } + }, new ICreateServiceObjectWithAttachmentParam() { + public Object createServiceObjectWithAttachmentParam( + ItemAttachment itemAttachment, boolean isNew) + throws ExchangeXmlException { + return new MeetingRequest(itemAttachment); + } + }); + + // MeetingResponse + this.addServiceObjectType(XmlElementNames.MeetingResponse, + MeetingResponse.class, + new ICreateServiceObjectWithServiceParam() { + public Object createServiceObjectWithServiceParam( + ExchangeService srv) throws ExchangeXmlException { + return new MeetingResponse(srv); + } + }, new ICreateServiceObjectWithAttachmentParam() { + public Object createServiceObjectWithAttachmentParam( + ItemAttachment itemAttachment, boolean isNew) + throws ExchangeXmlException { + return new MeetingResponse(itemAttachment); + } + }); + + // PostItem + this.addServiceObjectType(XmlElementNames.PostItem, PostItem.class, + new ICreateServiceObjectWithServiceParam() { + public Object createServiceObjectWithServiceParam( + ExchangeService srv) throws ExchangeXmlException { + return new PostItem(srv); + } + }, new ICreateServiceObjectWithAttachmentParam() { + public Object createServiceObjectWithAttachmentParam( + ItemAttachment itemAttachment, boolean isNew) + throws ExchangeXmlException { + return new PostItem(itemAttachment); + } + }); + + // SearchFolder + this.addServiceObjectType(XmlElementNames.SearchFolder, + SearchFolder.class, new ICreateServiceObjectWithServiceParam() { + public Object createServiceObjectWithServiceParam( + ExchangeService srv) throws ExchangeXmlException { + return new SearchFolder(srv); + } + }, null); + + // Task + this.addServiceObjectType(XmlElementNames.Task, Task.class, + new ICreateServiceObjectWithServiceParam() { + public Object createServiceObjectWithServiceParam( + ExchangeService srv) throws ExchangeXmlException { + return new Task(srv); + } + }, new ICreateServiceObjectWithAttachmentParam() { + public Object createServiceObjectWithAttachmentParam( + ItemAttachment itemAttachment, boolean isNew) throws ExchangeXmlException { + return new Task(itemAttachment); + } + }); + + // TasksFolder + this.addServiceObjectType(XmlElementNames.TasksFolder, TasksFolder.class, TasksFolder::new, null); + } + + /** + * Adds specified type of service object to map. + * + * @param xmlElementName the xml element name + * @param cls the cls + * @param createServiceObjectWithServiceParam the create service object with service param + * @param createServiceObjectWithAttachmentParam the create service object with attachment param + */ + private void addServiceObjectType( + String xmlElementName, + Class cls, + ICreateServiceObjectWithServiceParam createServiceObjectWithServiceParam, + ICreateServiceObjectWithAttachmentParam createServiceObjectWithAttachmentParam) { + this.xmlElementNameToServiceObjectClassMap.put(xmlElementName, cls); + this.serviceObjectConstructorsWithServiceParam.put(cls, + createServiceObjectWithServiceParam); + if (createServiceObjectWithAttachmentParam != null) { + this.serviceObjectConstructorsWithAttachmentParam.put(cls, + createServiceObjectWithAttachmentParam); + } + } + + /** + * Return Dictionary that maps from element name to ServiceObject Type. + * + * @return the xml element name to service object class map + */ + public Map> getXmlElementNameToServiceObjectClassMap() { + return this.xmlElementNameToServiceObjectClassMap; + } + + /** + * Return Dictionary that maps from ServiceObject Type to + * CreateServiceObjectWithServiceParam delegate with ExchangeService + * parameter. + * + * @return the service object constructors with service param + */ + public Map, ICreateServiceObjectWithServiceParam> + getServiceObjectConstructorsWithServiceParam() { + return this.serviceObjectConstructorsWithServiceParam; + } + + /** + * Return Dictionary that maps from ServiceObject Type to + * CreateServiceObjectWithAttachmentParam delegate with ItemAttachment + * parameter. + * + * @return the service object constructors with attachment param + */ + public Map, ICreateServiceObjectWithAttachmentParam> + getServiceObjectConstructorsWithAttachmentParam() { + return this.serviceObjectConstructorsWithAttachmentParam; + } + + /** + * Set event to happen when property changed. + * + * @param change change event + */ + protected void addOnChangeEvent( + ICreateServiceObjectWithAttachmentParam change) { + onChangeList.add(change); + } + + /** + * Remove the event from happening when property changed. + * + * @param change change event + */ + protected void removeChangeEvent( + ICreateServiceObjectWithAttachmentParam change) { + onChangeList.remove(change); + } + + /** + * The on change list. + */ + private final List onChangeList = + new ArrayList(); + + /** + * The on change list1. + */ + private final List onChangeList1 = + new ArrayList(); + + /** + * Set event to happen when property changed. + * + * @param change change event + */ + protected void addOnChangeEvent( + ICreateServiceObjectWithServiceParam change) { + onChangeList1.add(change); + } + + /** + * Remove the event from happening when property changed. + * + * @param change change event + */ + protected void removeChangeEvent( + ICreateServiceObjectWithServiceParam change) { + onChangeList1.remove(change); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/CalendarFolder.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/CalendarFolder.java new file mode 100644 index 000000000..f896ac0c4 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/CalendarFolder.java @@ -0,0 +1,156 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.folder; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.FindItemResponse; +import com.eischet.ews.api.core.response.ServiceResponseCollection; +import com.eischet.ews.api.core.service.item.Appointment; +import com.eischet.ews.api.property.complex.FolderId; +import com.eischet.ews.api.search.CalendarView; +import com.eischet.ews.api.search.FindItemsResults; +import com.eischet.ews.api.search.filter.SearchFilter; + +/** + * Represents a folder containing appointments. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.CalendarFolder) +public class CalendarFolder extends Folder { + + /** + * Binds to an existing calendar folder and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @param propertySet the property set + * @return A CalendarFolder instance representing the calendar folder + * corresponding to the specified Id + * @throws Exception the exception + */ + public static CalendarFolder bind(ExchangeService service, FolderId id, + PropertySet propertySet) throws Exception { + return service.bindToFolder(CalendarFolder.class, id, propertySet); + } + + /** + * Binds to an existing calendar folder and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @return A CalendarFolder instance representing the calendar folder + * corresponding to the specified Id + * @throws Exception the exception + */ + public static CalendarFolder bind(ExchangeService service, FolderId id) + throws Exception { + return CalendarFolder.bind(service, id, PropertySet + .getFirstClassProperties()); + } + + /** + * Binds to an existing calendar folder and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service the service + * @param name the name + * @param propertySet the property set + * @return A CalendarFolder instance representing the calendar folder with + * the specified name. + * @throws Exception the exception + */ + public static CalendarFolder bind(ExchangeService service, + WellKnownFolderName name, PropertySet + propertySet) throws Exception { + return CalendarFolder.bind(service, new FolderId(name), propertySet); + } + + /** + * Binds to an existing calendar folder and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service the service + * @param name the name + * @return A CalendarFolder instance representing the calendar folder with + * the specified name. + * @throws Exception the exception + */ + public static CalendarFolder bind(ExchangeService service, + WellKnownFolderName name) throws Exception { + return CalendarFolder.bind(service, new FolderId(name), PropertySet + .getFirstClassProperties()); + } + + /** + * Initializes an unsaved local instance of "CalendarFolder". To bind to an + * existing calendar folder, use CalendarFolder.Bind() instead. Calling this + * method results in a call to EWS. + * + * @param service the service + * @throws Exception the exception + */ + public CalendarFolder(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Obtains a list of appointments by searching the contents of this folder + * and performing recurrence expansion for recurring appointments. Calling + * this method results in a call to EWS. + * + * @param view the view + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindItemsResults findAppointments(CalendarView view) + throws Exception { + EwsUtilities.validateParam(view, "view"); + + ServiceResponseCollection> responses = + this.internalFindItems((SearchFilter) null, view, null + /* groupBy */); + + return responses.getResponseAtIndex(0).getResults(); + } + + /** + * Obtains a list of appointments by searching the contents of this folder + * and performing recurrence expansion. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/ContactsFolder.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/ContactsFolder.java new file mode 100644 index 000000000..d9908f542 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/ContactsFolder.java @@ -0,0 +1,127 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.folder; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.FolderId; + +/** + * Represents a folder containing contacts. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.ContactsFolder) +public class ContactsFolder extends Folder { + + /** + * Initializes an unsaved local instance of the class.To bind to an + * existing contacts folder, use ContactsFolder.Bind() instead. + * + * @param service the service + * @throws Exception the exception + */ + public ContactsFolder(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Binds to an existing contacts folder and loads the specified set of + * property. + * + * @param service the service + * @param id the id + * @param propertySet the property set + * @return A ContactsFolder instance representing the contacts folder + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static ContactsFolder bind(ExchangeService service, FolderId id, + PropertySet propertySet) throws Exception { + return service.bindToFolder(ContactsFolder.class, id, propertySet); + } + + /** + * Binds to an existing contacts folder and loads its first class + * property. + * + * @param service the service + * @param id the id + * @return A ContactsFolder instance representing the contacts folder + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static ContactsFolder bind(ExchangeService service, FolderId id) + throws Exception { + return ContactsFolder.bind(service, id, PropertySet + .getFirstClassProperties()); + } + + /** + * Binds to an existing contacts folder and loads the specified set of + * property. + * + * @param service the service + * @param name the name + * @param propertySet the property set + * @return A ContactsFolder instance representing the contacts folder + * corresponding to the specified name. + * @throws Exception the exception + */ + public static ContactsFolder bind(ExchangeService service, + WellKnownFolderName name, PropertySet propertySet) + throws Exception { + return ContactsFolder.bind(service, new FolderId(name), propertySet); + } + + /** + * Binds to an existing contacts folder and loads its first class + * property. + * + * @param service the service + * @param name the name + * @return A ContactsFolder instance representing the contacts folder + * corresponding to the specified name. + * @throws Exception the exception + */ + public static ContactsFolder bind(ExchangeService service, + WellKnownFolderName name) throws Exception { + return ContactsFolder.bind(service, new FolderId(name), PropertySet + .getFirstClassProperties()); + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/Folder.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/Folder.java new file mode 100644 index 000000000..f1e069451 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/Folder.java @@ -0,0 +1,763 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.folder; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.enumeration.service.DeleteMode; +import com.eischet.ews.api.core.enumeration.service.EffectiveRights; +import com.eischet.ews.api.core.enumeration.service.SendCancellationsMode; +import com.eischet.ews.api.core.enumeration.service.calendar.AffectedTaskOccurrence; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.misc.InvalidOperationException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.FindItemResponse; +import com.eischet.ews.api.core.response.ServiceResponseCollection; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.core.service.schema.FolderSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.property.complex.ExtendedPropertyCollection; +import com.eischet.ews.api.property.complex.FolderId; +import com.eischet.ews.api.property.complex.FolderPermissionCollection; +import com.eischet.ews.api.property.complex.ManagedFolderInformation; +import com.eischet.ews.api.property.definition.ExtendedPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; +import com.eischet.ews.api.search.*; +import com.eischet.ews.api.search.filter.SearchFilter; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents a generic folder. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.Folder) +public class Folder extends ServiceObject { + + private static final Logger LOG = Logger.getLogger(Folder.class.getCanonicalName()); + + /** + * Initializes an unsaved local instance of {@link Folder}. + * + * @param service EWS service to which this object belongs + */ + public Folder(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Binds to an existing folder, whatever its actual type is, and loads the + * specified set of property. Calling this method results in a call to + * EWS. + * + * @param service The service to use to bind to the folder. + * @param id The Id of the folder to bind to. + * @param propertySet The set of property to load. + * @return A Folder instance representing the folder corresponding to the + * specified Id. + * @throws Exception the exception + */ + public static Folder bind(ExchangeService service, FolderId id, + PropertySet propertySet) throws Exception { + return service.bindToFolder(Folder.class, id, propertySet); + } + + /** + * Binds to an existing folder, whatever its actual type is, and loads the + * specified set of property. Calling this method results in a call to + * EWS. + * + * @param service , The service to use to bind to the folder. + * @param id , The Id of the folder to bind to. + * @return A Folder instance representing the folder corresponding to the + * specified Id. + * @throws Exception the exception + */ + public static Folder bind(ExchangeService service, FolderId id) + throws Exception { + return Folder.bind(service, id, PropertySet.getFirstClassProperties()); + } + + /** + * Binds to an existing folder, whatever its actual type is, and loads the + * specified set of property. Calling this method results in a call to + * EWS. + * + * @param service The service to use to bind to the folder. + * @param name The name of the folder to bind to. + * @param propertySet The set of property to load. + * @return A Folder instance representing the folder corresponding to the + * specified Id. + * @throws Exception the exception + */ + public static Folder bind(ExchangeService service, + WellKnownFolderName name, PropertySet propertySet) + throws Exception { + return Folder.bind(service, new FolderId(name), propertySet); + } + + /** + * Binds to an existing folder, whatever its actual type is, and loads the + * specified set of property. Calling this method results in a call to + * EWS. + * + * @param service The service to use to bind to the folder. + * @param name The name of the folder to bind to. + * @return the folder + * @throws Exception the exception + */ + public static Folder bind(ExchangeService service, WellKnownFolderName name) + throws Exception { + return Folder.bind(service, new FolderId(name), PropertySet + .getFirstClassProperties()); + } + + /** + * Validates this instance. + * + * @throws Exception the exception + */ + @Override + public void validate() throws Exception { + super.validate(); + + // Validate folder permissions + try { + if (this.getPropertyBag().contains(FolderSchema.Permissions)) { + this.getPermissions().validate(); + } + } catch (ServiceLocalException e) { + LOG.log(Level.SEVERE, "validation error", e); + } + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return FolderSchema.Instance; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the name of the change XML element. + * + * @return Xml element name + */ + @Override + public String getChangeXmlElementName() { + return XmlElementNames.FolderChange; + } + + /** + * Gets the name of the set field XML element. + * + * @return Xml element name + */ + @Override + public String getSetFieldXmlElementName() { + return XmlElementNames.SetFolderField; + } + + /** + * Gets the name of the delete field XML element. + * + * @return Xml element name + */ + @Override + public String getDeleteFieldXmlElementName() { + return XmlElementNames.DeleteFolderField; + } + + /** + * Loads the specified set of property on the object. + * + * @param propertySet The property to load. + * @throws Exception the exception + */ + @Override + protected void internalLoad(PropertySet propertySet) throws Exception { + this.throwIfThisIsNew(); + + this.getService().loadPropertiesForFolder(this, propertySet); + } + + /** + * Deletes the object. + * + * @param deleteMode the delete mode + * @param sendCancellationsMode Indicates whether meeting cancellation messages should be + * sent. + * @param affectedTaskOccurrences Indicate which occurrence of a recurring task should be + * deleted. + * @throws Exception the exception + */ + @Override + protected void internalDelete(DeleteMode deleteMode, + SendCancellationsMode sendCancellationsMode, + AffectedTaskOccurrence affectedTaskOccurrences) throws Exception { + try { + this.throwIfThisIsNew(); + } catch (InvalidOperationException e) { + LOG.log(Level.SEVERE, "internalDelete error", e); + } + + this.getService().deleteFolder(this.getId(), deleteMode); + } + + /** + * Deletes the folder. Calling this method results in a call to EWS. + * + * @param deleteMode the delete mode + * @throws Exception the exception + */ + public void delete(DeleteMode deleteMode) throws Exception { + this.internalDelete(deleteMode, null, null); + } + + /** + * Empties the folder. Calling this method results in a call to EWS. + * + * @param deletemode the delete mode + * @param deleteSubFolders Indicates whether sub-folder should also be deleted. + */ + public void empty(DeleteMode deletemode, boolean deleteSubFolders) + throws Exception { + this.throwIfThisIsNew(); + this.getService().emptyFolder(this.getId(), + deletemode, deleteSubFolders); + } + + /** + * Saves this folder in a specific folder. Calling this method results in a + * call to EWS. + * + * @param parentFolderId The Id of the folder in which to save this folder. + * @throws Exception the exception + */ + public void save(FolderId parentFolderId) throws Exception { + this.throwIfThisIsNotNew(); + + EwsUtilities.validateParam(parentFolderId, "parentFolderId"); + + if (this.isDirty()) { + this.getService().createFolder(this, parentFolderId); + } + } + + /** + * Saves this folder in a specific folder. Calling this method results in a + * call to EWS. + * + * @param parentFolderName The name of the folder in which to save this folder. + * @throws Exception the exception + */ + public void save(WellKnownFolderName parentFolderName) throws Exception { + this.save(new FolderId(parentFolderName)); + } + + /** + * Applies the local changes that have been made to this folder. Calling + * this method results in a call to EWS. + * + * @throws Exception the exception + */ + public void update() throws Exception { + if (this.isDirty()) { + if (this.getPropertyBag().getIsUpdateCallNecessary()) { + this.getService().updateFolder(this); + } + } + } + + /** + * Copies this folder into a specific folder. Calling this method results in + * a call to EWS. + * + * @param destinationFolderId The Id of the folder in which to copy this folder. + * @return A Folder representing the copy of this folder. + * @throws Exception the exception + */ + public Folder copy(FolderId destinationFolderId) throws Exception { + this.throwIfThisIsNew(); + + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + + return this.getService().copyFolder(this.getId(), destinationFolderId); + } + + /** + * Copies this folder into the specified folder. Calling this method results + * in a call to EWS. + * + * @param destinationFolderName The name of the folder in which to copy this folder. + * @return A Folder representing the copy of this folder. + * @throws Exception the exception + */ + public Folder copy(WellKnownFolderName destinationFolderName) + throws Exception { + return this.copy(new FolderId(destinationFolderName)); + } + + /** + * Moves this folder to a specific folder. Calling this method results in a + * call to EWS. + * + * @param destinationFolderId The Id of the folder in which to move this folder. + * @return A new folder representing this folder in its new location. After + * Move completes, this folder does not exist anymore. + * @throws Exception the exception + */ + public Folder move(FolderId destinationFolderId) throws Exception { + this.throwIfThisIsNew(); + + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + + return this.getService().moveFolder(this.getId(), destinationFolderId); + } + + /** + * Moves this folder to a specific folder. Calling this method results in a + * call to EWS. + * + * @param destinationFolderName The name of the folder in which to move this folder. + * @return A new folder representing this folder in its new location. After + * Move completes, this folder does not exist anymore. + * @throws Exception the exception + */ + public Folder move(WellKnownFolderName destinationFolderName) + throws Exception { + return this.move(new FolderId(destinationFolderName)); + } + + /** + * Find item. + * + * @param The type of the item. + * @param queryString query string to be used for indexed search + * @param view The view controlling the number of item returned. + * @param groupBy The group by. + * @return FindItems response collection. + * @throws Exception the exception + */ + ServiceResponseCollection> + internalFindItems(String queryString, ViewBase view, Grouping groupBy) + throws Exception { + ArrayList folderIdArry = new ArrayList<>(); + folderIdArry.add(this.getId()); + + this.throwIfThisIsNew(); + return this.getService().findItems(folderIdArry, + null, /* searchFilter */ + queryString, view, groupBy, ServiceErrorHandling.ThrowOnError); + + } + + /** + * Find item. + * + * @param The type of the item. + * @param searchFilter The search filter. Available search filter classes include + * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection + * @param view The view controlling the number of item returned. + * @param groupBy The group by. + * @return FindItems response collection. + * @throws Exception the exception + */ + ServiceResponseCollection> + internalFindItems(SearchFilter searchFilter, + ViewBase view, Grouping groupBy) + throws Exception { + ArrayList folderIdArry = new ArrayList<>(); + folderIdArry.add(this.getId()); + this.throwIfThisIsNew(); + + return this.getService().findItems(folderIdArry, searchFilter, + null, /* queryString */ + view, groupBy, ServiceErrorHandling.ThrowOnError); + } + + /** + * Find item. + * + * @param searchFilter The search filter. Available search filter classes include + * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection + * @param view The view controlling the number of item returned. + * @return FindItems results collection. + * @throws Exception the exception + */ + public FindItemsResults findItems(SearchFilter searchFilter, + ItemView view) throws Exception { + EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); + + ServiceResponseCollection> responses = this + .internalFindItems(searchFilter, view, null /* groupBy */); + + return responses.getResponseAtIndex(0).getResults(); + } + + /** + * Find item. + * + * @param queryString query string to be used for indexed search + * @param view The view controlling the number of item returned. + * @return FindItems results collection. + * @throws Exception the exception + */ + public FindItemsResults findItems(String queryString, ItemView view) + throws Exception { + EwsUtilities.validateParamAllowNull(queryString, "queryString"); + + ServiceResponseCollection> responses = this + .internalFindItems(queryString, view, null /* groupBy */); + + return responses.getResponseAtIndex(0).getResults(); + } + + /** + * Find item. + * + * @param view The view controlling the number of item returned. + * @return FindItems results collection. + * @throws Exception the exception + */ + public FindItemsResults findItems(ItemView view) throws Exception { + ServiceResponseCollection> responses = this + .internalFindItems((SearchFilter) null, view, + null /* groupBy */); + + return responses.getResponseAtIndex(0).getResults(); + } + + /** + * Find item. + * + * @param searchFilter The search filter. Available search filter classes include + * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection + * @param view The view controlling the number of item returned. + * @param groupBy The group by. + * @return A collection of grouped item representing the contents of this + * folder. + * @throws Exception the exception + */ + public GroupedFindItemsResults findItems(SearchFilter searchFilter, + ItemView view, Grouping groupBy) throws Exception { + EwsUtilities.validateParam(groupBy, "groupBy"); + EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); + + ServiceResponseCollection> responses = this + .internalFindItems(searchFilter, view, groupBy); + + return responses.getResponseAtIndex(0).getGroupedFindResults(); + } + + /** + * Find item. + * + * @param queryString query string to be used for indexed search + * @param view The view controlling the number of item returned. + * @param groupBy The group by. + * @return A collection of grouped item representing the contents of this + * folder. + * @throws Exception the exception + */ + public GroupedFindItemsResults findItems(String queryString, + ItemView view, Grouping groupBy) throws Exception { + EwsUtilities.validateParam(groupBy, "groupBy"); + + ServiceResponseCollection> responses = this + .internalFindItems(queryString, view, groupBy); + + return responses.getResponseAtIndex(0).getGroupedFindResults(); + } + + /** + * Obtains a list of folder by searching the sub-folder of this folder. + * Calling this method results in a call to EWS. + * + * @param view The view controlling the number of folder returned. + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindFoldersResults findFolders(FolderView view) throws Exception { + this.throwIfThisIsNew(); + + return this.getService().findFolders(this.getId(), view); + } + + /** + * Obtains a list of folder by searching the sub-folder of this folder. + * Calling this method results in a call to EWS. + * + * @param searchFilter The search filter. Available search filter classes include + * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection + * @param view The view controlling the number of folder returned. + * @return An object representing the results of the search operation. + * @throws Exception the exception + */ + public FindFoldersResults findFolders(SearchFilter searchFilter, + FolderView view) throws Exception { + this.throwIfThisIsNew(); + + return this.getService().findFolders(this.getId(), searchFilter, view); + } + + /** + * Obtains a grouped list of item by searching the contents of this folder. + * Calling this method results in a call to EWS. + * + * @param view The view controlling the number of folder returned. + * @param groupBy The grouping criteria. + * @return A collection of grouped item representing the contents of this + * folder. + * @throws Exception the exception + */ + public GroupedFindItemsResults findItems(ItemView view, + Grouping groupBy) throws Exception { + EwsUtilities.validateParam(groupBy, "groupBy"); + + return this.findItems((SearchFilter) null, view, groupBy); + } + + /** + * Get the property definition for the Id property. + * + * @return the id property definition + */ + @Override + public PropertyDefinition getIdPropertyDefinition() { + return FolderSchema.Id; + } + + /** + * Sets the extended property. + * + * @param extendedPropertyDefinition The extended property definition. + * @param value The value. + * @throws Exception the exception + */ + public void setExtendedProperty( + ExtendedPropertyDefinition extendedPropertyDefinition, Object value) + throws Exception { + this.getExtendedProperties().setExtendedProperty( + extendedPropertyDefinition, value); + } + + /** + * Removes an extended property. + * + * @param extendedPropertyDefinition The extended property definition. + * @return True if property was removed. + * @throws Exception the exception + */ + public boolean removeExtendedProperty( + ExtendedPropertyDefinition extendedPropertyDefinition) + throws Exception { + return this.getExtendedProperties().removeExtendedProperty( + extendedPropertyDefinition); + } + + /** + * True if property was removed. + * + * @return Extended property collection. + * @throws Exception the exception + */ + @Override + protected ExtendedPropertyCollection getExtendedProperties() + throws Exception { + return this.getExtendedPropertiesForService(); + } + + /** + * Gets the Id of the folder. + * + * @return the id + */ + public FolderId getId() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(getIdPropertyDefinition()); + } + + /** + * Gets the Id of this folder's parent folder. + * + * @return the parent folder id + */ + public FolderId getParentFolderId() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(FolderSchema.ParentFolderId); + } + + /** + * Gets the number of child folder this folder has. + * + * @return the child folder count + * @throws NumberFormatException the number format exception + */ + public int getChildFolderCount() throws NumberFormatException, + ExchangeXmlException { + // TODO: this is super terrible, get rid of the number format exception! + return (Integer.parseInt(this.getPropertyBag().getObjectFromPropertyDefinition(FolderSchema.ChildFolderCount).toString())); + } + + /** + * Gets the display name of the folder. + * + * @return the display name + */ + public String getDisplayName() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + FolderSchema.DisplayName); + } + + /** + * Sets the display name of the folder. + * + * @param value Name of the folder + * @throws Exception the exception + */ + public void setDisplayName(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + FolderSchema.DisplayName, value); + } + + /** + * Gets the custom class name of this folder. + * + * @return the folder class + * @throws ServiceLocalException the service local exception + */ + public String getFolderClass() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + FolderSchema.FolderClass); + } + + /** + * Sets the custom class name of this folder. + * + * @param value name of the folder + * @throws Exception the exception + */ + public void setFolderClass(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + FolderSchema.FolderClass, value); + } + + /** + * Gets the total number of item contained in the folder. + * + * @return the total count + * @throws NumberFormatException the number format exception + */ + public int getTotalCount() throws NumberFormatException, + ExchangeXmlException { + return (Integer.parseInt(this.getPropertyBag() + .getObjectFromPropertyDefinition(FolderSchema.TotalCount) + .toString())); + } + + /** + * Gets a list of extended property associated with the folder. + * + * @return the extended property for service + */ + // changed the name of method as another method with same name exists + public ExtendedPropertyCollection getExtendedPropertiesForService() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ServiceObjectSchema.extendedProperties); + } + + /** + * Gets the Email Lifecycle Management (ELC) information associated with the + * folder. + * + * @return the managed folder information + */ + public ManagedFolderInformation getManagedFolderInformation() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + FolderSchema.ManagedFolderInformation); + } + + /** + * Gets a value indicating the effective rights the current authenticated + * user has on the folder. + * + * @return the effective rights + */ + public EnumSet getEffectiveRights() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(FolderSchema.EffectiveRights); + } + + /** + * Gets a list of permissions for the folder. + * + * @return the permissions + * @throws ServiceLocalException the service local exception + */ + public FolderPermissionCollection getPermissions() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + FolderSchema.Permissions); + } + + /** + * Gets the number of unread item in the folder. + * + * @return the unread count + * @throws NumberFormatException the number format exception + */ + public int getUnreadCount() throws NumberFormatException, ExchangeXmlException { + return (Integer.parseInt(this.getPropertyBag() + .getObjectFromPropertyDefinition(FolderSchema.UnreadCount) + .toString())); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/SearchFolder.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/SearchFolder.java new file mode 100644 index 000000000..1ebe00fb3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/SearchFolder.java @@ -0,0 +1,165 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.folder; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.schema.SearchFolderSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.property.complex.FolderId; +import com.eischet.ews.api.property.complex.SearchFolderParameters; + +/** + * Represents a search folder. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.SearchFolder, returnedByServer = true) +public class SearchFolder extends Folder { + + /** + * Binds to an existing search folder and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @param propertySet the property set + * @return A SearchFolder instance representing the search folder + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static SearchFolder bind(ExchangeService service, FolderId id, + PropertySet propertySet) throws Exception { + return service.bindToFolder(SearchFolder.class, id, propertySet); + } + + /** + * Binds to an existing search folder and loads its first class property. + * Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @return A SearchFolder instance representing the search folder + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static SearchFolder bind(ExchangeService service, FolderId id) + throws Exception { + return SearchFolder.bind(service, id, PropertySet + .getFirstClassProperties()); + } + + /** + * Binds to an existing search folder and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service the service + * @param name the name + * @param propertySet the property set + * @return A SearchFolder instance representing the search folder with the + * specified name. + * @throws Exception the exception + */ + public static SearchFolder bind(ExchangeService service, + WellKnownFolderName name, PropertySet propertySet) + throws Exception { + return SearchFolder.bind(service, new FolderId(name), propertySet); + } + + /** + * Binds to an existing search folder and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service the service + * @param name the name + * @return A SearchFolder instance representing the search folder with the + * specified name. + * @throws Exception the exception + */ + public static SearchFolder bind(ExchangeService service, + WellKnownFolderName name) throws Exception { + return SearchFolder.bind(service, new FolderId(name), PropertySet + .getFirstClassProperties()); + } + + /** + * Initializes an unsaved local instance of the class. To bind to an + * existing search folder, use SearchFolder.Bind() instead. + * + * @param service the service + * @throws Exception the exception + */ + public SearchFolder(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return SearchFolderSchema.Instance; + } + + /** + * Validates this instance. + * + * @throws Exception the exception + */ + @Override + public void validate() throws Exception { + super.validate(); + if (this.getSearchParameters() != null) { + this.getSearchParameters().validate(); + } + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the search parameters associated with the search folder. + * + * @return the search parameters + * @throws Exception the exception + */ + public SearchFolderParameters getSearchParameters() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition( + SearchFolderSchema.SearchParameters); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/TasksFolder.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/TasksFolder.java new file mode 100644 index 000000000..a36465d37 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/folder/TasksFolder.java @@ -0,0 +1,126 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.folder; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.FolderId; + +/** + * Represents a folder containing task item. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.TasksFolder) +public class TasksFolder extends Folder { + + /** + * Initializes an unsaved local instance of the class. + * + * @param service the service + * @throws Exception the exception + */ + public TasksFolder(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Binds to an existing tasks folder and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @param propertySet the property set + * @return A TasksFolder instance representing the task folder corresponding + * to the specified Id. + * @throws Exception the exception + */ + public static TasksFolder bind(ExchangeService service, FolderId id, + PropertySet propertySet) throws Exception { + return service.bindToFolder(TasksFolder.class, id, propertySet); + } + + /** + * Binds to an existing tasks folder and loads its first class property. + * Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @return A TasksFolder instance representing the task folder corresponding + * to the specified Id. + * @throws Exception the exception + */ + public static TasksFolder bind(ExchangeService service, FolderId id) + throws Exception { + return TasksFolder.bind(service, id, PropertySet + .getFirstClassProperties()); + } + + /** + * Binds to an existing tasks folder and loads specified set of property. + * Calling this method results in a call to EWS. + * + * @param service the service + * @param name the name + * @param propertySet the property set + * @return A TasksFolder instance representing the tasks folder with the + * specified name. + * @throws Exception the exception + */ + public static TasksFolder bind(ExchangeService service, + WellKnownFolderName name, PropertySet propertySet) + throws Exception { + return TasksFolder.bind(service, new FolderId(name), propertySet); + } + + /** + * Binds to an existing tasks folder and loads its first class property. + * Calling this method results in a call to EWS. + * + * @param service the service + * @param name the name + * @return A TasksFolder instance representing the tasks folder with the + * specified name. + * @throws Exception the exception + */ + public static TasksFolder bind(ExchangeService service, + WellKnownFolderName name) throws Exception { + return TasksFolder.bind(service, new FolderId(name), PropertySet + .getFirstClassProperties()); + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Appointment.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Appointment.java new file mode 100644 index 000000000..175ec34d6 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Appointment.java @@ -0,0 +1,1213 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.attribute.Attachable; +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.LegacyFreeBusyStatus; +import com.eischet.ews.api.core.enumeration.property.MeetingResponseType; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.enumeration.service.*; +import com.eischet.ews.api.core.enumeration.service.calendar.AppointmentType; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.response.AcceptMeetingInvitationMessage; +import com.eischet.ews.api.core.service.response.CancelMeetingMessage; +import com.eischet.ews.api.core.service.response.DeclineMeetingInvitationMessage; +import com.eischet.ews.api.core.service.response.ResponseMessage; +import com.eischet.ews.api.core.service.schema.AppointmentSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.misc.CalendarActionResults; +import com.eischet.ews.api.misc.TimeSpan; +import com.eischet.ews.api.property.complex.*; +import com.eischet.ews.api.property.complex.recurrence.pattern.Recurrence; +import com.eischet.ews.api.property.complex.time.TimeZoneDefinition; + +import java.time.LocalDateTime; +import java.util.Arrays; + +/** + * Represents an appointment or a meeting. Properties available on appointments + * are defined in the AppointmentSchema class. + */ +@Attachable +@ServiceObjectDefinition(xmlElementName = XmlElementNames.CalendarItem) +public class Appointment extends Item implements ICalendarActionProvider { + + /** + * Initializes an unsaved local instance of Appointment". To bind to an + * existing appointment, use Appointment.Bind() instead. + * + * @param service The ExchangeService instance to which this appointmtnt is + * bound. + * @throws Exception the exception + */ + public Appointment(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Initializes a new instance of Appointment. + * + * @param parentAttachment the parent attachment + * @param isNew If true, attachment is new. + * @throws Exception the exception + */ + public Appointment(ItemAttachment parentAttachment, boolean isNew) throws ExchangeXmlException { + // If we're running against Exchange 2007, we need to explicitly preset + // the StartTimeZone property since Exchange 2007 will otherwise scope + // start and end to UTC. + super(parentAttachment); + } + + /** + * Binds to an existing appointment and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @param propertySet the property set + * @return An Appointment instance representing the appointment + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static Appointment bind(ExchangeService service, ItemId id, + PropertySet propertySet) throws Exception { + return service.bindToItem(Appointment.class, id, propertySet); + } + + /** + * Binds to an existing appointment and loads its first class property. + * Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @return An Appointment instance representing the appointment + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static Appointment bind(ExchangeService service, ItemId id) + throws Exception { + return Appointment.bind(service, id, PropertySet.FirstClassProperties); + } + + /** + * Binds to an existing appointment and loads its first class property. + * Calling this method results in a call to EWS. + * + * @param service the service + * @param recurringMasterId the recurring master id + * @param occurenceIndex the occurence index + * @return An Appointment instance representing the appointment + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static Appointment bindToOccurrence(ExchangeService service, + ItemId recurringMasterId, int occurenceIndex) throws Exception { + return Appointment.bindToOccurrence(service, recurringMasterId, + occurenceIndex, PropertySet.FirstClassProperties); + } + + /** + * Binds to an existing appointment and loads its first class property. + * Calling this method results in a call to EWS. + * + * @param service the service + * @param recurringMasterId the recurring master id + * @param occurenceIndex the occurence index + * @param propertySet the property set + * @return An Appointment instance representing the appointment + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static Appointment bindToOccurrence(ExchangeService service, + ItemId recurringMasterId, int occurenceIndex, + PropertySet propertySet) throws Exception { + AppointmentOccurrenceId occurenceId = new AppointmentOccurrenceId( + recurringMasterId.getUniqueId(), occurenceIndex); + return Appointment.bind(service, occurenceId, propertySet); + } + + /** + * Binds to the master appointment of a recurring series and loads its first + * class property. Calling this method results in a call to EWS. + * + * @param service the service + * @param occurrenceId the occurrence id + * @return An Appointment instance representing the appointment + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static Appointment bindToRecurringMaster(ExchangeService service, + ItemId occurrenceId) throws Exception { + return Appointment.bindToRecurringMaster(service, occurrenceId, + PropertySet.FirstClassProperties); + } + + /** + * Binds to the master appointment of a recurring series and loads its first + * class property. Calling this method results in a call to EWS. + * + * @param service the service + * @param occurrenceId the occurrence id + * @param propertySet the property set + * @return An Appointment instance representing the appointment + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static Appointment bindToRecurringMaster(ExchangeService service, + ItemId occurrenceId, PropertySet propertySet) throws Exception { + RecurringAppointmentMasterId recurringMasterId = + new RecurringAppointmentMasterId( + occurrenceId.getUniqueId()); + return Appointment.bind(service, recurringMasterId, propertySet); + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object + */ + @Override + public ServiceObjectSchema getSchema() { + return AppointmentSchema.Instance; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Determines whether property defined with + * ScopedDateTimePropertyDefinition require custom time zone scoping. + * + * @return if this item type requires custom scoping for scoped date/time + * property; otherwise, . + */ + @Override + protected boolean getIsCustomDateTimeScopingRequired() { + return true; + } + + /** + * Validates this instance. + * + * @throws Exception + */ + @Override + public void validate() throws Exception { + super.validate(); + + // PS # 250452: Make sure that if we're + //on the Exchange2007_SP1 schema version, + // if any of the following + // property are set or updated: + // o Start + // o End + // o IsAllDayEvent + // o Recurrence + // ... then, we must send the MeetingTimeZone element + // (which is generated from StartTimeZone for + // Exchange2007_SP1 request (see + //StartTimeZonePropertyDefinition.cs). + // If the StartTimeZone isn't + // in the property bag, then throw, because clients must + // supply the proper time zone - either by + // loading it from a currently-existing appointment, + //or by setting it directly. + // Otherwise, to dirty + // the StartTimeZone property, we just set it to its current value. + if ((this.getService().getRequestedServerVersion() == ExchangeVersion.Exchange2007_SP1) && + !(this.getService().getExchange2007CompatibilityMode())) { + if (this.getPropertyBag().isPropertyUpdated(AppointmentSchema.Start) || + this.getPropertyBag().isPropertyUpdated(AppointmentSchema.End) || + this.getPropertyBag().isPropertyUpdated(AppointmentSchema.IsAllDayEvent) || + this.getPropertyBag().isPropertyUpdated(AppointmentSchema.Recurrence)) { + // If the property isn't in the property bag, throw.... + if (!this.getPropertyBag().contains(AppointmentSchema.StartTimeZone)) { + throw new ServiceLocalException("StartTimeZone required when setting the Start, End, IsAllDayEvent, " + + "or Recurrence property. You must load or assign this property " + + "before attempting to update the appointment."); + //getStartTimeZoneRequired()); + } + + // Otherwise, set the time zone to its current value to + // force it to be sent with the request. + this.setStartTimeZone(this.getStartTimeZone()); + } + } + } + + /** + * Creates a reply response to the organizer and/or attendees of the + * meeting. + * + * @param replyAll the reply all + * @return A ResponseMessage representing the reply response that can + * subsequently be modified and sent. + * @throws Exception the exception + */ + public ResponseMessage createReply(boolean replyAll) throws Exception { + this.throwIfThisIsNew(); + + return new ResponseMessage(this, + replyAll ? ResponseMessageType.ReplyAll : + ResponseMessageType.Reply); + } + + /** + * Replies to the organizer and/or the attendees of the meeting. Calling + * this method results in a call to EWS. + * + * @param bodyPrefix the body prefix + * @param replyAll the reply all + * @throws Exception the exception + */ + public void reply(MessageBody bodyPrefix, boolean replyAll) + throws Exception { + ResponseMessage responseMessage = this.createReply(replyAll); + + responseMessage.setBodyPrefix(bodyPrefix); + responseMessage.sendAndSaveCopy(); + } + + /** + * Creates a forward message from this appointment. + * + * @return A ResponseMessage representing the forward response that can + * subsequently be modified and sent. + * @throws Exception the exception + */ + public ResponseMessage createForward() throws Exception { + this.throwIfThisIsNew(); + return new ResponseMessage(this, ResponseMessageType.Forward); + } + + /** + * Forwards the appointment. Calling this method results in a call to EWS. + * + * @param bodyPrefix the body prefix + * @param toRecipients the to recipients + * @throws Exception the exception + */ + public void forward(MessageBody bodyPrefix, EmailAddress... toRecipients) + throws Exception { + if (null != toRecipients) { + forward(bodyPrefix, Arrays.asList(toRecipients)); + } + } + + /** + * Forwards the appointment. Calling this method results in a call to EWS. + * + * @param bodyPrefix the body prefix + * @param toRecipients the to recipients + * @throws Exception the exception + */ + public void forward(MessageBody bodyPrefix, + Iterable toRecipients) throws Exception { + ResponseMessage responseMessage = this.createForward(); + + responseMessage.setBodyPrefix(bodyPrefix); + responseMessage.getToRecipients() + .addEmailRange(toRecipients.iterator()); + + responseMessage.sendAndSaveCopy(); + } + + /** + * Saves this appointment in the specified folder. Calling this method + * results in at least one call to EWS. Mutliple calls to EWS might be made + * if attachments have been added. + * + * @param destinationFolderName the destination folder name + * @param sendInvitationsMode the send invitations mode + * @throws Exception the exception + */ + public void save(WellKnownFolderName destinationFolderName, + SendInvitationsMode sendInvitationsMode) throws Exception { + this.internalCreate(new FolderId(destinationFolderName), null, + sendInvitationsMode); + } + + /** + * Saves this appointment in the specified folder. Calling this method + * results in at least one call to EWS. Mutliple calls to EWS might be made + * if attachments have been added. + * + * @param destinationFolderId the destination folder id + * @param sendInvitationsMode the send invitations mode + * @throws Exception the exception + */ + public void save(FolderId destinationFolderId, + SendInvitationsMode sendInvitationsMode) throws Exception { + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + + this.internalCreate(destinationFolderId, null, sendInvitationsMode); + } + + /** + * Saves this appointment in the Calendar folder. Calling this method + * results in at least one call to EWS. Mutliple calls to EWS might be made + * if attachments have been added. + * + * @param sendInvitationsMode the send invitations mode + * @throws Exception the exception + */ + public void save(SendInvitationsMode sendInvitationsMode) throws Exception { + this.internalCreate(null, null, sendInvitationsMode); + } + + /** + * Applies the local changes that have been made to this appointment. + * Calling this method results in at least one call to EWS. Mutliple calls + * to EWS might be made if attachments have been added or removed. + * + * @param conflictResolutionMode the conflict resolution mode + * @param sendInvitationsOrCancellationsMode the send invitations or cancellations mode + * @throws Exception the exception + */ + public void update( + ConflictResolutionMode conflictResolutionMode, + SendInvitationsOrCancellationsMode + sendInvitationsOrCancellationsMode) + throws Exception { + this.internalUpdate(null, conflictResolutionMode, null, + sendInvitationsOrCancellationsMode); + } + + /** + * Deletes this appointment. Calling this method results in a call to EWS. + * + * @param deleteMode the delete mode + * @param sendCancellationsMode the send cancellations mode + * @throws Exception the exception + */ + public void delete(DeleteMode deleteMode, + SendCancellationsMode sendCancellationsMode) throws Exception { + this.internalDelete(deleteMode, sendCancellationsMode, null); + } + + /** + * Creates a local meeting acceptance message that can be customized and + * sent. + * + * @param tentative the tentative + * @return An AcceptMeetingInvitationMessage representing the meeting + * acceptance message. + * @throws Exception the exception + */ + public AcceptMeetingInvitationMessage createAcceptMessage(boolean tentative) + throws Exception { + return new AcceptMeetingInvitationMessage(this, tentative); + } + + /** + * Creates a local meeting acceptance message that can be customized and + * sent. + * + * @return A CancelMeetingMessage representing the meeting cancellation + * message. + * @throws Exception the exception + */ + public CancelMeetingMessage createCancelMeetingMessage() throws Exception { + return new CancelMeetingMessage(this); + } + + /** + * Creates a local meeting declination message that can be customized and + * sent. + * + * @return A DeclineMeetingInvitation representing the meeting declination + * message. + * @throws Exception the exception + */ + public DeclineMeetingInvitationMessage createDeclineMessage() + throws Exception { + return new DeclineMeetingInvitationMessage(this); + } + + /** + * Accepts the meeting. Calling this method results in a call to EWS. + * + * @param sendResponse the send response + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + public CalendarActionResults accept(boolean sendResponse) throws Exception { + return this.internalAccept(false, sendResponse); + } + + /** + * Tentatively accepts the meeting. Calling this method results in a call to + * EWS. + * + * @param sendResponse the send response + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + public CalendarActionResults acceptTentatively(boolean sendResponse) + throws Exception { + return this.internalAccept(true, sendResponse); + } + + /** + * Accepts the meeting. + * + * @param tentative the tentative + * @param sendResponse the send response + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + protected CalendarActionResults internalAccept(boolean tentative, + boolean sendResponse) throws Exception { + AcceptMeetingInvitationMessage accept = this + .createAcceptMessage(tentative); + + if (sendResponse) { + return accept.calendarSendAndSaveCopy(); + } else { + return accept.calendarSave(); + } + } + + /** + * Cancels the meeting and sends cancellation messages to all attendees. + * Calling this method results in a call to EWS. + * + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + public CalendarActionResults cancelMeeting() throws Exception { + return this.createCancelMeetingMessage().calendarSendAndSaveCopy(); + } + + /** + * Cancels the meeting and sends cancellation messages to all attendees. + * Calling this method results in a call to EWS. + * + * @param cancellationMessageText the cancellation message text + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + public CalendarActionResults cancelMeeting(String cancellationMessageText) + throws Exception { + CancelMeetingMessage cancelMsg = this.createCancelMeetingMessage(); + cancelMsg.setBody(new MessageBody(cancellationMessageText)); + return cancelMsg.calendarSendAndSaveCopy(); + } + + /** + * Declines the meeting invitation. Calling this method results in a call to + * EWS. + * + * @param sendResponse the send response + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + public CalendarActionResults decline(boolean + sendResponse) throws Exception { + DeclineMeetingInvitationMessage decline = this.createDeclineMessage(); + + if (sendResponse) { + return decline.calendarSendAndSaveCopy(); + } else { + return decline.calendarSave(); + } + } + + /** + * Gets the default setting for sending cancellations on Delete. + * + * @return If Delete() is called on Appointment, we want to send + * cancellations and save a copy. + */ + @Override + protected SendCancellationsMode getDefaultSendCancellationsMode() { + return SendCancellationsMode.SendToAllAndSaveCopy; + } + + /** + * Gets the default settings for sending invitations on Save. + * + * @return the default send invitations mode + */ + @Override + protected SendInvitationsMode getDefaultSendInvitationsMode() { + return SendInvitationsMode.SendToAllAndSaveCopy; + } + + /** + * Gets the default settings for sending invitations on Save. + * + * @return the default send invitations or cancellations mode + */ + @Override + protected SendInvitationsOrCancellationsMode + getDefaultSendInvitationsOrCancellationsMode() { + return SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy; + } + + // Properties + + /** + * Gets the start time of the appointment. + * + * @return the start + * @throws ServiceLocalException the service local exception + */ + public LocalDateTime getStart() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.Start); + } + + /** + * Sets the start. + * + * @param value the new start + * @throws Exception the exception + */ + public void setStart(LocalDateTime value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.Start, value); + } + + /** + * Gets or sets the end time of the appointment. + * + * @return the end + */ + public LocalDateTime getEnd() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.End); + } + + /** + * Sets the end. + * + * @param value the new end + * @throws Exception the exception + */ + public void setEnd(LocalDateTime value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.End, value); + } + + /** + * Gets the original start time of this appointment. + * + * @return the original start + */ + public LocalDateTime getOriginalStart() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(AppointmentSchema.OriginalStart); + } + + /** + * Gets a value indicating whether this appointment is an all day + * event. + * + * @return the checks if is all day event + */ + public Boolean getIsAllDayEvent() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.IsAllDayEvent); + } + + /** + * Sets the checks if is all day event. + * + * @param value the new checks if is all day event + * @throws Exception the exception + */ + public void setIsAllDayEvent(Boolean value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.IsAllDayEvent, value); + } + + /** + * Gets a value indicating the free/busy status of the owner of this + * appointment. + * + * @return the legacy free busy status + */ + public LegacyFreeBusyStatus getLegacyFreeBusyStatus() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.LegacyFreeBusyStatus); + } + + /** + * Sets the legacy free busy status. + * + * @param value the new legacy free busy status + * @throws Exception the exception + */ + public void setLegacyFreeBusyStatus(LegacyFreeBusyStatus value) + throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.LegacyFreeBusyStatus, value); + } + + /** + * Gets the location of this appointment. + * + * @return the location + */ + public String getLocation() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.Location); + } + + /** + * Sets the location. + * + * @param value the new location + * @throws Exception the exception + */ + public void setLocation(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.Location, value); + } + + /** + * Gets a text indicating when this appointment occurs. The text returned by + * When is localized using the Exchange Server culture or using the culture + * specified in the PreferredCulture property of the ExchangeService object + * this appointment is bound to. + * + * @return the when + */ + public String getWhen() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(AppointmentSchema.When); + } + + /** + * Gets a value indicating whether the appointment is a meeting. + * + * @return the checks if is meeting + */ + public Boolean getIsMeeting() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.IsMeeting); + } + + /** + * Gets a value indicating whether the appointment has been cancelled. + * + * @return the checks if is cancelled + */ + public Boolean getIsCancelled() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.IsCancelled); + } + + /** + * Gets a value indicating whether the appointment is recurring. + * + * @return the checks if is recurring + */ + public Boolean getIsRecurring() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.IsRecurring); + } + + /** + * Gets a value indicating whether the meeting request has already been + * sent. + * + * @return the meeting request was sent + */ + public Boolean getMeetingRequestWasSent() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.MeetingRequestWasSent); + } + + /** + * Gets a value indicating whether response are requested when + * invitations are sent for this meeting. + * + * @return the checks if is response requested + */ + public Boolean getIsResponseRequested() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.IsResponseRequested); + } + + /** + * Sets the checks if is response requested. + * + * @param value the new checks if is response requested + * @throws Exception the exception + */ + public void setIsResponseRequested(Boolean value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.IsResponseRequested, value); + } + + /** + * Gets a value indicating the type of this appointment. + * + * @return the appointment type + */ + public AppointmentType getAppointmentType() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.AppointmentType); + } + + /** + * Gets a value indicating what was the last response of the user that + * loaded this meeting. + * + * @return the my response type + * @throws ServiceLocalException the service local exception + */ + public MeetingResponseType getMyResponseType() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.MyResponseType); + } + + /** + * Gets the organizer of this meeting. The Organizer property is read-only + * and is only relevant for attendees. The organizer of a meeting is + * automatically set to the user that created the meeting. + * + * @return the organizer + */ + public EmailAddress getOrganizer() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.Organizer); + } + + /** + * Gets a list of required attendees for this meeting. + * + * @return the required attendees + * @throws ServiceLocalException the service local exception + */ + public AttendeeCollection getRequiredAttendees() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.RequiredAttendees); + } + + /** + * Gets a list of optional attendeed for this meeting. + * + * @return the optional attendees + */ + public AttendeeCollection getOptionalAttendees() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.OptionalAttendees); + } + + /** + * Gets a list of resources for this meeting. + * + * @return the resources + */ + public AttendeeCollection getResources() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.Resources); + } + + /** + * Gets the number of calendar entries that conflict with this appointment + * in the authenticated user's calendar. + * + * @return the conflicting meeting count + */ + public Integer getConflictingMeetingCount() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.ConflictingMeetingCount); + } + + /** + * Gets the number of calendar entries that are adjacent to this appointment + * in the authenticated user's calendar. + * + * @return the adjacent meeting count + */ + public Integer getAdjacentMeetingCount() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.AdjacentMeetingCount); + } + + /** + * Gets a list of meetings that conflict with this appointment in the + * authenticated user's calendar. + * + * @return the conflicting meetings + */ + public ItemCollection getConflictingMeetings() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.ConflictingMeetings); + } + + /** + * Gets a list of meetings that conflict with this appointment in the + * authenticated user's calendar. + * + * @return the adjacent meetings + */ + public ItemCollection getAdjacentMeetings() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.AdjacentMeetings); + } + + /** + * Gets the duration of this appointment. + * + * @return the duration + */ + public TimeSpan getDuration() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.Duration); + } + + /** + * Gets the name of the time zone this appointment is defined in. + * + * @return the time zone + * @throws ServiceLocalException the service local exception + */ + public String getTimeZone() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.TimeZone); + } + + /** + * Gets the time when the attendee replied to the meeting request. + * + * @return the appointment reply time + */ + public LocalDateTime getAppointmentReplyTime() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.AppointmentReplyTime); + } + + /** + * Gets the sequence number of this appointment. + * + * @return the appointment sequence number + */ + public Integer getAppointmentSequenceNumber() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.AppointmentSequenceNumber); + } + + /** + * Gets the state of this appointment. + * + * @return the appointment state + */ + public Integer getAppointmentState() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.AppointmentState); + } + + /** + * Gets the recurrence pattern for this appointment. Available + * recurrence pattern classes include Recurrence.DailyPattern, + * Recurrence.MonthlyPattern and Recurrence.YearlyPattern. + * + * @return the recurrence + */ + public Recurrence getRecurrence() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.Recurrence); + } + + /** + * Sets the recurrence. + * + * @param value the new recurrence + * @throws Exception the exception + */ + public void setRecurrence(Recurrence value) throws Exception { + if (value != null) { + if (value.isRegenerationPattern()) { + throw new ServiceLocalException("Regeneration pattern can only be used with Task item."); + } + } + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.Recurrence, value); + } + + /** + * Gets an OccurrenceInfo identifying the first occurrence of this meeting. + * + * @return the first occurrence + */ + public OccurrenceInfo getFirstOccurrence() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.FirstOccurrence); + } + + /** + * Gets an OccurrenceInfo identifying the first occurrence of this meeting. + * + * @return the last occurrence + */ + public OccurrenceInfo getLastOccurrence() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.LastOccurrence); + } + + /** + * Gets a list of modified occurrences for this meeting. + * + * @return the modified occurrences + */ + public OccurrenceInfoCollection getModifiedOccurrences() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.ModifiedOccurrences); + } + + /** + * Gets a list of deleted occurrences for this meeting. + * + * @return the deleted occurrences + */ + public DeletedOccurrenceInfoCollection getDeletedOccurrences() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.DeletedOccurrences); + } + + /** + * Gets the start time zone. + * + * @return the start time zone + */ + public TimeZoneDefinition getStartTimeZone() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.StartTimeZone); + } + + /** + * Sets the start time zone. + * + * @param value the new start time zone + * @throws Exception the exception + */ + public void setStartTimeZone(TimeZoneDefinition value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.StartTimeZone, value); + + } + + /** + * Gets the start time zone. + * + * @return the start time zone + */ + public TimeZoneDefinition getEndTimeZone() throws ExchangeXmlException { + return getPropertyBag() + .getObjectFromPropertyDefinition(AppointmentSchema.EndTimeZone); + } + + /** + * Sets the start time zone. + * + * @param value the new end time zone + * @throws Exception the exception + */ + public void setEndTimeZone(TimeZoneDefinition value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.EndTimeZone, value); + + } + + /** + * Gets the type of conferencing that will be used during the + * meeting. + * + * @return the conference type + */ + public Integer getConferenceType() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.ConferenceType); + } + + /** + * Sets the conference type. + * + * @param value the new conference type + * @throws Exception the exception + */ + public void setConferenceType(Integer value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.ConferenceType, value); + } + + /** + * Gets a value indicating whether new time proposals are allowed + * for attendees of this meeting. + * + * @return the allow new time proposal + */ + public Boolean getAllowNewTimeProposal() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.AllowNewTimeProposal); + } + + /** + * Sets the allow new time proposal. + * + * @param value the new allow new time proposal + * @throws Exception the exception + */ + public void setAllowNewTimeProposal(Boolean value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.AllowNewTimeProposal, value); + } + + /** + * Gets a value indicating whether this is an online meeting. + * + * @return the checks if is online meeting + */ + public Boolean getIsOnlineMeeting() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.IsOnlineMeeting); + } + + /** + * Sets the checks if is online meeting. + * + * @param value the new checks if is online meeting + * @throws Exception the exception + */ + public void setIsOnlineMeeting(Boolean value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.IsOnlineMeeting, value); + } + + /** + * Gets the URL of the meeting workspace. A meeting workspace is a + * shared Web site for planning meetings and tracking results. + * + * @return the meeting workspace url + */ + public String getMeetingWorkspaceUrl() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.MeetingWorkspaceUrl); + } + + /** + * Sets the meeting workspace url. + * + * @param value the new meeting workspace url + * @throws Exception the exception + */ + public void setMeetingWorkspaceUrl(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.MeetingWorkspaceUrl, value); + } + + /** + * Gets the URL of the Microsoft NetShow online meeting. + * + * @return the net show url + */ + public String getNetShowUrl() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.NetShowUrl); + } + + /** + * Sets the net show url. + * + * @param value the new net show url + * @throws Exception the exception + */ + public void setNetShowUrl(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.NetShowUrl, value); + } + + /** + * Gets the ICalendar Uid. + * + * @return the i cal uid + */ + public String getICalUid() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.ICalUid); + } + + /** + * Sets the ICalendar Uid. + * + * @param value the i cal uid + * @throws Exception + *///this.PropertyBag[AppointmentSchema.ICalUid] = value; + public void setICalUid(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + AppointmentSchema.ICalUid, value); + } + + /** + * Gets the ICalendar RecurrenceId. + * + * @return the i cal recurrence id + */ + public LocalDateTime getICalRecurrenceId() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.ICalRecurrenceId); + } + + /** + * Gets the ICalendar DateTimeStamp. + * + * @return the i cal date time stamp + */ + public LocalDateTime getICalDateTimeStamp() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.ICalDateTimeStamp); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Contact.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Contact.java new file mode 100644 index 000000000..3b37add04 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Contact.java @@ -0,0 +1,967 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.attribute.Attachable; +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PhysicalAddressIndex; +import com.eischet.ews.api.core.enumeration.service.ContactSource; +import com.eischet.ews.api.core.enumeration.service.FileAsMapping; +import com.eischet.ews.api.core.exception.service.local.PropertyException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.schema.ContactSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.complex.*; + +import java.io.File; +import java.io.InputStream; +import java.time.LocalDate; + +/** + * Represents a contact. Properties available on contacts are defined in the + * ContactSchema class. + */ +@Attachable +@ServiceObjectDefinition(xmlElementName = XmlElementNames.Contact, returnedByServer = true) +public class Contact extends Item { + + /** + * The Contact picture name. + */ + private final String ContactPictureName = "ContactPicture.jpg"; + + /** + * Initializes an unsaved local instance of {@link Contact}. + * To bind to an existing contact, use Contact.Bind() instead. + * + * @param service the service + */ + public Contact(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Initializes a new instance of the {@link Contact} class. + * + * @param parentAttachment the parent attachment + */ + public Contact(ItemAttachment parentAttachment) throws ExchangeXmlException { + super(parentAttachment); + } + + /** + * Binds to an existing contact and loads the specified set of property. + * Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @param propertySet the property set + * @return A Contact instance representing the contact corresponding to the + * specified Id. + * @throws Exception the exception + */ + public static Contact bind(ExchangeService service, ItemId id, + PropertySet propertySet) throws Exception { + return service.bindToItem(Contact.class, id, propertySet); + } + + /** + * Binds to an existing contact and loads its first class property. + * Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @return A Contact instance representing the contact corresponding to the + * specified Id. + * @throws Exception the exception + */ + public static Contact bind(ExchangeService service, ItemId id) + throws Exception { + return Contact.bind(service, id, PropertySet.getFirstClassProperties()); + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return ContactSchema.Instance; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Sets the contact's picture using the specified byte array. + * + * @param content the new contact picture + * @throws Exception the exception + */ + public void setContactPicture(byte[] content) throws Exception { + EwsUtilities.validateMethodVersion(this.getService(), ExchangeVersion.Exchange2010, "SetContactPicture"); + + internalRemoveContactPicture(); + FileAttachment fileAttachment = getAttachments().addFileAttachment( + ContactPictureName, content); + fileAttachment.setIsContactPhoto(true); + } + + /** + * Sets the contact's picture using the specified stream. + * + * @param contentStream the new contact picture + * @throws Exception the exception + */ + public void setContactPicture(InputStream contentStream) throws Exception { + EwsUtilities.validateMethodVersion(this.getService(), + ExchangeVersion.Exchange2010, "SetContactPicture"); + + internalRemoveContactPicture(); + FileAttachment fileAttachment = getAttachments().addFileAttachment( + ContactPictureName, contentStream); + fileAttachment.setIsContactPhoto(true); + } + + /** + * Sets the contact's picture using the specified file. + * + * @param fileName the new contact picture + * @throws Exception the exception + */ + public void setContactPicture(String fileName) throws Exception { + EwsUtilities.validateMethodVersion(this.getService(), + ExchangeVersion.Exchange2010, "SetContactPicture"); + + internalRemoveContactPicture(); + FileAttachment fileAttachment = getAttachments().addFileAttachment( + new File(fileName).getName(), fileName); + fileAttachment.setIsContactPhoto(true); + } + + /** + * Retrieves the file attachment that holds the contact's picture. + * + * @return The file attachment that holds the contact's picture. + * @throws ServiceLocalException the service local exception + */ + public FileAttachment getContactPictureAttachment() throws ExchangeXmlException { + EwsUtilities.validateMethodVersion(this.getService(), + ExchangeVersion.Exchange2010, "GetContactPictureAttachment"); + + if (!this.getPropertyBag().isPropertyLoaded(ContactSchema.Attachments)) { + throw new PropertyException("The attachment collection must be loaded."); + } + + for (Attachment fileAttachment : this.getAttachments()) { + if (fileAttachment instanceof FileAttachment) { + if (((FileAttachment) fileAttachment).isContactPhoto()) { + return (FileAttachment) fileAttachment; + } + } + } + return null; + } + + /** + * Removes the picture from local attachment collection. + * + * @throws Exception the exception + */ + private void internalRemoveContactPicture() throws Exception { + // Iterates in reverse order to remove file attachments that have + // IsContactPhoto set to true. + for (int index = this.getAttachments().getCount() - 1; index >= 0; index--) { + FileAttachment fileAttachment = (FileAttachment) this + .getAttachments().getPropertyAtIndex(index); + if (fileAttachment != null) { + if (fileAttachment.isContactPhoto()) { + this.getAttachments().remove(fileAttachment); + } + } + } + + } + + /** + * Removes the contact's picture. + * + * @throws Exception the exception + */ + public void removeContactPicture() throws Exception { + EwsUtilities.validateMethodVersion(this.getService(), + ExchangeVersion.Exchange2010, "RemoveContactPicture"); + + if (!this.getPropertyBag().isPropertyLoaded(ContactSchema.Attachments)) { + throw new PropertyException("The attachment collection must be loaded."); + } + + internalRemoveContactPicture(); + } + + /** + * Validates this instance. + * + * @throws ServiceVersionException the service version exception + * @throws Exception the exception + */ + @Override + public void validate() throws ServiceVersionException, Exception { + super.validate(); + + Object fileAsMapping; + OutParam outParam = new OutParam(); + if (this.tryGetProperty(ContactSchema.FileAsMapping, outParam)) { + fileAsMapping = outParam.getParam(); + // FileAsMapping is extended by 5 new values in 2010 mode. Validate + // that they are used according the version. + EwsUtilities.validateEnumVersionValue( + (FileAsMapping) fileAsMapping, this.getService() + .getRequestedServerVersion()); + } + } + + /** + * Gets the name under which this contact is filed as. FileAs can be + * manually set or can be automatically calculated based on the value of the + * FileAsMapping property. + * + * @return the file as + * @throws ServiceLocalException the service local exception + */ + public String getFileAs() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.FileAs); + + } + + /** + * Sets the file as. + * + * @param value the new file as + * @throws Exception the exception + */ + public void setFileAs(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.FileAs, value); + } + + /** + * Gets a value indicating how the FileAs property should be + * automatically calculated. + * + * @return the file as mapping + * @throws ServiceLocalException the service local exception + */ + public FileAsMapping getFileAsMapping() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.FileAsMapping); + } + + /** + * Sets the file as. + * + * @param value the new file as + * @throws Exception the exception + */ + public void setFileAs(FileAsMapping value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.FileAsMapping, value); + } + + /** + * Gets the display name of the contact. + * + * @return the display name + * @throws ServiceLocalException the service local exception + */ + public String getDisplayName() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.DisplayName); + } + + /** + * Sets the display name. + * + * @param value the new display name + * @throws Exception the exception + */ + public void setDisplayName(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.DisplayName, value); + } + + /** + * Gets the given name of the contact. + * + * @return the given name + * @throws ServiceLocalException the service local exception + */ + public String getGivenName() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.GivenName); + } + + /** + * Sets the given name. + * + * @param value the new given name + * @throws Exception the exception + */ + public void setGivenName(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.GivenName, value); + } + + /** + * Gets the initials of the contact. + * + * @return the initials + * @throws ServiceLocalException the service local exception + */ + public String getInitials() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.Initials); + } + + /** + * Sets the initials. + * + * @param value the new initials + * @throws Exception the exception + */ + public void setInitials(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.Initials, value); + } + + /** + * Gets the middle name of the contact. + * + * @return the middle name + * @throws ServiceLocalException the service local exception + */ + public String getMiddleName() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.MiddleName); + } + + /** + * Sets the middle name. + * + * @param value the new middle name + * @throws Exception the exception + */ + public void setMiddleName(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.MiddleName, value); + } + + /** + * Gets the nick name of the contact. + * + * @return the nick name + * @throws ServiceLocalException the service local exception + */ + public String getNickName() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.NickName); + } + + /** + * Sets the nick name. + * + * @param value the new nick name + * @throws Exception the exception + */ + public void setNickName(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.NickName, value); + } + + /** + * Gets the complete name of the contact. + * + * @return the complete name + * @throws ServiceLocalException the service local exception + */ + public CompleteName getCompleteName() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.CompleteName); + } + + /** + * Gets the company name of the contact. + * + * @return the company name + * @throws ServiceLocalException the service local exception + */ + public String getCompanyName() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.CompanyName); + } + + /** + * Sets the company name. + * + * @param value the new company name + * @throws Exception the exception + */ + public void setCompanyName(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.CompanyName, value); + } + + /** + * Gets an indexed list of e-mail addresses for the contact. For example, to + * set the first e-mail address, use the following syntax: + * EmailAddresses[EmailAddressKey.EmailAddress1] = "john.doe@contoso.com" + * + * @return the email addresses + * @throws ServiceLocalException the service local exception + */ + public EmailAddressDictionary getEmailAddresses() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.EmailAddresses); + } + + /** + * Gets an indexed list of physical addresses for the contact. For example, + * to set the first business address, use the following syntax: + * physical[PhysicalAddressKey.Business] = new PhysicalAddressEntry() + * + * @return the physical addresses + * @throws ServiceLocalException the service local exception + */ + public PhysicalAddressDictionary getPhysicalAddresses() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.PhysicalAddresses); + } + + /** + * Gets an indexed list of phone numbers for the contact. For example, to + * set the home phone number, use the following syntax: + * PhoneNumbers[PhoneNumberKey.HomePhone] = "phone number" + * + * @return the phone numbers + * @throws ServiceLocalException the service local exception + */ + public PhoneNumberDictionary getPhoneNumbers() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag() + .getObjectFromPropertyDefinition(ContactSchema.PhoneNumbers); + } + + /** + * Gets the contact's assistant name. + * + * @return the assistant name + * @throws ServiceLocalException the service local exception + */ + public String getAssistantName() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.AssistantName); + } + + /** + * Sets the assistant name. + * + * @param value the new assistant name + * @throws Exception the exception + */ + public void setAssistantName(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.AssistantName, value); + } + + /** + * Gets the contact's assistant name. + * + * @return the birthday + * @throws ServiceLocalException the service local exception + */ + public LocalDate getBirthday() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.Birthday); + + } + + /** + * Sets the birthday. + * + * @param value the new birthday + * @throws Exception the exception + */ + public void setBirthday(LocalDate value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.Birthday, value); + } + + /** + * Gets the business home page of the contact. + * + * @return the business home page + * @throws ServiceLocalException the service local exception + */ + public String getBusinessHomePage() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.BusinessHomePage); + + } + + /** + * Sets the business home page. + * + * @param value the new business home page + * @throws Exception the exception + */ + public void setBusinessHomePage(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.BusinessHomePage, value); + } + + /** + * Gets a list of children for the contact. + * + * @return the children + * @throws ServiceLocalException the service local exception + */ + public StringList getChildren() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.Children); + } + + /** + * Sets the children. + * + * @param value the new children + * @throws Exception the exception + */ + public void setChildren(StringList value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.Children, value); + } + + /** + * Gets a list of companies for the contact. + * + * @return the companies + * @throws ServiceLocalException the service local exception + */ + public StringList getCompanies() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.Companies); + } + + /** + * Sets the companies. + * + * @param value the new companies + * @throws Exception the exception + */ + public void setCompanies(StringList value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.Companies, value); + } + + /** + * Gets the source of the contact. + * + * @return the contact source + * @throws ServiceLocalException the service local exception + */ + public ContactSource getContactSource() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag() + .getObjectFromPropertyDefinition(ContactSchema.ContactSource); + } + + /** + * Gets the department of the contact. + * + * @return the department + * @throws ServiceLocalException the service local exception + */ + public String getDepartment() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.Department); + } + + /** + * Sets the department. + * + * @param value the new department + * @throws Exception the exception + */ + public void setDepartment(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.Department, value); + } + + /** + * Gets the generation of the contact. + * + * @return the generation + * @throws ServiceLocalException the service local exception + */ + public String getGeneration() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.Generation); + } + + /** + * Sets the generation. + * + * @param value the new generation + * @throws Exception the exception + */ + public void setGeneration(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.Generation, value); + } + + /** + * Gets an indexed list of Instant Messaging addresses for the contact. For + * example, to set the first IM address, use the following syntax: + * ImAddresses[ImAddressKey.ImAddress1] = "john.doe@contoso.com" + * + * @return the im addresses + * @throws ServiceLocalException the service local exception + */ + public ImAddressDictionary getImAddresses() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.ImAddresses); + } + + /** + * Gets the contact's job title. + * + * @return the job title + * @throws ServiceLocalException the service local exception + */ + public String getJobTitle() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.JobTitle); + } + + /** + * Sets the job title. + * + * @param value the new job title + * @throws Exception the exception + */ + public void setJobTitle(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.JobTitle, value); + } + + /** + * Gets the name of the contact's manager. + * + * @return the manager + * @throws ServiceLocalException the service local exception + */ + public String getManager() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.Manager); + } + + /** + * Sets the manager. + * + * @param value the new manager + * @throws Exception the exception + */ + public void setManager(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.Manager, value); + } + + /** + * Gets the mileage for the contact. + * + * @return the mileage + */ + public String getMileage() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.Mileage); + } + + /** + * Sets the mileage. + * + * @param value the new mileage + * @throws Exception the exception + */ + public void setMileage(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.Mileage, value); + } + + /** + * Gets the location of the contact's office. + * + * @return the office location + */ + public String getOfficeLocation() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.OfficeLocation); + } + + /** + * Sets the office location. + * + * @param value the new office location + * @throws Exception the exception + */ + public void setOfficeLocation(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.OfficeLocation, value); + } + + /** + * Gets the index of the contact's postal address. When set, + * PostalAddressIndex refers to an entry in the PhysicalAddresses indexed + * list. + * + * @return the postal address index + */ + public PhysicalAddressIndex getPostalAddressIndex() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.PostalAddressIndex); + } + + /** + * Sets the postal address index. + * + * @param value the new postal address index + * @throws Exception the exception + */ + public void setPostalAddressIndex(PhysicalAddressIndex value) + throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.PostalAddressIndex, value); + } + + /** + * Gets the contact's profession. + * + * @return the profession + */ + public String getProfession() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.Profession); + } + + /** + * Sets the profession. + * + * @param value the new profession + * @throws Exception the exception + */ + public void setProfession(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.Profession, value); + } + + /** + * Gets the name of the contact's spouse. + * + * @return the spouse name + */ + public String getSpouseName() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.SpouseName); + } + + /** + * Sets the spouse name. + * + * @param value the new spouse name + * @throws Exception the exception + */ + public void setSpouseName(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.SpouseName, value); + } + + /** + * Gets the surname of the contact. + * + * @return the surname + */ + public String getSurname() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.Surname); + } + + /** + * Sets the surname. + * + * @param value the new surname + * @throws Exception the exception + */ + public void setSurname(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.Surname, value); + } + + /** + * Gets the date of the contact's wedding anniversary. + * + * @return the wedding anniversary + */ + public LocalDate getWeddingAnniversary() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.WeddingAnniversary); + } + + /** + * Sets the wedding anniversary. + * + * @param value the new wedding anniversary + * @throws Exception the exception + */ + public void setWeddingAnniversary(LocalDate value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.WeddingAnniversary, value); + } + + /** + * Gets a value indicating whether this contact has a picture associated + * with it. + * + * @return the checks for picture + */ + public Boolean getHasPicture() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ContactSchema.HasPicture); + } + + /** + * Gets the funn phonetic name from the directory + */ + public String getPhoneticFullName() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.PhoneticFullName); + } + + /** + * Gets the funn phonetic name from the directory + */ + public String getPhoneticFirstName() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.PhoneticFirstName); + } + + /** + * Gets the phonetic last name from the directory + * + */ + public String getPhoneticLastName() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.PhoneticLastName); + } + + /** + * Gets the Alias from the directory + * + */ + public String getAlias() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.Alias); + } + + /** + * Get the Notes from the directory + * + */ + public String getNotes() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.Notes); + } + + /** + * Gets the Photo from the directory + * + */ + public byte[] getDirectoryPhoto() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.Photo); + } + + /** + * Gets the User SMIME certificate from the directory + * + */ + public byte[][] getUserSMIMECertificate() throws ExchangeXmlException { + ByteArrayArray array = this.getPropertyBag() + .getObjectFromPropertyDefinition(ContactSchema.UserSMIMECertificate); + return array.getContent(); + } + + /** + * Gets the MSExchange certificate from the directory + * + */ + public byte[][] getMSExchangeCertificate() throws ExchangeXmlException { + ByteArrayArray array = getPropertyBag() + .getObjectFromPropertyDefinition(ContactSchema.MSExchangeCertificate); + return array.getContent(); + } + + /** + * Gets the DirectoryID as Guid or DN string + * + */ + public String getDirectoryId() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.DirectoryId); + } + + /** + * Gets the manager mailbox information + * + */ + public EmailAddress getManagerMailbox() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.ManagerMailbox); + } + + /** + * Get the direct reports mailbox information + * + */ + public EmailAddressCollection getDirectReports() throws ExchangeXmlException { + return getPropertyBag() + .getObjectFromPropertyDefinition(ContactSchema.DirectReports); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/ContactGroup.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/ContactGroup.java new file mode 100644 index 000000000..f8c8b1843 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/ContactGroup.java @@ -0,0 +1,183 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.attribute.RequiredServerVersion; +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.exception.service.local.ServiceObjectPropertyException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.schema.ContactGroupSchema; +import com.eischet.ews.api.core.service.schema.ContactSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.property.complex.GroupMemberCollection; +import com.eischet.ews.api.property.complex.ItemAttachment; +import com.eischet.ews.api.property.complex.ItemId; + +/** + * Represents a Contact Group. Properties available on contact groups are + * defined in the ContactGroupSchema class. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.DistributionList, returnedByServer = true) +public class ContactGroup extends Item { + + /** + * Initializes an unsaved local instance of the class. + * + * @param service the service + * @throws Exception the exception + */ + public ContactGroup(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Initializes an new instance of the class. + * + * @param parentAttachment the parent attachment + * @throws Exception the exception + */ + public ContactGroup(ItemAttachment parentAttachment) throws ExchangeXmlException { + super(parentAttachment); + } + + /** + * Gets the name under which this contact group is filed as. + * + * @return the file as + * @throws Exception the exception + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010) + public String getFileAs() throws Exception { + return (String) this.getObjectFromPropertyDefinition(ContactSchema.FileAs); + } + + /** + * Gets the display name of the contact group. + * + * @return the display name + * @throws Exception the exception + */ + public String getDisplayName() throws Exception { + return (String) this + .getObjectFromPropertyDefinition(ContactSchema.DisplayName); + } + + /** + * Sets the display name. + * + * @param value the new display name + * @throws Exception the exception + */ + public void setDisplayName(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ContactSchema.DisplayName, value); + } + + /** + * Gets the members of the contact group. + * + * @return the members + * @throws Exception the exception + */ + @RequiredServerVersion(version = ExchangeVersion.Exchange2010) + public GroupMemberCollection getMembers() throws Exception { + return (GroupMemberCollection) this + .getObjectFromPropertyDefinition(ContactGroupSchema.Members); + + } + + /** + * Binds to an existing contact group and loads the specified set of + * property.Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @param propertySet the property set + * @return A ContactGroup instance representing the contact group + * corresponding to the specified Id + * @throws Exception the exception + */ + public static ContactGroup bind(ExchangeService service, ItemId id, + PropertySet propertySet) throws Exception { + return service.bindToItem(ContactGroup.class, id, propertySet); + } + + /** + * Binds to an existing contact group and loads the specified set of + * property.Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @return A ContactGroup instance representing the contact group + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static ContactGroup bind(ExchangeService service, ItemId id) + throws Exception { + return ContactGroup.bind(service, id, PropertySet + .getFirstClassProperties()); + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return ContactGroupSchema.Instance; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Sets the subject. + * + * @param subject the new subject + * @throws ServiceObjectPropertyException the service object property exception + */ + @Override + public void setSubject(String subject) + throws ServiceObjectPropertyException { + // Set is disabled in client API even though it is implemented in + // protocol for Item.Subject. + // Setting Subject out of sync with DisplayName breaks interop with OLK. + // See E14:70417, 65663, 6529. + throw new ServiceObjectPropertyException("This property is read-only and can't be set.", + ContactGroupSchema.Subject); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Conversation.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Conversation.java new file mode 100644 index 000000000..83e4c3158 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Conversation.java @@ -0,0 +1,880 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.Importance; +import com.eischet.ews.api.core.enumeration.service.ConversationFlagStatus; +import com.eischet.ews.api.core.enumeration.service.DeleteMode; +import com.eischet.ews.api.core.enumeration.service.SendCancellationsMode; +import com.eischet.ews.api.core.enumeration.service.calendar.AffectedTaskOccurrence; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.remote.ServiceResponseException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.schema.ConversationSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.complex.*; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Represents a collection of Conversation related property. + * Properties available on this object are defined + * in the ConversationSchema class. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.Conversation) +public class Conversation extends ServiceObject { + + /** + * Initializes an unsaved local instance of Conversation. + * + * @param service The service + * The ExchangeService object to which the item will be bound. + * @throws Exception + */ + public Conversation(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Internal method to return the schema associated with this type of object + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return ConversationSchema.Instance; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which + * this service object type is supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2010_SP1; + } + + /** + * The property definition for the Id of this object. + * + * @return A PropertyDefinition instance. + */ + @Override + public PropertyDefinition getIdPropertyDefinition() { + return ConversationSchema.Id; + } + + /** + * This method is not supported in this object. + * Loads the specified set of property on the object. + * + * @param propertySet The propertySet + * The property to load. + */ + @Override + protected void internalLoad(PropertySet propertySet) { + throw new UnsupportedOperationException(); + } + + /** + * This is not supported in this object. + * Deletes the object. + * + * @param deleteMode The deleteMode + * The deletion mode. + * @param sendCancellationsMode The sendCancellationsMode + * Indicates whether meeting cancellation messages should be sent. + * @param affectedTaskOccurrences The affectedTaskOccurrences + * Indicate which occurrence of a recurring task should be deleted. + */ + @Override + protected void internalDelete(DeleteMode deleteMode, + SendCancellationsMode sendCancellationsMode, + AffectedTaskOccurrence affectedTaskOccurrences) { + throw new UnsupportedOperationException(); + } + + /** + * This method is not supported in this object. + * Gets the name of the change XML element. + * + * @return XML element name + */ + @Override + public String getChangeXmlElementName() { + throw new UnsupportedOperationException(); + } + + /** + * This method is not supported in this object. + * Gets the name of the delete field XML element. + * + * @return XML element name + */ + @Override + public String getDeleteFieldXmlElementName() { + throw new UnsupportedOperationException(); + } + + /** + * This method is not supported in this object. + * Gets the name of the set field XML element. + * + * @return XML element name + */ + @Override + public String getSetFieldXmlElementName() { + throw new UnsupportedOperationException(); + } + + /** + * This method is not supported in this object. + * Gets a value indicating whether a time zone + * SOAP header should be emitted in a CreateItem + * or UpdateItem request so this item can be property saved or updated. + * + * @param isUpdateOperation Indicates whether + * the operation being petrformed is an update operation. + * @return true if a time zone SOAP header + * should be emitted; otherwise, false. + */ + @Override + protected boolean getIsTimeZoneHeaderRequired(boolean isUpdateOperation) { + throw new UnsupportedOperationException(); + } + + /** + * This method is not supported in this object. + * Gets the extended property collection. + * + * @return Extended property collection. + */ + @Override + protected ExtendedPropertyCollection getExtendedProperties() { + throw new UnsupportedOperationException(); + } + + /** + * Sets up a conversation so that any item + * received within that conversation is always categorized. + * Calling this method results in a call to EWS. + * + * @param categories The categories that should be stamped on item in the conversation. + * @param processSynchronously Indicates whether the method should + * return only once enabling this rule and stamping existing item + * in the conversation is completely done. + * If processSynchronously is false, the method returns immediately. + * @throws Exception + * @throws IndexOutOfBoundsException + * @throws ServiceResponseException + */ + public void enableAlwaysCategorizeItems(Iterable categories, + boolean processSynchronously) throws ServiceResponseException, + IndexOutOfBoundsException, Exception { + + ArrayList convArry = new ArrayList(); + convArry.add(this.getId()); + + this.getService().enableAlwaysCategorizeItemsInConversations( + convArry, + categories, + processSynchronously).getResponseAtIndex(0).throwIfNecessary(); + } + + /** + * Sets up a conversation so that any item + * received within that conversation is no longer categorized. + * Calling this method results in a call to EWS. + * + * @param processSynchronously Indicates whether the method should + * return only once disabling this rule and + * removing the categories from existing item + * in the conversation is completely done. If processSynchronously + * is false, the method returns immediately. + * @throws Exception + * @throws IndexOutOfBoundsException + * @throws ServiceResponseException + */ + public void disableAlwaysCategorizeItems(boolean processSynchronously) + throws ServiceResponseException, IndexOutOfBoundsException, Exception { + ArrayList convArry = new ArrayList(); + convArry.add(this.getId()); + this.getService().disableAlwaysCategorizeItemsInConversations( + convArry, processSynchronously). + getResponseAtIndex(0).throwIfNecessary(); + } + + /** + * Sets up a conversation so that any item received + * within that conversation is always moved to Deleted Items folder. + * Calling this method results in a call to EWS. + * + * @param processSynchronously Indicates whether the method should + * return only once enabling this rule and deleting existing item + * in the conversation is completely done. If processSynchronously + * is false, the method returns immediately. + * @throws Exception + * @throws IndexOutOfBoundsException + * @throws ServiceResponseException + */ + public void enableAlwaysDeleteItems(boolean processSynchronously) + throws ServiceResponseException, IndexOutOfBoundsException, Exception { + ArrayList convArry = new ArrayList(); + convArry.add(this.getId()); + this.getService().enableAlwaysDeleteItemsInConversations( + convArry, + processSynchronously).getResponseAtIndex(0).throwIfNecessary(); + } + + /** + * Sets up a conversation so that any item received within that + * conversation is no longer moved to Deleted Items folder. + * Calling this method results in a call to EWS. + * + * @param processSynchronously Indicates whether the method should return + * only once disabling this rule and restoring the item + * in the conversation is completely done. If processSynchronously + * is false, the method returns immediately. + * @throws Exception + * @throws IndexOutOfBoundsException + * @throws ServiceResponseException + */ + public void disableAlwaysDeleteItems(boolean processSynchronously) + throws ServiceResponseException, IndexOutOfBoundsException, Exception { + ArrayList convArry = new ArrayList(); + convArry.add(this.getId()); + this.getService().disableAlwaysDeleteItemsInConversations( + convArry, + processSynchronously).getResponseAtIndex(0).throwIfNecessary(); + } + + /** + * Sets up a conversation so that any item received within + * that conversation is always moved to a specific folder. + * Calling this method results in a call to EWS. + * + * @param destinationFolderId The Id of the folder to which conversation item should be moved. + * @param processSynchronously Indicates whether the method should return only + * once enabling this rule + * and moving existing item in the conversation is completely done. + * If processSynchronously is false, the method returns immediately. + * @throws Exception + * @throws IndexOutOfBoundsException + * @throws ServiceResponseException + */ + public void enableAlwaysMoveItems(FolderId destinationFolderId, + boolean processSynchronously) throws ServiceResponseException, + IndexOutOfBoundsException, Exception { + ArrayList convArry = new ArrayList(); + convArry.add(this.getId()); + this.getService().enableAlwaysMoveItemsInConversations( + convArry, + destinationFolderId, + processSynchronously).getResponseAtIndex(0).throwIfNecessary(); + } + + /** + * Sets up a conversation so that any item received within + * that conversation is no longer moved to a specific + * folder. Calling this method results in a call to EWS. + * + * @param processSynchronously Indicates whether the method should return only + * once disabling this + * rule is completely done. If processSynchronously + * is false, the method returns immediately. + * @throws Exception + * @throws IndexOutOfBoundsException + * @throws ServiceResponseException + */ + public void disableAlwaysMoveItemsInConversation(boolean processSynchronously) + throws ServiceResponseException, IndexOutOfBoundsException, Exception { + ArrayList convArry = new ArrayList(); + convArry.add(this.getId()); + this.getService().disableAlwaysMoveItemsInConversations( + convArry, + processSynchronously).getResponseAtIndex(0).throwIfNecessary(); + } + + /** + * Deletes item in the specified conversation. + * Calling this method results in a call to EWS. + * + * @param contextFolderId The Id of the folder item must belong + * to in order to be deleted. If contextFolderId is + * null, item across the entire mailbox are deleted. + * @param deleteMode The deletion mode. + * @throws Exception + * @throws IndexOutOfBoundsException + * @throws ServiceResponseException + */ + public void deleteItems(FolderId contextFolderId, DeleteMode deleteMode) + throws ServiceResponseException, IndexOutOfBoundsException, Exception { + Map m = new HashMap<>(); + m.put(this.getId(), this.getGlobalLastDeliveryTime()); + + List> f = new ArrayList<>(); + f.add(m); + + this.getService().deleteItemsInConversations(f, contextFolderId, deleteMode).getResponseAtIndex(0).throwIfNecessary(); + } + + + /** + * Moves item in the specified conversation to a specific folder. + * Calling this method results in a call to EWS. + * + * @param contextFolderId The Id of the folder item must belong to + * in order to be moved. If contextFolderId is null, + * item across the entire mailbox are moved. + * @param destinationFolderId The Id of the destination folder. + * @throws Exception + * @throws IndexOutOfBoundsException + * @throws ServiceResponseException + */ + public void moveItemsInConversation( + FolderId contextFolderId, + FolderId destinationFolderId) throws ServiceResponseException, + IndexOutOfBoundsException, Exception { + Map m = new HashMap<>(); + m.put(this.getId(), this.getGlobalLastDeliveryTime()); + + List> f = new ArrayList<>(); + f.add(m); + + this.getService().moveItemsInConversations(f, contextFolderId, destinationFolderId).getResponseAtIndex(0).throwIfNecessary(); + } + + /** + * Copies item in the specified conversation to a specific folder. + * Calling this method results in a call to EWS. + * + * @param contextFolderId The Id of the folder item must belong to in + * order to be copied. If contextFolderId + * is null, item across the entire mailbox are copied. + * @param destinationFolderId The Id of the destination folder. + * @throws Exception + * @throws IndexOutOfBoundsException + * @throws ServiceResponseException + */ + public void copyItemsInConversation( + FolderId contextFolderId, + FolderId destinationFolderId) throws ServiceResponseException, + IndexOutOfBoundsException, Exception { + Map m = new HashMap<>(); + m.put(this.getId(), this.getGlobalLastDeliveryTime()); + + List> f = new ArrayList<>(); + f.add(m); + + this.getService().copyItemsInConversations(f, contextFolderId, destinationFolderId).getResponseAtIndex(0).throwIfNecessary(); + } + + /** + * Sets the read state of item in the specified conversation. + * Calling this method results in a call to EWS. + * + * @param contextFolderId The Id of the folder item must + * belong to in order for their read state to + * be set. If contextFolderId is null, the read states of + * item across the entire mailbox are set. + * @param isRead if set to true, conversation item are marked as read; + * otherwise they are marked as unread. + * @throws Exception + * @throws IndexOutOfBoundsException + * @throws ServiceResponseException + */ + public void setReadStateForItemsInConversation( + FolderId contextFolderId, + boolean isRead) throws ServiceResponseException, + IndexOutOfBoundsException, Exception { + Map m = new HashMap<>(); + m.put(this.getId(), this.getGlobalLastDeliveryTime()); + + List> f = new ArrayList<>(); + f.add(m); + + this.getService().setReadStateForItemsInConversations( + f, contextFolderId, isRead). + getResponseAtIndex(0).throwIfNecessary(); + } + + /** + * Gets the Id of this Conversation. + * + * @return Id + */ + public ConversationId getId() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + getIdPropertyDefinition()); + } + + /** + * Gets the topic of this Conversation. + * + * @return value + * @throws ArgumentException + */ + public String getTopic() throws ArgumentException { + String returnValue = ""; + + /**This property need not be present hence the + * property bag may not contain it. + *Check for the presence of this property before accessing it. + */ + if (this.getPropertyBag().contains(ConversationSchema.Topic)) { + OutParam out = new OutParam(); + this.getPropertyBag().tryGetPropertyType(String.class, + ConversationSchema.Topic, + out); + returnValue = out.getParam(); + } + + return returnValue; + } + + /** + * Gets a list of all the people who have received + * messages in this conversation in the current folder only. + * + * @return String + * @throws Exception + */ + public StringList getUniqueRecipients() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.UniqueRecipients); + } + + /** + * Gets a list of all the people who have received + * messages in this conversation across all folder in the mailbox. + * + * @return String + * @throws Exception + */ + public StringList getGlobalUniqueRecipients() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.GlobalUniqueRecipients); + } + + /** + * Gets a list of all the people who have sent messages + * that are currently unread in this conversation in + * the current folder only. + * + * @return unreadSenders + * @throws ArgumentException + */ + public StringList getUniqueUnreadSenders() throws ArgumentException { + StringList unreadSenders = null; + + /**This property need not be present hence + * the property bag may not contain it. + *Check for the presence of this property before accessing it. + */ + if (this.getPropertyBag().contains(ConversationSchema.UniqueUnreadSenders)) { + OutParam out = new OutParam(); + this.getPropertyBag().tryGetPropertyType(StringList.class, + ConversationSchema.UniqueUnreadSenders, + out); + unreadSenders = out.getParam(); + } + + return unreadSenders; + } + + + /** + * Gets a list of all the people who have sent + * messages that are currently unread in this + * conversation across all folder in the mailbox. + * + * @return unreadSenders + * @throws ArgumentException + */ + public StringList getGlobalUniqueUnreadSenders() throws ArgumentException { + StringList unreadSenders = null; + + // This property need not be present hence + //the property bag may not contain it. + // Check for the presence of this property before accessing it. + if (this.getPropertyBag().contains(ConversationSchema.GlobalUniqueUnreadSenders)) { + OutParam out = new OutParam(); + this.getPropertyBag().tryGetPropertyType(StringList.class, + ConversationSchema.GlobalUniqueUnreadSenders, + out); + unreadSenders = out.getParam(); + } + + return unreadSenders; + } + + /** + * Gets a list of all the people who have sent + * messages in this conversation in the current folder only. + * + * @return String + * @throws Exception + */ + public StringList getUniqueSenders() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.UniqueSenders); + } + + /** + * Gets a list of all the people who have sent messages + * in this conversation across all folder in the mailbox. + * + * @return String + * @throws Exception + */ + public StringList getGlobalUniqueSenders() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.GlobalUniqueSenders); + } + + /** + * Gets the delivery time of the message that was last + * received in this conversation in the current folder only. + * + * @return Date + * @throws Exception + */ + public LocalDateTime getLastDeliveryTime() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.LastDeliveryTime); + } + + /** + * Gets the delivery time of the message that was last + * received in this conversation across all folder in the mailbox. + * + * @return Date + * @throws Exception + */ + public LocalDateTime getGlobalLastDeliveryTime() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition(ConversationSchema.GlobalLastDeliveryTime); + } + + /** + * Gets a list summarizing the categories stamped on + * messages in this conversation, in the current folder only. + * + * @return value + * @throws ArgumentException + */ + public StringList getCategories() throws ArgumentException { + StringList returnValue = null; + + /**This property need not be present hence + * the property bag may not contain it. + * Check for the presence of this property before accessing it. + */ + if (this.getPropertyBag().contains(ConversationSchema.Categories)) { + OutParam out = new OutParam(); + this.getPropertyBag().tryGetPropertyType(StringList.class, + ConversationSchema.Categories, + out); + returnValue = out.getParam(); + } + return returnValue; + } + + /** + * Gets a list summarizing the categories stamped on + * messages in this conversation, across all folder in the mailbox. + * + * @return returnValue + * @throws ArgumentException + */ + public StringList getGlobalCategories() throws ArgumentException { + StringList returnValue = null; + + // This property need not be present hence the + //property bag may not contain it. + // Check for the presence of this property before accessing it. + if (this.getPropertyBag().contains(ConversationSchema.GlobalCategories)) { + OutParam out = new OutParam(); + this.getPropertyBag().tryGetPropertyType(StringList.class, + ConversationSchema.GlobalCategories, + out); + returnValue = out.getParam(); + } + return returnValue; + } + + /** + * Gets the flag status for this conversation, calculated + * by aggregating individual messages flag status in the current folder. + * + * @return returnValue + * @throws ArgumentException + */ + public ConversationFlagStatus getFlagStatus() throws ArgumentException { + ConversationFlagStatus returnValue = ConversationFlagStatus.NotFlagged; + + // This property need not be present hence the + //property bag may not contain it. + // Check for the presence of this property before accessing it. + if (this.getPropertyBag().contains(ConversationSchema.FlagStatus)) { + OutParam out = new OutParam(); + this.getPropertyBag().tryGetPropertyType( + ConversationFlagStatus.class, + ConversationSchema.FlagStatus, + out); + returnValue = out.getParam(); + } + + return returnValue; + } + + /** + * Gets the flag status for this conversation, calculated by aggregating + * individual messages flag status across all folder in the mailbox. + * + * @return returnValue + * @throws ArgumentException + */ + public ConversationFlagStatus getGlobalFlagStatus() + throws ArgumentException { + ConversationFlagStatus returnValue = ConversationFlagStatus.NotFlagged; + + // This property need not be present hence the + //property bag may not contain it. + // Check for the presence of this property before accessing it. + if (this.getPropertyBag().contains(ConversationSchema.GlobalFlagStatus)) { + OutParam out = new OutParam(); + this.getPropertyBag().tryGetPropertyType( + ConversationFlagStatus.class, + ConversationSchema.GlobalFlagStatus, + out); + returnValue = out.getParam(); + } + + return returnValue; + } + + /** + * Gets a value indicating if at least one message in this + * conversation, in the current folder only, has an attachment. + * + * @return Value + */ + public boolean getHasAttachments() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ConversationSchema.HasAttachments); + } + + /** + * Gets a value indicating if at least one message + * in this conversation, across all folder in the mailbox, + * has an attachment. + * + * @return boolean + */ + public boolean getGlobalHasAttachments() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.GlobalHasAttachments); + } + + /** + * Gets the total number of messages in this conversation + * in the current folder only. + * + * @return integer + */ + public int getMessageCount() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.MessageCount); + } + + /** + * Gets the total number of messages in this + * conversation across all folder in the mailbox. + * + * @return integer + */ + public int getGlobalMessageCount() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.GlobalMessageCount); + } + + /** + * Gets the total number of unread messages in this + * conversation in the current folder only. + * + * @return returnValue + * @throws ArgumentException + */ + public int getUnreadCount() throws ArgumentException { + int returnValue = 0; + + /**This property need not be present hence the + * property bag may not contain it. + * Check for the presence of this property before accessing it. + */ + if (this.getPropertyBag().contains(ConversationSchema.UnreadCount)) { + OutParam out = new OutParam(); + this.getPropertyBag().tryGetPropertyType(Integer.class, + ConversationSchema.UnreadCount, + out); + returnValue = out.getParam().intValue(); + } + + return returnValue; + } + + /** + * Gets the total number of unread messages in this + * conversation across all folder in the mailbox. + * + * @return returnValue + * @throws ArgumentException + */ + public int getGlobalUnreadCount() throws ArgumentException { + int returnValue = 0; + + if (this.getPropertyBag().contains(ConversationSchema.GlobalUnreadCount)) { + OutParam out = new OutParam(); + this.getPropertyBag().tryGetPropertyType(Integer.class, + ConversationSchema.GlobalUnreadCount, + out); + returnValue = out.getParam().intValue(); + } + return returnValue; + + } + + + /** + * Gets the size of this conversation, calculated by + * adding the sizes of all messages in the conversation in + * the current folder only. + * + * @return integer + */ + public int getSize() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.Size); + } + + /** + * Gets the size of this conversation, calculated by + * adding the sizes of all messages in the conversation + * across all folder in the mailbox. + * + * @return integer + */ + public int getGlobalSize() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.GlobalSize); + } + + /** + * Gets a list summarizing the classes of the item + * in this conversation, in the current folder only. + * + * @return string + * @throws Exception + */ + public StringList getItemClasses() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.ItemClasses); + } + + /** + * Gets a list summarizing the classes of the item + * in this conversation, across all folder in the mailbox. + * + * @return string + * @throws Exception + */ + public StringList getGlobalItemClasses() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.GlobalItemClasses); + } + + /** + * Gets the importance of this conversation, calculated by + * aggregating individual messages importance in the current folder only. + * + * @return important + * @throws Exception + */ + public Importance getImportance() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.Importance); + } + + /** + * Gets the importance of this conversation, calculated by + * aggregating individual messages importance across all + * folder in the mailbox. + * + * @return important + * @throws Exception + */ + public Importance getGlobalImportance() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.GlobalImportance); + } + + /** + * Gets the Ids of the messages in this conversation, + * in the current folder only. + * + * @return Id + * @throws Exception + */ + public ItemIdCollection getItemIds() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.ItemIds); + } + + /** + * Gets the Ids of the messages in this conversation, + * across all folder in the mailbox. + * + * @return Id + * @throws Exception + */ + public ItemIdCollection getGlobalItemIds() throws Exception { + return getPropertyBag().getObjectFromPropertyDefinition( + ConversationSchema.GlobalItemIds); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/EmailMessage.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/EmailMessage.java new file mode 100644 index 000000000..28f3c5cf7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/EmailMessage.java @@ -0,0 +1,578 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.attribute.Attachable; +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.enumeration.service.ConflictResolutionMode; +import com.eischet.ews.api.core.enumeration.service.MessageDisposition; +import com.eischet.ews.api.core.enumeration.service.ResponseMessageType; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.response.ResponseMessage; +import com.eischet.ews.api.core.service.response.SuppressReadReceipt; +import com.eischet.ews.api.core.service.schema.EmailMessageSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.property.complex.*; + +import java.util.Arrays; + +/** + * Represents an e-mail message. Properties available on e-mail messages are + * defined in the EmailMessageSchema class. + */ +@Attachable +@ServiceObjectDefinition(xmlElementName = XmlElementNames.Message) +public class EmailMessage extends Item { + + /** + * Initializes an unsaved local instance of EmailMessage. To bind to an + * existing e-mail message, use EmailMessage.Bind() instead. + * + * @param service The ExchangeService object to which the e-mail message will be + * bound. + * @throws Exception the exception + */ + public EmailMessage(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Initializes a new instance of the "EmailMessage" class. + * + * @param parentAttachment The parent attachment. + */ + public EmailMessage(ItemAttachment parentAttachment) throws ExchangeXmlException { + super(parentAttachment); + } + + /** + * Binds to an existing e-mail message and loads the specified set of + * property.Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @param propertySet the property set + * @return An EmailMessage instance representing the e-mail message + * corresponding to the specified Id + * @throws Exception the exception + */ + public static EmailMessage bind(ExchangeService service, ItemId id, + PropertySet propertySet) throws Exception { + return service.bindToItem(EmailMessage.class, id, propertySet); + + } + + /** + * Binds to an existing e-mail message and loads its first class + * property.Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @return An EmailMessage instance representing the e-mail message + * corresponding to the specified Id + * @throws Exception the exception + */ + public static EmailMessage bind(ExchangeService service, ItemId id) + throws Exception { + return EmailMessage.bind(service, id, PropertySet + .getFirstClassProperties()); + } + + /** + * Method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return EmailMessageSchema.Instance; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Send message. + * + * @param parentFolderId The parent folder id. + * @param messageDisposition The message disposition. + * @throws Exception the exception + */ + private void internalSend(FolderId parentFolderId, + MessageDisposition messageDisposition) throws Exception { + this.throwIfThisIsAttachment(); + + if (this.isNew()) { + if ((this.getAttachments().getCount() == 0) || + (messageDisposition == MessageDisposition.SaveOnly)) { + this.internalCreate(parentFolderId, messageDisposition, null); + } else { + // Bug E14:80316 -- If the message has attachments, save as a + // draft (and add attachments) before sending. + this.internalCreate(null, // null means use the Drafts folder in + // the mailbox of the authenticated + // user. + MessageDisposition.SaveOnly, null); + + this.getService().sendItem(this, parentFolderId); + } + } else if (this.isDirty()) { + // Validate and save attachments before sending. + this.getAttachments().validate(); + this.getAttachments().save(); + + if (this.getPropertyBag().getIsUpdateCallNecessary()) { + this.internalUpdate(parentFolderId, + ConflictResolutionMode.AutoResolve, messageDisposition, + null); + } else { + this.getService().sendItem(this, parentFolderId); + } + } else { + this.getService().sendItem(this, parentFolderId); + } + + // this.internalCreate(parentFolderId, messageDisposition, null); + } + + /** + * Creates a reply response to the message. + * + * @param replyAll the reply all + * @return A ResponseMessage representing the reply response that can + * subsequently be modified and sent. + * @throws Exception the exception + */ + public ResponseMessage createReply(boolean replyAll) throws Exception { + this.throwIfThisIsNew(); + + return new ResponseMessage(this, + replyAll ? ResponseMessageType.ReplyAll : + ResponseMessageType.Reply); + } + + /** + * Creates a forward response to the message. + * + * @return A ResponseMessage representing the forward response that can + * subsequently be modified and sent. + * @throws Exception the exception + */ + public ResponseMessage createForward() throws Exception { + this.throwIfThisIsNew(); + return new ResponseMessage(this, ResponseMessageType.Forward); + } + + /** + * Replies to the message. Calling this method results in a call to EWS. + * + * @param bodyPrefix the body prefix + * @param replyAll the reply all + * @throws Exception the exception + */ + public void reply(MessageBody bodyPrefix, boolean replyAll) + throws Exception { + ResponseMessage responseMessage = this.createReply(replyAll); + responseMessage.setBodyPrefix(bodyPrefix); + responseMessage.sendAndSaveCopy(); + } + + /** + * Forwards the message. Calling this method results in a call to EWS. + * + * @param bodyPrefix the body prefix + * @param toRecipients the to recipients + * @throws Exception the exception + */ + public void forward(MessageBody bodyPrefix, EmailAddress... toRecipients) + throws Exception { + if (null != toRecipients) { + forward(bodyPrefix, Arrays.asList(toRecipients)); + } + } + + /** + * Forwards the message. Calling this method results in a call to EWS. + * + * @param bodyPrefix the body prefix + * @param toRecipients the to recipients + * @throws Exception the exception + */ + public void forward(MessageBody bodyPrefix, + Iterable toRecipients) throws Exception { + ResponseMessage responseMessage = this.createForward(); + + responseMessage.setBodyPrefix(bodyPrefix); + responseMessage.getToRecipients() + .addEmailRange(toRecipients.iterator()); + + responseMessage.sendAndSaveCopy(); + } + + /** + * Sends this e-mail message. Calling this method results in at least one + * call to EWS. + * + * @throws Exception the exception + */ + public void send() throws Exception { + internalSend(null, MessageDisposition.SendOnly); + } + + /** + * Sends this e-mail message and saves a copy of it in the specified + * folder. SendAndSaveCopy does not work if the message has unsaved + * attachments. In that case, the message must first be saved and then sent. + * Calling this method results in a call to EWS. + * + * @param destinationFolderId the destination folder id + * @throws Exception the exception + */ + public void sendAndSaveCopy(FolderId destinationFolderId) throws Exception { + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + this.internalSend(destinationFolderId, + MessageDisposition.SendAndSaveCopy); + } + + /** + * Sends this e-mail message and saves a copy of it in the specified + * folder. SendAndSaveCopy does not work if the message has unsaved + * attachments. In that case, the message must first be saved and then sent. + * Calling this method results in a call to EWS. + * + * @param destinationFolderName the destination folder name + * @throws Exception the exception + */ + public void sendAndSaveCopy(WellKnownFolderName destinationFolderName) + throws Exception { + this.internalSend(new FolderId(destinationFolderName), + MessageDisposition.SendAndSaveCopy); + } + + /** + * Sends this e-mail message and saves a copy of it in the Sent Items + * folder. SendAndSaveCopy does not work if the message has unsaved + * attachments. In that case, the message must first be saved and then sent. + * Calling this method results in a call to EWS. + * + * @throws Exception the exception + */ + public void sendAndSaveCopy() throws Exception { + this.internalSend(new FolderId(WellKnownFolderName.SentItems), + MessageDisposition.SendAndSaveCopy); + } + + /** + * Suppresses the read receipt on the message. Calling this method results + * in a call to EWS. + * + * @throws Exception the exception + */ + public void suppressReadReceipt() throws Exception { + this.throwIfThisIsNew(); + new SuppressReadReceipt(this).internalCreate(null, null); + } + + /** + * Gets the list of To recipients for the e-mail message. + * + * @return The list of To recipients for the e-mail message. + */ + public EmailAddressCollection getToRecipients() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.ToRecipients); + } + + /** + * Gets the list of Bcc recipients for the e-mail message. + * + * @return the bcc recipients + */ + public EmailAddressCollection getBccRecipients() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.BccRecipients); + } + + /** + * Gets the list of Cc recipients for the e-mail message. + * + * @return the cc recipients + */ + public EmailAddressCollection getCcRecipients() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.CcRecipients); + } + + /** + * Gets the conversation topic of the e-mail message. + * + * @return the conversation topic + */ + public String getConversationTopic() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(EmailMessageSchema.ConversationTopic); + } + + /** + * Gets the conversation index of the e-mail message. + * + * @return the conversation index + */ + public byte[] getConversationIndex() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.ConversationIndex); + } + + /** + * Gets the "on behalf" sender of the e-mail message. + * + * @return the from + */ + public EmailAddress getFrom() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.From); + } + + /** + * Sets the from. + * + * @param value the new from + * @throws Exception the exception + */ + public void setFrom(EmailAddress value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.From, value); + } + + /** + * Gets a value indicating whether this is an associated message. + * + * @return the checks if is associated + */ + public boolean getIsAssociated() throws ExchangeXmlException { + return super.getIsAssociated(); + } + + // The "new" keyword is used to expose the setter only on Message types, + // because + // EWS only supports creation of FAI Message types. IsAssociated is a + // readonly + // property of the Item type but it is used by the CreateItem web method for + // creating + // associated messages. + + /** + * Sets the checks if is associated. + * + * @param value the new checks if is associated + * @throws Exception the exception + */ + public void setIsAssociated(boolean value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.IsAssociated, value); + } + + /** + * Gets a value indicating whether a read receipt is requested for + * the e-mail message. + * + * @return the checks if is delivery receipt requested + */ + public Boolean getIsDeliveryReceiptRequested() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.IsDeliveryReceiptRequested); + } + + /** + * Sets the checks if is delivery receipt requested. + * + * @param value the new checks if is delivery receipt requested + * @throws Exception the exception + */ + public void setIsDeliveryReceiptRequested(Boolean value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.IsDeliveryReceiptRequested, value); + } + + /** + * Gets a value indicating whether the e-mail message is read. + * + * @return the checks if is read + */ + public Boolean getIsRead() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.IsRead); + } + + /** + * Sets the checks if is read. + * + * @param value the new checks if is read + * @throws Exception the exception + */ + public void setIsRead(Boolean value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.IsRead, value); + } + + /** + * Gets a value indicating whether a read receipt is requested for + * the e-mail message. + * + * @return the checks if is read receipt requested + */ + public Boolean getIsReadReceiptRequested() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.IsReadReceiptRequested); + } + + /** + * Sets the checks if is read receipt requested. + * + * @param value the new checks if is read receipt requested + * @throws Exception the exception + */ + public void setIsReadReceiptRequested(Boolean value) throws ExchangeXmlException { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.IsReadReceiptRequested, value); + } + + /** + * Gets a value indicating whether a response is requested for the + * e-mail message. + * + * @return the checks if is response requested + */ + public Boolean getIsResponseRequested() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.IsResponseRequested); + } + + /** + * Sets the checks if is response requested. + * + * @param value the new checks if is response requested + * @throws Exception the exception + */ + public void setIsResponseRequested(Boolean value) throws ExchangeXmlException { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.IsResponseRequested, value); + } + + /** + * Gets the Internat Message Id of the e-mail message. + * + * @return the internet message id + */ + public String getInternetMessageId() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.InternetMessageId); + } + + /** + * Gets the references of the e-mail message. + * + * @return the references + */ + public String getReferences() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.References); + } + + /** + * Sets the references. + * + * @param value the new references + * @throws Exception the exception + */ + public void setReferences(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.References, value); + } + + /** + * Gets a list of e-mail addresses to which replies should be addressed. + * + * @return the reply to + */ + public EmailAddressCollection getReplyTo() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.ReplyTo); + } + + /** + * Gets the sender of the e-mail message. + * + * @return the sender + */ + public EmailAddress getSender() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(EmailMessageSchema.Sender); + } + + /** + * Sets the sender. + * + * @param value the new sender + * @throws Exception the exception + */ + public void setSender(EmailAddress value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.Sender, value); + } + + /** + * Gets the ReceivedBy property of the e-mail message. + * + * @return the received by + */ + public EmailAddress getReceivedBy() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(EmailMessageSchema.ReceivedBy); + } + + /** + * Gets the ReceivedRepresenting property of the e-mail message. + * + * @return the received representing + */ + public EmailAddress getReceivedRepresenting() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(EmailMessageSchema.ReceivedRepresenting); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/ICalendarActionProvider.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/ICalendarActionProvider.java new file mode 100644 index 000000000..bfda1cf59 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/ICalendarActionProvider.java @@ -0,0 +1,87 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.core.service.response.AcceptMeetingInvitationMessage; +import com.eischet.ews.api.core.service.response.DeclineMeetingInvitationMessage; +import com.eischet.ews.api.misc.CalendarActionResults; + +/** + * Interface defintion of a group of methods that are common to item that + * return CalendarActionResults. + */ +public interface ICalendarActionProvider { + + /** + * Implements the Accept method. + * + * @param sendResponse Indicates whether to send a response to the organizer. + * @return A CalendarActionResults object containing the various item that + * were created or modified as a result of this operation. + * @throws Exception the exception + */ + CalendarActionResults accept(boolean sendResponse) throws Exception; + + /** + * Implements the AcceptTentatively method. + * + * @param sendResponse Indicates whether to send a response to the organizer. + * @return A CalendarActionResults object containing the various item that + * were created or modified as a result of this operation. + * @throws Exception the exception + */ + CalendarActionResults acceptTentatively(boolean sendResponse) + throws Exception; + + /** + * Implements the Decline method. + * + * @param sendResponse Indicates whether to send a response to the organizer. + * @return A CalendarActionResults object containing the various item that + * were created or modified as a result of this operation. + * @throws Exception the exception + */ + CalendarActionResults decline(boolean sendResponse) throws Exception; + + /** + * Implements the CreateAcceptMessage method. + * + * @param tentative Indicates whether the new AcceptMeetingInvitationMessage + * should represent a Tentative accept response (as opposed to an + * Accept response). + * @return A new AcceptMeetingInvitationMessage. + * @throws Exception the exception + */ + AcceptMeetingInvitationMessage createAcceptMessage(boolean tentative) + throws Exception; + + /** + * Implements the DeclineMeetingInvitationMessage method. + * + * @return A new DeclineMeetingInvitationMessage. + * @throws Exception the exception + */ + DeclineMeetingInvitationMessage createDeclineMessage() throws Exception; + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Item.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Item.java new file mode 100644 index 000000000..895ff293e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Item.java @@ -0,0 +1,1122 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.attribute.Attachable; +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.Importance; +import com.eischet.ews.api.core.enumeration.property.Sensitivity; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.enumeration.service.*; +import com.eischet.ews.api.core.enumeration.service.calendar.AffectedTaskOccurrence; +import com.eischet.ews.api.core.enumeration.service.error.ServiceErrorHandling; +import com.eischet.ews.api.core.exception.misc.InvalidOperationException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.remote.ServiceResponseException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.schema.ItemSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.property.complex.*; +import com.eischet.ews.api.property.definition.ExtendedPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.ListIterator; + +/** + * Represents a generic item. Properties available on item are defined in the + * ItemSchema class. + */ +@Attachable +@ServiceObjectDefinition(xmlElementName = XmlElementNames.Item) +public class Item extends ServiceObject { + + /** + * The parent attachment. + */ + private ItemAttachment parentAttachment; + + /** + * Initializes an unsaved local instance of . To bind to + * an existing item, use Item.Bind() instead. + * + * @param service the service + * @throws Exception the exception + */ + public Item(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Initializes a new instance of the item class. + * + * @param parentAttachment The parent attachment. + * @throws Exception the exception + */ + public Item(final ItemAttachment parentAttachment) throws ExchangeXmlException { + this(parentAttachment.getOwner().getService()); + this.parentAttachment = parentAttachment; + } + + /** + * Binds to an existing item, whatever its actual type is, and loads the + * specified set of property. Calling this method results in a call to + * EWS. + * + * @param service The service to use to bind to the item. + * @param id The Id of the item to bind to. + * @param propertySet The set of property to load. + * @return An Item instance representing the item corresponding to the + * specified Id. + * @throws Exception the exception + */ + public static Item bind(ExchangeService service, ItemId id, + PropertySet propertySet) throws Exception { + return service.bindToItem(Item.class, id, propertySet); + } + + /** + * Binds to an existing item, whatever its actual type is, and loads the + * specified set of property. Calling this method results in a call to + * EWS. + * + * @param service The service to use to bind to the item. + * @param id The Id of the item to bind to. + * @return An Item instance representing the item corresponding to the + * specified Id. + * @throws Exception the exception + */ + public static Item bind(ExchangeService service, ItemId id) + throws Exception { + return Item.bind(service, id, PropertySet.getFirstClassProperties()); + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return ItemSchema.getInstance(); + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Throws exception if this is attachment. + * + * @throws InvalidOperationException the invalid operation exception + */ + protected void throwIfThisIsAttachment() throws InvalidOperationException { + if (this.isAttachment()) { + throw new InvalidOperationException("This operation isn't supported on attachments."); + } + } + + /** + * The property definition for the Id of this object. + * + * @return A PropertyDefinition instance. + */ + public PropertyDefinition getIdPropertyDefinition() { + return ItemSchema.Id; + } + + /** + * The property definition for the Id of this object. + * + * @param propertySet the property set + * @throws Exception the exception + */ + @Override + protected void internalLoad(PropertySet propertySet) throws Exception { + this.throwIfThisIsNew(); + this.throwIfThisIsAttachment(); + + ArrayList itemArry = new ArrayList(); + itemArry.add(this); + this.getService().internalLoadPropertiesForItems(itemArry, propertySet, + ServiceErrorHandling.ThrowOnError); + } + + /** + * Deletes the object. + * + * @param deleteMode the delete mode + * @param sendCancellationsMode the send cancellations mode + * @param affectedTaskOccurrences the affected task occurrences + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + @Override + protected void internalDelete(DeleteMode deleteMode, + SendCancellationsMode sendCancellationsMode, + AffectedTaskOccurrence affectedTaskOccurrences) + throws ServiceLocalException, Exception { + this.throwIfThisIsNew(); + this.throwIfThisIsAttachment(); + + // If sendCancellationsMode is null, use the default value that's + // appropriate for item type. + if (sendCancellationsMode == null) { + sendCancellationsMode = this.getDefaultSendCancellationsMode(); + } + + // If affectedTaskOccurrences is null, use the default value that's + // appropriate for item type. + if (affectedTaskOccurrences == null) { + affectedTaskOccurrences = this.getDefaultAffectedTaskOccurrences(); + } + + this.getService().deleteItem(this.getId(), deleteMode, + sendCancellationsMode, affectedTaskOccurrences); + } + + /** + * Create item. + * + * @param parentFolderId the parent folder id + * @param messageDisposition the message disposition + * @param sendInvitationsMode the send invitations mode + * @throws Exception the exception + */ + protected void internalCreate(FolderId parentFolderId, + MessageDisposition messageDisposition, + SendInvitationsMode sendInvitationsMode) throws Exception { + this.throwIfThisIsNotNew(); + this.throwIfThisIsAttachment(); + + if (this.isNew() || this.isDirty()) { + this.getService().createItem( + this, + parentFolderId, + messageDisposition, + sendInvitationsMode != null ? sendInvitationsMode : this + .getDefaultSendInvitationsMode()); + + this.getAttachments().save(); + } + } + + /** + * Update item. + * + * @param parentFolderId the parent folder id + * @param conflictResolutionMode the conflict resolution mode + * @param messageDisposition the message disposition + * @param sendInvitationsOrCancellationsMode the send invitations or cancellations mode + * @return Updated item. + * @throws ServiceResponseException the service response exception + * @throws Exception the exception + */ + protected Item internalUpdate( + FolderId parentFolderId, + ConflictResolutionMode conflictResolutionMode, + MessageDisposition messageDisposition, + SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode) + throws ServiceResponseException, Exception { + this.throwIfThisIsNew(); + this.throwIfThisIsAttachment(); + + Item returnedItem = null; + + if (this.isDirty() && this.getPropertyBag().getIsUpdateCallNecessary()) { + returnedItem = this + .getService() + .updateItem( + this, + parentFolderId, + conflictResolutionMode, + messageDisposition, + sendInvitationsOrCancellationsMode != null ? sendInvitationsOrCancellationsMode + : this + .getDefaultSendInvitationsOrCancellationsMode()); + } + if (this.hasUnprocessedAttachmentChanges()) { + // Validation of the item and its attachments occurs in + // UpdateItems. + // If we didn't update the item we still need to validate + // attachments. + this.getAttachments().validate(); + this.getAttachments().save(); + + } + + return returnedItem; + } + + /** + * Gets a value indicating whether this instance has unprocessed attachment + * collection changes. + * + * @throws ServiceLocalException + */ + public boolean hasUnprocessedAttachmentChanges() throws ExchangeXmlException { + return this.getAttachments().hasUnprocessedChanges(); + + } + + /** + * Gets the parent attachment of this item. + * + * @return the parent attachment + */ + public ItemAttachment getParentAttachment() { + return this.parentAttachment; + } + + /** + * Gets Id of the root item for this item. + * + * @return the root item id + * @throws ServiceLocalException the service local exception + */ + public ItemId getRootItemId() throws ServiceLocalException, ExchangeXmlException { + + if (this.isAttachment()) { + return this.getParentAttachment().getOwner().getRootItemId(); + } else { + return this.getId(); + } + } + + /** + * Deletes the item. Calling this method results in a call to EWS. + * + * @param deleteMode the delete mode + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + public void delete(DeleteMode deleteMode) throws ServiceLocalException, + Exception { + this.internalDelete(deleteMode, null, null); + } + + /** + * Saves this item in a specific folder. Calling this method results in at + * least one call to EWS. Mutliple calls to EWS might be made if attachments + * have been added. + * + * @param parentFolderId the parent folder id + * @throws Exception the exception + */ + public void save(FolderId parentFolderId) throws Exception { + EwsUtilities.validateParam(parentFolderId, "parentFolderId"); + this.internalCreate(parentFolderId, MessageDisposition.SaveOnly, null); + } + + /** + * Saves this item in a specific folder. Calling this method results in at + * least one call to EWS. Mutliple calls to EWS might be made if attachments + * have been added. + * + * @param parentFolderName the parent folder name + * @throws Exception the exception + */ + public void save(WellKnownFolderName parentFolderName) throws Exception { + this.internalCreate(new FolderId(parentFolderName), + MessageDisposition.SaveOnly, null); + } + + /** + * Saves this item in the default folder based on the item's type (for + * example, an e-mail message is saved to the Drafts folder). Calling this + * method results in at least one call to EWS. Mutliple calls to EWS might + * be made if attachments have been added. + * + * @throws Exception the exception + */ + public void save() throws Exception { + this.internalCreate(null, MessageDisposition.SaveOnly, null); + } + + /** + * Applies the local changes that have been made to this item. Calling this + * method results in at least one call to EWS. Mutliple calls to EWS might + * be made if attachments have been added or removed. + * + * @param conflictResolutionMode the conflict resolution mode + * @throws ServiceResponseException the service response exception + * @throws Exception the exception + */ + public void update(ConflictResolutionMode conflictResolutionMode) + throws ServiceResponseException, Exception { + this.internalUpdate(null /* parentFolder */, conflictResolutionMode, + MessageDisposition.SaveOnly, null); + } + + /** + * Creates a copy of this item in the specified folder. Calling this method + * results in a call to EWS. Copy returns null if the copy operation is + * across two mailboxes or between a mailbox and a public folder. + * + * @param destinationFolderId the destination folder id + * @return The copy of this item. + * @throws Exception the exception + */ + public Item copy(FolderId destinationFolderId) throws Exception { + + this.throwIfThisIsNew(); + this.throwIfThisIsAttachment(); + + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + + return this.getService().copyItem(this.getId(), destinationFolderId); + } + + /** + * Creates a copy of this item in the specified folder. Calling this method + * results in a call to EWS. Copy returns null if the copy operation is + * across two mailboxes or between a mailbox and a public folder. + * + * @param destinationFolderName the destination folder name + * @return The copy of this item. + * @throws Exception the exception + */ + public Item copy(WellKnownFolderName destinationFolderName) + throws Exception { + return this.copy(new FolderId(destinationFolderName)); + } + + /** + * Moves this item to a the specified folder. Calling this method results in + * a call to EWS. Move returns null if the move operation is across two + * mailboxes or between a mailbox and a public folder. + * + * @param destinationFolderId the destination folder id + * @return The moved copy of this item. + * @throws Exception the exception + */ + public Item move(FolderId destinationFolderId) throws Exception { + this.throwIfThisIsNew(); + this.throwIfThisIsAttachment(); + + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + + return this.getService().moveItem(this.getId(), destinationFolderId); + } + + /** + * Moves this item to a the specified folder. Calling this method results in + * a call to EWS. Move returns null if the move operation is across two + * mailboxes or between a mailbox and a public folder. + * + * @param destinationFolderName the destination folder name + * @return The moved copy of this item. + * @throws Exception the exception + */ + public Item move(WellKnownFolderName destinationFolderName) + throws Exception { + return this.move(new FolderId(destinationFolderName)); + } + + /** + * Sets the extended property. + * + * @param extendedPropertyDefinition the extended property definition + * @param value the value + * @throws Exception the exception + */ + public void setExtendedProperty( + ExtendedPropertyDefinition extendedPropertyDefinition, Object value) + throws Exception { + this.getExtendedProperties().setExtendedProperty( + extendedPropertyDefinition, value); + } + + /** + * Removes an extended property. + * + * @param extendedPropertyDefinition the extended property definition + * @return True if property was removed. + * @throws Exception the exception + */ + public boolean removeExtendedProperty( + ExtendedPropertyDefinition extendedPropertyDefinition) + throws Exception { + return this.getExtendedProperties().removeExtendedProperty( + extendedPropertyDefinition); + } + + /** + * Validates this instance. + * + * @throws Exception the exception + */ + @Override + public void validate() throws Exception { + super.validate(); + this.getAttachments().validate(); + } + + /** + * Gets a value indicating whether a time zone SOAP header should be emitted + * in a CreateItem or UpdateItem request so this item can be property saved + * or updated. + * + * @param isUpdateOperation Indicates whether the operation being petrformed is an update + * operation. + * @return true if a time zone SOAP header should be emitted; + * otherwise,false + */ + public boolean getIsTimeZoneHeaderRequired(boolean isUpdateOperation) + throws Exception { + // Starting E14SP2, attachment will be sent along with CreateItem + // request. + // if the attachment used to require the Timezone header, CreateItem + // request should do so too. + // + + if (!isUpdateOperation + && (this.getService().getRequestedServerVersion().ordinal() >= ExchangeVersion.Exchange2010_SP2 + .ordinal())) { + + ListIterator items = this.getAttachments().getItems() + .listIterator(); + + while (items.hasNext()) { + + ItemAttachment itemAttachment = (ItemAttachment) items.next(); + + if ((itemAttachment.getItem() != null) + && itemAttachment + .getItem() + .getIsTimeZoneHeaderRequired(false /* isUpdateOperation */)) { + return true; + } + } + } + + /* + * for (ItemAttachment itemAttachment : + * this.getAttachments().OfType().getc) { if + * ((itemAttachment.Item != null) && + * itemAttachment.Item.GetIsTimeZoneHeaderRequired(false /* // + * isUpdateOperation )) { return true; } } + */ + + return super.getIsTimeZoneHeaderRequired(isUpdateOperation); + } + + // region Properties + + /** + * Gets a value indicating whether the item is an attachment. + * + * @return true, if is attachment + */ + public boolean isAttachment() { + return this.parentAttachment != null; + } + + /** + * Gets a value indicating whether this object is a real store item, or if + * it's a local object that has yet to be saved. + * + * @return the checks if is new + * @throws ServiceLocalException the service local exception + */ + public boolean getIsNew() throws ServiceLocalException, ExchangeXmlException { + + // Item attachments don't have an Id, need to check whether the + // parentAttachment is new or not. + if (this.isAttachment()) { + return this.getParentAttachment().isNew(); + } else { + return super.isNew(); + } + } + + /** + * Gets the Id of this item. + * + * @return the id + */ + public ItemId getId() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(getIdPropertyDefinition()); + } + + /** + * Get the MIME content of this item. + * + * @return the mime content + */ + public MimeContent getMimeContent() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.MimeContent); + } + + /** + * Sets the mime content. + * + * @param value the new mime content + * @throws Exception the exception + */ + public void setMimeContent(MimeContent value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.MimeContent, value); + } + + /** + * Gets the Id of the parent folder of this item. + * + * @return the parent folder id + */ + public FolderId getParentFolderId() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.ParentFolderId); + } + + /** + * Gets the sensitivity of this item. + * + * @return the sensitivity + */ + public Sensitivity getSensitivity() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.Sensitivity); + } + + /** + * Sets the sensitivity. + * + * @param value the new sensitivity + * @throws Exception the exception + */ + public void setSensitivity(Sensitivity value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.Sensitivity, value); + } + + /** + * Gets a list of the attachments to this item. + * + * @return the attachments + * @throws ServiceLocalException the service local exception + */ + public AttachmentCollection getAttachments() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.Attachments); + } + + /** + * Gets the time when this item was received. + * + * @return the date time received + */ + public LocalDateTime getDateTimeReceived() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.DateTimeReceived); + } + + /** + * Gets the size of this item. + * + * @return the size + */ + public int getSize() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.Size); + } + + /** + * Gets the list of categories associated with this item. + * + * @return the categories + */ + public StringList getCategories() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.Categories); + } + + /** + * Sets the categories. + * + * @param value the new categories + * @throws Exception the exception + */ + public void setCategories(StringList value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.Categories, value); + } + + /** + * Gets the culture associated with this item. + * + * @return the culture + */ + public String getCulture() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.Culture); + } + + /** + * Sets the culture. + * + * @param value the new culture + * @throws Exception the exception + */ + public void setCulture(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.Culture, value); + } + + /** + * Gets the importance of this item. + * + * @return the importance + */ + public Importance getImportance() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.Importance); + } + + /** + * Sets the importance. + * + * @param value the new importance + * @throws Exception the exception + */ + public void setImportance(Importance value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.Importance, value); + } + + /** + * Gets the In-Reply-To reference of this item. + * + * @return the in reply to + */ + public String getInReplyTo() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.InReplyTo); + } + + /** + * Sets the in reply to. + * + * @param value the new in reply to + * @throws Exception the exception + */ + public void setInReplyTo(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.InReplyTo, value); + } + + /** + * Gets a value indicating whether the message has been submitted to be + * sent. + * + * @return the checks if is submitted + */ + public boolean getIsSubmitted() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.IsSubmitted); + } + + /** + * Gets a value indicating whether the message has been submitted to be + * sent. + * + * @return the checks if is associated + * @throws ServiceLocalException the service local exception + */ + public boolean getIsAssociated() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.IsAssociated); + } + + /** + * Gets a value indicating whether the message has been submitted to be + * sent. + * + * @return the checks if is draft + */ + public boolean getIsDraft() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.IsDraft); + } + + /** + * Gets a value indicating whether the item has been sent by the current + * authenticated user. + * + * @return the checks if is from me + */ + public boolean getIsFromMe() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.IsFromMe); + } + + /** + * Gets a value indicating whether the item is a resend of another item. + * + * @return the checks if is resend + */ + public boolean getIsResend() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.IsResend); + } + + /** + * Gets a value indicating whether the item has been modified since it was + * created. + * + * @return the checks if is unmodified + */ + public boolean getIsUnmodified() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.IsUnmodified); + } + + /** + * Gets a list of Internet headers for this item. + * + * @return the internet message headers + */ + public InternetMessageHeaderCollection getInternetMessageHeaders() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.InternetMessageHeaders); + } + + /** + * Gets the date and time this item was sent. + * + * @return the date time sent + */ + public LocalDateTime getDateTimeSent() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.DateTimeSent); + } + + /** + * Gets the date and time this item was created. + * + * @return the date time created + */ + public LocalDateTime getDateTimeCreated() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.DateTimeCreated); + } + + /** + * Gets a value indicating which response actions are allowed on this item. + * Examples of response actions are Reply and Forward. + * + * @return the allowed response actions + */ + public EnumSet getAllowedResponseActions() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.AllowedResponseActions); + } + + /** + * Gets the date and time when the reminder is due for this item. + * + * @return the reminder due by + */ + public LocalDateTime getReminderDueBy() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.ReminderDueBy); + } + + /** + * Sets the reminder due by. + * + * @param value the new reminder due by + * @throws Exception the exception + */ + public void setReminderDueBy(LocalDateTime value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.ReminderDueBy, value); + } + + /** + * Gets a value indicating whether a reminder is set for this item. + * + * @return the checks if is reminder set + */ + public boolean getIsReminderSet() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.IsReminderSet); + } + + /** + * Sets the checks if is reminder set. + * + * @param value the new checks if is reminder set + * @throws Exception the exception + */ + public void setIsReminderSet(Boolean value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.IsReminderSet, value); + } + + /** + * Gets the number of minutes before the start of this item when the + * reminder should be triggered. + * + * @return the reminder minutes before start + */ + public int getReminderMinutesBeforeStart() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.ReminderMinutesBeforeStart); + } + + /** + * Sets the reminder minutes before start. + * + * @param value the new reminder minutes before start + * @throws Exception the exception + */ + public void setReminderMinutesBeforeStart(int value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.ReminderMinutesBeforeStart, value); + } + + /** + * Gets a text summarizing the Cc receipients of this item. + * + * @return the display cc + */ + public String getDisplayCc() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.DisplayCc); + } + + /** + * Gets a text summarizing the To recipients of this item. + * + * @return the display to + */ + public String getDisplayTo() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.DisplayTo); + } + + /** + * Gets a value indicating whether the item has attachments. + * + * @return the checks for attachments + */ + public boolean getHasAttachments() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.HasAttachments); + } + + /** + * Gets the body of this item. + * + * @return MessageBody + */ + public MessageBody getBody() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.Body); + } + + /** + * Sets the body. + * + * @param value the new body + * @throws Exception the exception + */ + public void setBody(MessageBody value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition(ItemSchema.Body, + value); + } + + /** + * Gets the custom class name of this item. + * + * @return the item class + */ + public String getItemClass() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.ItemClass); + } + + /** + * Sets the item class. + * + * @param value the new item class + * @throws Exception the exception + */ + public void setItemClass(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.ItemClass, value); + } + + /** + * Sets the subject. + * + * @param subject the new subject + * @throws Exception the exception + */ + public void setSubject(String subject) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.Subject, subject); + } + + /** + * Gets the subject. + * + * @return the subject + */ + public String getSubject() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.Subject); + } + + /** + * Gets the query string that should be appended to the Exchange Web client + * URL to open this item using the appropriate read form in a web browser. + * + * @return the web client read form query string + */ + public String getWebClientReadFormQueryString() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.WebClientReadFormQueryString); + } + + /** + * Gets the query string that should be appended to the Exchange Web client + * URL to open this item using the appropriate read form in a web browser. + * + * @return the web client edit form query string + */ + public String getWebClientEditFormQueryString() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.WebClientEditFormQueryString); + } + + /** + * Gets a list of extended property defined on this item. + * + * @return the extended property + */ + @Override + public ExtendedPropertyCollection getExtendedProperties() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ServiceObjectSchema.extendedProperties); + } + + /** + * Gets a value indicating the effective rights the current authenticated + * user has on this item. + * + * @return the effective rights + */ + public EnumSet getEffectiveRights() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.EffectiveRights); + } + + /** + * Gets the name of the user who last modified this item. + * + * @return the last modified name + */ + public String getLastModifiedName() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.LastModifiedName); + } + + /** + * Gets the date and time this item was last modified. + * + * @return the last modified time + */ + public LocalDateTime getLastModifiedTime() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.LastModifiedTime); + } + + /** + * Gets the Id of the conversation this item is part of. + * + * @return the conversation id + */ + public ConversationId getConversationId() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.ConversationId); + } + + /** + * Gets the body part that is unique to the conversation this item is part + * of. + * + * @return the unique body + */ + public UniqueBody getUniqueBody() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + ItemSchema.UniqueBody); + } + + /** + * Gets the default setting for how to treat affected task occurrences on + * Delete. Subclasses will override this for different default behavior. + * + * @return the default affected task occurrences + */ + protected AffectedTaskOccurrence getDefaultAffectedTaskOccurrences() { + return null; + } + + /** + * Gets the default setting for sending cancellations on Delete. Subclasses + * will override this for different default behavior. + * + * @return the default send cancellations mode + */ + protected SendCancellationsMode getDefaultSendCancellationsMode() { + return null; + } + + /** + * Gets the default settings for sending invitations on Save. Subclasses + * will override this for different default behavior. + * + * @return the default send invitations mode + */ + protected SendInvitationsMode getDefaultSendInvitationsMode() { + return null; + } + + /** + * Gets the default settings for sending invitations or cancellations on + * Update. Subclasses will override this for different default behavior. + * + * @return the default send invitations or cancellations mode + */ + protected SendInvitationsOrCancellationsMode getDefaultSendInvitationsOrCancellationsMode() { + return null; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/MeetingCancellation.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/MeetingCancellation.java new file mode 100644 index 000000000..cc97df530 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/MeetingCancellation.java @@ -0,0 +1,132 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.response.RemoveFromCalendar; +import com.eischet.ews.api.misc.CalendarActionResults; +import com.eischet.ews.api.property.complex.ItemAttachment; +import com.eischet.ews.api.property.complex.ItemId; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents a meeting cancellation message. Properties available on meeting + * messages are defined in the MeetingMessageSchema class. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.MeetingCancellation) +public class MeetingCancellation extends MeetingMessage { + + private static final Logger LOG = Logger.getLogger(MeetingCancellation.class.getCanonicalName()); + + /** + * Initializes a new instance of the class. + * + * @param parentAttachment The parent attachment. + * @throws Exception the exception + */ + public MeetingCancellation(ItemAttachment parentAttachment) throws ExchangeXmlException { + super(parentAttachment); + } + + /** + * Initializes a new instance of the class. + * + * @param service EWS service to which this object belongs. + * @throws Exception the exception + */ + public MeetingCancellation(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Binds to an existing meeting cancellation message and loads the specified + * set of property. Calling this method results in a call to EWS. + * + * @param service The service to use to bind to the meeting cancellation + * message. + * @param id The Id of the meeting cancellation message to bind to. + * @param propertySet The set of property to load. + * @return A MeetingCancellation instance representing the meeting + * cancellation message corresponding to the specified Id. + */ + public static MeetingCancellation bind(ExchangeService service, ItemId id, + PropertySet propertySet) { + try { + return service.bindToItem(MeetingCancellation.class, id, + propertySet); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error binding meeting cancellation", e); + return null; + } + } + + /** + * Binds to an existing meeting cancellation message and loads the specified + * set of property. Calling this method results in a call to EWS. + * + * @param service The service to use to bind to the meeting cancellation + * message. + * @param id The Id of the meeting cancellation message to bind to. + * @return A MeetingCancellation instance representing the meeting + * cancellation message corresponding to the specified Id. + */ + public static MeetingCancellation bind(ExchangeService service, ItemId id) { + return MeetingCancellation.bind(service, id, PropertySet + .getFirstClassProperties()); + } + + /** + * Removes the meeting associated with the cancellation message from the + * user's calendar. + * + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + public CalendarActionResults removeMeetingFromCalendar() + throws ServiceLocalException, Exception { + return new CalendarActionResults(new RemoveFromCalendar(this) + .internalCreate(null, null)); + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/MeetingMessage.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/MeetingMessage.java new file mode 100644 index 000000000..3a25b8a35 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/MeetingMessage.java @@ -0,0 +1,201 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.MeetingResponseType; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.schema.MeetingMessageSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.property.complex.ItemAttachment; +import com.eischet.ews.api.property.complex.ItemId; + +import java.time.LocalDateTime; + + +/** + * Represents a meeting-related message. Properties available on meeting + * messages are defined in the MeetingMessageSchema class. + */ + +@ServiceObjectDefinition(xmlElementName = XmlElementNames.MeetingMessage) +@EditorBrowsable(state = EditorBrowsableState.Never) +public class MeetingMessage extends EmailMessage { + + /** + * Initializes a new instance of the "MeetingMessage" class. + * + * @param parentAttachment the parent attachment + * @throws Exception the exception + */ + public MeetingMessage(ItemAttachment parentAttachment) throws ExchangeXmlException { + super(parentAttachment); + } + + /** + * Initializes a new instance of the "MeetingMessage" class. + * + * @param service EWS service to which this object belongs. + * @throws Exception the exception + */ + public MeetingMessage(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Binds to an existing meeting message and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service The service to use to bind to the meeting message. + * @param id The Id of the meeting message to bind to. + * @param propertySet The set of property to load. + * @return A MeetingMessage instance representing the meeting message + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static MeetingMessage bind(ExchangeService service, ItemId id, + PropertySet propertySet) throws Exception { + return (MeetingMessage) service.bindToItem(id, propertySet); + } + + /** + * Binds to an existing meeting message and loads its first class + * property. Calling this method results in a call to EWS. + * + * @param service The service to use to bind to the meeting message. + * @param id The Id of the meeting message to bind to. + * @return A MeetingMessage instance representing the meeting message + * corresponding to the specified Id. + * @throws Exception the exception + */ + public static MeetingMessage bind(ExchangeService service, ItemId id) + throws Exception { + return MeetingMessage.bind(service, id, PropertySet + .getFirstClassProperties()); + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return MeetingMessageSchema.getInstance(); + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the associated appointment ID. + * + * @return the associated appointment ID. + */ + public ItemId getAssociatedAppointmentId() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + MeetingMessageSchema.AssociatedAppointmentId); + } + + /** + * Gets whether the meeting message has been processed. + * + * @return whether the meeting message has been processed. + */ + public Boolean getHasBeenProcessed() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + MeetingMessageSchema.HasBeenProcessed); + } + + /** + * Gets the response type indicated by this meeting message. + * + * @return the response type indicated by this meeting message. + */ + public MeetingResponseType getResponseType() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + MeetingMessageSchema.ResponseType); + } + + /** + * Gets the ICalendar Uid. + * + * @return the ical uid + */ + public String getICalUid() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + MeetingMessageSchema.ICalUid); + } + + /** + * Gets the ICalendar RecurrenceId. + * + * @return the ical recurrence id + */ + public LocalDateTime getICalRecurrenceId() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(MeetingMessageSchema.ICalRecurrenceId); + } + + /** + * Gets the ICalendar DateTimeStamp. + * + * @return the ical date time stamp + */ + public LocalDateTime getICalDateTimeStamp() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(MeetingMessageSchema.ICalDateTimeStamp); + } + + /** + * Gets the IsDelegated property. + * + * @return True if delegated; false otherwise. + */ + public Boolean getIsDelegated() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(MeetingMessageSchema.IsDelegated); + } + + /** + * Gets the IsOutOfDate property. + * + * @return True if out of date; false otherwise. + */ + public Boolean getIsOutOfDate() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(MeetingMessageSchema.IsOutOfDate); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/MeetingRequest.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/MeetingRequest.java new file mode 100644 index 000000000..299348560 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/MeetingRequest.java @@ -0,0 +1,701 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.LegacyFreeBusyStatus; +import com.eischet.ews.api.core.enumeration.property.MeetingResponseType; +import com.eischet.ews.api.core.enumeration.service.MeetingRequestType; +import com.eischet.ews.api.core.enumeration.service.calendar.AppointmentType; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.response.AcceptMeetingInvitationMessage; +import com.eischet.ews.api.core.service.response.DeclineMeetingInvitationMessage; +import com.eischet.ews.api.core.service.schema.AppointmentSchema; +import com.eischet.ews.api.core.service.schema.MeetingRequestSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.misc.CalendarActionResults; +import com.eischet.ews.api.misc.TimeSpan; +import com.eischet.ews.api.property.complex.*; +import com.eischet.ews.api.property.complex.recurrence.pattern.Recurrence; +import com.eischet.ews.api.property.complex.time.TimeZoneDefinition; + +import java.time.LocalDateTime; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents a meeting request that an attendee can accept + * or decline. Properties available on meeting + * request are defined in the MeetingRequestSchema class. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.MeetingRequest) +public class MeetingRequest extends MeetingMessage implements ICalendarActionProvider { + + private static final Logger LOG = Logger.getLogger(MeetingRequest.class.getCanonicalName()); + + /** + * Initializes a new instance of the class. + * + * @param parentAttachment The parent attachment + * @throws Exception throws Exception + */ + public MeetingRequest(ItemAttachment parentAttachment) throws ExchangeXmlException { + super(parentAttachment); + } + + /** + * Initializes a new instance of the class. + * + * @param service EWS service to which this object belongs. + * @throws Exception throws Exception + */ + public MeetingRequest(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Binds to an existing meeting response and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service The service to use to bind to the meeting request. + * @param id The Id of the meeting request to bind to. + * @param propertySet The set of property to load. + * @return A MeetingResponse instance representing the meeting request + * corresponding to the specified Id. + */ + public static MeetingRequest bind(ExchangeService service, ItemId id, + PropertySet propertySet) { + try { + return service.bindToItem(MeetingRequest.class, id, propertySet); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error binding meeting request", e); + return null; + } + } + + /** + * Binds to an existing meeting response and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service The service to use to bind to the meeting request. + * @param id The Id of the meeting request to bind to. + * @return A MeetingResponse instance representing the meeting request + * corresponding to the specified Id. + */ + public static MeetingRequest bind(ExchangeService service, ItemId id) { + return MeetingRequest.bind(service, id, PropertySet + .getFirstClassProperties()); + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return MeetingRequestSchema.Instance; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Creates a local meeting acceptance message that can be customized and + * sent. + * + * @param tentative Specifies whether the meeting will be tentatively accepted. + * @return An AcceptMeetingInvitationMessage representing the meeting + * acceptance message. + */ + public AcceptMeetingInvitationMessage createAcceptMessage(boolean + tentative) { + try { + return new AcceptMeetingInvitationMessage(this, tentative); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error creating accept message", e); + return null; + } + } + + /** + * Creates a local meeting declination message that can be customized and + * sent. + * + * @return A DeclineMeetingInvitation representing the meeting declination + * message. + */ + public DeclineMeetingInvitationMessage createDeclineMessage() { + try { + return new DeclineMeetingInvitationMessage(this); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error creating decline message", e); + return null; + } + } + + /** + * Accepts the meeting. Calling this method results in a call to EWS. + * + * @param sendResponse Indicates whether to send a response to the organizer. + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception throws Exception + */ + public CalendarActionResults accept(boolean sendResponse) throws Exception { + return this.internalAccept(false, sendResponse); + } + + /** + * Tentatively accepts the meeting. Calling this method results in a call to + * EWS. + * + * @param sendResponse Indicates whether to send a response to the organizer. + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception throws Exception + */ + public CalendarActionResults acceptTentatively(boolean sendResponse) + throws Exception { + return this.internalAccept(true, sendResponse); + } + + /** + * Accepts the meeting. + * + * @param tentative True if tentative accept. + * @param sendResponse Indicates whether to send a response to the organizer. + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception throws Exception + */ + protected CalendarActionResults internalAccept(boolean tentative, + boolean sendResponse) throws Exception { + AcceptMeetingInvitationMessage accept = this + .createAcceptMessage(tentative); + + if (sendResponse) { + return accept.calendarSendAndSaveCopy(); + } else { + return accept.calendarSave(); + + } + } + + /** + * Declines the meeting invitation. Calling this method results in a call to + * EWS. + * + * @param sendResponse Indicates whether to send a response to the organizer. + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception throws Exception + */ + public CalendarActionResults decline(boolean sendResponse) + throws Exception { + DeclineMeetingInvitationMessage decline = this.createDeclineMessage(); + + if (sendResponse) { + return decline.calendarSendAndSaveCopy(); + } else { + return decline.calendarSave(); + } + } + + /** + * Gets the type of this meeting request. + * + * @return the meeting request type + */ + public MeetingRequestType getMeetingRequestType() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(MeetingRequestSchema.MeetingRequestType); + } + + /** + * Gets the a value representing the intended free/busy status of the + * meeting. + * + * @return the intended free busy status + */ + public LegacyFreeBusyStatus getIntendedFreeBusyStatus() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(MeetingRequestSchema.IntendedFreeBusyStatus); + } + + /** + * Gets the start time of the appointment. + * + * @return the start + */ + public LocalDateTime getStart() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(AppointmentSchema.Start); + } + + /** + * Gets the end time of the appointment. + * + * @return the end + */ + public LocalDateTime getEnd() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(AppointmentSchema.End); + } + + /** + * Gets the original start time of the appointment. + * + * @return the original start + */ + public LocalDateTime getOriginalStart() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(AppointmentSchema.OriginalStart); + } + + /** + * Gets a value indicating whether this appointment is an all day event. + * + * @return the checks if is all day event + */ + public boolean getIsAllDayEvent() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.IsAllDayEvent) != null; + } + + /** + * Gets a value indicating the free/busy status of the owner of this + * appointment. + * + * @return the legacy free busy status + */ + public LegacyFreeBusyStatus legacyFreeBusyStatus() + throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.LegacyFreeBusyStatus); + } + + /** + * Gets the location of this appointment. + * + * @return the location + * @throws ServiceLocalException the service local exception + */ + public String getLocation() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.Location); + } + + /** + * Gets a text indicating when this appointment occurs. The text returned by + * When is localized using the Exchange Server culture or using the culture + * specified in the PreferredCulture property of the ExchangeService object + * this appointment is bound to. + * + * @return the when + */ + public String getWhen() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.When); + } + + /** + * Gets a value indicating whether the appointment is a meeting. + * + * @return the checks if is meeting + * @throws ServiceLocalException the service local exception + */ + public boolean getIsMeeting() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.IsMeeting) != null; + } + + /** + * Gets a value indicating whether the appointment has been cancelled. + * + * @return the checks if is cancelled + * @throws ServiceLocalException the service local exception + */ + public boolean getIsCancelled() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.IsCancelled) != null; + } + + /** + * Gets a value indicating whether the appointment is recurring. + * + * @return the checks if is recurring + * @throws ServiceLocalException the service local exception + */ + public boolean getIsRecurring() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.IsRecurring) != null; + } + + /** + * Gets a value indicating whether the meeting request has already been + * sent. + * + * @return the meeting request was sent + * @throws ServiceLocalException the service local exception + */ + public boolean getMeetingRequestWasSent() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.MeetingRequestWasSent) != null; + } + + /** + * Gets a value indicating the type of this appointment. + * + * @return the appointment type + * @throws ServiceLocalException the service local exception + */ + public AppointmentType getAppointmentType() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.AppointmentType); + } + + /** + * Gets a value indicating what was the last response of the user that + * loaded this meeting. + * + * @return the my response type + * @throws ServiceLocalException the service local exception + */ + public MeetingResponseType getMyResponseType() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.MyResponseType); + } + + /** + * Gets the organizer of this meeting. + * + * @return the organizer + * @throws ServiceLocalException the service local exception + */ + public EmailAddress getOrganizer() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.Organizer); + } + + /** + * Gets a list of required attendees for this meeting. + * + * @return the required attendees + * @throws ServiceLocalException the service local exception + */ + public AttendeeCollection getRequiredAttendees() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.RequiredAttendees); + } + + /** + * Gets a list of optional attendeed for this meeting. + * + * @return the optional attendees + * @throws ServiceLocalException the service local exception + */ + public AttendeeCollection getOptionalAttendees() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.OptionalAttendees); + } + + /** + * Gets a list of resources for this meeting. + * + * @return the resources + * @throws ServiceLocalException the service local exception + */ + public AttendeeCollection getResources() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.Resources); + } + + /** + * Gets the number of calendar entries that conflict with + * this appointment in the authenticated user's calendar. + * + * @return the conflicting meeting count + * @throws NumberFormatException the number format exception + * @throws ServiceLocalException the service local exception + */ + public int getConflictingMeetingCount() throws NumberFormatException, + ServiceLocalException, ExchangeXmlException { + return (Integer.parseInt(this.getPropertyBag() + .getObjectFromPropertyDefinition( + AppointmentSchema.ConflictingMeetingCount).toString())); + } + + /** + * Gets the number of calendar entries that are adjacent to + * this appointment in the authenticated user's calendar. + * + * @return the adjacent meeting count + * @throws NumberFormatException the number format exception + * @throws ServiceLocalException the service local exception + */ + public int getAdjacentMeetingCount() throws NumberFormatException, + ServiceLocalException, ExchangeXmlException { + return (Integer.parseInt(this.getPropertyBag() + .getObjectFromPropertyDefinition( + AppointmentSchema.AdjacentMeetingCount).toString())); + } + + /** + * Gets a list of meetings that conflict with + * this appointment in the authenticated user's calendar. + * + * @return the conflicting meetings + * @throws ServiceLocalException the service local exception + */ + public ItemCollection getConflictingMeetings() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.ConflictingMeetings); + } + + /** + * Gets a list of meetings that are adjacent with this + * appointment in the authenticated user's calendar. + * + * @return the adjacent meetings + * @throws ServiceLocalException the service local exception + */ + public ItemCollection getAdjacentMeetings() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.AdjacentMeetings); + } + + /** + * Gets the duration of this appointment. + * + * @return the duration + * @throws ServiceLocalException the service local exception + */ + public TimeSpan getDuration() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.Duration); + } + + /** + * Gets the name of the time zone this appointment is defined in. + * + * @return the time zone + * @throws ServiceLocalException the service local exception + */ + public String getTimeZone() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.TimeZone); + } + + /** + * Gets the time when the attendee replied to the meeting request. + * + * @return the appointment reply time + * @throws ServiceLocalException the service local exception + */ + public LocalDateTime getAppointmentReplyTime() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(AppointmentSchema.AppointmentReplyTime); + } + + /** + * Gets the sequence number of this appointment. + * + * @return the appointment sequence number + * @throws NumberFormatException the number format exception + * @throws ServiceLocalException the service local exception + */ + public int getAppointmentSequenceNumber() throws NumberFormatException, + ServiceLocalException, ExchangeXmlException { + return (Integer + .parseInt(this.getPropertyBag() + .getObjectFromPropertyDefinition( + AppointmentSchema.AppointmentSequenceNumber) + .toString())); + } + + /** + * Gets the state of this appointment. + * + * @return the appointment state + * @throws NumberFormatException the number format exception + * @throws ServiceLocalException the service local exception + */ + public int getAppointmentState() throws NumberFormatException, + ServiceLocalException, ExchangeXmlException { + return (Integer.parseInt(this.getPropertyBag() + .getObjectFromPropertyDefinition( + AppointmentSchema.AppointmentState).toString())); + } + + /** + * Gets the recurrence pattern for this meeting request. + * + * @return the recurrence + * @throws ServiceLocalException the service local exception + */ + public Recurrence getRecurrence() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.Recurrence); + } + + /** + * Gets an OccurrenceInfo identifying the first occurrence of this meeting. + * + * @return the first occurrence + * @throws ServiceLocalException the service local exception + */ + public OccurrenceInfo getFirstOccurrence() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.FirstOccurrence); + } + + /** + * Gets an OccurrenceInfo identifying the last occurrence of this meeting. + * + * @return the last occurrence + * @throws ServiceLocalException the service local exception + */ + public OccurrenceInfo getLastOccurrence() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.FirstOccurrence); + } + + /** + * Gets a list of modified occurrences for this meeting. + * + * @return the modified occurrences + * @throws ServiceLocalException the service local exception + */ + public OccurrenceInfoCollection getModifiedOccurrences() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.ModifiedOccurrences); + } + + /** + * Gets a list of deleted occurrences for this meeting. + * + * @return the deleted occurrences + * @throws ServiceLocalException the service local exception + */ + public DeletedOccurrenceInfoCollection getDeletedOccurrences() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.DeletedOccurrences); + } + + /** + * Gets time zone of the start property of this meeting request. + * + * @return the start time zone + * @throws ServiceLocalException the service local exception + */ + public TimeZoneDefinition getStartTimeZone() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.StartTimeZone); + } + + /** + * Gets time zone of the end property of this meeting request. + * + * @return the end time zone + * @throws ServiceLocalException the service local exception + */ + public TimeZoneDefinition getEndTimeZone() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.EndTimeZone); + } + + /** + * Gets the type of conferencing that will be used during the meeting. + * + * @return the conference type + * @throws NumberFormatException the number format exception + * @throws ServiceLocalException the service local exception + */ + public int getConferenceType() throws NumberFormatException, + ServiceLocalException, ExchangeXmlException { + return (Integer.parseInt(this.getPropertyBag() + .getObjectFromPropertyDefinition( + AppointmentSchema.ConferenceType).toString())); + } + + /** + * Gets a value indicating whether new time + * proposals are allowed for attendees of this meeting. + * + * @return the allow new time proposal + * @throws ServiceLocalException the service local exception + */ + public boolean getAllowNewTimeProposal() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.AllowNewTimeProposal); + } + + /** + * Gets a value indicating whether this is an online meeting. + * + * @return the checks if is online meeting + * @throws ServiceLocalException the service local exception + */ + public boolean getIsOnlineMeeting() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.IsOnlineMeeting); + } + + /** + * Gets the URL of the meeting workspace. A meeting + * workspace is a shared Web site for + * planning meetings and tracking results. + * + * @return the meeting workspace url + */ + public String getMeetingWorkspaceUrl() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.MeetingWorkspaceUrl); + } + + /** + * Gets the URL of the Microsoft NetShow online meeting. + * + * @return the net show url + */ + public String getNetShowUrl() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + AppointmentSchema.NetShowUrl); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/MeetingResponse.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/MeetingResponse.java new file mode 100644 index 000000000..1b6f589b4 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/MeetingResponse.java @@ -0,0 +1,109 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ItemAttachment; +import com.eischet.ews.api.property.complex.ItemId; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents a response to a meeting request. Properties available on meeting + * messages are defined in the MeetingMessageSchema class. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.MeetingResponse) +public class MeetingResponse extends MeetingMessage { + + private static final Logger LOG = Logger.getLogger(MeetingResponse.class.getCanonicalName()); + + /** + * Initializes a new instance of the class. + * + * @param parentAttachment The parentAttachment + * @throws Exception the exception + */ + public MeetingResponse(ItemAttachment parentAttachment) throws ExchangeXmlException { + super(parentAttachment); + } + + /** + * Initializes a new instance of the class. + * + * @param service EWS service to which this object belongs. + * @throws Exception the exception + */ + public MeetingResponse(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Binds to an existing meeting response and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service The service to use to bind to the meeting response. + * @param id The Id of the meeting response to bind to. + * @param propertySet The set of property to load. + * @return A MeetingResponse instance representing the meeting response + * corresponding to the specified Id. + */ + public static MeetingResponse bind(ExchangeService service, ItemId id, PropertySet propertySet) { + try { + return service.bindToItem(MeetingResponse.class, id, propertySet); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error binding meeting response", e); + return null; + } + } + + /** + * Binds to an existing meeting response and loads the specified set of + * property. Calling this method results in a call to EWS. + * + * @param service The service to use to bind to the meeting response. + * @param id The Id of the meeting response to bind to. + * @return A MeetingResponse instance representing the meeting response + * corresponding to the specified Id. + */ + public static MeetingResponse bind(ExchangeService service, ItemId id) { + return MeetingResponse.bind(service, id, PropertySet.getFirstClassProperties()); + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/PostItem.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/PostItem.java new file mode 100644 index 000000000..4152235e8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/PostItem.java @@ -0,0 +1,351 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.attribute.Attachable; +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.ResponseMessageType; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.response.PostReply; +import com.eischet.ews.api.core.service.response.ResponseMessage; +import com.eischet.ews.api.core.service.schema.EmailMessageSchema; +import com.eischet.ews.api.core.service.schema.PostItemSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.property.complex.EmailAddress; +import com.eischet.ews.api.property.complex.ItemAttachment; +import com.eischet.ews.api.property.complex.ItemId; +import com.eischet.ews.api.property.complex.MessageBody; + +import java.time.LocalDateTime; +import java.util.Arrays; + +/** + * Represents a post item. Properties available on post item are defined in the + * PostItemSchema class. + */ +@Attachable +@ServiceObjectDefinition(xmlElementName = XmlElementNames.PostItem) +public final class PostItem extends Item { + + /** + * Initializes an unsaved local instance of PostItem.To bind to an existing + * post item, use PostItem.Bind() instead. + * + * @param service the service + * @throws Exception the exception + */ + public PostItem(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Initializes a new instance of the class. + * + * @param parentAttachment the parent attachment + * @throws Exception the exception + */ + public PostItem(ItemAttachment parentAttachment) throws ExchangeXmlException { + super(parentAttachment); + } + + /** + * Binds to an existing post item and loads the specified set of property. + * Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @param propertySet the property set + * @return An PostItem instance representing the post item corresponding to + * the specified Id. + * @throws Exception the exception + */ + public static PostItem bind(ExchangeService service, ItemId id, + PropertySet propertySet) throws Exception { + return service.bindToItem(PostItem.class, id, propertySet); + } + + /** + * Binds to an existing post item and loads its first class property. + * calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @return An PostItem instance representing the post item corresponding to + * the specified Id. + * @throws Exception the exception + */ + public static PostItem bind(ExchangeService service, ItemId id) + throws Exception { + return PostItem + .bind(service, id, PropertySet.getFirstClassProperties()); + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return PostItemSchema.Instance; + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Creates a post reply to this post item. + * + * @return A PostReply that can be modified and saved. + * @throws Exception the exception + */ + public PostReply createPostReply() throws Exception { + this.throwIfThisIsNew(); + return new PostReply(this); + } + + /** + * Posts a reply to this post item. Calling this method results in a call to + * EWS. + * + * @param bodyPrefix the body prefix + * @throws Exception the exception + */ + public void postReply(MessageBody bodyPrefix) throws Exception { + PostReply postReply = this.createPostReply(); + postReply.setBodyPrefix(bodyPrefix); + postReply.save(); + } + + /** + * Creates a e-mail reply response to the post item. + * + * @param replyAll the reply all + * @return A ResponseMessage representing the e-mail reply response that can + * subsequently be modified and sent. + * @throws Exception the exception + */ + public ResponseMessage createReply(boolean replyAll) throws Exception { + this.throwIfThisIsNew(); + return new ResponseMessage(this, + replyAll ? ResponseMessageType.ReplyAll : + ResponseMessageType.Reply); + } + + /** + * Replies to the post item. Calling this method results in a call to EWS. + * + * @param bodyPrefix the body prefix + * @param replyAll the reply all + * @throws Exception the exception + */ + public void reply(MessageBody bodyPrefix, boolean replyAll) + throws Exception { + ResponseMessage responseMessage = this.createReply(replyAll); + responseMessage.setBodyPrefix(bodyPrefix); + responseMessage.sendAndSaveCopy(); + } + + /** + * Creates a forward response to the post item. + * + * @return A ResponseMessage representing the forward response that can + * subsequently be modified and sent. + * @throws Exception the exception + */ + public ResponseMessage createForward() throws Exception { + this.throwIfThisIsNew(); + return new ResponseMessage(this, ResponseMessageType.Forward); + } + + /** + * Forwards the post item. Calling this method results in a call to EWS. + * + * @param bodyPrefix the body prefix + * @param toRecipients the to recipients + * @throws Exception the exception + */ + public void forward(MessageBody bodyPrefix, EmailAddress... toRecipients) + throws Exception { + forward(bodyPrefix, Arrays.asList(toRecipients)); + } + + /** + * Forwards the post item. Calling this method results in a call to EWS. + * + * @param bodyPrefix the body prefix + * @param toRecipients the to recipients + * @throws Exception the exception + */ + public void forward(MessageBody bodyPrefix, + Iterable toRecipients) throws Exception { + ResponseMessage responseMessage = this.createForward(); + responseMessage.setBodyPrefix(bodyPrefix); + responseMessage.getToRecipients() + .addEmailRange(toRecipients.iterator()); + + responseMessage.sendAndSaveCopy(); + } + + // Properties + + /** + * Gets the conversation index of the post item. + * + * @return the conversation index + */ + public byte[] getConversationIndex() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.ConversationIndex); + } + + /** + * Gets the conversation topic of the post item. + * + * @return the conversation topic + */ + public String getConversationTopic() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.ConversationTopic); + } + + /** + * Gets the "on behalf" poster of the post item. + * + * @return the from + */ + public EmailAddress getFrom() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.From); + } + + /** + * Sets the from. + * + * @param value the new from + * @throws Exception the exception + */ + public void setFrom(EmailAddress value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.From, value); + } + + /** + * Gets the Internet message Id of the post item. + * + * @return the internet message id + */ + public String getInternetMessageId() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.InternetMessageId); + } + + /** + * Gets a value indicating whether the post item is read. + * + * @return the checks if is read + * @throws ServiceLocalException the service local exception + */ + public Boolean getIsRead() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.IsRead); + } + + /** + * Sets the checks if is read. + * + * @param value the new checks if is read + * @throws Exception the exception + */ + public void setIsRead(Boolean value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.IsRead, value); + } + + /** + * Gets the the date and time when the post item was posted. + * + * @return the posted time + * @throws ServiceLocalException the service local exception + */ + public LocalDateTime getPostedTime() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(PostItemSchema.PostedTime); + } + + /** + * Gets the references of the post item. + * + * @return the references + * @throws ServiceLocalException the service local exception + */ + public String getReferences() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(EmailMessageSchema.References); + } + + /** + * Sets the checks if is read. + * + * @param value the new checks if is read + * @throws Exception the exception + */ + public void setIsRead(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.References, value); + } + + /** + * Gets the sender (poster) of the post item. + * + * @return the sender + * @throws ServiceLocalException the service local exception + */ + public EmailAddress getSender() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + EmailMessageSchema.Sender); + } + + /** + * Sets the sender. + * + * @param value the new sender + * @throws Exception the exception + */ + public void setSender(EmailAddress value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.Sender, value); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Task.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Task.java new file mode 100644 index 000000000..acd22c47a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/item/Task.java @@ -0,0 +1,587 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.item; + +import com.eischet.ews.api.attribute.Attachable; +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.TaskDelegationState; +import com.eischet.ews.api.core.enumeration.service.*; +import com.eischet.ews.api.core.enumeration.service.calendar.AffectedTaskOccurrence; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.remote.ServiceResponseException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.core.service.schema.TaskSchema; +import com.eischet.ews.api.property.complex.ItemAttachment; +import com.eischet.ews.api.property.complex.ItemId; +import com.eischet.ews.api.property.complex.StringList; +import com.eischet.ews.api.property.complex.recurrence.pattern.Recurrence; + +import java.time.LocalDateTime; + +/** + * Represents a Task item. Properties available on tasks are defined in the + * TaskSchema class. + */ +@Attachable +@ServiceObjectDefinition(xmlElementName = XmlElementNames.Task) +public class Task extends Item { + + private static final double PERCENT_MIN = 0.0D; + private static final double PERCENT_MAX = 100.0D; + + + /** + * Initializes an unsaved local instance of Task.To bind to an existing + * task, use Task.Bind() instead. + * + * @param service the service + * @throws Exception the exception + */ + public Task(ExchangeService service) throws ExchangeXmlException { + super(service); + } + + /** + * Initializes a new instance of the class. + * + * @param parentAttachment the parent attachment + * @throws Exception the exception + */ + public Task(ItemAttachment parentAttachment) throws ExchangeXmlException { + super(parentAttachment); + } + + /** + * Binds to an existing task and loads the specified set of property. + * Calling this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @param propertySet the property set + * @return A Task instance representing the task corresponding to the + * specified Id. + * @throws Exception the exception + */ + public static Task bind(ExchangeService service, ItemId id, + PropertySet propertySet) throws Exception { + return service.bindToItem(Task.class, id, propertySet); + } + + /** + * Binds to an existing task and loads its first class property. Calling + * this method results in a call to EWS. + * + * @param service the service + * @param id the id + * @return A Task instance representing the task corresponding to the + * specified Id. + * @throws Exception the exception + */ + public static Task bind(ExchangeService service, ItemId id) + throws Exception { + return Task.bind(service, id, PropertySet.getFirstClassProperties()); + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return TaskSchema.Instance; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets a value indicating whether a time zone SOAP header should be + * emitted in a CreateItem or UpdateItem request so this item can be + * property saved or updated. + * + * @param isUpdateOperation the is update operation + * @return if a time zone SOAP header should be emitted; otherwise, . + */ + @Override + public boolean getIsTimeZoneHeaderRequired(boolean isUpdateOperation) { + return true; + } + + /** + * Deletes the current occurrence of a recurring task. After the current + * occurrence isdeleted, the task represents the next occurrence. Developers + * should call Load to retrieve the new property values of the task. Calling + * this method results in a call to EWS. + * + * @param deleteMode the delete mode + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + public void deleteCurrentOccurrence(DeleteMode deleteMode) + throws ServiceLocalException, Exception { + this.internalDelete(deleteMode, null, + AffectedTaskOccurrence.SpecifiedOccurrenceOnly); + } + + /** + * Applies the local changes that have been made to this task. Calling + * this method results in at least one call to EWS. Mutliple calls to EWS + * might be made if attachments have been added or removed. + * + * @param conflictResolutionMode the conflict resolution mode + * @return A Task object representing the completed occurrence if the task + * is recurring and the update marks it as completed; or a Task + * object representing the current occurrence if the task is + * recurring and the uypdate changed its recurrence pattern; or null + * in every other case. + * @throws ServiceResponseException the service response exception + * @throws Exception the exception + */ + public Task updateTask(ConflictResolutionMode conflictResolutionMode) throws ServiceResponseException, Exception { + return (Task) this.internalUpdate(null /* parentFolder */, conflictResolutionMode, MessageDisposition.SaveOnly, null); + } + + // Properties + + /** + * Gets the actual amount of time that is spent on the task. + * + * @return the actual work + */ + public Integer getActualWork() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.ActualWork); + } + + /** + * Sets the checks if is read. + * + * @param value the new checks if is read + * @throws Exception the exception + */ + public void setActualWork(Integer value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + TaskSchema.ActualWork, value); + } + + /** + * Gets the date and time the task was assigned. + * + * @return the assigned time + */ + public LocalDateTime getAssignedTime() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.AssignedTime); + } + + /** + * Gets the billing information of the task. + * + * @return the billing information + */ + public String getBillingInformation() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.BillingInformation); + } + + /** + * Sets the billing information. + * + * @param value the new billing information + * @throws Exception the exception + */ + public void setBillingInformation(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + TaskSchema.BillingInformation, value); + } + + /** + * Gets the number of times the task has changed since it was created. + * + * @return the change count + * @throws ServiceLocalException the service local exception + */ + public Integer getChangeCount() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.ChangeCount); + } + + /** + * Gets a list of companies associated with the task. + * + * @return the companies + * @throws ServiceLocalException the service local exception + */ + public StringList getCompanies() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.Companies); + } + + /** + * Sets the companies. + * + * @param value the new companies + * @throws Exception the exception + */ + public void setCompanies(StringList value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + TaskSchema.Companies, value); + } + + /** + * Gets the date and time on which the task was completed. + * + * @return the complete date + * @throws ServiceLocalException the service local exception + */ + public LocalDateTime getCompleteDate() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.CompleteDate); + } + + /** + * Sets the complete date. + * + * @param value the new complete date + * @throws Exception the exception + */ + public void setCompleteDate(LocalDateTime value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + TaskSchema.CompleteDate, value); + } + + /** + * Gets a list of contacts associated with the task. + * + * @return the contacts + * @throws ServiceLocalException the service local exception + */ + public StringList getContacts() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.Contacts); + } + + /** + * Sets the contacts. + * + * @param value the new contacts + * @throws Exception the exception + */ + public void setContacts(StringList value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + TaskSchema.Contacts, value); + } + + /** + * Gets the current delegation state of the task. + * + * @return the delegation state + * @throws ServiceLocalException the service local exception + */ + public TaskDelegationState getDelegationState() + throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.DelegationState); + } + + /** + * Gets the name of the delegator of this task. + * + * @return the delegator + * @throws ServiceLocalException the service local exception + */ + public String getDelegator() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.Delegator); + } + + /** + * Gets a list of contacts associated with the task. + * + * @return the due date + * @throws ServiceLocalException the service local exception + */ + public LocalDateTime getDueDate() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.DueDate); + } + + /** + * Sets the due date. + * + * @param value the new due date + * @throws Exception the exception + */ + public void setDueDate(LocalDateTime value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + TaskSchema.DueDate, value); + } + + /** + * Gets a value indicating the mode of the task. + * + * @return the mode + * @throws ServiceLocalException the service local exception + */ + public TaskMode getMode() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(TaskSchema.Mode); + } + + /** + * Gets a value indicating whether the task is complete. + * + * @return the checks if is complete + * @throws ServiceLocalException the service local exception + */ + public Boolean getIsComplete() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.IsComplete); + } + + /** + * Gets a value indicating whether the task is recurring. + * + * @return the checks if is recurring + * @throws ServiceLocalException the service local exception + */ + public Boolean getIsRecurring() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.IsRecurring); + } + + /** + * Gets a value indicating whether the task is a team task. + * + * @return the checks if is team task + * @throws ServiceLocalException the service local exception + */ + public Boolean getIsTeamTask() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.IsTeamTask); + } + + /** + * Gets the mileage of the task. + * + * @return the mileage + * @throws ServiceLocalException the service local exception + */ + public String getMileage() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.Mileage); + } + + /** + * Sets the mileage. + * + * @param value the new mileage + * @throws Exception the exception + */ + public void setMileage(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + TaskSchema.Mileage, value); + } + + /** + * Gets the name of the owner of the task. + * + * @return the owner + * @throws ServiceLocalException the service local exception + */ + public String getOwner() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.Owner); + } + + /** + * Gets the completion percentage of the task. + * PercentComplete must be between + * 0 and 100. + * + * @return the percent complete + * @throws ServiceLocalException the service local exception + */ + public Double getPercentComplete() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.PercentComplete); + } + + /** + * Sets the completion percentage of the task. + * PercentComplete must be between + * 0.0 and 100.0 . + * + * @param value the new percent complete + * @throws Exception the exception + * @deprecated use Double parameter instead + */ + @Deprecated + public void setPercentComplete(String value) throws Exception { + setPercentComplete(Double.valueOf(value)); + } + + /** + * Sets the completion percentage of the task. + * PercentComplete must be between + * 0.0 and 100.0 . + * + * @param value the new percent complete + * @throws Exception the exception + */ + public void setPercentComplete(Double value) throws Exception { + if (value == null || Double.isNaN(value) || value < PERCENT_MIN || value > PERCENT_MAX) { + throw new IllegalArgumentException( + String.format("%s must be between %f and %f", + value, PERCENT_MIN, PERCENT_MAX)); + } + this.getPropertyBag().setObjectFromPropertyDefinition( + TaskSchema.PercentComplete, value); + } + + /** + * Gets the recurrence pattern for this task. Available recurrence + * pattern classes include Recurrence.DailyPattern, + * Recurrence.MonthlyPattern and Recurrence.YearlyPattern. + * + * @return the recurrence + * @throws ServiceLocalException the service local exception + */ + public Recurrence getRecurrence() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.Recurrence); + } + + /** + * Sets the recurrence. + * + * @param value the new recurrence + * @throws Exception the exception + */ + public void setRecurrence(Recurrence value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + TaskSchema.Recurrence, value); + } + + /** + * Gets the date and time on which the task starts. + * + * @return the start date + * @throws ServiceLocalException the service local exception + */ + public LocalDateTime getStartDate() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.StartDate); + } + + /** + * Sets the start date. + * + * @param value the new start date + * @throws Exception the exception + */ + public void setStartDate(LocalDateTime value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + TaskSchema.StartDate, value); + } + + /** + * Gets the status of the task. + * + * @return the status + * @throws ServiceLocalException the service local exception + */ + public TaskStatus getStatus() throws ServiceLocalException, ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(TaskSchema.Status); + } + + /** + * Sets the status. + * + * @param value the new status + * @throws Exception the exception + */ + public void setStatus(TaskStatus value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + TaskSchema.Status, value); + } + + /** + * Gets a string representing the status of the task, localized according to + * the PreferredCulture property of the ExchangeService object the task is + * bound to. + * + * @return the status description + */ + public String getStatusDescription() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition(TaskSchema.StatusDescription); + } + + /** + * Gets the total amount of work spent on the task. + * + * @return the total work + */ + public Integer getTotalWork() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + TaskSchema.TotalWork); + } + + /** + * Sets the total work. + * + * @param value the new total work + * @throws Exception the exception + */ + public void setTotalWork(Integer value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + TaskSchema.TotalWork, value); + } + + /** + * Gets the default setting for how to treat affected task occurrences on + * Delete. AffectedTaskOccurrence.AllOccurrences: All affected Task + * occurrences will be deleted. + * + * @return the default affected task occurrences + */ + @Override + protected AffectedTaskOccurrence getDefaultAffectedTaskOccurrences() { + return AffectedTaskOccurrence.AllOccurrences; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/response/AcceptMeetingInvitationMessage.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/AcceptMeetingInvitationMessage.java new file mode 100644 index 000000000..5e18ab0b8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/AcceptMeetingInvitationMessage.java @@ -0,0 +1,100 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.response; + +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.core.service.item.MeetingResponse; + +/** + * Represents a meeting acceptance message. + */ +public final class AcceptMeetingInvitationMessage extends + CalendarResponseMessage { + + /** + * The tentative. + */ + private final boolean tentative; + + /** + * Initializes a new instance of the AcceptMeetingInvitationMessage class. + * + * @param referenceItem the reference item + * @param tentative the tentative + * @throws Exception the exception + */ + public AcceptMeetingInvitationMessage(Item referenceItem, boolean tentative) throws Exception { + super(referenceItem); + this.tentative = tentative; + } + + /** + * This methods lets subclasses of ServiceObject override the default + * mechanism by which the XML element name associated with their type is + * retrieved. + * + * @return The XML element name associated with this type. If this method + * returns null or empty, the XML element name associated with this + * type is determined by the EwsObjectDefinition attribute that + * decorates the type, if present. + *

+ * Item and folder classes that can be returned by EWS MUST rely on + * the EwsObjectDefinition attribute for XML element name determination. + *

+ */ + @Override + public String getXmlElementName() { + // getXmlElementOverride is pvt and getXmlElementName returns + // getXmlElementOverride + if (this.tentative) { + return XmlElementNames.TentativelyAcceptItem; + } else { + return XmlElementNames.AcceptItem; + } + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the tentative. + * + * @return Gets a value indicating whether the associated meeting is + * tentatively accepted. + */ + public boolean getTentative() { + return this.tentative; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/response/CalendarResponseMessage.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/CalendarResponseMessage.java new file mode 100644 index 000000000..3b6239aed --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/CalendarResponseMessage.java @@ -0,0 +1,215 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.response; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.property.Sensitivity; +import com.eischet.ews.api.core.service.item.EmailMessage; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.core.service.schema.CalendarResponseObjectSchema; +import com.eischet.ews.api.core.service.schema.EmailMessageSchema; +import com.eischet.ews.api.core.service.schema.ItemSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.property.complex.*; + +/** + * Represents the base class for accept, tentatively accept and decline response + * messages. + * + * @param The type of message that is created when this response message is + * saved. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class CalendarResponseMessage + extends CalendarResponseMessageBase { + + /** + * Initializes a new instance of the CalendarResponseMessage class. + * + * @param referenceItem The reference item + * @throws Exception the exception + */ + protected CalendarResponseMessage(Item referenceItem) throws Exception { + super(referenceItem); + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return CalendarResponseObjectSchema.Instance; + } + + /** + * Gets the body of the response. + * + * @return the body + * @throws Exception the exception + */ + public MessageBody getBody() throws Exception { + return (MessageBody) this + .getObjectFromPropertyDefinition(ItemSchema.Body); + } + + /** + * Sets the body. + * + * @param value the new body + * @throws Exception the exception + */ + public void setBody(MessageBody value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition(ItemSchema.Body, + value); + } + + /** + * Gets a list of recipients the response will be sent to. + * + * @return the to recipients + * @throws Exception the exception + */ + public EmailAddressCollection getToRecipients() throws Exception { + return (EmailAddressCollection) this + .getObjectFromPropertyDefinition( + EmailMessageSchema.ToRecipients); + } + + /** + * Gets a list of recipients the response will be sent to as Cc. + * + * @return the cc recipients + * @throws Exception the exception + */ + public EmailAddressCollection getCcRecipients() throws Exception { + return (EmailAddressCollection) this + .getObjectFromPropertyDefinition( + EmailMessageSchema.CcRecipients); + } + + /** + * Gets a list of recipients this response will be sent to as Bcc. + * + * @return the bcc recipients + * @throws Exception the exception + */ + public EmailAddressCollection getBccRecipients() throws Exception { + return (EmailAddressCollection) this + .getObjectFromPropertyDefinition( + EmailMessageSchema.BccRecipients); + } + + /** + * Gets the item class. + * + * @return the item class + * @throws Exception the exception + */ + protected String getItemClass() throws Exception { + return (String) this + .getObjectFromPropertyDefinition(ItemSchema.ItemClass); + } + + /** + * Sets the item class. + * + * @param value the new item class + * @throws Exception the exception + */ + protected void setItemClass(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.ItemClass, value); + } + + /** + * Gets the sensitivity of this response. + * + * @return the sensitivity + * @throws Exception the exception + */ + public Sensitivity getSensitivity() throws Exception { + return (Sensitivity) this + .getObjectFromPropertyDefinition(ItemSchema.Sensitivity); + } + + /** + * Sets the sensitivity. + * + * @param value the new sensitivity + * @throws Exception the exception + */ + public void setSensitivity(Sensitivity value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ItemSchema.Sensitivity, value); + } + + /** + * Gets a list of attachments to this response. + * + * @return the attachments + * @throws Exception the exception + */ + public AttachmentCollection getAttachments() throws Exception { + return (AttachmentCollection) this + .getObjectFromPropertyDefinition(ItemSchema.Attachments); + } + + /** + * Gets the internet message headers. + * + * @return the internet message headers + * @throws Exception the exception + */ + protected InternetMessageHeaderCollection getInternetMessageHeaders() + throws Exception { + return (InternetMessageHeaderCollection) this + .getObjectFromPropertyDefinition( + ItemSchema.InternetMessageHeaders); + } + + /** + * Gets the sender of this response. + * + * @return the sender + * @throws Exception the exception + */ + public EmailAddress getSender() throws Exception { + return (EmailAddress) this + .getObjectFromPropertyDefinition(EmailMessageSchema.Sender); + } + + /** + * Sets the sender. + * + * @param value the new sender + * @throws Exception the exception + */ + public void setSender(EmailAddress value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.Sender, value); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/response/CalendarResponseMessageBase.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/CalendarResponseMessageBase.java new file mode 100644 index 000000000..f724fbb47 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/CalendarResponseMessageBase.java @@ -0,0 +1,160 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.response; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.enumeration.service.MessageDisposition; +import com.eischet.ews.api.core.service.item.EmailMessage; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.misc.CalendarActionResults; +import com.eischet.ews.api.property.complex.FolderId; + +/** + * Represents the base class for all calendar-related response messages. + * + * @param The type of message that is created when this response message is + * saved. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class CalendarResponseMessageBase + extends ResponseObject { + + /** + * Initializes a new instance of the CalendarResponseMessageBase class. + * + * @param referenceItem the reference item + * @throws Exception the exception + */ + CalendarResponseMessageBase(Item referenceItem) throws Exception { + super(referenceItem); + } + + /** + * Saves the response in the specified folder. Calling this method results + * in a call to EWS. + * + * @param destinationFolderId The Id of the folder in which to save the response. + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + + public CalendarActionResults calendarSave(FolderId destinationFolderId) + throws Exception { + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + + return new CalendarActionResults(this.internalCreate( + destinationFolderId, MessageDisposition.SaveOnly)); + } + + /** + * Saves the response in the specified folder. Calling this method results + * in a call to EWS. + * + * @param destinationFolderName The name of the folder in which to save the response. + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + public CalendarActionResults calendarSave( + WellKnownFolderName destinationFolderName) throws Exception { + return new CalendarActionResults(this.internalCreate(new FolderId( + destinationFolderName), MessageDisposition.SaveOnly)); + } + + /** + * Saves the response in the Drafts folder. Calling this method results in a + * call to EWS. + * + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + public CalendarActionResults calendarSave() throws Exception { + return new CalendarActionResults(this.internalCreate(null, + MessageDisposition.SaveOnly)); + } + + /** + * Sends this response without saving a copy. Calling this method results in + * a call to EWS. + * + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + public CalendarActionResults calendarSend() throws Exception { + return new CalendarActionResults(this.internalCreate(null, + MessageDisposition.SendOnly)); + } + + /** + * Sends this response ans saves a copy in the specified folder. Calling + * this method results in a call to EWS. + * + * @param destinationFolderId The Id of the folder in which to save the copy of the message. + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + + public CalendarActionResults calendarSendAndSaveCopy( + FolderId destinationFolderId) throws Exception { + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + return new CalendarActionResults(this.internalCreate( + destinationFolderId, MessageDisposition.SendAndSaveCopy)); + } + + /** + * Sends this response ans saves a copy in the specified folder. Calling + * this method results in a call to EWS. + * + * @param destinationFolderName the destination folder name + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + public CalendarActionResults calendarSendAndSaveCopy( + WellKnownFolderName destinationFolderName) throws Exception { + return new CalendarActionResults(this.internalCreate(new FolderId( + destinationFolderName), MessageDisposition.SendAndSaveCopy)); + } + + /** + * Sends this response ans saves a copy in the specified folder. Calling + * this method results in a call to EWS. + * + * @return A CalendarActionResults object containing the various item that + * were created or modified as a results of this operation. + * @throws Exception the exception + */ + public CalendarActionResults calendarSendAndSaveCopy() throws Exception { + return new CalendarActionResults(this.internalCreate(null, + MessageDisposition.SendAndSaveCopy)); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/response/CancelMeetingMessage.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/CancelMeetingMessage.java new file mode 100644 index 000000000..133e91b0f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/CancelMeetingMessage.java @@ -0,0 +1,96 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.response; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.core.service.item.MeetingCancellation; +import com.eischet.ews.api.core.service.schema.CancelMeetingMessageSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.property.complex.MessageBody; + +/** + * Represents a meeting cancellation message. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.CancelCalendarItem, returnedByServer = false) +public final class CancelMeetingMessage extends + CalendarResponseMessageBase { + + /** + * Initializes a new instance of the class. + * + * @param referenceItem the reference item + * @throws Exception the exception + */ + public CancelMeetingMessage(Item referenceItem) throws Exception { + super(referenceItem); + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ServiceObjectSchema getSchema() { + return CancelMeetingMessageSchema.Instance; + } + + /** + * Gets the body of the response. + * + * @return the body + */ + public MessageBody getBody() throws ExchangeXmlException { + return getPropertyBag().getObjectFromPropertyDefinition( + CancelMeetingMessageSchema.Body); + } + + /** + * Sets the body. + * + * @param value the new body + * @throws Exception the exception + */ + public void setBody(MessageBody value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + CancelMeetingMessageSchema.Body, value); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/response/DeclineMeetingInvitationMessage.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/DeclineMeetingInvitationMessage.java new file mode 100644 index 000000000..a67f4eeae --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/DeclineMeetingInvitationMessage.java @@ -0,0 +1,61 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.response; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.core.service.item.MeetingResponse; + +/** + * Represents a meeting declination message. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.DeclineItem, returnedByServer = false) +public final class DeclineMeetingInvitationMessage extends + CalendarResponseMessage { + + /** + * Initializes a new instance of the DeclineMeetingInvitationMessage class. + * + * @param referenceItem the reference item + * @throws Exception the exception + */ + public DeclineMeetingInvitationMessage(Item referenceItem) + throws Exception { + super(referenceItem); + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/response/PostReply.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/PostReply.java new file mode 100644 index 000000000..95e3c297a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/PostReply.java @@ -0,0 +1,254 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.response; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.enumeration.service.DeleteMode; +import com.eischet.ews.api.core.enumeration.service.MessageDisposition; +import com.eischet.ews.api.core.enumeration.service.SendCancellationsMode; +import com.eischet.ews.api.core.enumeration.service.calendar.AffectedTaskOccurrence; +import com.eischet.ews.api.core.exception.misc.InvalidOperationException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.core.service.item.PostItem; +import com.eischet.ews.api.core.service.schema.*; +import com.eischet.ews.api.property.complex.FolderId; +import com.eischet.ews.api.property.complex.ItemId; +import com.eischet.ews.api.property.complex.MessageBody; + +import java.util.List; + +/** + * Represents a reply to a post item. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.PostReplyItem, returnedByServer = false) +public final class PostReply extends ServiceObject { + + /** + * The reference item. + */ + private final Item referenceItem; + + /** + * Initializes a new instance of the class. + * + * @param referenceItem the reference item + * @throws Exception the exception + */ + public PostReply(Item referenceItem) throws Exception { + super(referenceItem.getService()); + referenceItem.throwIfThisIsNew(); + + this.referenceItem = referenceItem; + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return PostReplySchema.Instance; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Create a PostItem response. + * + * @param parentFolderId the parent folder id + * @param messageDisposition the message disposition + * @return Created PostItem. + * @throws Exception the exception + */ + protected PostItem internalCreate(FolderId parentFolderId, + MessageDisposition messageDisposition) throws Exception { + ((ItemId) this + .getObjectFromPropertyDefinition( + ResponseObjectSchema.ReferenceItemId)) + .assign(this.referenceItem.getId()); + + List items = this.getService().internalCreateResponseObject(this, + parentFolderId, messageDisposition); + + PostItem postItem = EwsUtilities.findFirstItemOfType(PostItem.class, + items); + + // This should never happen. If it does, we have a bug. + EwsUtilities + .ewsAssert(postItem != null, "PostReply.InternalCreate", + "postItem is null. The CreateItem call did" + " not return the expected PostItem."); + + return postItem; + } + + /** + * Loads the specified set of property on the object. + * + * @param propertySet the property set + * @throws InvalidOperationException the invalid operation exception + */ + @Override + protected void internalLoad(PropertySet propertySet) + throws InvalidOperationException { + throw new InvalidOperationException("Loading this type of object is not supported."); + } + + /** + * Deletes the object. + * + * @param deleteMode the delete mode + * @param sendCancellationsMode the send cancellations mode + * @param affectedTaskOccurrences the affected task occurrences + * @throws InvalidOperationException the invalid operation exception + */ + @Override + protected void internalDelete(DeleteMode deleteMode, + SendCancellationsMode sendCancellationsMode, + AffectedTaskOccurrence affectedTaskOccurrences) + throws InvalidOperationException { + throw new InvalidOperationException("Deleting this type of object isn't authorized."); + } + + /** + * Saves the post reply in the same folder as the original post item. + * Calling this method results in a call to EWS. + * + * @return A PostItem representing the posted reply + * @throws Exception the exception + */ + public PostItem save() throws Exception { + return this.internalCreate(null, null); + } + + /** + * Saves the post reply in the same folder as the original post item. + * Calling this method results in a call to EWS. + * + * @param destinationFolderId the destination folder id + * @return A PostItem representing the posted reply + * @throws Exception the exception + */ + public PostItem save(FolderId destinationFolderId) throws Exception { + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + return this.internalCreate(destinationFolderId, null); + } + + /** + * Saves the post reply in a specified folder. Calling this method results + * in a call to EWS. + * + * @param destinationFolderName the destination folder name + * @return A PostItem representing the posted reply. + * @throws Exception the exception + */ + public PostItem save(WellKnownFolderName destinationFolderName) + throws Exception { + return this.internalCreate(new FolderId(destinationFolderName), null); + } + + /** + * Gets the subject of the post reply. + * + * @return the subject + * @throws Exception the exception + */ + public String getSubject() throws Exception { + return (String) this + .getObjectFromPropertyDefinition(EmailMessageSchema.Subject); + } + + /** + * Sets the subject. + * + * @param value the new subject + * @throws Exception the exception + */ + public void setSubject(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.Subject, value); + } + + /** + * Gets the body of the post reply. + * + * @return the body + * @throws Exception the exception + */ + public MessageBody getBody() throws Exception { + return (MessageBody) this + .getObjectFromPropertyDefinition(ItemSchema.Body); + } + + /** + * Sets the body. + * + * @param value the new body + * @throws Exception the exception + */ + public void setBody(MessageBody value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition(ItemSchema.Body, + value); + } + + /** + * Gets the body prefix that should be prepended to the original + * post item's body. + * + * @return the body prefix + * @throws Exception the exception + */ + public MessageBody getBodyPrefix() throws Exception { + return (MessageBody) this + .getObjectFromPropertyDefinition( + ResponseObjectSchema.BodyPrefix); + } + + /** + * Sets the body prefix. + * + * @param value the new body prefix + * @throws Exception the exception + */ + public void setBodyPrefix(MessageBody value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ResponseObjectSchema.BodyPrefix, value); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/response/RemoveFromCalendar.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/RemoveFromCalendar.java new file mode 100644 index 000000000..8af167741 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/RemoveFromCalendar.java @@ -0,0 +1,135 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.response; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.DeleteMode; +import com.eischet.ews.api.core.enumeration.service.MessageDisposition; +import com.eischet.ews.api.core.enumeration.service.SendCancellationsMode; +import com.eischet.ews.api.core.enumeration.service.calendar.AffectedTaskOccurrence; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.core.service.schema.ResponseObjectSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.property.complex.FolderId; +import com.eischet.ews.api.property.complex.ItemId; + +import java.util.List; + +/** + * Represents a response object created to remove a calendar item from a meeting + * cancellation. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.RemoveItem, returnedByServer = false) +public class RemoveFromCalendar extends + ServiceObject { + + /** + * The reference item. + */ + private final Item referenceItem; + + /** + * Initializes a new instance of the RemoveFromCalendar class. + * + * @param referenceItem The reference item + * @throws Exception the exception + */ + public RemoveFromCalendar(Item referenceItem) throws Exception { + super(referenceItem.getService()); + + referenceItem.throwIfThisIsNew(); + + this.referenceItem = referenceItem; + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return ResponseObjectSchema.Instance; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Loads the specified set of property on the object. + * + * @param propertySet The property to load. + */ + @Override + protected void internalLoad(PropertySet propertySet) { + throw new UnsupportedOperationException(); + } + + /** + * Deletes the object. + * + * @param deleteMode The deletion mode. + * @param sendCancellationsMode Indicates whether meeting cancellation messages should be + * sent. + * @param affectedTaskOccurrences Indicate which occurrence of a recurring task should be + * deleted. + */ + @Override + protected void internalDelete(DeleteMode deleteMode, + SendCancellationsMode sendCancellationsMode, + AffectedTaskOccurrence affectedTaskOccurrences) { + throw new UnsupportedOperationException(); + } + + /** + * Create response object. + * + * @param parentFolderId The parent folder id. + * @param messageDisposition The message disposition. + * @return A list of item that were created or modified as a results of + * this operation. + * @throws Exception the exception + */ + public List internalCreate(FolderId parentFolderId, MessageDisposition messageDisposition) throws Exception { + ((ItemId) this.getPropertyBag().getObjectFromPropertyDefinition( + ResponseObjectSchema.ReferenceItemId)) + .assign(this.referenceItem.getId()); + + return this.getService().internalCreateResponseObject(this, + parentFolderId, messageDisposition); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/response/ResponseMessage.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/ResponseMessage.java new file mode 100644 index 000000000..6033c3230 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/ResponseMessage.java @@ -0,0 +1,220 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.response; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.ResponseMessageType; +import com.eischet.ews.api.core.service.item.EmailMessage; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.core.service.schema.*; +import com.eischet.ews.api.property.complex.EmailAddressCollection; +import com.eischet.ews.api.property.complex.MessageBody; + +/** + * The Class ResponseMessage. + */ +public final class ResponseMessage extends ResponseObject { + + /** + * Represents the base class for e-mail related response (Reply, Reply all + * and Forward). + */ + private final ResponseMessageType responseType; + + /** + * Initializes a new instance of the class. + * + * @param referenceItem the reference item + * @param responseType the response type + * @throws Exception the exception + */ + public ResponseMessage(Item referenceItem, ResponseMessageType responseType) + throws Exception { + super(referenceItem); + this.responseType = responseType; + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return ResponseMessageSchema.Instance; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * This methods lets subclasses of ServiceObject override the default + * mechanism by which the XML element name associated with their type is + * retrieved. + * + * @return The XML element name associated with this type. If this method + * returns null or empty, the XML element name associated with this + * type is determined by the EwsObjectDefinition attribute that + * decorates the type,if present. + */ + protected String getXmlElementNameOverride() { + + if (this.responseType == ResponseMessageType.Reply) { + return XmlElementNames.ReplyToItem; + } else if (this.responseType == ResponseMessageType.ReplyAll) { + return XmlElementNames.ReplyAllToItem; + } else if (this.responseType == ResponseMessageType.Forward) { + return XmlElementNames.ForwardItem; + } else { + EwsUtilities.ewsAssert(false, "ResponseMessage.GetXmlElementNameOverride", + "An unexpected value for responseType could not be handled."); + return null; // Because the compiler wants it + } + + } + + /** + * Gets a value indicating the type of response this object represents. + * + * @return the response type + */ + public ResponseMessageType getResponseType() { + return this.responseType; + } + + /** + * Gets the body of the response. + * + * @return the body + * @throws Exception the exception + */ + public MessageBody getBody() throws Exception { + return (MessageBody) this + .getObjectFromPropertyDefinition(ItemSchema.Body); + } + + /** + * Sets the body. + * + * @param value the new body + * @throws Exception the exception + */ + public void setBody(MessageBody value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition(ItemSchema.Body, + value); + } + + /** + * Gets a list of recipients the response will be sent to. + * + * @return the to recipients + * @throws Exception the exception + */ + public EmailAddressCollection getToRecipients() throws Exception { + return (EmailAddressCollection) this + .getObjectFromPropertyDefinition( + EmailMessageSchema.ToRecipients); + } + + /** + * Gets a list of recipients the response will be sent to as Cc. + * + * @return the cc recipients + * @throws Exception the exception + */ + public EmailAddressCollection getCcRecipients() throws Exception { + return (EmailAddressCollection) this + .getObjectFromPropertyDefinition( + EmailMessageSchema.CcRecipients); + } + + /** + * Gets a list of recipients the response will be sent to as Cc. + * + * @return the bcc recipients + * @throws Exception the exception + */ + public EmailAddressCollection getBccRecipients() throws Exception { + return (EmailAddressCollection) this + .getObjectFromPropertyDefinition( + EmailMessageSchema.BccRecipients); + } + + /** + * Gets the subject of this response. + * + * @return the subject + * @throws Exception the exception + */ + public String getSubject() throws Exception { + return (String) this + .getObjectFromPropertyDefinition(EmailMessageSchema.Subject); + } + + /** + * Sets the subject. + * + * @param value the new subject + * @throws Exception the exception + */ + public void setSubject(String value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + EmailMessageSchema.Subject, value); + } + + /** + * Gets the body prefix of this response. The body prefix will be + * prepended to the original message's body when the response is created. + * + * @return the body prefix + * @throws Exception the exception + */ + public MessageBody getBodyPrefix() throws Exception { + return (MessageBody) this + .getObjectFromPropertyDefinition( + ResponseObjectSchema.BodyPrefix); + } + + /** + * Sets the body prefix. + * + * @param value the new body prefix + * @throws Exception the exception + */ + public void setBodyPrefix(MessageBody value) throws Exception { + this.getPropertyBag().setObjectFromPropertyDefinition( + ResponseObjectSchema.BodyPrefix, value); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/response/ResponseObject.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/ResponseObject.java new file mode 100644 index 000000000..b5d337c7c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/ResponseObject.java @@ -0,0 +1,212 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.response; + +/** + * Represents the base class for all response that can be sent. + */ + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.enumeration.service.DeleteMode; +import com.eischet.ews.api.core.enumeration.service.MessageDisposition; +import com.eischet.ews.api.core.enumeration.service.SendCancellationsMode; +import com.eischet.ews.api.core.enumeration.service.calendar.AffectedTaskOccurrence; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.EmailMessage; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.core.service.schema.ResponseObjectSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.property.complex.FolderId; +import com.eischet.ews.api.property.complex.ItemId; + +import java.util.List; + +/** + * The Class ResponseObject. + * + * @param the generic type + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class ResponseObject extends ServiceObject { + + /** + * The reference item. + */ + private final Item referenceItem; + + /** + * Initializes a new instance of the class. + * + * @param referenceItem the reference item + * @throws Exception the exception + */ + protected ResponseObject(Item referenceItem) throws Exception { + super(referenceItem.getService()); + referenceItem.throwIfThisIsNew(); + this.referenceItem = referenceItem; + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return ResponseObjectSchema.Instance; + } + + /** + * Loads the specified set of property on the object. + * + * @param propertySet the property set + */ + @Override + protected void internalLoad(PropertySet propertySet) { + throw new UnsupportedOperationException(); + } + + /** + * Deletes the object. + * + * @param deleteMode the delete mode + * @param sendCancellationsMode the send cancellations mode + * @param affectedTaskOccurrences the affected task occurrences + */ + @Override + protected void internalDelete(DeleteMode deleteMode, + SendCancellationsMode sendCancellationsMode, + AffectedTaskOccurrence affectedTaskOccurrences) { + throw new UnsupportedOperationException(); + } + + /** + * Create the response object. + * + * @param destinationFolderId the destination folder id + * @param messageDisposition the message disposition + * @return The list of item returned by EWS. + * @throws Exception the exception + */ + protected List internalCreate(FolderId destinationFolderId, + MessageDisposition messageDisposition) throws Exception { + ((ItemId) this.getPropertyBag().getObjectFromPropertyDefinition( + ResponseObjectSchema.ReferenceItemId)) + .assign(this.referenceItem.getId()); + return this.getService().internalCreateResponseObject(this, + destinationFolderId, messageDisposition); + } + + /** + * Saves the response in the specified folder. Calling this method results + * in a call to EWS. + * + * @param destinationFolderId the destination folder id + * @return A TMessage that represents the response. + * @throws Exception the exception + */ + public TMessage save(FolderId destinationFolderId) throws Exception { + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + return (TMessage) this.internalCreate(destinationFolderId, + MessageDisposition.SaveOnly).get(0); + } + + /** + * Saves the response in the specified folder. Calling this method results + * in a call to EWS. + * + * @param destinationFolderName the destination folder name + * @return A TMessage that represents the response. + * @throws Exception the exception + */ + public TMessage save(WellKnownFolderName destinationFolderName) + throws Exception { + return (TMessage) this.internalCreate( + new FolderId(destinationFolderName), + MessageDisposition.SaveOnly).get(0); + } + + /** + * Saves the response in the Drafts folder. Calling this method results in a + * call to EWS. + * + * @return A TMessage that represents the response. + * @throws Exception the exception + */ + public TMessage save() throws Exception { + return (TMessage) this + .internalCreate(null, MessageDisposition.SaveOnly).get(0); + } + + /** + * Sends this response without saving a copy. Calling this method results in + * a call to EWS. + * + * @throws Exception the exception + */ + public void send() throws Exception { + this.internalCreate(null, MessageDisposition.SendOnly); + } + + /** + * Sends this response and saves a copy in the specified folder. Calling + * this method results in a call to EWS. + * + * @param destinationFolderId the destination folder id + * @throws Exception the exception + */ + public void sendAndSaveCopy(FolderId destinationFolderId) throws Exception { + EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); + this.internalCreate(destinationFolderId, + MessageDisposition.SendAndSaveCopy); + } + + /** + * Sends this response and saves a copy in the specified folder. Calling + * this method results in a call to EWS. + * + * @param destinationFolderName the destination folder name + * @throws Exception the exception + */ + public void sendAndSaveCopy(WellKnownFolderName destinationFolderName) + throws Exception { + this.internalCreate(new FolderId(destinationFolderName), + MessageDisposition.SendAndSaveCopy); + } + + /** + * Sends this response and saves a copy in the Sent Items folder. Calling + * this method results in a call to EWS. + * + * @throws Exception the exception + */ + public void sendAndSaveCopy() throws Exception { + this.internalCreate(null, MessageDisposition.SendAndSaveCopy); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/response/SuppressReadReceipt.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/SuppressReadReceipt.java new file mode 100644 index 000000000..225cee610 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/response/SuppressReadReceipt.java @@ -0,0 +1,124 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.response; + +import com.eischet.ews.api.attribute.ServiceObjectDefinition; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.DeleteMode; +import com.eischet.ews.api.core.enumeration.service.MessageDisposition; +import com.eischet.ews.api.core.enumeration.service.SendCancellationsMode; +import com.eischet.ews.api.core.enumeration.service.calendar.AffectedTaskOccurrence; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.core.service.schema.ResponseObjectSchema; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.property.complex.FolderId; +import com.eischet.ews.api.property.complex.ItemId; + +/** + * Represents a response object created to supress read receipts for an item. + */ +@ServiceObjectDefinition(xmlElementName = XmlElementNames.SuppressReadReceipt, returnedByServer = false) +public final class SuppressReadReceipt extends ServiceObject { + + /** + * The reference item. + */ + private final Item referenceItem; + + /** + * Initializes a new instance of the class. + * + * @param referenceItem the reference item + * @throws Exception the exception + */ + public SuppressReadReceipt(Item referenceItem) throws Exception { + super(referenceItem.getService()); + + referenceItem.throwIfThisIsNew(); + this.referenceItem = referenceItem; + } + + /** + * Internal method to return the schema associated with this type of object. + * + * @return The schema associated with this type of object. + */ + @Override + public ServiceObjectSchema getSchema() { + return ResponseObjectSchema.Instance; + } + + /** + * Gets the minimum required server version. + * + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public ExchangeVersion getMinimumRequiredServerVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Loads the specified set of property on the object. + * + * @param propertySet the property set + */ + @Override + protected void internalLoad(PropertySet propertySet) { + throw new UnsupportedOperationException(); + } + + /** + * Deletes the object. + * + * @param deleteMode the delete mode + * @param sendCancellationsMode the send cancellations mode + * @param affectedTaskOccurrences the affected task occurrences + */ + @Override + protected void internalDelete(DeleteMode deleteMode, + SendCancellationsMode sendCancellationsMode, + AffectedTaskOccurrence affectedTaskOccurrences) { + throw new UnsupportedOperationException(); + } + + /** + * Create the response object. + * + * @param parentFolderId the parent folder id + * @param messageDisposition the message disposition + * @throws Exception the exception + */ + public void internalCreate(FolderId parentFolderId, MessageDisposition messageDisposition) throws Exception { + ((ItemId) this.getPropertyBag().getObjectFromPropertyDefinition( + ResponseObjectSchema.ReferenceItemId)) + .assign(this.referenceItem.getId()); + this.getService().internalCreateResponseObject(this, parentFolderId, + messageDisposition); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/AppointmentSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/AppointmentSchema.java new file mode 100644 index 000000000..6d0722603 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/AppointmentSchema.java @@ -0,0 +1,877 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.Schema; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.LegacyFreeBusyStatus; +import com.eischet.ews.api.core.enumeration.property.MeetingResponseType; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.enumeration.service.calendar.AppointmentType; +import com.eischet.ews.api.core.service.item.Appointment; +import com.eischet.ews.api.property.complex.*; +import com.eischet.ews.api.property.definition.*; + +import java.util.EnumSet; + +/** + * Represents the schema for appointment and meeting request. + */ +@Schema +public class AppointmentSchema extends ItemSchema { + + /** + * Field URIs for Appointment. + */ + private interface FieldUris { + + /** + * The Start. + */ + String Start = "calendar:Start"; + + /** + * The End. + */ + String End = "calendar:End"; + + /** + * The Original start. + */ + String OriginalStart = "calendar:OriginalStart"; + + /** + * The Is all day event. + */ + String IsAllDayEvent = "calendar:IsAllDayEvent"; + + /** + * The Legacy free busy status. + */ + String LegacyFreeBusyStatus = "calendar:LegacyFreeBusyStatus"; + + /** + * The Location. + */ + String Location = "calendar:Location"; + + /** + * The When. + */ + String When = "calendar:When"; + + /** + * The Is meeting. + */ + String IsMeeting = "calendar:IsMeeting"; + + /** + * The Is cancelled. + */ + String IsCancelled = "calendar:IsCancelled"; + + /** + * The Is recurring. + */ + String IsRecurring = "calendar:IsRecurring"; + + /** + * The Meeting request was sent. + */ + String MeetingRequestWasSent = "calendar:MeetingRequestWasSent"; + + /** + * The Is response requested. + */ + String IsResponseRequested = "calendar:IsResponseRequested"; + + /** + * The Calendar item type. + */ + String CalendarItemType = "calendar:CalendarItemType"; + + /** + * The My response type. + */ + String MyResponseType = "calendar:MyResponseType"; + + /** + * The Organizer. + */ + String Organizer = "calendar:Organizer"; + + /** + * The Required attendees. + */ + String RequiredAttendees = "calendar:RequiredAttendees"; + + /** + * The Optional attendees. + */ + String OptionalAttendees = "calendar:OptionalAttendees"; + + /** + * The Resources. + */ + String Resources = "calendar:Resources"; + + /** + * The Conflicting meeting count. + */ + String ConflictingMeetingCount = "calendar:ConflictingMeetingCount"; + + /** + * The Adjacent meeting count. + */ + String AdjacentMeetingCount = "calendar:AdjacentMeetingCount"; + + /** + * The Conflicting meetings. + */ + String ConflictingMeetings = "calendar:ConflictingMeetings"; + + /** + * The Adjacent meetings. + */ + String AdjacentMeetings = "calendar:AdjacentMeetings"; + + /** + * The Duration. + */ + String Duration = "calendar:Duration"; + + /** + * The Time zone. + */ + String TimeZone = "calendar:TimeZone"; + + /** + * The Appointment reply time. + */ + String AppointmentReplyTime = "calendar:AppointmentReplyTime"; + + /** + * The Appointment sequence number. + */ + String AppointmentSequenceNumber = "calendar:AppointmentSequenceNumber"; + + /** + * The Appointment state. + */ + String AppointmentState = "calendar:AppointmentState"; + + /** + * The Recurrence. + */ + String Recurrence = "calendar:Recurrence"; + + /** + * The First occurrence. + */ + String FirstOccurrence = "calendar:FirstOccurrence"; + + /** + * The Last occurrence. + */ + String LastOccurrence = "calendar:LastOccurrence"; + + /** + * The Modified occurrences. + */ + String ModifiedOccurrences = "calendar:ModifiedOccurrences"; + + /** + * The Deleted occurrences. + */ + String DeletedOccurrences = "calendar:DeletedOccurrences"; + + /** + * The Meeting time zone. + */ + String MeetingTimeZone = "calendar:MeetingTimeZone"; + + /** + * The Start time zone. + */ + String StartTimeZone = "calendar:StartTimeZone"; + + /** + * The End time zone. + */ + String EndTimeZone = "calendar:EndTimeZone"; + + /** + * The Conference type. + */ + String ConferenceType = "calendar:ConferenceType"; + + /** + * The Allow new time proposal. + */ + String AllowNewTimeProposal = "calendar:AllowNewTimeProposal"; + + /** + * The Is online meeting. + */ + String IsOnlineMeeting = "calendar:IsOnlineMeeting"; + + /** + * The Meeting workspace url. + */ + String MeetingWorkspaceUrl = "calendar:MeetingWorkspaceUrl"; + + /** + * The Net show url. + */ + String NetShowUrl = "calendar:NetShowUrl"; + + /** + * The Uid. + */ + String Uid = "calendar:UID"; + + /** + * The Recurrence id. + */ + String RecurrenceId = "calendar:RecurrenceId"; + + /** + * The Date time stamp. + */ + String DateTimeStamp = "calendar:DateTimeStamp"; + } + + // Defines the StartTimeZone property. + /** + * The Constant StartTimeZone. + */ + public static final PropertyDefinition StartTimeZone = + new StartTimeZonePropertyDefinition( + XmlElementNames.StartTimeZone, FieldUris.StartTimeZone, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the EndTimeZone property. + /** + * The Constant EndTimeZone. + */ + public static final PropertyDefinition EndTimeZone = + new TimeZonePropertyDefinition( + XmlElementNames.EndTimeZone, FieldUris.EndTimeZone, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010); + + // Defines the Start property. + /** + * The Constant Start. + */ + public static final PropertyDefinition Start = + new DateTimePropertyDefinition( + XmlElementNames.Start, FieldUris.Start, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the End property. + /** + * The Constant End. + */ + public static final PropertyDefinition End = new DateTimePropertyDefinition( + XmlElementNames.End, FieldUris.End, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the OriginalStart property. + /** + * The Constant OriginalStart. + */ + public static final PropertyDefinition OriginalStart = + new DateTimePropertyDefinition( + XmlElementNames.OriginalStart, FieldUris.OriginalStart, + ExchangeVersion.Exchange2007_SP1); + + // Defines the IsAllDayEvent property. + /** + * The Constant IsAllDayEvent. + */ + public static final PropertyDefinition IsAllDayEvent = + new BoolPropertyDefinition( + XmlElementNames.IsAllDayEvent, FieldUris.IsAllDayEvent, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the LegacyFreeBusyStatus property. + /** + * The Constant LegacyFreeBusyStatus. + */ + public static final PropertyDefinition LegacyFreeBusyStatus = + new GenericPropertyDefinition( + LegacyFreeBusyStatus.class, + XmlElementNames.LegacyFreeBusyStatus, + FieldUris.LegacyFreeBusyStatus, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the Location property. + /** + * The Constant Location. + */ + public static final PropertyDefinition Location = + new StringPropertyDefinition( + XmlElementNames.Location, FieldUris.Location, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the When property. + /** + * The Constant When. + */ + public static final PropertyDefinition When = new StringPropertyDefinition( + XmlElementNames.When, FieldUris.When, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the IsMeeting property. + /** + * The Constant IsMeeting. + */ + public static final PropertyDefinition IsMeeting = + new BoolPropertyDefinition( + XmlElementNames.IsMeeting, FieldUris.IsMeeting, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the IsCancelled property. + /** + * The Constant IsCancelled. + */ + public static final PropertyDefinition IsCancelled = + new BoolPropertyDefinition( + XmlElementNames.IsCancelled, FieldUris.IsCancelled, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the IsRecurring property. + /** + * The Constant IsRecurring. + */ + public static final PropertyDefinition IsRecurring = + new BoolPropertyDefinition( + XmlElementNames.IsRecurring, FieldUris.IsRecurring, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the MeetingRequestWasSent property. + /** + * The Constant MeetingRequestWasSent. + */ + public static final PropertyDefinition MeetingRequestWasSent = + new BoolPropertyDefinition( + XmlElementNames.MeetingRequestWasSent, + FieldUris.MeetingRequestWasSent, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the IsResponseRequested property. + /** + * The Constant IsResponseRequested. + */ + public static final PropertyDefinition IsResponseRequested = + new BoolPropertyDefinition( + XmlElementNames.IsResponseRequested, FieldUris.IsResponseRequested, + EnumSet.of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the AppointmentType property. + /** + * The Constant AppointmentType. + */ + public static final PropertyDefinition AppointmentType = + new GenericPropertyDefinition( + AppointmentType.class, + XmlElementNames.CalendarItemType, FieldUris.CalendarItemType, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the MyResponseType property. + /** + * The Constant MyResponseType. + */ + public static final PropertyDefinition MyResponseType = + new GenericPropertyDefinition( + MeetingResponseType.class, + XmlElementNames.MyResponseType, FieldUris.MyResponseType, EnumSet + .of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the Organizer property. + /** + * The Constant Organizer. + */ + public static final PropertyDefinition Organizer = + new ContainedPropertyDefinition( + EmailAddress.class, + XmlElementNames.Organizer, FieldUris.Organizer, + XmlElementNames.Mailbox, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public EmailAddress createComplexProperty() { + return new EmailAddress(); + } + }); + + // Defines the RequiredAttendees property. + + /** + * The Constant RequiredAttendees. + */ + public static final PropertyDefinition RequiredAttendees = + new ComplexPropertyDefinition( + AttendeeCollection.class, + XmlElementNames.RequiredAttendees, FieldUris.RequiredAttendees, + EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public AttendeeCollection createComplexProperty() { + return new AttendeeCollection(); + } + }); + + // Defines the OptionalAttendees property. + /** + * The Constant OptionalAttendees. + */ + public static final PropertyDefinition OptionalAttendees = + new ComplexPropertyDefinition( + AttendeeCollection.class, + XmlElementNames.OptionalAttendees, FieldUris.OptionalAttendees, + EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public AttendeeCollection createComplexProperty() { + return new AttendeeCollection(); + } + }); + + // Defines the Resources property. + + /** + * The Constant Resources. + */ + public static final PropertyDefinition Resources = + new ComplexPropertyDefinition( + AttendeeCollection.class, + XmlElementNames.Resources, FieldUris.Resources, EnumSet.of( + PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public AttendeeCollection createComplexProperty() { + return new AttendeeCollection(); + } + }); + + // Defines the ConflictingMeetingCount property. + /** + * The Constant ConflictingMeetingCount. + */ + public static final PropertyDefinition ConflictingMeetingCount = + new IntPropertyDefinition( + XmlElementNames.ConflictingMeetingCount, + FieldUris.ConflictingMeetingCount, + ExchangeVersion.Exchange2007_SP1); + + // Defines the AdjacentMeetingCount property. + /** + * The Constant AdjacentMeetingCount. + */ + public static final PropertyDefinition AdjacentMeetingCount = + new IntPropertyDefinition( + XmlElementNames.AdjacentMeetingCount, + FieldUris.AdjacentMeetingCount, ExchangeVersion.Exchange2007_SP1); + + // Defines the ConflictingMeetings property. + /** + * The Constant ConflictingMeetings. + */ + public static final PropertyDefinition ConflictingMeetings = + new ComplexPropertyDefinition>( + XmlElementNames.ConflictingMeetings, + FieldUris.ConflictingMeetings, + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate + >() { + public ItemCollection createComplexProperty() { + return new ItemCollection(); + } + }); + + // Defines the AdjacentMeetings property. + /** + * The Constant AdjacentMeetings. + */ + public static final PropertyDefinition AdjacentMeetings = + new ComplexPropertyDefinition>( + XmlElementNames.AdjacentMeetings, + FieldUris.AdjacentMeetings, + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate + >() { + public ItemCollection createComplexProperty() { + return new ItemCollection(); + } + }); + + // Defines the Duration property. + /** + * The Constant Duration. + */ + public static final PropertyDefinition Duration = + new TimeSpanPropertyDefinition( + XmlElementNames.Duration, FieldUris.Duration, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the TimeZone property. + /** + * The Constant TimeZone. + */ + public static final PropertyDefinition TimeZone = + new StringPropertyDefinition( + XmlElementNames.TimeZone, FieldUris.TimeZone, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the AppointmentReplyTime property. + /** + * The Constant AppointmentReplyTime. + */ + public static final PropertyDefinition AppointmentReplyTime = + new DateTimePropertyDefinition( + XmlElementNames.AppointmentReplyTime, + FieldUris.AppointmentReplyTime, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the AppointmentSequenceNumber property. + /** + * The Constant AppointmentSequenceNumber. + */ + public static final PropertyDefinition AppointmentSequenceNumber = + new IntPropertyDefinition( + XmlElementNames.AppointmentSequenceNumber, + FieldUris.AppointmentSequenceNumber, + ExchangeVersion.Exchange2007_SP1); + + // Defines the AppointmentState property. + /** + * The Constant AppointmentState. + */ + public static final PropertyDefinition AppointmentState = + new IntPropertyDefinition( + XmlElementNames.AppointmentState, FieldUris.AppointmentState, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the Recurrence property. + /** + * The Constant Recurrence. + */ + public static final PropertyDefinition Recurrence = + new RecurrencePropertyDefinition( + XmlElementNames.Recurrence, FieldUris.Recurrence, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete), + ExchangeVersion.Exchange2007_SP1); + + // Defines the FirstOccurrence property. + /** + * The Constant FirstOccurrence. + */ + public static final PropertyDefinition FirstOccurrence = + new ComplexPropertyDefinition( + OccurrenceInfo.class, + XmlElementNames.FirstOccurrence, FieldUris.FirstOccurrence, + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public OccurrenceInfo createComplexProperty() { + return new OccurrenceInfo(); + } + }); + + // Defines the LastOccurrence property. + /** + * The Constant LastOccurrence. + */ + public static final PropertyDefinition LastOccurrence = + new ComplexPropertyDefinition( + OccurrenceInfo.class, + XmlElementNames.LastOccurrence, FieldUris.LastOccurrence, + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public OccurrenceInfo createComplexProperty() { + return new OccurrenceInfo(); + } + }); + + // Defines the ModifiedOccurrences property. + /** + * The Constant ModifiedOccurrences. + */ + public static final PropertyDefinition ModifiedOccurrences = + new ComplexPropertyDefinition( + OccurrenceInfoCollection.class, + XmlElementNames.ModifiedOccurrences, + FieldUris.ModifiedOccurrences, + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate + () { + public OccurrenceInfoCollection createComplexProperty() { + return new OccurrenceInfoCollection(); + } + }); + + // Defines the DeletedOccurrences property. + /** + * The Constant DeletedOccurrences. + */ + public static final PropertyDefinition DeletedOccurrences = + new ComplexPropertyDefinition( + DeletedOccurrenceInfoCollection.class, + XmlElementNames.DeletedOccurrences, + FieldUris.DeletedOccurrences, + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate + () { + public DeletedOccurrenceInfoCollection createComplexProperty() { + return new DeletedOccurrenceInfoCollection(); + } + }); + + // Defines the MeetingTimeZone property. + /** + * The Constant MeetingTimeZone. + */ + public static final PropertyDefinition MeetingTimeZone = + new MeetingTimeZonePropertyDefinition( + XmlElementNames.MeetingTimeZone, FieldUris.MeetingTimeZone, EnumSet + .of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate), + ExchangeVersion.Exchange2007_SP1); + + // Defines the ConferenceType property. + /** + * The Constant ConferenceType. + */ + public static final PropertyDefinition ConferenceType = + new IntPropertyDefinition( + XmlElementNames.ConferenceType, FieldUris.ConferenceType, EnumSet + .of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the AllowNewTimeProposal property. + /** + * The Constant AllowNewTimeProposal. + */ + public static final PropertyDefinition AllowNewTimeProposal = + new BoolPropertyDefinition( + XmlElementNames.AllowNewTimeProposal, + FieldUris.AllowNewTimeProposal, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the IsOnlineMeeting property. + /** + * The Constant IsOnlineMeeting. + */ + public static final PropertyDefinition IsOnlineMeeting = + new BoolPropertyDefinition( + XmlElementNames.IsOnlineMeeting, FieldUris.IsOnlineMeeting, EnumSet + .of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the MeetingWorkspaceUrl property. + /** + * The Constant MeetingWorkspaceUrl. + */ + public static final PropertyDefinition MeetingWorkspaceUrl = + new StringPropertyDefinition( + XmlElementNames.MeetingWorkspaceUrl, FieldUris.MeetingWorkspaceUrl, + EnumSet.of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the NetShowUrl property. + /** + * The Constant NetShowUrl. + */ + public static final PropertyDefinition NetShowUrl = + new StringPropertyDefinition( + XmlElementNames.NetShowUrl, FieldUris.NetShowUrl, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the iCalendar Uid property. + /** + * The Constant ICalUid. + */ + public static final PropertyDefinition ICalUid = + new StringPropertyDefinition( + XmlElementNames.Uid, FieldUris.Uid, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + // Defines the iCalendar RecurrenceId property. + /** + * The Constant ICalRecurrenceId. + */ + public static final PropertyDefinition ICalRecurrenceId = + new DateTimePropertyDefinition( + XmlElementNames.RecurrenceId, FieldUris.RecurrenceId, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, true); + // Defines the iCalendar DateTimeStamp property. + /** + * The Constant ICalDateTimeStamp. + */ + public static final PropertyDefinition ICalDateTimeStamp = + new DateTimePropertyDefinition( + XmlElementNames.DateTimeStamp, FieldUris.DateTimeStamp, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, true); // isNullable + + // Instance of schema. + // This must be after the declaration of property definitions. + /** + * The Constant Instance. + */ + public static final AppointmentSchema Instance = new AppointmentSchema(); + + /** + * Registers property. + *

+ * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the + * same order as they are defined in types.xsd) + *

+ */ + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(Start); + this.registerProperty(End); + this.registerProperty(OriginalStart); + this.registerProperty(IsAllDayEvent); + this.registerProperty(LegacyFreeBusyStatus); + this.registerProperty(Location); + this.registerProperty(When); + this.registerProperty(IsMeeting); + this.registerProperty(IsCancelled); + this.registerProperty(IsRecurring); + this.registerProperty(MeetingRequestWasSent); + this.registerProperty(IsResponseRequested); + this.registerProperty(AppointmentType); + this.registerProperty(MyResponseType); + this.registerProperty(Organizer); + this.registerProperty(RequiredAttendees); + this.registerProperty(OptionalAttendees); + this.registerProperty(Resources); + this.registerProperty(ConflictingMeetingCount); + this.registerProperty(AdjacentMeetingCount); + this.registerProperty(ConflictingMeetings); + this.registerProperty(AdjacentMeetings); + this.registerProperty(Duration); + this.registerProperty(TimeZone); + this.registerProperty(AppointmentReplyTime); + this.registerProperty(AppointmentSequenceNumber); + this.registerProperty(AppointmentState); + this.registerProperty(Recurrence); + this.registerProperty(FirstOccurrence); + this.registerProperty(LastOccurrence); + this.registerProperty(ModifiedOccurrences); + this.registerProperty(DeletedOccurrences); + this.registerInternalProperty(MeetingTimeZone); + this.registerProperty(StartTimeZone); + this.registerProperty(EndTimeZone); + this.registerProperty(ConferenceType); + this.registerProperty(AllowNewTimeProposal); + this.registerProperty(IsOnlineMeeting); + this.registerProperty(MeetingWorkspaceUrl); + this.registerProperty(NetShowUrl); + this.registerProperty(ICalUid); + this.registerProperty(ICalRecurrenceId); + this.registerProperty(ICalDateTimeStamp); + } + + /** + * Instantiates a new appointment schema. + */ + AppointmentSchema() { + super(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/CalendarResponseObjectSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/CalendarResponseObjectSchema.java new file mode 100644 index 000000000..c20988d4d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/CalendarResponseObjectSchema.java @@ -0,0 +1,60 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +/** + * Represents the schema for CalendarResponseObject. + */ +public class CalendarResponseObjectSchema extends ServiceObjectSchema { + + // This must be declared after the property definitions + /** + * The Constant Instance. + */ + public static final CalendarResponseObjectSchema Instance = + new CalendarResponseObjectSchema(); + + /** + * Registers property. + */ + // / IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the + // same order as they are defined in types.xsd) + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(ItemSchema.ItemClass); + this.registerProperty(ItemSchema.Sensitivity); + this.registerProperty(ItemSchema.Body); + this.registerProperty(ItemSchema.Attachments); + this.registerProperty(ItemSchema.InternetMessageHeaders); + this.registerProperty(EmailMessageSchema.Sender); + this.registerProperty(EmailMessageSchema.ToRecipients); + this.registerProperty(EmailMessageSchema.CcRecipients); + this.registerProperty(EmailMessageSchema.BccRecipients); + this.registerProperty(EmailMessageSchema.IsReadReceiptRequested); + this.registerProperty(EmailMessageSchema.IsDeliveryReceiptRequested); + this.registerProperty(ResponseObjectSchema.ReferenceItemId); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/CancelMeetingMessageSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/CancelMeetingMessageSchema.java new file mode 100644 index 000000000..3b1912ad0 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/CancelMeetingMessageSchema.java @@ -0,0 +1,75 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; +import com.eischet.ews.api.property.complex.MessageBody; +import com.eischet.ews.api.property.definition.ComplexPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import java.util.EnumSet; + +/** + * Represents a meeting cancellation message. + */ +public class CancelMeetingMessageSchema extends ServiceObjectSchema { + + /** + * The Constant Body. + */ + public static final PropertyDefinition Body = + new ComplexPropertyDefinition( + MessageBody.class, + XmlElementNames.NewBodyContent, EnumSet + .of(PropertyDefinitionFlags.CanSet), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public MessageBody createComplexProperty() { + return new MessageBody(); + } + }); + + /** + * This must be declared after the property definitions. + */ + public static final CancelMeetingMessageSchema Instance = + new CancelMeetingMessageSchema(); + + /** + * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN + * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd) + */ + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(EmailMessageSchema.IsReadReceiptRequested); + this.registerProperty(EmailMessageSchema.IsDeliveryReceiptRequested); + this.registerProperty(ResponseObjectSchema.ReferenceItemId); + this.registerProperty(CancelMeetingMessageSchema.Body); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ContactGroupSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ContactGroupSchema.java new file mode 100644 index 000000000..c2ce9e36c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ContactGroupSchema.java @@ -0,0 +1,132 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.Schema; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.property.complex.GroupMemberCollection; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; +import com.eischet.ews.api.property.definition.ComplexPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import java.util.EnumSet; + +/** + * Represents the schema for contact groups. + */ +@Schema +public class ContactGroupSchema extends ItemSchema { + + + // Defines the DisplayName property. + /** + * The Constant DisplayName. + */ + public static final PropertyDefinition DisplayName = + ContactSchema.DisplayName; + + + // Defines the FileAs property. + /** + * The Constant FileAs. + */ + public static final PropertyDefinition FileAs = ContactSchema.FileAs; + + + // Defines the Members property. + /** + * The Constant Members. + */ + public static final PropertyDefinition Members = + new ComplexPropertyDefinition( + GroupMemberCollection.class, + XmlElementNames.Members, + FieldUris.Members, + EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate), + ExchangeVersion.Exchange2010, + new ICreateComplexPropertyDelegate() { + @Override + public GroupMemberCollection createComplexProperty() { + return new GroupMemberCollection(); + } + }); + + + //This must be declared after the property definitions. + /** + * The Constant Instance. + */ + public static final ContactGroupSchema Instance = + new ContactGroupSchema(); + + + // Initializes a new instance of the + // class. + + /** + * Instantiates a new contact group schema. + */ + protected ContactGroupSchema() { + super(); + } + + //Registers property. + // IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. + // the same order as they are defined in types.xsd) + + /** + * Registers property. + *

+ * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the + * same order as they are defined in types.xsd) + *

+ */ + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(DisplayName); + this.registerProperty(FileAs); + this.registerProperty(Members); + } + + + // Field URIs for Members. + + + /** + * The Interface FieldUris. + */ + private interface FieldUris { + /** + * FieldUri for members. + */ + String Members = "distributionlist:Members"; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ContactSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ContactSchema.java new file mode 100644 index 000000000..b4d76e3ac --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ContactSchema.java @@ -0,0 +1,1276 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.Schema; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PhysicalAddressIndex; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.enumeration.service.ContactSource; +import com.eischet.ews.api.core.enumeration.service.FileAsMapping; +import com.eischet.ews.api.property.complex.*; +import com.eischet.ews.api.property.definition.*; + +import java.util.EnumSet; + +/** + * Represents the schema for contacts. + */ +@Schema +public class ContactSchema extends ItemSchema { + + /** + * FieldURIs for contacts. + */ + private interface FieldUris { + + /** + * The File as. + */ + String FileAs = "contacts:FileAs"; + + /** + * The File as mapping. + */ + String FileAsMapping = "contacts:FileAsMapping"; + + /** + * The Display name. + */ + String DisplayName = "contacts:DisplayName"; + + /** + * The Given name. + */ + String GivenName = "contacts:GivenName"; + + /** + * The Initials. + */ + String Initials = "contacts:Initials"; + + /** + * The Middle name. + */ + String MiddleName = "contacts:MiddleName"; + + /** + * The Nick name. + */ + String NickName = "contacts:Nickname"; + + /** + * The Complete name. + */ + String CompleteName = "contacts:CompleteName"; + + /** + * The Company name. + */ + String CompanyName = "contacts:CompanyName"; + + /** + * The Email address. + */ + String EmailAddress = "contacts:EmailAddress"; + + /** + * The Email addresses. + */ + String EmailAddresses = "contacts:EmailAddresses"; + + /** + * The Physical addresses. + */ + String PhysicalAddresses = "contacts:PhysicalAddresses"; + + /** + * The Phone number. + */ + String PhoneNumber = "contacts:PhoneNumber"; + + /** + * The Phone numbers. + */ + String PhoneNumbers = "contacts:PhoneNumbers"; + + /** + * The Assistant name. + */ + String AssistantName = "contacts:AssistantName"; + + /** + * The Birthday. + */ + String Birthday = "contacts:Birthday"; + + /** + * The Business home page. + */ + String BusinessHomePage = "contacts:BusinessHomePage"; + + /** + * The Children. + */ + String Children = "contacts:Children"; + + /** + * The Companies. + */ + String Companies = "contacts:Companies"; + + /** + * The Contact source. + */ + String ContactSource = "contacts:ContactSource"; + + /** + * The Department. + */ + String Department = "contacts:Department"; + + /** + * The Generation. + */ + String Generation = "contacts:Generation"; + + /** + * The Im address. + */ + String ImAddress = "contacts:ImAddress"; + + /** + * The Im addresses. + */ + String ImAddresses = "contacts:ImAddresses"; + + /** + * The Job title. + */ + String JobTitle = "contacts:JobTitle"; + + /** + * The Manager. + */ + String Manager = "contacts:Manager"; + + /** + * The Mileage. + */ + String Mileage = "contacts:Mileage"; + + /** + * The Office location. + */ + String OfficeLocation = "contacts:OfficeLocation"; + + /** + * The Physical address city. + */ + String PhysicalAddressCity = "contacts:PhysicalAddress:City"; + + /** + * The Physical address country or region. + */ + String PhysicalAddressCountryOrRegion = + "contacts:PhysicalAddress:CountryOrRegion"; + + /** + * The Physical address state. + */ + String PhysicalAddressState = "contacts:PhysicalAddress:State"; + + /** + * The Physical address street. + */ + String PhysicalAddressStreet = "contacts:PhysicalAddress:Street"; + + /** + * The Physical address postal code. + */ + String PhysicalAddressPostalCode = + "contacts:PhysicalAddress:PostalCode"; + + /** + * The Postal address index. + */ + String PostalAddressIndex = "contacts:PostalAddressIndex"; + + /** + * The Profession. + */ + String Profession = "contacts:Profession"; + + /** + * The Spouse name. + */ + String SpouseName = "contacts:SpouseName"; + + /** + * The Surname. + */ + String Surname = "contacts:Surname"; + + /** + * The Wedding anniversary. + */ + String WeddingAnniversary = "contacts:WeddingAnniversary"; + + /** + * The Has picture. + */ + String HasPicture = "contacts:HasPicture"; + + /** + * The PhoneticFullName. + */ + + String PhoneticFullName = "contacts:PhoneticFullName"; + + /** + * The PhoneticFirstName. + */ + + String PhoneticFirstName = "contacts:PhonetiFirstName"; + + /** + * The PhoneticFirstName. + */ + + String PhoneticLastName = "contacts:PhonetiLastName"; + + /** + * The Aias. + */ + + String Alias = "contacts:Alias"; + + /** + * The Notes. + */ + + String Notes = "contacts:Notes"; + + /** + * The Photo. + */ + + String Photo = "contacts:Photo"; + + /** + * The UserSMIMECertificate. + */ + + String UserSMIMECertificate = "contacts:UserSMIMECertificate"; + + /** + * The MSExchangeCertificate. + */ + + String MSExchangeCertificate = "contacts:MSExchangeCertificate"; + + /** + * The DirectoryId. + */ + + String DirectoryId = "contacts:DirectoryId"; + + /** + * The ManagerMailbox. + */ + + String ManagerMailbox = "contacts:ManagerMailbox"; + + /** + * The DirectReports. + */ + + String DirectReports = "contacts:DirectReports"; + } + + + /** + * Defines the FileAs property. + */ + public static final PropertyDefinition FileAs = + new StringPropertyDefinition( + XmlElementNames.FileAs, FieldUris.FileAs, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the FileAsMapping property. + */ + public static final PropertyDefinition FileAsMapping = + new GenericPropertyDefinition( + FileAsMapping.class, + XmlElementNames.FileAsMapping, FieldUris.FileAsMapping, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the DisplayName property. + */ + public static final PropertyDefinition DisplayName = + new StringPropertyDefinition( + XmlElementNames.DisplayName, FieldUris.DisplayName, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the GivenName property. + */ + public static final PropertyDefinition GivenName = + new StringPropertyDefinition( + XmlElementNames.GivenName, FieldUris.GivenName, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Initials property. + */ + public static final PropertyDefinition Initials = + new StringPropertyDefinition( + XmlElementNames.Initials, FieldUris.Initials, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the MiddleName property. + */ + public static final PropertyDefinition MiddleName = + new StringPropertyDefinition( + XmlElementNames.MiddleName, FieldUris.MiddleName, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the NickName property. + */ + public static final PropertyDefinition NickName = + new StringPropertyDefinition( + XmlElementNames.NickName, FieldUris.NickName, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the CompleteName property. + */ + public static final PropertyDefinition CompleteName = + new ComplexPropertyDefinition( + CompleteName.class, + XmlElementNames.CompleteName, FieldUris.CompleteName, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public CompleteName createComplexProperty() { + return new CompleteName(); + } + }); + + /** + * Defines the CompanyName property. + */ + public static final PropertyDefinition CompanyName = + new StringPropertyDefinition( + XmlElementNames.CompanyName, FieldUris.CompanyName, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the EmailAddresses property. + */ + public static final PropertyDefinition EmailAddresses = + new ComplexPropertyDefinition( + EmailAddressDictionary.class, + XmlElementNames.EmailAddresses, + FieldUris.EmailAddresses, + EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate + () { + @Override + public EmailAddressDictionary createComplexProperty() { + return new EmailAddressDictionary(); + } + }); + + /** + * Defines the PhysicalAddresses property. + */ + public static final PropertyDefinition PhysicalAddresses = + new ComplexPropertyDefinition( + PhysicalAddressDictionary.class, + XmlElementNames.PhysicalAddresses, + FieldUris.PhysicalAddresses, + EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate + () { + @Override + public PhysicalAddressDictionary createComplexProperty() { + return new PhysicalAddressDictionary(); + } + }); + + /** + * Defines the PhoneNumbers property. + */ + public static final PropertyDefinition PhoneNumbers = + new ComplexPropertyDefinition( + PhoneNumberDictionary.class, + XmlElementNames.PhoneNumbers, + FieldUris.PhoneNumbers, + EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate + () { + @Override + public PhoneNumberDictionary createComplexProperty() { + return new PhoneNumberDictionary(); + } + }); + + /** + * Defines the AssistantName property. + */ + public static final PropertyDefinition AssistantName = + new StringPropertyDefinition( + XmlElementNames.AssistantName, FieldUris.AssistantName, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Birthday property. + */ + public static final PropertyDefinition Birthday = + new DateTimePropertyDefinition( + XmlElementNames.Birthday, FieldUris.Birthday, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the BusinessHomePage property. + *

+ * Defined as anyURI in the EWS schema. String is fine here. + */ + public static final PropertyDefinition BusinessHomePage = + new StringPropertyDefinition( + XmlElementNames.BusinessHomePage, FieldUris.BusinessHomePage, + EnumSet.of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Children property. + */ + public static final PropertyDefinition Children = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.Children, FieldUris.Children, EnumSet.of( + PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public StringList createComplexProperty() { + return new StringList(); + } + }); + + /** + * Defines the Companies property. + */ + public static final PropertyDefinition Companies = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.Companies, FieldUris.Companies, EnumSet.of( + PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public StringList createComplexProperty() { + return new StringList(); + } + }); + + /** + * Defines the ContactSource property. + */ + public static final PropertyDefinition ContactSource = + new GenericPropertyDefinition( + ContactSource.class, + XmlElementNames.ContactSource, FieldUris.ContactSource, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Department property. + */ + public static final PropertyDefinition Department = + new StringPropertyDefinition( + XmlElementNames.Department, FieldUris.Department, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Generation property. + */ + public static final PropertyDefinition Generation = + new StringPropertyDefinition( + XmlElementNames.Generation, FieldUris.Generation, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the ImAddresses property. + */ + public static final PropertyDefinition ImAddresses = + new ComplexPropertyDefinition( + ImAddressDictionary.class, + XmlElementNames.ImAddresses, FieldUris.ImAddresses, EnumSet.of( + PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public ImAddressDictionary createComplexProperty() { + return new ImAddressDictionary(); + } + }); + + /** + * Defines the JobTitle property. + */ + public static final PropertyDefinition JobTitle = + new StringPropertyDefinition( + XmlElementNames.JobTitle, FieldUris.JobTitle, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Manager property. + */ + public static final PropertyDefinition Manager = + new StringPropertyDefinition( + XmlElementNames.Manager, FieldUris.Manager, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Mileage property. + */ + public static final PropertyDefinition Mileage = + new StringPropertyDefinition( + XmlElementNames.Mileage, FieldUris.Mileage, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the OfficeLocation property. + */ + public static final PropertyDefinition OfficeLocation = + new StringPropertyDefinition( + XmlElementNames.OfficeLocation, FieldUris.OfficeLocation, EnumSet + .of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the PostalAddressIndex property. + */ + public static final PropertyDefinition PostalAddressIndex = + new GenericPropertyDefinition( + PhysicalAddressIndex.class, + XmlElementNames.PostalAddressIndex, FieldUris.PostalAddressIndex, + EnumSet.of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Profession property. + */ + public static final PropertyDefinition Profession = + new StringPropertyDefinition( + XmlElementNames.Profession, FieldUris.Profession, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the SpouseName property. + */ + public static final PropertyDefinition SpouseName = + new StringPropertyDefinition( + XmlElementNames.SpouseName, FieldUris.SpouseName, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Surname property. + */ + public static final PropertyDefinition Surname = + new StringPropertyDefinition( + XmlElementNames.Surname, FieldUris.Surname, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the WeddingAnniversary property. + */ + public static final PropertyDefinition WeddingAnniversary = + new DateTimePropertyDefinition( + XmlElementNames.WeddingAnniversary, FieldUris.WeddingAnniversary, + EnumSet.of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the HasPicture property. + */ + public static final PropertyDefinition HasPicture = + new BoolPropertyDefinition( + XmlElementNames.HasPicture, FieldUris.HasPicture, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010); + /** + * Defines PhoeniticFullName property ** + */ + + public static final PropertyDefinition PhoneticFullName = + new StringPropertyDefinition( + XmlElementNames.PhoneticFullName, + FieldUris.PhoneticFullName, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines PhoenticFirstName property ** + */ + + public static final PropertyDefinition PhoneticFirstName = + new StringPropertyDefinition( + XmlElementNames.PhoneticFirstName, + FieldUris.PhoneticFirstName, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines PhoneticLastName Property ** + */ + + public static final PropertyDefinition PhoneticLastName = + new StringPropertyDefinition( + XmlElementNames.PhoneticLastName, + FieldUris.PhoneticLastName, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the Alias Property ** + */ + + public static final PropertyDefinition Alias = + new StringPropertyDefinition( + XmlElementNames.Alias, + FieldUris.Alias, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + + /** + * Defines the Notes Property ** + */ + + public static final PropertyDefinition Notes = + new StringPropertyDefinition( + XmlElementNames.Notes, + FieldUris.Notes, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines Photo Property ** + */ + + public static final PropertyDefinition Photo = + new ByteArrayPropertyDefinition( + XmlElementNames.Photo, + FieldUris.Photo, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines UserSMIMECertificate Property ** + */ + + public static final PropertyDefinition UserSMIMECertificate = + new ComplexPropertyDefinition( + ByteArrayArray.class, + XmlElementNames.UserSMIMECertificate, + FieldUris.UserSMIMECertificate, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public ByteArrayArray createComplexProperty() { + return new ByteArrayArray(); + } + }); + + /** + * Defines MSExchangeCertificate Property ** + */ + + public static final PropertyDefinition MSExchangeCertificate = + new ComplexPropertyDefinition( + ByteArrayArray.class, + XmlElementNames.MSExchangeCertificate, + FieldUris.MSExchangeCertificate, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public ByteArrayArray createComplexProperty() { + return new ByteArrayArray(); + } + }); + + + /** + * Defines DirectoryId Property ** + */ + + public static final PropertyDefinition DirectoryId = + new StringPropertyDefinition( + XmlElementNames.DirectoryId, + FieldUris.DirectoryId, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines ManagerMailbox Property ** + */ + + public static final PropertyDefinition ManagerMailbox = + new ContainedPropertyDefinition( + EmailAddress.class, + XmlElementNames.ManagerMailbox, + FieldUris.ManagerMailbox, + XmlElementNames.Mailbox, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public EmailAddress createComplexProperty() { + return new EmailAddress(); + } + }); + + /** + * Defines DirectReports Property ** + */ + + public static final PropertyDefinition DirectReports = + new ComplexPropertyDefinition( + EmailAddressCollection.class, + XmlElementNames.DirectReports, + FieldUris.DirectReports, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public EmailAddressCollection createComplexProperty() { + return new EmailAddressCollection(); + } + }); + + + /** + * Defines the EmailAddress1 property. + */ + public static final IndexedPropertyDefinition EmailAddress1 = + new IndexedPropertyDefinition( + FieldUris.EmailAddress, "EmailAddress1"); + + /** + * Defines the EmailAddress2 property. + */ + public static final IndexedPropertyDefinition EmailAddress2 = + new IndexedPropertyDefinition( + FieldUris.EmailAddress, "EmailAddress2"); + + /** + * Defines the EmailAddress3 property. + */ + public static final IndexedPropertyDefinition EmailAddress3 = + new IndexedPropertyDefinition( + FieldUris.EmailAddress, "EmailAddress3"); + + /** + * Defines the ImAddress1 property. + */ + public static final IndexedPropertyDefinition ImAddress1 = + new IndexedPropertyDefinition( + FieldUris.ImAddress, "ImAddress1"); + + /** + * Defines the ImAddress2 property. + */ + public static final IndexedPropertyDefinition ImAddress2 = + new IndexedPropertyDefinition( + FieldUris.ImAddress, "ImAddress2"); + + /** + * Defines the ImAddress3 property. + */ + public static final IndexedPropertyDefinition ImAddress3 = + new IndexedPropertyDefinition( + FieldUris.ImAddress, "ImAddress3"); + + /** + * Defines the AssistentPhone property. + */ + public static final IndexedPropertyDefinition AssistantPhone = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "AssistantPhone"); + + /** + * Defines the BusinessFax property. + */ + public static final IndexedPropertyDefinition BusinessFax = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "BusinessFax"); + + /** + * Defines the BusinessPhone property. + */ + public static final IndexedPropertyDefinition BusinessPhone = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "BusinessPhone"); + + /** + * Defines the BusinessPhone2 property. + */ + public static final IndexedPropertyDefinition BusinessPhone2 = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "BusinessPhone2"); + + /** + * Defines the Callback property. + */ + public static final IndexedPropertyDefinition Callback = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "Callback"); + + /** + * Defines the CarPhone property. + */ + public static final IndexedPropertyDefinition CarPhone = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "CarPhone"); + + /** + * Defines the CompanyMainPhone property. + */ + public static final IndexedPropertyDefinition CompanyMainPhone = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "CompanyMainPhone"); + + /** + * Defines the HomeFax property. + */ + public static final IndexedPropertyDefinition HomeFax = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "HomeFax"); + + /** + * Defines the HomePhone property. + */ + public static final IndexedPropertyDefinition HomePhone = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "HomePhone"); + + /** + * Defines the HomePhone2 property. + */ + public static final IndexedPropertyDefinition HomePhone2 = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "HomePhone2"); + + /** + * Defines the Isdn property. + */ + public static final IndexedPropertyDefinition Isdn = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "Isdn"); + + /** + * Defines the MobilePhone property. + */ + public static final IndexedPropertyDefinition MobilePhone = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "MobilePhone"); + + /** + * Defines the OtherFax property. + */ + public static final IndexedPropertyDefinition OtherFax = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "OtherFax"); + + /** + * Defines the OtherTelephone property. + */ + public static final IndexedPropertyDefinition OtherTelephone = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "OtherTelephone"); + + /** + * Defines the Pager property. + */ + public static final IndexedPropertyDefinition Pager = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "Pager"); + + /** + * Defines the PrimaryPhone property. + */ + public static final IndexedPropertyDefinition PrimaryPhone = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "PrimaryPhone"); + + /** + * Defines the RadioPhone property. + */ + public static final IndexedPropertyDefinition RadioPhone = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "RadioPhone"); + + /** + * Defines the Telex property. + */ + public static final IndexedPropertyDefinition Telex = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "Telex"); + + /** + * Defines the TtyTddPhone property. + */ + public static final IndexedPropertyDefinition TtyTddPhone = + new IndexedPropertyDefinition( + FieldUris.PhoneNumber, "TtyTddPhone"); + + /** + * Defines the BusinessAddressStreet property. + */ + public static final IndexedPropertyDefinition BusinessAddressStreet = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressStreet, "Business"); + + /** + * Defines the BusinessAddressCity property. + */ + public static final IndexedPropertyDefinition BusinessAddressCity = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressCity, "Business"); + + /** + * Defines the BusinessAddressState property. + */ + public static final IndexedPropertyDefinition BusinessAddressState = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressState, "Business"); + + /** + * Defines the BusinessAddressCountryOrRegion property. + */ + public static final IndexedPropertyDefinition + BusinessAddressCountryOrRegion = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressCountryOrRegion, "Business"); + + /** + * Defines the BusinessAddressPostalCode property. + */ + public static final IndexedPropertyDefinition BusinessAddressPostalCode = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressPostalCode, "Business"); + + /** + * Defines the HomeAddressStreet property. + */ + public static final IndexedPropertyDefinition HomeAddressStreet = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressStreet, "Home"); + + /** + * Defines the HomeAddressCity property. + */ + public static final IndexedPropertyDefinition HomeAddressCity = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressCity, "Home"); + + /** + * Defines the HomeAddressState property. + */ + public static final IndexedPropertyDefinition HomeAddressState = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressState, "Home"); + + /** + * Defines the HomeAddressCountryOrRegion property. + */ + public static final IndexedPropertyDefinition HomeAddressCountryOrRegion = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressCountryOrRegion, "Home"); + + /** + * Defines the HomeAddressPostalCode property. + */ + public static final IndexedPropertyDefinition HomeAddressPostalCode = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressPostalCode, "Home"); + + /** + * Defines the OtherAddressStreet property. + */ + public static final IndexedPropertyDefinition OtherAddressStreet = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressStreet, "Other"); + + /** + * Defines the OtherAddressCity property. + */ + public static final IndexedPropertyDefinition OtherAddressCity = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressCity, "Other"); + + /** + * Defines the OtherAddressState property. + */ + public static final IndexedPropertyDefinition OtherAddressState = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressState, "Other"); + + /** + * Defines the OtherAddressCountryOrRegion property. + */ + public static final IndexedPropertyDefinition OtherAddressCountryOrRegion = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressCountryOrRegion, "Other"); + + /** + * Defines the OtherAddressPostalCode property. + */ + public static final IndexedPropertyDefinition OtherAddressPostalCode = + new IndexedPropertyDefinition( + FieldUris.PhysicalAddressPostalCode, "Other"); + + // This must be declared after the property definitions + /** + * The Constant Instance. + */ + public static final ContactSchema Instance = new ContactSchema(); + + /** + * Registers property. + *

+ * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the + * same order as they are defined in types.xsd) + */ + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(FileAs); + this.registerProperty(FileAsMapping); + this.registerProperty(DisplayName); + this.registerProperty(GivenName); + this.registerProperty(Initials); + this.registerProperty(MiddleName); + this.registerProperty(NickName); + this.registerProperty(CompleteName); + this.registerProperty(CompanyName); + this.registerProperty(EmailAddresses); + this.registerProperty(PhysicalAddresses); + this.registerProperty(PhoneNumbers); + this.registerProperty(AssistantName); + this.registerProperty(Birthday); + this.registerProperty(BusinessHomePage); + this.registerProperty(Children); + this.registerProperty(Companies); + this.registerProperty(ContactSource); + this.registerProperty(Department); + this.registerProperty(Generation); + this.registerProperty(ImAddresses); + this.registerProperty(JobTitle); + this.registerProperty(Manager); + this.registerProperty(Mileage); + this.registerProperty(OfficeLocation); + this.registerProperty(PostalAddressIndex); + this.registerProperty(Profession); + this.registerProperty(SpouseName); + this.registerProperty(Surname); + this.registerProperty(WeddingAnniversary); + this.registerProperty(HasPicture); + this.registerProperty(PhoneticFullName); + this.registerProperty(PhoneticFirstName); + this.registerProperty(PhoneticLastName); + this.registerProperty(Alias); + this.registerProperty(Notes); + this.registerProperty(Photo); + this.registerProperty(UserSMIMECertificate); + this.registerProperty(MSExchangeCertificate); + this.registerProperty(DirectoryId); + this.registerProperty(ManagerMailbox); + this.registerProperty(DirectReports); + + this.registerIndexedProperty(EmailAddress1); + this.registerIndexedProperty(EmailAddress2); + this.registerIndexedProperty(EmailAddress3); + this.registerIndexedProperty(ImAddress1); + this.registerIndexedProperty(ImAddress2); + this.registerIndexedProperty(ImAddress3); + this.registerIndexedProperty(AssistantPhone); + this.registerIndexedProperty(BusinessFax); + this.registerIndexedProperty(BusinessPhone); + this.registerIndexedProperty(BusinessPhone2); + this.registerIndexedProperty(Callback); + this.registerIndexedProperty(CarPhone); + this.registerIndexedProperty(CompanyMainPhone); + this.registerIndexedProperty(HomeFax); + this.registerIndexedProperty(HomePhone); + this.registerIndexedProperty(HomePhone2); + this.registerIndexedProperty(Isdn); + this.registerIndexedProperty(MobilePhone); + this.registerIndexedProperty(OtherFax); + this.registerIndexedProperty(OtherTelephone); + this.registerIndexedProperty(Pager); + this.registerIndexedProperty(PrimaryPhone); + this.registerIndexedProperty(RadioPhone); + this.registerIndexedProperty(Telex); + this.registerIndexedProperty(TtyTddPhone); + this.registerIndexedProperty(BusinessAddressStreet); + this.registerIndexedProperty(BusinessAddressCity); + this.registerIndexedProperty(BusinessAddressState); + this.registerIndexedProperty(BusinessAddressCountryOrRegion); + this.registerIndexedProperty(BusinessAddressPostalCode); + this.registerIndexedProperty(HomeAddressStreet); + this.registerIndexedProperty(HomeAddressCity); + this.registerIndexedProperty(HomeAddressState); + this.registerIndexedProperty(HomeAddressCountryOrRegion); + this.registerIndexedProperty(HomeAddressPostalCode); + this.registerIndexedProperty(OtherAddressStreet); + this.registerIndexedProperty(OtherAddressCity); + this.registerIndexedProperty(OtherAddressState); + this.registerIndexedProperty(OtherAddressCountryOrRegion); + this.registerIndexedProperty(OtherAddressPostalCode); + + } + + /** + * Instantiates a new contact schema. + */ + ContactSchema() { + super(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ConversationSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ConversationSchema.java new file mode 100644 index 000000000..68cefd349 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ConversationSchema.java @@ -0,0 +1,651 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.Schema; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.Importance; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.enumeration.service.ConversationFlagStatus; +import com.eischet.ews.api.property.complex.ConversationId; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; +import com.eischet.ews.api.property.complex.ItemIdCollection; +import com.eischet.ews.api.property.complex.StringList; +import com.eischet.ews.api.property.definition.*; + +import java.util.EnumSet; + +/** + * Represents the schema for Conversation. + */ +@Schema +public class ConversationSchema extends ServiceObjectSchema { + + /** + * Field URIs for Item. + */ + private static class FieldUris { + /** + * The Constant ConversationId. + */ + public static final String ConversationId = + "conversation:ConversationId"; + + /** + * The Constant ConversationTopic. + */ + public static final String ConversationTopic = + "conversation:ConversationTopic"; + + /** + * The Constant UniqueRecipients. + */ + public static final String UniqueRecipients = + "conversation:UniqueRecipients"; + + /** + * The Constant GlobalUniqueRecipients. + */ + public static final String GlobalUniqueRecipients = + "conversation:GlobalUniqueRecipients"; + + /** + * The Constant UniqueUnreadSenders. + */ + public static final String UniqueUnreadSenders = + "conversation:UniqueUnreadSenders"; + + /** + * The Constant GlobalUniqueUnreadSenders. + */ + public static final String GlobalUniqueUnreadSenders = + "conversation:GlobalUniqueUnreadSenders"; + + /** + * The Constant UniqueSenders. + */ + public static final String UniqueSenders = "conversation:UniqueSenders"; + + /** + * The Constant GlobalUniqueSenders. + */ + public static final String GlobalUniqueSenders = + "conversation:GlobalUniqueSenders"; + + /** + * The Constant LastDeliveryTime. + */ + public static final String LastDeliveryTime = + "conversation:LastDeliveryTime"; + + /** + * The Constant GlobalLastDeliveryTime. + */ + public static final String GlobalLastDeliveryTime = + "conversation:GlobalLastDeliveryTime"; + + /** + * The Constant Categories. + */ + public static final String Categories = "conversation:Categories"; + + /** + * The Constant GlobalCategories. + */ + public static final String GlobalCategories = + "conversation:GlobalCategories"; + + /** + * The Constant FlagStatus. + */ + public static final String FlagStatus = "conversation:FlagStatus"; + + /** + * The Constant GlobalFlagStatus. + */ + public static final String GlobalFlagStatus = + "conversation:GlobalFlagStatus"; + + /** + * The Constant HasAttachments. + */ + public static final String HasAttachments = + "conversation:HasAttachments"; + + /** + * The Constant GlobalHasAttachments. + */ + public static final String GlobalHasAttachments = + "conversation:GlobalHasAttachments"; + + /** + * The Constant MessageCount. + */ + public static final String MessageCount = "conversation:MessageCount"; + + /** + * The Constant GlobalMessageCount. + */ + public static final String GlobalMessageCount = + "conversation:GlobalMessageCount"; + + /** + * The Constant UnreadCount. + */ + public static final String UnreadCount = "conversation:UnreadCount"; + + /** + * The Constant GlobalUnreadCount. + */ + public static final String GlobalUnreadCount = + "conversation:GlobalUnreadCount"; + + /** + * The Constant Size. + */ + public static final String Size = "conversation:Size"; + + /** + * The Constant GlobalSize. + */ + public static final String GlobalSize = "conversation:GlobalSize"; + + /** + * The Constant ItemClasses. + */ + public static final String ItemClasses = "conversation:ItemClasses"; + + /** + * The Constant GlobalItemClasses. + */ + public static final String GlobalItemClasses = + "conversation:GlobalItemClasses"; + + /** + * The Constant Importance. + */ + public static final String Importance = "conversation:Importance"; + + /** + * The Constant GlobalImportance. + */ + public static final String GlobalImportance = + "conversation:GlobalImportance"; + + /** + * The Constant ItemIds. + */ + public static final String ItemIds = "conversation:ItemIds"; + + /** + * The Constant GlobalItemIds. + */ + public static final String GlobalItemIds = "conversation:GlobalItemIds"; + + } + + + /** + * Defines the Id property. + */ + public static final PropertyDefinition Id = new ComplexPropertyDefinition( + ConversationId.class, + XmlElementNames.ConversationId, FieldUris.ConversationId, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public ConversationId createComplexProperty() { + return new ConversationId(); + } + }); + + /** + * Defines the Topic property. + */ + public static final PropertyDefinition Topic = + new StringPropertyDefinition( + XmlElementNames.ConversationTopic, + FieldUris.ConversationTopic, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the UniqueRecipients property. + */ + public static final PropertyDefinition UniqueRecipients = new + ComplexPropertyDefinition( + StringList.class, + XmlElementNames.UniqueRecipients, + FieldUris.UniqueRecipients, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(); + } + }); + + + /** + * Defines the GlobalUniqueRecipients property. + */ + public static final PropertyDefinition GlobalUniqueRecipients = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.GlobalUniqueRecipients, + FieldUris.GlobalUniqueRecipients, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(); + } + }); + + /** + * Defines the UniqueUnreadSenders property. + */ + public static final PropertyDefinition UniqueUnreadSenders = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.UniqueUnreadSenders, + FieldUris.UniqueUnreadSenders, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(); + } + }); + + /** + * Defines the GlobalUniqueUnreadSenders property. + */ + public static final PropertyDefinition GlobalUniqueUnreadSenders = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.GlobalUniqueUnreadSenders, + FieldUris.GlobalUniqueUnreadSenders, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(); + } + }); + + /** + * Defines the UniqueSenders property. + */ + public static final PropertyDefinition UniqueSenders = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.UniqueSenders, + FieldUris.UniqueSenders, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(); + } + }); + + /** + * Defines the GlobalUniqueSenders property. + */ + public static final PropertyDefinition GlobalUniqueSenders = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.GlobalUniqueSenders, + FieldUris.GlobalUniqueSenders, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(); + } + }); + + /** + * Defines the LastDeliveryTime property. + */ + public static final PropertyDefinition LastDeliveryTime = + new DateTimePropertyDefinition( + XmlElementNames.LastDeliveryTime, + FieldUris.LastDeliveryTime, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the GlobalLastDeliveryTime property. + */ + public static final PropertyDefinition GlobalLastDeliveryTime = + new DateTimePropertyDefinition( + XmlElementNames.GlobalLastDeliveryTime, + FieldUris.GlobalLastDeliveryTime, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the Categories property. + */ + public static final PropertyDefinition Categories = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.Categories, + FieldUris.Categories, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(); + } + }); + + /** + * Defines the GlobalCategories property. + */ + public static final PropertyDefinition GlobalCategories = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.GlobalCategories, + FieldUris.GlobalCategories, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(); + } + }); + + /** + * Defines the FlagStatus property. + */ + public static final PropertyDefinition FlagStatus = + new GenericPropertyDefinition( + ConversationFlagStatus.class, + XmlElementNames.FlagStatus, + FieldUris.FlagStatus, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the GlobalFlagStatus property. + */ + public static final PropertyDefinition GlobalFlagStatus = + new GenericPropertyDefinition( + ConversationFlagStatus.class, + XmlElementNames.GlobalFlagStatus, + FieldUris.GlobalFlagStatus, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the HasAttachments property. + */ + public static final PropertyDefinition HasAttachments = + new BoolPropertyDefinition( + XmlElementNames.HasAttachments, + FieldUris.HasAttachments, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the GlobalHasAttachments property. + */ + public static final PropertyDefinition GlobalHasAttachments = + new BoolPropertyDefinition( + XmlElementNames.GlobalHasAttachments, + FieldUris.GlobalHasAttachments, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the MessageCount property. + */ + public static final PropertyDefinition MessageCount = + new IntPropertyDefinition( + XmlElementNames.MessageCount, + FieldUris.MessageCount, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the GlobalMessageCount property. + */ + public static final PropertyDefinition GlobalMessageCount = + new IntPropertyDefinition( + XmlElementNames.GlobalMessageCount, + FieldUris.GlobalMessageCount, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the UnreadCount property. + */ + public static final PropertyDefinition UnreadCount = + new IntPropertyDefinition( + XmlElementNames.UnreadCount, + FieldUris.UnreadCount, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the GlobalUnreadCount property. + */ + public static final PropertyDefinition GlobalUnreadCount = + new IntPropertyDefinition( + XmlElementNames.GlobalUnreadCount, + FieldUris.GlobalUnreadCount, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the Size property. + */ + public static final PropertyDefinition Size = + new IntPropertyDefinition( + XmlElementNames.Size, + FieldUris.Size, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the GlobalSize property. + */ + public static final PropertyDefinition GlobalSize = + new IntPropertyDefinition( + XmlElementNames.GlobalSize, + FieldUris.GlobalSize, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the ItemClasses property. + */ + public static final PropertyDefinition ItemClasses = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.ItemClasses, + FieldUris.ItemClasses, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(XmlElementNames. + ItemClass); + } + }); + + /** + * Defines the GlobalItemClasses property. + */ + public static final PropertyDefinition GlobalItemClasses = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.GlobalItemClasses, + FieldUris.GlobalItemClasses, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(XmlElementNames. + ItemClass); + } + }); + + /** + * Defines the Importance property. + */ + public static final PropertyDefinition Importance = + new GenericPropertyDefinition( + Importance.class, + XmlElementNames.Importance, + FieldUris.Importance, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the GlobalImportance property. + */ + public static final PropertyDefinition GlobalImportance = + new GenericPropertyDefinition( + Importance.class, + XmlElementNames.GlobalImportance, + FieldUris.GlobalImportance, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1); + + /** + * Defines the ItemIds property. + */ + public static final PropertyDefinition ItemIds = + new ComplexPropertyDefinition( + ItemIdCollection.class, + XmlElementNames.ItemIds, + FieldUris.ItemIds, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public ItemIdCollection createComplexProperty() { + return new ItemIdCollection(); + } + }); + + /** + * Defines the GlobalItemIds property. + */ + public static final PropertyDefinition GlobalItemIds = + new ComplexPropertyDefinition( + ItemIdCollection.class, + XmlElementNames.GlobalItemIds, + FieldUris.GlobalItemIds, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP1, + new ICreateComplexPropertyDelegate() { + public ItemIdCollection createComplexProperty() { + return new ItemIdCollection(); + } + }); + + /** + * This must be declared after the property definitions + */ + public static final ConversationSchema Instance = + new ConversationSchema(); + + /** + * Registers property. + */ + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(Id); + this.registerProperty(Topic); + this.registerProperty(UniqueRecipients); + this.registerProperty(GlobalUniqueRecipients); + this.registerProperty(UniqueUnreadSenders); + this.registerProperty(GlobalUniqueUnreadSenders); + this.registerProperty(UniqueSenders); + this.registerProperty(GlobalUniqueSenders); + this.registerProperty(LastDeliveryTime); + this.registerProperty(GlobalLastDeliveryTime); + this.registerProperty(Categories); + this.registerProperty(GlobalCategories); + this.registerProperty(FlagStatus); + this.registerProperty(GlobalFlagStatus); + this.registerProperty(HasAttachments); + this.registerProperty(GlobalHasAttachments); + this.registerProperty(MessageCount); + this.registerProperty(GlobalMessageCount); + this.registerProperty(UnreadCount); + this.registerProperty(GlobalUnreadCount); + this.registerProperty(Size); + this.registerProperty(GlobalSize); + this.registerProperty(ItemClasses); + this.registerProperty(GlobalItemClasses); + this.registerProperty(Importance); + this.registerProperty(GlobalImportance); + this.registerProperty(ItemIds); + this.registerProperty(GlobalItemIds); + } + + /** + * Initializes a new instance of + * the ConversationSchema class. + */ + protected ConversationSchema() { + super(); + } + + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/EmailMessageSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/EmailMessageSchema.java new file mode 100644 index 000000000..fa3886510 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/EmailMessageSchema.java @@ -0,0 +1,417 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.Schema; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.property.complex.EmailAddress; +import com.eischet.ews.api.property.complex.EmailAddressCollection; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; +import com.eischet.ews.api.property.definition.*; + +import java.util.EnumSet; + +/** + * Represents the schema for e-mail messages. + */ +@Schema +public class EmailMessageSchema extends ItemSchema { + + /** + * The Interface FieldUris. + */ + private interface FieldUris { + + /** + * The Conversation index. + */ + String ConversationIndex = "message:ConversationIndex"; + + /** + * The Conversation topic. + */ + String ConversationTopic = "message:ConversationTopic"; + + /** + * The Internet message id. + */ + String InternetMessageId = "message:InternetMessageId"; + + /** + * The Is read. + */ + String IsRead = "message:IsRead"; + + /** + * The Is response requested. + */ + String IsResponseRequested = "message:IsResponseRequested"; + + /** + * The Is read receipt requested. + */ + String IsReadReceiptRequested = "message:IsReadReceiptRequested"; + + /** + * The Is delivery receipt requested. + */ + String IsDeliveryReceiptRequested = + "message:IsDeliveryReceiptRequested"; + + /** + * The References. + */ + String References = "message:References"; + + /** + * The Reply to. + */ + String ReplyTo = "message:ReplyTo"; + + /** + * The From. + */ + String From = "message:From"; + + /** + * The Sender. + */ + String Sender = "message:Sender"; + + /** + * The To recipients. + */ + String ToRecipients = "message:ToRecipients"; + + /** + * The Cc recipients. + */ + String CcRecipients = "message:CcRecipients"; + + /** + * The Bcc recipients. + */ + String BccRecipients = "message:BccRecipients"; + + /** + * The Received by. + */ + String ReceivedBy = "message:ReceivedBy"; + + /** + * The Received representing. + */ + String ReceivedRepresenting = "message:ReceivedRepresenting"; + } + + + /** + * Defines the ToRecipients property. + */ + public static final PropertyDefinition ToRecipients = + new ComplexPropertyDefinition( + EmailAddressCollection.class, + XmlElementNames.ToRecipients, + FieldUris.ToRecipients, + EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public EmailAddressCollection createComplexProperty() { + return new EmailAddressCollection(); + } + }); + + /** + * Defines the BccRecipients property. + */ + public static final PropertyDefinition BccRecipients = + new ComplexPropertyDefinition( + EmailAddressCollection.class, + XmlElementNames.BccRecipients, + FieldUris.BccRecipients, + EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate + () { + @Override + public EmailAddressCollection createComplexProperty() { + return new EmailAddressCollection(); + } + }); + + /** + * Defines the CcRecipients property. + */ + public static final PropertyDefinition CcRecipients = + new ComplexPropertyDefinition( + EmailAddressCollection.class, + XmlElementNames.CcRecipients, + FieldUris.CcRecipients, + EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate + () { + @Override + public EmailAddressCollection createComplexProperty() { + return new EmailAddressCollection(); + } + }); + + /** + * Defines the ConversationIndex property. + */ + public static final PropertyDefinition ConversationIndex = + new ByteArrayPropertyDefinition( + XmlElementNames.ConversationIndex, FieldUris.ConversationIndex, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the ConversationTopic property. + */ + public static final PropertyDefinition ConversationTopic = + new StringPropertyDefinition( + XmlElementNames.ConversationTopic, FieldUris.ConversationTopic, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the From property. + */ + public static final PropertyDefinition From = + new ContainedPropertyDefinition( + EmailAddress.class, + XmlElementNames.From, FieldUris.From, XmlElementNames.Mailbox, + EnumSet.of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public EmailAddress createComplexProperty() { + return new EmailAddress(); + } + }); + + /** + * Defines the IsDeliveryReceiptRequested property. + */ + public static final PropertyDefinition IsDeliveryReceiptRequested = + new BoolPropertyDefinition( + XmlElementNames.IsDeliveryReceiptRequested, + FieldUris.IsDeliveryReceiptRequested, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsRead property. + */ + public static final PropertyDefinition IsRead = new BoolPropertyDefinition( + XmlElementNames.IsRead, FieldUris.IsRead, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsReadReceiptRequested property. + */ + public static final PropertyDefinition IsReadReceiptRequested = + new BoolPropertyDefinition( + XmlElementNames.IsReadReceiptRequested, + FieldUris.IsReadReceiptRequested, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsResponseRequested property. + */ + public static final PropertyDefinition IsResponseRequested = + new BoolPropertyDefinition( + XmlElementNames.IsResponseRequested, FieldUris.IsResponseRequested, + EnumSet.of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, true); // isNullable + + /** + * Defines the InternetMessageId property. + */ + public static final PropertyDefinition InternetMessageId = + new StringPropertyDefinition( + XmlElementNames.InternetMessageId, FieldUris.InternetMessageId, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the References property. + */ + public static final PropertyDefinition References = + new StringPropertyDefinition( + XmlElementNames.References, FieldUris.References, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the ReplyTo property. + */ + public static final PropertyDefinition ReplyTo = + new ComplexPropertyDefinition( + EmailAddressCollection.class, + XmlElementNames.ReplyTo, + FieldUris.ReplyTo, + EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate + () { + @Override + public EmailAddressCollection createComplexProperty() { + return new EmailAddressCollection(); + } + }); + + /** + * Defines the Sender property. + */ + public static final PropertyDefinition Sender = + new ContainedPropertyDefinition( + EmailAddress.class, + XmlElementNames.Sender, FieldUris.Sender, XmlElementNames.Mailbox, + EnumSet.of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public EmailAddress createComplexProperty() { + return new EmailAddress(); + } + }); + + /** + * Defines the ReceivedBy property. + */ + public static final PropertyDefinition ReceivedBy = + new ContainedPropertyDefinition( + EmailAddress.class, + XmlElementNames.ReceivedBy, FieldUris.ReceivedBy, + XmlElementNames.Mailbox, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public EmailAddress createComplexProperty() { + return new EmailAddress(); + } + }); + + /** + * Defines the ReceivedRepresenting property. + */ + public static final PropertyDefinition ReceivedRepresenting = + new ContainedPropertyDefinition( + EmailAddress.class, + XmlElementNames.ReceivedRepresenting, + FieldUris.ReceivedRepresenting, XmlElementNames.Mailbox, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public EmailAddress createComplexProperty() { + return new EmailAddress(); + } + }); + + /** + * The Constant Instance. + */ + public static final EmailMessageSchema Instance = + new EmailMessageSchema(); + + /** + * Gets the single instance of EmailMessageSchema. + * + * @return single instance of EmailMessageSchema + */ + public static EmailMessageSchema getInstance() { + return Instance; + } + + /** + * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN + * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd) + */ + @Override + protected void registerProperties() { + super.registerProperties(); + this.registerProperty(Sender); + this.registerProperty(ToRecipients); + this.registerProperty(CcRecipients); + this.registerProperty(BccRecipients); + this.registerProperty(IsReadReceiptRequested); + this.registerProperty(IsDeliveryReceiptRequested); + this.registerProperty(ConversationIndex); + this.registerProperty(ConversationTopic); + this.registerProperty(From); + this.registerProperty(InternetMessageId); + this.registerProperty(IsRead); + this.registerProperty(IsResponseRequested); + this.registerProperty(References); + this.registerProperty(ReplyTo); + this.registerProperty(ReceivedBy); + this.registerProperty(ReceivedRepresenting); + } + + /** + * Initializes a new instance. + */ + protected EmailMessageSchema() { + super(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/FolderSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/FolderSchema.java new file mode 100644 index 000000000..cf5cd5b0c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/FolderSchema.java @@ -0,0 +1,246 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.Schema; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.property.complex.FolderId; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; +import com.eischet.ews.api.property.complex.ManagedFolderInformation; +import com.eischet.ews.api.property.definition.*; + +import java.util.EnumSet; + +/** + * Represents the schema for folder. + */ +@Schema +public class FolderSchema extends ServiceObjectSchema { + + /** + * Field URIs for folder. + */ + private static class FieldUris { + + /** + * The Constant FolderId. + */ + public final static String FolderId = "folder:FolderId"; + + /** + * The Constant ParentFolderId. + */ + public final static String ParentFolderId = "folder:ParentFolderId"; + + /** + * The Constant DisplayName. + */ + public final static String DisplayName = "folder:DisplayName"; + + /** + * The Constant UnreadCount. + */ + public final static String UnreadCount = "folder:UnreadCount"; + + /** + * The Constant TotalCount. + */ + public final static String TotalCount = "folder:TotalCount"; + + /** + * The Constant ChildFolderCount. + */ + public final static String ChildFolderCount = "folder:ChildFolderCount"; + + /** + * The Constant FolderClass. + */ + public final static String FolderClass = "folder:FolderClass"; + + /** + * The Constant ManagedFolderInformation. + */ + public final static String ManagedFolderInformation = + "folder:ManagedFolderInformation"; + + /** + * The Constant EffectiveRights. + */ + public final static String EffectiveRights = "folder:EffectiveRights"; + + /** + * The Constant PermissionSet. + */ + public final static String PermissionSet = "folder:PermissionSet"; + } + + + /** + * Defines the Id property. + */ + public static final PropertyDefinition Id = + new ComplexPropertyDefinition( + FolderId.class, + XmlElementNames.FolderId, FieldUris.FolderId, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public FolderId createComplexProperty() { + return new FolderId(); + } + } + + ); + + /** + * Defines the FolderClass property. + */ + public static final PropertyDefinition FolderClass = + new StringPropertyDefinition( + XmlElementNames.FolderClass, FieldUris.FolderClass, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the ParentFolderId property. + */ + public static final PropertyDefinition ParentFolderId = + new ComplexPropertyDefinition( + FolderId.class, + XmlElementNames.ParentFolderId, FieldUris.ParentFolderId, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public FolderId createComplexProperty() { + return new FolderId(); + } + }); + + /** + * Defines the ChildFolderCount property. + */ + public static final PropertyDefinition ChildFolderCount = + new IntPropertyDefinition( + XmlElementNames.ChildFolderCount, FieldUris.ChildFolderCount, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the DisplayName property. + */ + public static final PropertyDefinition DisplayName = + new StringPropertyDefinition( + XmlElementNames.DisplayName, FieldUris.DisplayName, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the UnreadCount property. + */ + public static final PropertyDefinition UnreadCount = + new IntPropertyDefinition( + XmlElementNames.UnreadCount, FieldUris.UnreadCount, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the TotalCount property. + */ + public static final PropertyDefinition TotalCount = + new IntPropertyDefinition( + XmlElementNames.TotalCount, FieldUris.TotalCount, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the ManagedFolderInformation property. + */ + public static final PropertyDefinition ManagedFolderInformation = + new ComplexPropertyDefinition( + ManagedFolderInformation.class, + XmlElementNames.ManagedFolderInformation, + FieldUris.ManagedFolderInformation, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate + () { + public ManagedFolderInformation createComplexProperty() { + return new ManagedFolderInformation(); + } + }); + + /** + * Defines the EffectiveRights property. + */ + public static final PropertyDefinition EffectiveRights = + new EffectiveRightsPropertyDefinition( + XmlElementNames.EffectiveRights, FieldUris.EffectiveRights, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Permissions property. + */ + public static final PropertyDefinition Permissions = + new PermissionSetPropertyDefinition( + XmlElementNames.PermissionSet, FieldUris.PermissionSet, EnumSet.of( + PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete), + ExchangeVersion.Exchange2007_SP1); + + /** + * This must be declared after the property definitions. + */ + public static final FolderSchema Instance = new FolderSchema(); + + /** + * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN + * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd) + */ + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(Id); + this.registerProperty(ParentFolderId); + this.registerProperty(FolderClass); + this.registerProperty(DisplayName); + this.registerProperty(TotalCount); + this.registerProperty(ChildFolderCount); + this.registerProperty(ServiceObjectSchema.extendedProperties); + this.registerProperty(ManagedFolderInformation); + this.registerProperty(EffectiveRights); + this.registerProperty(Permissions); + this.registerProperty(UnreadCount); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ItemSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ItemSchema.java new file mode 100644 index 000000000..1f41eb2ab --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ItemSchema.java @@ -0,0 +1,734 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.Schema; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.Importance; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.enumeration.property.Sensitivity; +import com.eischet.ews.api.property.complex.*; +import com.eischet.ews.api.property.definition.*; + +import java.util.EnumSet; + +/** + * Represents the schema for generic item. + */ +@Schema +public class ItemSchema extends ServiceObjectSchema { + + /** + * The Interface FieldUris. + */ + private interface FieldUris { + + /** + * The Item id. + */ + String ItemId = "item:ItemId"; + + /** + * The Parent folder id. + */ + String ParentFolderId = "item:ParentFolderId"; + + /** + * The Item class. + */ + String ItemClass = "item:ItemClass"; + + /** + * The Mime content. + */ + String MimeContent = "item:MimeContent"; + + /** + * The Attachments. + */ + String Attachments = "item:Attachments"; + + /** + * The Subject. + */ + String Subject = "item:Subject"; + + /** + * The Date time received. + */ + String DateTimeReceived = "item:DateTimeReceived"; + + /** + * The Size. + */ + String Size = "item:Size"; + + /** + * The Categories. + */ + String Categories = "item:Categories"; + + /** + * The Has attachments. + */ + String HasAttachments = "item:HasAttachments"; + + /** + * The Importance. + */ + String Importance = "item:Importance"; + + /** + * The In reply to. + */ + String InReplyTo = "item:InReplyTo"; + + /** + * The Internet message headers. + */ + String InternetMessageHeaders = "item:InternetMessageHeaders"; + + /** + * The Is associated. + */ + String IsAssociated = "item:IsAssociated"; + + /** + * The Is draft. + */ + String IsDraft = "item:IsDraft"; + + /** + * The Is from me. + */ + String IsFromMe = "item:IsFromMe"; + + /** + * The Is resend. + */ + String IsResend = "item:IsResend"; + + /** + * The Is submitted. + */ + String IsSubmitted = "item:IsSubmitted"; + + /** + * The Is unmodified. + */ + String IsUnmodified = "item:IsUnmodified"; + + /** + * The Date time sent. + */ + String DateTimeSent = "item:DateTimeSent"; + + /** + * The Date time created. + */ + String DateTimeCreated = "item:DateTimeCreated"; + + /** + * The Body. + */ + String Body = "item:Body"; + + /** + * The Response objects. + */ + String ResponseObjects = "item:ResponseObjects"; + + /** + * The Sensitivity. + */ + String Sensitivity = "item:Sensitivity"; + + /** + * The Reminder due by. + */ + String ReminderDueBy = "item:ReminderDueBy"; + + /** + * The Reminder is set. + */ + String ReminderIsSet = "item:ReminderIsSet"; + + /** + * The Reminder minutes before start. + */ + String ReminderMinutesBeforeStart = "item:ReminderMinutesBeforeStart"; + + /** + * The Display to. + */ + String DisplayTo = "item:DisplayTo"; + + /** + * The Display cc. + */ + String DisplayCc = "item:DisplayCc"; + + /** + * The Culture. + */ + String Culture = "item:Culture"; + + /** + * The Effective rights. + */ + String EffectiveRights = "item:EffectiveRights"; + + /** + * The Last modified name. + */ + String LastModifiedName = "item:LastModifiedName"; + + /** + * The Last modified time. + */ + String LastModifiedTime = "item:LastModifiedTime"; + + /** + * The Web client read form query string. + */ + String WebClientReadFormQueryString = + "item:WebClientReadFormQueryString"; + + /** + * The Web client edit form query string. + */ + String WebClientEditFormQueryString = + "item:WebClientEditFormQueryString"; + + /** + * The Conversation id. + */ + String ConversationId = "item:ConversationId"; + + /** + * The Unique body. + */ + String UniqueBody = "item:UniqueBody"; + + String StoreEntryId = "item:StoreEntryId"; + } + + + /** + * Defines the Id property. + */ + public static final PropertyDefinition Id = new ComplexPropertyDefinition( + ItemId.class, + XmlElementNames.ItemId, FieldUris.ItemId, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public ItemId createComplexProperty() { + return new ItemId(); + } + }); + + /** + * Defines the Body property. + */ + public static final PropertyDefinition Body = new + ComplexPropertyDefinition( + MessageBody.class, + XmlElementNames.Body, FieldUris.Body, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public MessageBody createComplexProperty() { + return new MessageBody(); + } + }); + + /** + * Defines the ItemClass property. + */ + public static final PropertyDefinition ItemClass = new StringPropertyDefinition( + XmlElementNames.ItemClass, FieldUris.ItemClass, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Subject property. + */ + public static final PropertyDefinition Subject = new + StringPropertyDefinition( + XmlElementNames.Subject, FieldUris.Subject, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the MimeContent property. + */ + public static final PropertyDefinition MimeContent = + new ComplexPropertyDefinition( + MimeContent.class, + XmlElementNames.MimeContent, FieldUris.MimeContent, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.MustBeExplicitlyLoaded), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public MimeContent createComplexProperty() { + return new MimeContent(); + } + }); + + /** + * Defines the ParentFolderId property. + */ + public static final PropertyDefinition ParentFolderId = + new ComplexPropertyDefinition( + FolderId.class, + XmlElementNames.ParentFolderId, FieldUris.ParentFolderId, + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public FolderId createComplexProperty() { + return new FolderId(); + } + }); + + /** + * Defines the Sensitivity property. + */ + public static final PropertyDefinition Sensitivity = + new GenericPropertyDefinition( + Sensitivity.class, + XmlElementNames.Sensitivity, FieldUris.Sensitivity, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Attachments property. + */ + public static final PropertyDefinition Attachments = new AttachmentsPropertyDefinition(); + + /** + * Defines the DateTimeReceived property. + */ + public static final PropertyDefinition DateTimeReceived = + new DateTimePropertyDefinition( + XmlElementNames.DateTimeReceived, FieldUris.DateTimeReceived, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Size property. + */ + public static final PropertyDefinition Size = new IntPropertyDefinition( + XmlElementNames.Size, FieldUris.Size, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Categories property. + */ + public static final PropertyDefinition Categories = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.Categories, FieldUris.Categories, EnumSet.of( + PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(); + } + }); + + /** + * Defines the Importance property. + */ + public static final PropertyDefinition Importance = + new GenericPropertyDefinition( + Importance.class, + XmlElementNames.Importance, FieldUris.Importance, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the InReplyTo property. + */ + public static final PropertyDefinition InReplyTo = + new StringPropertyDefinition( + XmlElementNames.InReplyTo, FieldUris.InReplyTo, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsSubmitted property. + */ + public static final PropertyDefinition IsSubmitted = + new BoolPropertyDefinition( + XmlElementNames.IsSubmitted, FieldUris.IsSubmitted, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsAssociated property. + */ + public static final PropertyDefinition IsAssociated = + new BoolPropertyDefinition( + XmlElementNames.IsAssociated, FieldUris.IsAssociated, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010); + + /** + * Defines the IsDraft property. + */ + public static final PropertyDefinition IsDraft = new BoolPropertyDefinition( + XmlElementNames.IsDraft, FieldUris.IsDraft, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsFromMe property. + */ + public static final PropertyDefinition IsFromMe = + new BoolPropertyDefinition( + XmlElementNames.IsFromMe, FieldUris.IsFromMe, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsResend property. + */ + public static final PropertyDefinition IsResend = + new BoolPropertyDefinition( + XmlElementNames.IsResend, FieldUris.IsResend, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsUnmodified property. + */ + public static final PropertyDefinition IsUnmodified = + new BoolPropertyDefinition( + XmlElementNames.IsUnmodified, FieldUris.IsUnmodified, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the InternetMessageHeaders property. + */ + public static final PropertyDefinition InternetMessageHeaders = + new ComplexPropertyDefinition( + InternetMessageHeaderCollection.class, + XmlElementNames.InternetMessageHeaders, + FieldUris.InternetMessageHeaders, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate + () { + public InternetMessageHeaderCollection createComplexProperty() { + return new InternetMessageHeaderCollection(); + } + }); + + /** + * Defines the DateTimeSent property. + */ + public static final PropertyDefinition DateTimeSent = + new DateTimePropertyDefinition( + XmlElementNames.DateTimeSent, FieldUris.DateTimeSent, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the DateTimeCreated property. + */ + public static final PropertyDefinition DateTimeCreated = + new DateTimePropertyDefinition( + XmlElementNames.DateTimeCreated, FieldUris.DateTimeCreated, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the AllowedResponseActions property. + */ + public static final PropertyDefinition AllowedResponseActions = + new ResponseObjectsPropertyDefinition( + XmlElementNames.ResponseObjects, FieldUris.ResponseObjects, + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the ReminderDueBy property. + */ + + public static final PropertyDefinition ReminderDueBy = + new DateTimePropertyDefinition( + XmlElementNames.ReminderDueBy, FieldUris.ReminderDueBy, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsReminderSet property. + */ + public static final PropertyDefinition IsReminderSet = + new BoolPropertyDefinition( + XmlElementNames.ReminderIsSet, // Note: server-side the name is + // ReminderIsSet + FieldUris.ReminderIsSet, EnumSet.of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the ReminderMinutesBeforeStart property. + */ + public static final PropertyDefinition ReminderMinutesBeforeStart = + new IntPropertyDefinition( + XmlElementNames.ReminderMinutesBeforeStart, + FieldUris.ReminderMinutesBeforeStart, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the DisplayCc property. + */ + public static final PropertyDefinition DisplayCc = + new StringPropertyDefinition( + XmlElementNames.DisplayCc, FieldUris.DisplayCc, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the DisplayTo property. + */ + public static final PropertyDefinition DisplayTo = + new StringPropertyDefinition( + XmlElementNames.DisplayTo, FieldUris.DisplayTo, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the HasAttachments property. + */ + public static final PropertyDefinition HasAttachments = + new BoolPropertyDefinition( + XmlElementNames.HasAttachments, FieldUris.HasAttachments, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Culture property. + */ + public static final PropertyDefinition Culture = + new StringPropertyDefinition( + XmlElementNames.Culture, FieldUris.Culture, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the EffectiveRights property. + */ + public static final PropertyDefinition EffectiveRights = + new EffectiveRightsPropertyDefinition( + XmlElementNames.EffectiveRights, FieldUris.EffectiveRights, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the LastModifiedName property. + */ + public static final PropertyDefinition LastModifiedName = + new StringPropertyDefinition( + XmlElementNames.LastModifiedName, FieldUris.LastModifiedName, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the LastModifiedTime property. + */ + public static final PropertyDefinition LastModifiedTime = + new DateTimePropertyDefinition( + XmlElementNames.LastModifiedTime, FieldUris.LastModifiedTime, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the WebClientReadFormQueryString property. + */ + public static final PropertyDefinition WebClientReadFormQueryString = + new StringPropertyDefinition( + XmlElementNames.WebClientReadFormQueryString, + FieldUris.WebClientReadFormQueryString, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010); + + /** + * Defines the WebClientEditFormQueryString property. + */ + public static final PropertyDefinition WebClientEditFormQueryString = + new StringPropertyDefinition( + XmlElementNames.WebClientEditFormQueryString, + FieldUris.WebClientEditFormQueryString, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010); + + /** + * Defines the ConversationId property. + */ + public static final PropertyDefinition ConversationId = + new ComplexPropertyDefinition( + ConversationId.class, + XmlElementNames.ConversationId, FieldUris.ConversationId, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010, + new ICreateComplexPropertyDelegate() { + public ConversationId createComplexProperty() { + return new ConversationId(); + } + }); + + /** + * Defines the UniqueBody property. + */ + public static final PropertyDefinition UniqueBody = + new ComplexPropertyDefinition( + UniqueBody.class, + XmlElementNames.UniqueBody, FieldUris.UniqueBody, EnumSet + .of(PropertyDefinitionFlags.MustBeExplicitlyLoaded), + ExchangeVersion.Exchange2010, + new ICreateComplexPropertyDelegate() { + public UniqueBody createComplexProperty() { + return new UniqueBody(); + } + }); + + /** + * Defines the StoreEntryId property. + */ + + public static final PropertyDefinition StoreEntryId = + new ByteArrayPropertyDefinition( + XmlElementNames.StoreEntryId, + FieldUris.StoreEntryId, + EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2010_SP2); + + + /** + * The Constant Instance. + */ + protected static final ItemSchema Instance = new ItemSchema(); + + /** + * Gets the single instance of ItemSchema. + * + * @return single instance of ItemSchema + */ + public static ItemSchema getInstance() { + return Instance; + } + + /** + * Registers property. + *

+ * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the + * same order as they are defined in types.xsd) + *

+ */ + @Override + protected void registerProperties() { + super.registerProperties(); + this.registerProperty(MimeContent); + this.registerProperty(Id); + this.registerProperty(ParentFolderId); + this.registerProperty(ItemClass); + this.registerProperty(Subject); + this.registerProperty(Sensitivity); + this.registerProperty(Body); + this.registerProperty(Attachments); + this.registerProperty(DateTimeReceived); + this.registerProperty(Size); + this.registerProperty(Categories); + this.registerProperty(Importance); + this.registerProperty(InReplyTo); + this.registerProperty(IsSubmitted); + this.registerProperty(IsDraft); + this.registerProperty(IsFromMe); + this.registerProperty(IsResend); + this.registerProperty(IsUnmodified); + this.registerProperty(InternetMessageHeaders); + this.registerProperty(DateTimeSent); + this.registerProperty(DateTimeCreated); + this.registerProperty(AllowedResponseActions); + this.registerProperty(ReminderDueBy); + this.registerProperty(IsReminderSet); + this.registerProperty(ReminderMinutesBeforeStart); + this.registerProperty(DisplayCc); + this.registerProperty(DisplayTo); + this.registerProperty(HasAttachments); + this.registerProperty(ServiceObjectSchema.extendedProperties); + this.registerProperty(Culture); + this.registerProperty(EffectiveRights); + this.registerProperty(LastModifiedName); + this.registerProperty(LastModifiedTime); + this.registerProperty(IsAssociated); + this.registerProperty(WebClientReadFormQueryString); + this.registerProperty(WebClientEditFormQueryString); + this.registerProperty(ConversationId); + this.registerProperty(UniqueBody); + this.registerProperty(StoreEntryId); + + } + + /** + * Initializes a new instance. + */ + protected ItemSchema() { + super(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/MeetingMessageSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/MeetingMessageSchema.java new file mode 100644 index 000000000..1d9add690 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/MeetingMessageSchema.java @@ -0,0 +1,189 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.Schema; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.MeetingResponseType; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; +import com.eischet.ews.api.property.complex.ItemId; +import com.eischet.ews.api.property.definition.BoolPropertyDefinition; +import com.eischet.ews.api.property.definition.ComplexPropertyDefinition; +import com.eischet.ews.api.property.definition.GenericPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import java.util.EnumSet; + +/** + * Represents the schema for meeting messages. + */ +@Schema +public class MeetingMessageSchema extends EmailMessageSchema { + + /** + * Field URIs for MeetingMessage. + */ + private interface FieldUris { + + /** + * The Associated calendar item id. + */ + String AssociatedCalendarItemId = "meeting:AssociatedCalendarItemId"; + + /** + * The Is delegated. + */ + String IsDelegated = "meeting:IsDelegated"; + + /** + * The Is out of date. + */ + String IsOutOfDate = "meeting:IsOutOfDate"; + + /** + * The Has been processed. + */ + String HasBeenProcessed = "meeting:HasBeenProcessed"; + + /** + * The Response type. + */ + String ResponseType = "meeting:ResponseType"; + } + + + /** + * Defines the AssociatedAppointmentId property. + */ + public static final PropertyDefinition AssociatedAppointmentId = + new ComplexPropertyDefinition( + // ItemId.class, + XmlElementNames.AssociatedCalendarItemId, + FieldUris.AssociatedCalendarItemId, + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public ItemId createComplexProperty() { + return new ItemId(); + } + }); + + /** + * Defines the IsDelegated property. + */ + public static final PropertyDefinition IsDelegated = + new BoolPropertyDefinition( + XmlElementNames.IsDelegated, FieldUris.IsDelegated, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsOutOfDate property. + */ + public static final PropertyDefinition IsOutOfDate = + new BoolPropertyDefinition( + XmlElementNames.IsOutOfDate, FieldUris.IsOutOfDate, + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the HasBeenProcessed property. + */ + public static final PropertyDefinition HasBeenProcessed = + new BoolPropertyDefinition( + XmlElementNames.HasBeenProcessed, FieldUris.HasBeenProcessed, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the ResponseType property. + */ + public static final PropertyDefinition ResponseType = + new GenericPropertyDefinition( + MeetingResponseType.class, + XmlElementNames.ResponseType, FieldUris.ResponseType, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the ICalendar Uid property. + */ + public static final PropertyDefinition ICalUid = AppointmentSchema.ICalUid; + + /** + * Defines the ICalendar RecurrenceId property. + */ + public static final PropertyDefinition ICalRecurrenceId = + AppointmentSchema.ICalRecurrenceId; + + /** + * Defines the ICalendar DateTimeStamp property. + */ + public static final PropertyDefinition ICalDateTimeStamp = + AppointmentSchema.ICalDateTimeStamp; + + /** + * This must be after the declaration of property definitions. + */ + protected static final MeetingMessageSchema Instance = + new MeetingMessageSchema(); + + /** + * Gets the single instance of MeetingMessageSchema. + * + * @return single instance of MeetingMessageSchema + */ + public static MeetingMessageSchema getInstance() { + return Instance; + } + + /** + * Registers property. + *

+ * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the + * same order as they are defined in types.xsd) + */ + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(AssociatedAppointmentId); + this.registerProperty(IsDelegated); + this.registerProperty(IsOutOfDate); + this.registerProperty(HasBeenProcessed); + this.registerProperty(ResponseType); + this.registerProperty(ICalUid); + this.registerProperty(ICalRecurrenceId); + this.registerProperty(ICalDateTimeStamp); + } + + /** + * Initializes a new instance of the class. + */ + protected MeetingMessageSchema() { + super(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/MeetingRequestSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/MeetingRequestSchema.java new file mode 100644 index 000000000..c0d8559c5 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/MeetingRequestSchema.java @@ -0,0 +1,376 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.Schema; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.LegacyFreeBusyStatus; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.enumeration.service.MeetingRequestType; +import com.eischet.ews.api.property.definition.GenericPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import java.util.EnumSet; + +/** + * Represents the schema for meeting request. + */ +@Schema +public class MeetingRequestSchema extends MeetingMessageSchema { + + /** + * Field URIs for MeetingRequest. + */ + private interface FieldUris { + + /** + * The Meeting request type. + */ + String MeetingRequestType = "meetingRequest:MeetingRequestType"; + + /** + * The Intended free busy status. + */ + String IntendedFreeBusyStatus = "meetingRequest:IntendedFreeBusyStatus"; + } + + + /** + * Defines the MeetingRequestType property. + */ + public static final PropertyDefinition MeetingRequestType = + new GenericPropertyDefinition( + MeetingRequestType.class, + XmlElementNames.MeetingRequestType, FieldUris.MeetingRequestType, + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IntendedFreeBusyStatus property. + */ + public static final PropertyDefinition IntendedFreeBusyStatus = + new GenericPropertyDefinition( + LegacyFreeBusyStatus.class, + XmlElementNames.IntendedFreeBusyStatus, + FieldUris.IntendedFreeBusyStatus, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Start property. + */ + public static final PropertyDefinition Start = AppointmentSchema.Start; + + /** + * Defines the End property. + */ + public static final PropertyDefinition End = AppointmentSchema.End; + + /** + * Defines the OriginalStart property. + */ + public static final PropertyDefinition OriginalStart = + AppointmentSchema.OriginalStart; + + /** + * Defines the IsAllDayEvent property. + */ + public static final PropertyDefinition IsAllDayEvent = + AppointmentSchema.IsAllDayEvent; + + /** + * Defines the LegacyFreeBusyStatus property. + */ + public static final PropertyDefinition LegacyFreeBusyStatus = + AppointmentSchema.LegacyFreeBusyStatus; + + /** + * Defines the Location property. + */ + public static final PropertyDefinition Location = + AppointmentSchema.Location; + + /** + * Defines the When property. + */ + public static final PropertyDefinition When = AppointmentSchema.When; + + /** + * Defines the IsMeeting property. + */ + public static final PropertyDefinition IsMeeting = + AppointmentSchema.IsMeeting; + + /** + * Defines the IsCancelled property. + */ + public static final PropertyDefinition IsCancelled = + AppointmentSchema.IsCancelled; + + /** + * Defines the IsRecurring property. + */ + public static final PropertyDefinition IsRecurring = + AppointmentSchema.IsRecurring; + + /** + * Defines the MeetingRequestWasSent property. + */ + public static final PropertyDefinition MeetingRequestWasSent = + AppointmentSchema.MeetingRequestWasSent; + + /** + * Defines the AppointmentType property. + */ + public static final PropertyDefinition AppointmentType = + AppointmentSchema.AppointmentType; + + /** + * Defines the MyResponseType property. + */ + public static final PropertyDefinition MyResponseType = + AppointmentSchema.MyResponseType; + + /** + * Defines the Organizer property. + */ + public static final PropertyDefinition Organizer = + AppointmentSchema.Organizer; + + /** + * Defines the RequiredAttendees property. + */ + public static final PropertyDefinition RequiredAttendees = + AppointmentSchema.RequiredAttendees; + + /** + * Defines the OptionalAttendees property. + */ + public static final PropertyDefinition OptionalAttendees = + AppointmentSchema.OptionalAttendees; + + /** + * Defines the Resources property. + */ + public static final PropertyDefinition Resources = + AppointmentSchema.Resources; + + /** + * Defines the ConflictingMeetingCount property. + */ + public static final PropertyDefinition ConflictingMeetingCount = + AppointmentSchema.ConflictingMeetingCount; + + /** + * Defines the AdjacentMeetingCount property. + */ + public static final PropertyDefinition AdjacentMeetingCount = + AppointmentSchema.AdjacentMeetingCount; + + /** + * Defines the ConflictingMeetings property. + */ + public static final PropertyDefinition ConflictingMeetings = + AppointmentSchema.ConflictingMeetings; + + /** + * Defines the AdjacentMeetings property. + */ + public static final PropertyDefinition AdjacentMeetings = + AppointmentSchema.AdjacentMeetings; + + /** + * Defines the Duration property. + */ + public static final PropertyDefinition Duration = + AppointmentSchema.Duration; + + /** + * Defines the TimeZone property. + */ + public static final PropertyDefinition TimeZone = + AppointmentSchema.TimeZone; + + /** + * Defines the AppointmentReplyTime property. + */ + public static final PropertyDefinition AppointmentReplyTime = + AppointmentSchema.AppointmentReplyTime; + + /** + * Defines the AppointmentSequenceNumber property. + */ + public static final PropertyDefinition AppointmentSequenceNumber = + AppointmentSchema.AppointmentSequenceNumber; + + /** + * Defines the AppointmentState property. + */ + public static final PropertyDefinition AppointmentState = + AppointmentSchema.AppointmentState; + + /** + * Defines the Recurrence property. + */ + public static final PropertyDefinition Recurrence = + AppointmentSchema.Recurrence; + + /** + * Defines the FirstOccurrence property. + */ + public static final PropertyDefinition FirstOccurrence = + AppointmentSchema.FirstOccurrence; + /** + * Defines the LastOccurrence property. + */ + public static final PropertyDefinition LastOccurrence = + AppointmentSchema.LastOccurrence; + + /** + * Defines the ModifiedOccurrences property. + */ + public static final PropertyDefinition ModifiedOccurrences = + AppointmentSchema.ModifiedOccurrences; + + /** + * Defines the Duration property. + */ + public static final PropertyDefinition DeletedOccurrences = + AppointmentSchema.DeletedOccurrences; + + /** + * Defines the MeetingTimeZone property. + */ + static final PropertyDefinition MeetingTimeZone = + AppointmentSchema.MeetingTimeZone; + + /** + * Defines the StartTimeZone property. + */ + public static final PropertyDefinition StartTimeZone = + AppointmentSchema.StartTimeZone; + + /** + * Defines the EndTimeZone property. + */ + public static final PropertyDefinition EndTimeZone = + AppointmentSchema.EndTimeZone; + + /** + * Defines the ConferenceType property. + */ + public static final PropertyDefinition ConferenceType = + AppointmentSchema.ConferenceType; + + /** + * Defines the AllowNewTimeProposal property. + */ + public static final PropertyDefinition AllowNewTimeProposal = + AppointmentSchema.AllowNewTimeProposal; + + /** + * Defines the IsOnlineMeeting property. + */ + public static final PropertyDefinition IsOnlineMeeting = + AppointmentSchema.IsOnlineMeeting; + + /** + * Defines the MeetingWorkspaceUrl property. + */ + public static final PropertyDefinition MeetingWorkspaceUrl = + AppointmentSchema.MeetingWorkspaceUrl; + + /** + * Defines the NetShowUrl property. + */ + public static final PropertyDefinition NetShowUrl = + AppointmentSchema.NetShowUrl; + + /** + * This must be after the declaration of property definitions. + */ + public static final MeetingRequestSchema Instance = + new MeetingRequestSchema(); + + /** + * Registers property. + *

+ * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the + * same order as they are defined in types.xsd) + */ + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(MeetingRequestType); + this.registerProperty(IntendedFreeBusyStatus); + + this.registerProperty(Start); + this.registerProperty(End); + this.registerProperty(OriginalStart); + this.registerProperty(IsAllDayEvent); + this.registerProperty(LegacyFreeBusyStatus); + this.registerProperty(Location); + this.registerProperty(When); + this.registerProperty(IsMeeting); + this.registerProperty(IsCancelled); + this.registerProperty(IsRecurring); + this.registerProperty(MeetingRequestWasSent); + this.registerProperty(AppointmentType); + this.registerProperty(MyResponseType); + this.registerProperty(Organizer); + this.registerProperty(RequiredAttendees); + this.registerProperty(OptionalAttendees); + this.registerProperty(Resources); + this.registerProperty(ConflictingMeetingCount); + this.registerProperty(AdjacentMeetingCount); + this.registerProperty(ConflictingMeetings); + this.registerProperty(AdjacentMeetings); + this.registerProperty(Duration); + this.registerProperty(TimeZone); + this.registerProperty(AppointmentReplyTime); + this.registerProperty(AppointmentSequenceNumber); + this.registerProperty(AppointmentState); + this.registerProperty(Recurrence); + this.registerProperty(FirstOccurrence); + this.registerProperty(LastOccurrence); + this.registerProperty(ModifiedOccurrences); + this.registerProperty(DeletedOccurrences); + this.registerInternalProperty(MeetingTimeZone); + this.registerProperty(StartTimeZone); + this.registerProperty(EndTimeZone); + this.registerProperty(ConferenceType); + this.registerProperty(AllowNewTimeProposal); + this.registerProperty(IsOnlineMeeting); + this.registerProperty(MeetingWorkspaceUrl); + this.registerProperty(NetShowUrl); + } + + /** + * Initializes a new instance of the class. + */ + protected MeetingRequestSchema() { + super(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/PostItemSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/PostItemSchema.java new file mode 100644 index 000000000..a8049c648 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/PostItemSchema.java @@ -0,0 +1,133 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.Schema; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.property.definition.DateTimePropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import java.util.EnumSet; + +/** + * Represents the schema for post item. + */ +@Schema +public final class PostItemSchema extends ItemSchema { + + /** + * Field URIs for PostItem. + */ + private interface FieldUris { + + /** + * The Posted time. + */ + String PostedTime = "postitem:PostedTime"; + } + + + /** + * Defines the ConversationIndex property. + */ + public static final PropertyDefinition ConversationIndex = + EmailMessageSchema.ConversationIndex; + + /** + * Defines the ConversationTopic property. + */ + public static final PropertyDefinition ConversationTopic = + EmailMessageSchema.ConversationTopic; + + /** + * Defines the From property. + */ + public static final PropertyDefinition From = EmailMessageSchema.From; + + /** + * Defines the InternetMessageId property. + */ + public static final PropertyDefinition InternetMessageId = + EmailMessageSchema.InternetMessageId; + + /** + * Defines the IsRead property. + */ + public static final PropertyDefinition IsRead = EmailMessageSchema.IsRead; + + /** + * Defines the PostedTime property. + */ + public static final PropertyDefinition PostedTime = + new DateTimePropertyDefinition( + XmlElementNames.PostedTime, FieldUris.PostedTime, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the References property. + */ + public static final PropertyDefinition References = + EmailMessageSchema.References; + + /** + * Defines the Sender property. + */ + public static final PropertyDefinition Sender = EmailMessageSchema.Sender; + + // This must be after the declaration of property definitions + /** + * The Constant Instance. + */ + public static final PostItemSchema Instance = new PostItemSchema(); + + /** + * Registers property. + *

+ * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the + * same order as they are defined in types.xsd) + */ + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(ConversationIndex); + this.registerProperty(ConversationTopic); + this.registerProperty(From); + this.registerProperty(InternetMessageId); + this.registerProperty(IsRead); + this.registerProperty(PostedTime); + this.registerProperty(References); + this.registerProperty(Sender); + } + + /** + * Initializes a new instance of the PostItemSchema class. + */ + protected PostItemSchema() { + super(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/PostReplySchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/PostReplySchema.java new file mode 100644 index 000000000..5496c0709 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/PostReplySchema.java @@ -0,0 +1,52 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +/** + * Represents PostReply schema definition. + */ +public final class PostReplySchema extends ServiceObjectSchema { + + // This must be declared after the property definitions + /** + * The Constant Instance. + */ + public static final PostReplySchema Instance = new PostReplySchema(); + + /** + * Registers property. + *

+ * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the + * same order as they are defined in types.xsd) + */ + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(ItemSchema.Subject); + this.registerProperty(ItemSchema.Body); + this.registerProperty(ResponseObjectSchema.ReferenceItemId); + this.registerProperty(ResponseObjectSchema.BodyPrefix); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ResponseMessageSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ResponseMessageSchema.java new file mode 100644 index 000000000..a2a5cac58 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ResponseMessageSchema.java @@ -0,0 +1,54 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +/** + * Represents ResponseMessage schema definition. + */ +public class ResponseMessageSchema extends ServiceObjectSchema { + + /** + * This must be declared after the property definitions. + */ + public static final ResponseMessageSchema Instance = new ResponseMessageSchema(); + + /** + * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN + * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd) + */ + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(ItemSchema.Subject); + this.registerProperty(ItemSchema.Body); + this.registerProperty(EmailMessageSchema.ToRecipients); + this.registerProperty(EmailMessageSchema.CcRecipients); + this.registerProperty(EmailMessageSchema.BccRecipients); + this.registerProperty(EmailMessageSchema.IsReadReceiptRequested); + this.registerProperty(EmailMessageSchema.IsDeliveryReceiptRequested); + this.registerProperty(ResponseObjectSchema.ReferenceItemId); + this.registerProperty(ResponseObjectSchema.BodyPrefix); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ResponseObjectSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ResponseObjectSchema.java new file mode 100644 index 000000000..50d3f20e7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ResponseObjectSchema.java @@ -0,0 +1,89 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; +import com.eischet.ews.api.property.complex.ItemId; +import com.eischet.ews.api.property.complex.MessageBody; +import com.eischet.ews.api.property.definition.ComplexPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import java.util.EnumSet; + +/** + * Represents ResponseObject schema definition. + */ +public class ResponseObjectSchema extends ServiceObjectSchema { + + /** + * The Reference item id. + */ + public static final PropertyDefinition ReferenceItemId = + new ComplexPropertyDefinition( + ItemId.class, + XmlElementNames.ReferenceItemId, EnumSet.of( + PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public ItemId createComplexProperty() { + return new ItemId(); + } + }); + + /** + * The Body prefix. + */ + public static final PropertyDefinition BodyPrefix = + new ComplexPropertyDefinition( + MessageBody.class, + XmlElementNames.NewBodyContent, EnumSet + .of(PropertyDefinitionFlags.CanSet), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public MessageBody createComplexProperty() { + return new MessageBody(); + } + }); + + /** + * This must be declared after the property definitions. + */ + public static final ResponseObjectSchema Instance = + new ResponseObjectSchema(); + + /** + * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN + * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd) + */ + @Override + protected void registerProperties() { + super.registerProperties(); + this.registerProperty(ResponseObjectSchema.ReferenceItemId); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/SearchFolderSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/SearchFolderSchema.java new file mode 100644 index 000000000..90fb4e65c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/SearchFolderSchema.java @@ -0,0 +1,91 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.Schema; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; +import com.eischet.ews.api.property.complex.SearchFolderParameters; +import com.eischet.ews.api.property.definition.ComplexPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import java.util.EnumSet; + +/** + * The Class SearchFolderSchema. + */ +@Schema +public class SearchFolderSchema extends FolderSchema { + + /** + * Field URIs for search folder. + */ + private interface FieldUris { + + /** + * The Search parameters. + */ + String SearchParameters = "folder:SearchParameters"; + } + + + /** + * Defines the SearchParameters property. + */ + public static final PropertyDefinition SearchParameters = + new ComplexPropertyDefinition( + SearchFolderParameters.class, + XmlElementNames.SearchParameters, + FieldUris.SearchParameters, + EnumSet.of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.AutoInstantiateOnRead), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + @Override + public SearchFolderParameters createComplexProperty() { + return new SearchFolderParameters(); + } + }); + + // This must be declared after the property definitions + /** + * The Constant Instance. + */ + public static final SearchFolderSchema Instance = new SearchFolderSchema(); + + /** + * Registers property. + */ + // IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the + // same order as they are defined in types.xsd) + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(SearchParameters); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ServiceObjectSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ServiceObjectSchema.java new file mode 100644 index 000000000..1f42225bd --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/ServiceObjectSchema.java @@ -0,0 +1,432 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ILazyMember; +import com.eischet.ews.api.core.LazyMember; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.complex.ExtendedPropertyCollection; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; +import com.eischet.ews.api.property.definition.ComplexPropertyDefinition; +import com.eischet.ews.api.property.definition.IndexedPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinitionBase; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents the base class for all item and folder schema. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class ServiceObjectSchema implements + Iterable { + + private static final Logger LOG = Logger.getLogger(ServiceObjectSchema.class.getCanonicalName()); + + /** + * The lock object. + */ + private static final Object lockObject = new Object(); + + /** + * List of all schema types. If you add a new ServiceObject subclass that + * has an associated schema, add the schema type to the list below. + */ + private static final LazyMember>> allSchemaTypes = new + LazyMember>>(new + ILazyMember>>() { + public List> createInstance() { + List> typeList = new ArrayList>(); + // typeList.add() + /* + * typeList.add(AppointmentSchema.class); + * typeList.add(CalendarResponseObjectSchema.class); + * typeList.add(CancelMeetingMessageSchema.class); + * typeList.add(ContactGroupSchema.class); + * typeList.add(ContactSchema.class); + * typeList.add(EmailMessageSchema.class); + * typeList.add(FolderSchema.class); + * typeList.add(ItemSchema.class); + * typeList.add(MeetingMessageSchema.class); + * typeList.add(MeetingRequestSchema.class); + * typeList.add(PostItemSchema.class); + * typeList.add(PostReplySchema.class); + * typeList.add(ResponseMessageSchema.class); + * typeList.add(ResponseObjectSchema.class); + * typeList.add(ServiceObjectSchema.class); + * typeList.add(SearchFolderSchema.class); + * typeList.add(TaskSchema.class); + */ + // Verify that all Schema types in the Managed API assembly + // have been included. + /* + * var missingTypes = from type in + * Assembly.GetExecutingAssembly().GetTypes() where + * type.IsSubclassOf(typeof(ServiceObjectSchema)) && + * !typeList.Contains(type) select type; if + * (missingTypes.Count() > 0) { throw new + * ServiceLocalException + * ("SchemaTypeList does not include all + * defined schema types." + * ); } + */ + return typeList; + } + }); + + /** + * Dictionary of all property definitions. + */ + private static final LazyMember> + allSchemaProperties = new + LazyMember>( + new ILazyMember>() { + public Map createInstance() { + Map propDefDictionary = + new HashMap(); + for (Class c : ServiceObjectSchema.allSchemaTypes + .getMember()) { + ServiceObjectSchema.addSchemaPropertiesToDictionary(c, + propDefDictionary); + } + return propDefDictionary; + } + }); + + /** + * Adds schema property to dictionary. + * + * @param type Schema type. + * @param propDefDictionary The property definition dictionary. + */ + protected static void addSchemaPropertiesToDictionary(Class type, + Map propDefDictionary) { + Field[] fields = type.getDeclaredFields(); + for (Field field : fields) { + int modifier = field.getModifiers(); + if (Modifier.isPublic(modifier) && Modifier.isStatic(modifier)) { + Object o; + try { + o = field.get(null); + if (o instanceof PropertyDefinition) { + PropertyDefinition propertyDefinition = + (PropertyDefinition) o; + // Some property definitions descend from + // ServiceObjectPropertyDefinition but don't have + // a Uri, like ExtendedProperties. Ignore them. + if (null != propertyDefinition.getUri() && + !propertyDefinition.getUri().isEmpty()) { + PropertyDefinitionBase existingPropertyDefinition; + if (propDefDictionary + .containsKey(propertyDefinition.getUri())) { + existingPropertyDefinition = propDefDictionary + .get(propertyDefinition.getUri()); + EwsUtilities + .ewsAssert(existingPropertyDefinition == propertyDefinition, + "Schema.allSchemaProperties." + "delegate", + String.format("There are at least " + + "two distinct property " + + "definitions with the" + + " following URI: %s", propertyDefinition.getUri())); + } else { + propDefDictionary.put(propertyDefinition + .getUri(), propertyDefinition); + // The following is a "generic hack" to register + // property that are not public and + // thus not returned by the above GetFields + // call. It is currently solely used to register + // the MeetingTimeZone property. + List associatedInternalProperties = + propertyDefinition.getAssociatedInternalProperties(); + for (PropertyDefinition associatedInternalProperty : associatedInternalProperties) { + propDefDictionary + .put(associatedInternalProperty + .getUri(), + associatedInternalProperty); + } + + } + } + } + } catch (IllegalArgumentException e) { + LOG.log(Level.SEVERE, "error adding schema properties", e); + + // Skip the field + } catch (IllegalAccessException e) { + LOG.log(Level.SEVERE, "error adding schema properties", e); + + // Skip the field + } + + } + } + } + + /** + * Adds the schema property names to dictionary. + * + * @param type The type. + * @param propertyNameDictionary The property name dictionary. + */ + protected static void addSchemaPropertyNamesToDictionary(Class type, + Map propertyNameDictionary) { + + Field[] fields = type.getDeclaredFields(); + for (Field field : fields) { + int modifier = field.getModifiers(); + if (Modifier.isPublic(modifier) && Modifier.isStatic(modifier)) { + Object o; + try { + o = field.get(null); + if (o instanceof PropertyDefinition) { + PropertyDefinition propertyDefinition = + (PropertyDefinition) o; + propertyNameDictionary.put(propertyDefinition, field + .getName()); + } + } catch (IllegalArgumentException e) { + LOG.log(Level.SEVERE, "error adding schema properties", e); + + // Skip the field + } catch (IllegalAccessException e) { + LOG.log(Level.SEVERE, "error adding schema properties", e); + + // Skip the field + } + } + } + } + + /** + * Initializes a new instance. + */ + protected ServiceObjectSchema() { + this.registerProperties(); + } + + /** + * Finds the property definition. + * + * @param uri The URI. + * @return Property definition. + */ + public static PropertyDefinitionBase findPropertyDefinition(String uri) { + return ServiceObjectSchema.allSchemaProperties.getMember().get(uri); + } + + /** + * Initialize schema property names. + */ + public static void initializeSchemaPropertyNames() { + synchronized (lockObject) { + for (Class type : ServiceObjectSchema.allSchemaTypes.getMember()) { + Field[] fields = type.getDeclaredFields(); + for (Field field : fields) { + int modifier = field.getModifiers(); + if (Modifier.isPublic(modifier) && + Modifier.isStatic(modifier)) { + Object o; + try { + o = field.get(null); + if (o instanceof PropertyDefinition) { + PropertyDefinition propertyDefinition = + (PropertyDefinition) o; + propertyDefinition.setName(field.getName()); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + LOG.log(Level.SEVERE, "error initializing schema properties", e); + + // Skip the field + } + } + } + } + } + } + + /** + * Defines the ExtendedProperties property. + */ + public static final PropertyDefinition extendedProperties = + new ComplexPropertyDefinition( + ExtendedPropertyCollection.class, + XmlElementNames.ExtendedProperty, + EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.ReuseInstance, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public ExtendedPropertyCollection createComplexProperty() { + return new ExtendedPropertyCollection(); + } + }); + + /** + * The property. + */ + private final Map properties = + new HashMap(); + + /** + * The visible property. + */ + private final List visibleProperties = + new ArrayList(); + + /** + * The first class property. + */ + private final List firstClassProperties = + new ArrayList(); + + /** + * The first class summary property. + */ + private final List firstClassSummaryProperties = + new ArrayList(); + + private final List indexedProperties = + new ArrayList(); + + /** + * Registers a schema property. + * + * @param property The property to register. + * @param isInternal Indicates whether the property is internal or should be + * visible to developers. + */ + private void registerProperty(PropertyDefinition property, + boolean isInternal) { + this.properties.put(property.getXmlElement(), property); + + if (!isInternal) { + this.visibleProperties.add(property); + } + + // If this property does not have to be requested explicitly, add + // it to the list of firstClassProperties. + if (!property.hasFlag(PropertyDefinitionFlags.MustBeExplicitlyLoaded)) { + this.firstClassProperties.add(property); + } + + // If this property can be found, add it to the list of + // firstClassSummaryProperties + if (property.hasFlag(PropertyDefinitionFlags.CanFind)) { + this.firstClassSummaryProperties.add(property); + } + } + + /** + * Registers a schema property that will be visible to developers. + * + * @param property The property to register. + */ + protected void registerProperty(PropertyDefinition property) { + this.registerProperty(property, false); + } + + /** + * Registers an internal schema property. + * + * @param property The property to register. + */ + protected void registerInternalProperty(PropertyDefinition property) { + this.registerProperty(property, true); + } + + /** + * Registers an indexed property. + * + * @param indexedProperty The indexed property to register. + */ + protected void registerIndexedProperty(IndexedPropertyDefinition + indexedProperty) { + this.indexedProperties.add(indexedProperty); + } + + + /** + * Registers property. + */ + protected void registerProperties() { + } + + /** + * Gets the list of first class property for this service object type. + * + * @return the first class property + */ + public List getFirstClassProperties() { + return this.firstClassProperties; + } + + /** + * Gets the list of first class summary property for this service object + * type. + * + * @return the first class summary property + */ + public List getFirstClassSummaryProperties() { + return this.firstClassSummaryProperties; + } + + /** + * Tries to get property definition. + * + * @param xmlElementName Name of the XML element. + * @param propertyDefinitionOutParam The property definition. + * @return True if property definition exists. + */ + public boolean tryGetPropertyDefinition(String xmlElementName, + OutParam propertyDefinitionOutParam) { + if (this.properties.containsKey(xmlElementName)) { + propertyDefinitionOutParam.setParam(this.properties + .get(xmlElementName)); + return true; + } else { + return false; + } + } + + /** + * Returns an iterator over a set of elements of type T. + * + * @return an Iterator. + */ + @Override + public Iterator iterator() { + return this.visibleProperties.iterator(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/TaskSchema.java b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/TaskSchema.java new file mode 100644 index 000000000..30d5ea2ec --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/core/service/schema/TaskSchema.java @@ -0,0 +1,455 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core.service.schema; + +import com.eischet.ews.api.attribute.Schema; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.enumeration.service.TaskMode; +import com.eischet.ews.api.core.enumeration.service.TaskStatus; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; +import com.eischet.ews.api.property.complex.StringList; +import com.eischet.ews.api.property.definition.*; + +import java.util.EnumSet; + +/** + * Represents the schema for task item. + */ +@Schema +public class TaskSchema extends ItemSchema { + + /** + * Field URIs for tasks. + */ + private static class FieldUris { + + /** + * The Constant ActualWork. + */ + public final static String ActualWork = "task:ActualWork"; + + /** + * The Constant AssignedTime. + */ + public final static String AssignedTime = "task:AssignedTime"; + + /** + * The Constant BillingInformation. + */ + public final static String BillingInformation = + "task:BillingInformation"; + + /** + * The Constant ChangeCount. + */ + public final static String ChangeCount = "task:ChangeCount"; + + /** + * The Constant Companies. + */ + public final static String Companies = "task:Companies"; + + /** + * The Constant CompleteDate. + */ + public final static String CompleteDate = "task:CompleteDate"; + + /** + * The Constant Contacts. + */ + public final static String Contacts = "task:Contacts"; + + /** + * The Constant DelegationState. + */ + public final static String DelegationState = "task:DelegationState"; + + /** + * The Constant Delegator. + */ + public final static String Delegator = "task:Delegator"; + + /** + * The Constant DueDate. + */ + public final static String DueDate = "task:DueDate"; + + /** + * The Constant IsAssignmentEditable. + */ + public final static String IsAssignmentEditable = + "task:IsAssignmentEditable"; + + /** + * The Constant IsComplete. + */ + public final static String IsComplete = "task:IsComplete"; + + /** + * The Constant IsRecurring. + */ + public final static String IsRecurring = "task:IsRecurring"; + + /** + * The Constant IsTeamTask. + */ + public final static String IsTeamTask = "task:IsTeamTask"; + + /** + * The Constant Mileage. + */ + public final static String Mileage = "task:Mileage"; + + /** + * The Constant Owner. + */ + public final static String Owner = "task:Owner"; + + /** + * The Constant PercentComplete. + */ + public final static String PercentComplete = "task:PercentComplete"; + + /** + * The Constant Recurrence. + */ + public final static String Recurrence = "task:Recurrence"; + + /** + * The Constant StartDate. + */ + public final static String StartDate = "task:StartDate"; + + /** + * The Constant Status. + */ + public final static String Status = "task:Status"; + + /** + * The Constant StatusDescription. + */ + public final static String StatusDescription = "task:StatusDescription"; + + /** + * The Constant TotalWork. + */ + public final static String TotalWork = "task:TotalWork"; + } + + + /** + * Defines the ActualWork property. + */ + public static final PropertyDefinition ActualWork = + new IntPropertyDefinition( + XmlElementNames.ActualWork, FieldUris.ActualWork, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + + true); // isNullable + + /** + * Defines the AssignedTime property. + */ + public static final PropertyDefinition AssignedTime = + new DateTimePropertyDefinition( + XmlElementNames.AssignedTime, FieldUris.AssignedTime, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, true); + + /** + * Defines the BillingInformation property. + */ + public static final PropertyDefinition BillingInformation = + new StringPropertyDefinition( + XmlElementNames.BillingInformation, FieldUris.BillingInformation, + EnumSet.of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the ChangeCount property. + */ + public static final PropertyDefinition ChangeCount = + new IntPropertyDefinition( + XmlElementNames.ChangeCount, FieldUris.ChangeCount, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Companies property. + */ + public static final PropertyDefinition Companies = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.Companies, FieldUris.Companies, EnumSet.of( + PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(); + } + }); + + /** + * Defines the CompleteDate property. + */ + public static final PropertyDefinition CompleteDate = + new DateTimePropertyDefinition( + XmlElementNames.CompleteDate, FieldUris.CompleteDate, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, true); // isNullable + + /** + * Defines the Contacts property. + */ + public static final PropertyDefinition Contacts = + new ComplexPropertyDefinition( + StringList.class, + XmlElementNames.Contacts, FieldUris.Contacts, EnumSet.of( + PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public StringList createComplexProperty() { + return new StringList(); + } + }); + + /** + * Defines the DelegationState property. + */ + public static final PropertyDefinition DelegationState = + new TaskDelegationStatePropertyDefinition( + XmlElementNames.DelegationState, FieldUris.DelegationState, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Delegator property. + */ + public static final PropertyDefinition Delegator = + new StringPropertyDefinition( + XmlElementNames.Delegator, FieldUris.Delegator, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the DueDate property. + */ + public static final PropertyDefinition DueDate = + new DateTimePropertyDefinition( + XmlElementNames.DueDate, FieldUris.DueDate, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, true); // isNullable + + /** + * Defines the Mode property. + */ + public static final PropertyDefinition Mode = + new GenericPropertyDefinition( + TaskMode.class, + XmlElementNames.IsAssignmentEditable, + FieldUris.IsAssignmentEditable, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsComplete property. + */ + public static final PropertyDefinition IsComplete = + new BoolPropertyDefinition( + XmlElementNames.IsComplete, FieldUris.IsComplete, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsRecurring property. + */ + public static final PropertyDefinition IsRecurring = + new BoolPropertyDefinition( + XmlElementNames.IsRecurring, FieldUris.IsRecurring, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the IsTeamTask property. + */ + public static final PropertyDefinition IsTeamTask = + new BoolPropertyDefinition( + XmlElementNames.IsTeamTask, FieldUris.IsTeamTask, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Mileage property. + */ + public static final PropertyDefinition Mileage = + new StringPropertyDefinition( + XmlElementNames.Mileage, FieldUris.Mileage, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Owner property. + */ + public static final PropertyDefinition Owner = new StringPropertyDefinition( + XmlElementNames.Owner, FieldUris.Owner, EnumSet + .of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the PercentComplete property. + */ + public static final PropertyDefinition PercentComplete = + new DoublePropertyDefinition( + XmlElementNames.PercentComplete, FieldUris.PercentComplete, EnumSet + .of(PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the Recurrence property. + */ + public static final PropertyDefinition Recurrence = + new RecurrencePropertyDefinition( + XmlElementNames.Recurrence, FieldUris.Recurrence, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the StartDate property. + */ + public static final PropertyDefinition StartDate = + new DateTimePropertyDefinition( + XmlElementNames.StartDate, FieldUris.StartDate, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, true); // isNullable + + /** + * Defines the Status property. + */ + public static final PropertyDefinition Status = + new GenericPropertyDefinition( + TaskStatus.class, + XmlElementNames.Status, FieldUris.Status, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the StatusDescription property. + */ + public static final PropertyDefinition StatusDescription = + new StringPropertyDefinition( + XmlElementNames.StatusDescription, FieldUris.StatusDescription, + EnumSet.of(PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1); + + /** + * Defines the TotalWork property. + */ + public static final PropertyDefinition TotalWork = + new IntPropertyDefinition( + XmlElementNames.TotalWork, FieldUris.TotalWork, EnumSet.of( + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.CanUpdate, + PropertyDefinitionFlags.CanDelete, + PropertyDefinitionFlags.CanFind), + ExchangeVersion.Exchange2007_SP1, true); // isNullable + + /** + * This must be declared after the property definitions. + */ + public static final TaskSchema Instance = new TaskSchema(); + + /** + * This must be declared after the property definitions. + */ + @Override + protected void registerProperties() { + super.registerProperties(); + + this.registerProperty(ActualWork); + this.registerProperty(AssignedTime); + this.registerProperty(BillingInformation); + this.registerProperty(ChangeCount); + this.registerProperty(Companies); + this.registerProperty(CompleteDate); + this.registerProperty(Contacts); + this.registerProperty(DelegationState); + this.registerProperty(Delegator); + this.registerProperty(DueDate); + this.registerProperty(Mode); + this.registerProperty(IsComplete); + this.registerProperty(IsRecurring); + this.registerProperty(IsTeamTask); + this.registerProperty(Mileage); + this.registerProperty(Owner); + this.registerProperty(PercentComplete); + this.registerProperty(Recurrence); + this.registerProperty(StartDate); + this.registerProperty(Status); + this.registerProperty(StatusDescription); + this.registerProperty(TotalWork); + } + + /** + * Initializes a new instance of the class. + */ + TaskSchema() { + super(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/credential/ExchangeCredentials.java b/ews-api/src/main/java/com/eischet/ews/api/credential/ExchangeCredentials.java new file mode 100644 index 000000000..8f71456cf --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/credential/ExchangeCredentials.java @@ -0,0 +1,158 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.credential; + +import com.eischet.ews.api.core.exception.misc.InvalidOperationException; +import com.eischet.ews.api.http.ExchangeHttpClient; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import java.io.ByteArrayOutputStream; +import java.net.URI; +import java.net.URISyntaxException; + +/** + * Base class of Exchange credential types. + */ +public abstract class ExchangeCredentials { + + /** + * Performs an implicit conversion from to . This + * allows a NetworkCredential object to be implictly converted to an + * ExchangeCredential which is useful when setting credential on an + * ExchangeService. + * + * @param userName Account user name. + * @param password Account password. + * @param domain Account domain. + * @return The result of the conversion. + */ + public static ExchangeCredentials + getExchangeCredentialsFromNetworkCredential( + String userName, String password, String domain) { + return new WebCredentials(userName, password, domain); + } + + + /** + * Return the url without ws-security address. + * + * @param url The url + * @return The absolute uri base. + */ + protected static String getUriWithoutWSSecurity(URI url) { + String absoluteUri = url.toString(); + int index = absoluteUri.indexOf("/wssecurity"); + + if (index == -1) { + return absoluteUri; + } else { + return absoluteUri.substring(0, index); + } + } + + /** + * This method is called to pre-authenticate credential before a service + * request is made. + */ + public void preAuthenticate() { + // do nothing by default. + } + + /** + * This method is called to apply credential to a service request before + * the request is made. + * + * @param client The request. + * @throws java.net.URISyntaxException the uRI syntax exception + */ + public void prepareWebRequest(ExchangeHttpClient.Request client) throws URISyntaxException { + // do nothing by default. + } + + /** + * Emit any extra necessary namespace aliases for the SOAP:header block. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + */ + public void emitExtraSoapHeaderNamespaceAliases(XMLStreamWriter writer) + throws XMLStreamException { + // do nothing by default. + } + + /** + * Serialize any extra necessary SOAP headers. This is used for + * authentication schemes that rely on WS-Security, or for endpoints + * requiring WS-Addressing. + * + * @param writer the writer + * @param webMethodName the Web method being called + * @throws XMLStreamException the XML stream exception + */ + public void serializeExtraSoapHeaders(XMLStreamWriter writer, String webMethodName) throws XMLStreamException { + // do nothing by default. + } + + /** + * Adjusts the URL endpoint based on the credential. + * + * @param url The URL. + * @return Adjust URL. + */ + public URI adjustUrl(URI url) throws URISyntaxException { + return new URI(getUriWithoutWSSecurity(url)); + } + + /** + * Gets the flag indicating whether any sign action need taken. + */ + public boolean isNeedSignature() { + return false; + } + + /** + * Add the signature element to the memory stream. + * + * @param memoryStream The memory stream. + */ + public void sign(ByteArrayOutputStream memoryStream) throws Exception { + throw new InvalidOperationException(); + } + + + /** + * Serialize SOAP headers used for authentication schemes that rely on WS-Security. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + */ + public void serializeWSSecurityHeaders(XMLStreamWriter writer) + throws XMLStreamException { + // do nothing by default. + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/credential/TokenCredentials.java b/ews-api/src/main/java/com/eischet/ews/api/credential/TokenCredentials.java new file mode 100644 index 000000000..359b8cae3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/credential/TokenCredentials.java @@ -0,0 +1,61 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.credential; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.exception.misc.ArgumentNullException; +import com.eischet.ews.api.http.ExchangeHttpClient; + +import java.net.URISyntaxException; + +/** + * TokenCredentials provides credential if you already have a token. + */ +public final class TokenCredentials extends WSSecurityBasedCredentials { + + /** + * Initializes a new instance of the TokenCredentials class. + * + * @param securityToken The token. + * @throws ArgumentNullException the argument null exception + */ + public TokenCredentials(String securityToken) throws Exception { + super(securityToken); + EwsUtilities.validateParam(securityToken, "securityToken"); + + } + + /** + * This method is called to apply credential to a service request before + * the request is made. + * + * @param request The request. + * @throws java.net.URISyntaxException the uRI syntax exception + */ + @Override + public void prepareWebRequest(ExchangeHttpClient.Request request) + throws URISyntaxException { + this.setEwsUrl(request.getUrl().toURI()); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/credential/WSSecurityBasedCredentials.java b/ews-api/src/main/java/com/eischet/ews/api/credential/WSSecurityBasedCredentials.java new file mode 100644 index 000000000..41f2cb030 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/credential/WSSecurityBasedCredentials.java @@ -0,0 +1,280 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.credential; + +import com.eischet.ews.api.core.EwsUtilities; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Calendar; + +/** + * WSSecurityBasedCredentials is the base class for all credential classes using + * WS-Security. + */ +public abstract class WSSecurityBasedCredentials extends ExchangeCredentials { + + /** + * The security token. + */ + private String securityToken; + + /** + * The ews url. + */ + private URI ewsUrl; + + protected static final String wsuTimeStampFormat = + "" + + "{0:yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'}" + + "{1:yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'}" + + ""; + //kavi-start + // WS-Security SecExt 1.0 Namespace (and the namespace prefix we will use + // for it). + /** The Constant WSSecuritySecExt10NamespacePrefix. */ + //protected static final String WSSecuritySecExt10NamespacePrefix = "wsse"; + + /** The Constant WSSecuritySecExt10Namespace. */ + //protected static final String WSSecuritySecExt10Namespace = + // "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; + + // WS-Addressing 1.0 Namespace (and the namespace prefix we will use for + // it). + + + /** The Constant WSAddressing10NamespacePrefix. */ + //protected static final String WSAddressing10NamespacePrefix = "wsa"; + + /** The Constant WSAddressing10Namespace. */ + //protected static final String WSAddressing10Namespace = + // "http://www.w3.org/2005/08/addressing"; + + //kavi end + + // The WS-Addressing headers format string to use for adding the + // WS-Addressing headers. + // Fill-Ins: %s = Web method name; %s = EWS URL + /** + * The Constant WsAddressingHeadersFormat. + */ + protected static final String wsAddressingHeadersFormat = + "http://schemas.microsoft.com/exchange/services/2006/messages/%s" + + + "http://www.w3.org/2005/08/addressing/anonymous" + + "" + + "%s"; + + // The WS-Security header format string to use for adding the WS-Security + // header. + // Fill-Ins: + // %s = EncryptedData block (the token) + /** + * The Constant WsSecurityHeaderFormat. + */ + protected static final String wsSecurityHeaderFormat = + "" + + " %s" + // EncryptedData (token) + ""; + + private boolean addTimestamp; + + // / Path suffix for WS-Security endpoint. + /** + * The Constant WsSecurityPathSuffix. + */ + protected static final String wsSecurityPathSuffix = "/wssecurity"; + + /** + * Initializes a new instance of the WSSecurityBasedCredentials class. + */ + protected WSSecurityBasedCredentials() { + } + + /** + * Initializes a new instance of the WSSecurityBasedCredentials class. + * + * @param securityToken The security token. + */ + protected WSSecurityBasedCredentials(String securityToken) { + this.securityToken = securityToken; + } + + /** + * Initializes a new instance of the WSSecurityBasedCredentials class. + * + * @param securityToken The security token. + * @param addTimestamp Timestamp should be added. + */ + protected WSSecurityBasedCredentials(String securityToken, boolean addTimestamp) { + this.securityToken = securityToken; + this.addTimestamp = addTimestamp; + } + + /** + * This method is called to pre-authenticate credential before a service + * request is made. + */ + @Override + public void preAuthenticate() { + // Nothing special to do here. + } + + /** + * Emit the extra namespace aliases used for WS-Security and WS-Addressing. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + */ + @Override + public void emitExtraSoapHeaderNamespaceAliases(XMLStreamWriter writer) + throws XMLStreamException { + writer.writeAttribute( + "xmlns", + "", + EwsUtilities.WSSecuritySecExtNamespacePrefix, + EwsUtilities.WSSecuritySecExtNamespace); + writer.writeAttribute( + "xmlns", + "", + EwsUtilities.WSAddressingNamespacePrefix, + EwsUtilities.WSAddressingNamespace); + } + + /** + * Serialize the WS-Security and WS-Addressing SOAP headers. + * + * @param writer the writer + * @param webMethodName the Web method being called + * @throws XMLStreamException the XML stream exception + */ + @Override + public void serializeExtraSoapHeaders(XMLStreamWriter writer, String webMethodName) throws XMLStreamException { + this.serializeWSAddressingHeaders(writer, webMethodName); + this.serializeWSSecurityHeaders(writer); + } + + /** + * Creates the WS-Addressing headers necessary to send with an outgoing request. + * + * @param xmlWriter the XML writer to serialize the headers to + * @param webMethodName the Web method being called + * @throws XMLStreamException the XML stream exception + */ + private void serializeWSAddressingHeaders(XMLStreamWriter xmlWriter, + String webMethodName) throws XMLStreamException { + EwsUtilities.ewsAssert(webMethodName != null, + "WSSecurityBasedCredentials.SerializeWSAddressingHeaders", + "Web method name cannot be null!"); + + EwsUtilities.ewsAssert(this.ewsUrl != null, + "WSSecurityBasedCredentials.SerializeWSAddressingHeaders", + "EWS Url cannot be null!"); + + // Format the WS-Addressing headers. + String wsAddressingHeaders = String.format( + WSSecurityBasedCredentials.wsAddressingHeadersFormat, + webMethodName, this.ewsUrl); + + // And write them out... + xmlWriter.writeCharacters(wsAddressingHeaders); + } + + /** + * Creates the WS-Security header necessary to send with an outgoing request. + * + * @param xmlWriter The XML writer to serialize the headers to + * @throws XMLStreamException the XML stream exception + */ + @Override + public void serializeWSSecurityHeaders(XMLStreamWriter xmlWriter) + throws XMLStreamException { + EwsUtilities.ewsAssert(this.securityToken != null, + "WSSecurityBasedCredentials.SerializeWSSecurityHeaders", + "Security token cannot be null!"); + + // + // 2007-09-20T01:13:10.468Z + // 2007-09-20T01:18:10.468Z + // + // + String timestamp = null; + if (this.addTimestamp) { + Calendar utcNow = Calendar.getInstance(); + utcNow.add(Calendar.MINUTE, 5); + timestamp = String.format(WSSecurityBasedCredentials.wsuTimeStampFormat, utcNow, utcNow); + + } + + // Format the WS-Security header based on all the information we have. + String wsSecurityHeader = String.format( + WSSecurityBasedCredentials.wsSecurityHeaderFormat, + timestamp + this.securityToken); + + // And write the header out... + xmlWriter.writeCharacters(wsSecurityHeader); + } + + /** + * Adjusts the URL based on the credential. + * + * @param url The URL. + * @return Adjust URL. + * @throws java.net.URISyntaxException the uRI syntax exception + */ + @Override + public URI adjustUrl(URI url) throws URISyntaxException { + return new URI(getUriWithoutWSSecurity(url) + WSSecurityBasedCredentials.wsSecurityPathSuffix); + } + + /** + * Gets the security token. + */ + protected String getSecurityToken() { + return this.securityToken; + } + + /** + * Sets the security token. + */ + protected void setSecurityToken(String value) { + securityToken = value; + } + + /** + * Gets the EWS URL. + */ + protected URI getEwsUrl() { + return this.ewsUrl; + } + + /** + * Sets the EWS URL. + */ + protected void setEwsUrl(URI value) { + ewsUrl = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/credential/WebCredentials.java b/ews-api/src/main/java/com/eischet/ews/api/credential/WebCredentials.java new file mode 100644 index 000000000..480d1c4cf --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/credential/WebCredentials.java @@ -0,0 +1,143 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.credential; + +import com.eischet.ews.api.http.ExchangeHttpClient; + +/** + * WebCredentials is used for password-based authentication schemes such as + * basic, digest, NTLM, and Kerberos authentication. + */ +public final class WebCredentials extends ExchangeCredentials { + + /** + * The domain. + */ + private final String domain; + + /** + * The user. + */ + private final String user; + + /** + * The pwd. + */ + private final String pwd; + + /** + * The use default credential. + */ + private boolean useDefaultCredentials = true; + + /** + * Gets the domain. + * + * @return the domain + */ + public String getDomain() { + return domain; + } + + /** + * Gets the user. + * + * @return the user + */ + public String getUser() { + return user; + } + + /** + * Gets the pwd. + * + * @return the pwd + */ + public String getPwd() { + return pwd; + } + + /** + * Checks if is use default credential. + * + * @return true, if is use default credential + */ + public boolean isUseDefaultCredentials() { + return useDefaultCredentials; + } + + /** + * Initializes a new instance to use default network credential. + */ + public WebCredentials() { + useDefaultCredentials = true; + this.user = null; + this.pwd = null; + this.domain = null; + } + + /** + * Initializes a new instance to use specified credential. + * + * @param userName Account user name. + * @param password Account password. + * @param domain Account domain. + */ + public WebCredentials(String userName, String password, String domain) { + if (userName == null || password == null) { + throw new IllegalArgumentException( + "User name or password can not be null"); + } + + this.domain = domain; + this.user = userName; + this.pwd = password; + useDefaultCredentials = false; + } + + /** + * Initializes a new instance to use specified credential. + * + * @param username The user name. + * @param password The password. + */ + public WebCredentials(String username, String password) { + this(username, password, ""); + } + + /** + * This method is called to apply credential to a service request before + * the request is made. + * + * @param request The request. + */ + @Override + public void prepareWebRequest(ExchangeHttpClient.Request request) { + if (useDefaultCredentials) { + request.setUseDefaultCredentials(true); + } else { + request.setCredentials(domain, user, pwd); + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/credential/WebProxyCredentials.java b/ews-api/src/main/java/com/eischet/ews/api/credential/WebProxyCredentials.java new file mode 100644 index 000000000..924e5a9a2 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/credential/WebProxyCredentials.java @@ -0,0 +1,51 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.credential; + +public class WebProxyCredentials { + + private final String username; + + private final String password; + + private final String domain; + + public WebProxyCredentials(String username, String password, String domain) { + this.username = username; + this.password = password; + this.domain = domain; + } + + public String getUsername() { + return username; + } + + public String getPassword() { + return password; + } + + public String getDomain() { + return domain; + } +} diff --git a/src/main/java/microsoft/exchange/webservices/data/credential/WindowsLiveCredentials.java b/ews-api/src/main/java/com/eischet/ews/api/credential/WindowsLiveCredentials.java similarity index 95% rename from src/main/java/microsoft/exchange/webservices/data/credential/WindowsLiveCredentials.java rename to ews-api/src/main/java/com/eischet/ews/api/credential/WindowsLiveCredentials.java index 807183d54..23cd06fdd 100644 --- a/src/main/java/microsoft/exchange/webservices/data/credential/WindowsLiveCredentials.java +++ b/ews-api/src/main/java/com/eischet/ews/api/credential/WindowsLiveCredentials.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.credential; +package com.eischet.ews.api.credential; public class WindowsLiveCredentials extends WSSecurityBasedCredentials { diff --git a/ews-api/src/main/java/com/eischet/ews/api/dns/DnsClient.java b/ews-api/src/main/java/com/eischet/ews/api/dns/DnsClient.java new file mode 100644 index 000000000..97ce8e8cb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/dns/DnsClient.java @@ -0,0 +1,108 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.dns; + +import com.eischet.ews.api.EWSConstants; +import com.eischet.ews.api.core.exception.dns.DnsException; + +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.DirContext; +import javax.naming.directory.InitialDirContext; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; + +/** + * Class that represents DNS Query client. + */ +public class DnsClient { + + /** + * Set up the environment used to construct the DirContext. + * + * @param dnsServerAddress + * @return + */ + static Hashtable getEnv(String dnsServerAddress) { + // Set up environment for creating initial context + Hashtable env = new Hashtable(); + env.put("java.naming.factory.initial", + "com.sun.jndi.dns.DnsContextFactory"); + if (dnsServerAddress != null && !dnsServerAddress.isEmpty()) { + env.put("java.naming.provider.url", "dns://" + dnsServerAddress); + } + return env; + } + + /** + * Performs Dns query. + * + * @param the generic type + * @param cls DnsRecord Type + * @param domain the domain + * @param dnsServerAddress IPAddress of DNS server to use (may be null) + * @return DnsRecord The DNS record list (never null but may be empty) + * @throws DnsException the dns exception + */ + + public static List dnsQuery(Class cls, String domain, String dnsServerAddress) throws + DnsException { + + List dnsRecordList = new ArrayList(); + try { + // Create initial context + DirContext ictx = new InitialDirContext(getEnv(dnsServerAddress)); + + // Retrieve SRV record context attribute for the specified domain + Attributes contextAttributes = ictx.getAttributes(domain, + new String[]{EWSConstants.SRVRECORD}); + if (contextAttributes != null) { + NamingEnumeration attributes = contextAttributes.getAll(); + if (attributes != null) { + while (attributes.hasMore()) { + Attribute attr = (Attribute) attributes.next(); + NamingEnumeration srvValues = attr.getAll(); + if (srvValues != null) { + while (srvValues.hasMore()) { + T dnsRecord = cls.newInstance(); + + // Loads the DNS SRV record + dnsRecord.load((String) srvValues.next()); + dnsRecordList.add(dnsRecord); + } + } + } + } + } + } catch (NamingException ne) { + throw new DnsException(ne.getMessage()); + } catch (Exception e) { + throw new DnsException(e.getMessage()); + } + return dnsRecordList; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/dns/DnsRecord.java b/ews-api/src/main/java/com/eischet/ews/api/dns/DnsRecord.java new file mode 100644 index 000000000..7632df6c1 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/dns/DnsRecord.java @@ -0,0 +1,74 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.dns; + +import com.eischet.ews.api.core.exception.dns.DnsException; + +/** + * Represents a DnsRecord. + */ +abstract class DnsRecord { + /* + * Name field of this DNS Record + */ + /** + * The name. + */ + private String name; + /* + * The suggested time for this dnsRecord to be valid + */ + /** + * The time to live. + */ + private int timeToLive; + + /** + * Retrieves the value of the name property. + * + * @return name + */ + public String getName() { + return name; + } + + /** + * Retrieves the value of the timeToLive property. + * + * @return timeToLive + */ + public int getTimeToLive() { + return timeToLive; + } + + /** + * loads the DNS Record. + * + * @param value the value + * @throws DnsException the dns exception + */ + protected void load(String value) throws DnsException { + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/dns/DnsSrvRecord.java b/ews-api/src/main/java/com/eischet/ews/api/dns/DnsSrvRecord.java new file mode 100644 index 000000000..61fa118f2 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/dns/DnsSrvRecord.java @@ -0,0 +1,131 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.dns; + +import com.eischet.ews.api.core.exception.dns.DnsException; + +import java.util.NoSuchElementException; +import java.util.StringTokenizer; + +/** + * Represents a DNS SRV Record. + */ +public class DnsSrvRecord extends DnsRecord { + /* + * The string representing the target host + */ + /** + * The target. + */ + private String target; + + /* + * priority of the target host specified in the owner name. + */ + /** + * The priority. + */ + private int priority; + /* + * weight of the target host + */ + /** + * The weight. + */ + private int weight; + /* + * port used on the target for the service + */ + /** + * The port. + */ + private int port; + + /** + * Retrieves the value of the target property. + * + * @return target + */ + public String getNameTarget() { + return this.target; + } + + /** + * Retrieves the value of the priority property. + * + * @return priority + */ + public int getPriority() { + return priority; + } + + /** + * Retrieves the value of the weight property. + * + * @return weight + */ + public int getWeight() { + return weight; + } + + /** + * Retrieves the value of the port property. + * + * @return port + */ + public int getPort() { + return port; + } + + /** + * Initializes a new instance of the DnsSrvRecord class. + * + * @param srvRecord srvRecord that is fetched from JNDI + * @throws DnsException the dns exception + */ + protected void load(String srvRecord) throws DnsException { + super.load(null); + StringTokenizer strTokens = new StringTokenizer(srvRecord); + try { + while (strTokens.hasMoreTokens()) { + String priority = strTokens.nextToken(); + this.priority = Integer.parseInt(priority); + + String weight = strTokens.nextToken(); + this.weight = Integer.parseInt(weight); + + String port = strTokens.nextToken(); + this.port = Integer.parseInt(port); + + String target = strTokens.nextToken(); + this.target = target; + } + } catch (NumberFormatException ne) { + throw new DnsException("NumberFormatException " + ne.getMessage()); + } catch (NoSuchElementException ne) { + throw new DnsException("NoSuchElementException " + ne.getMessage()); + } + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/http/ExchangeHttpClient.java b/ews-api/src/main/java/com/eischet/ews/api/http/ExchangeHttpClient.java new file mode 100644 index 000000000..a797ea980 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/http/ExchangeHttpClient.java @@ -0,0 +1,76 @@ +package com.eischet.ews.api.http; + +import com.eischet.ews.api.core.exception.http.EWSHttpException; + +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URL; +import java.util.Map; + +public interface ExchangeHttpClient extends Closeable { + + interface Request { + + void setUrl(URL toURL); + + void setRequestMethod(String get); + + void setAllowAutoRedirect(boolean b); + + void setPreAuthenticate(boolean preAuthenticate); + + void setTimeout(int timeout); + + void setContentType(String s); + + void setAccept(String s); + + void setUserAgent(String userAgent); + + void setAcceptGzipEncoding(boolean acceptGzipEncoding); + + void setHeaders(Map httpHeaders); + + void setUseDefaultCredentials(boolean useDefaultCredentials); + + void prepareConnection(); + + void close() throws IOException; + + OutputStream getOutputStream() throws EWSHttpException; + + int executeRequest() throws IOException, EWSHttpException; + + int getResponseCode() throws EWSHttpException; + + InputStream getInputStream() throws EWSHttpException, IOException; + + void setAllowAuthentication(boolean b); + + String getResponseHeaderField(String headerName) throws EWSHttpException; + + Map getResponseHeaders() throws EWSHttpException; + + String getResponseContentType() throws EWSHttpException; + + void setCredentials(String domain, String user, String pwd); + + URL getUrl(); + + String getContentEncoding() throws EWSHttpException; + + String getRequestMethod(); + + Map getRequestProperty() throws EWSHttpException; + + InputStream getErrorStream() throws EWSHttpException; + + String getResponseText() throws EWSHttpException; + } + + Request createRequest(); + Request createPoolingRequest(); + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/http/RequestFields.java b/ews-api/src/main/java/com/eischet/ews/api/http/RequestFields.java new file mode 100644 index 000000000..082752af0 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/http/RequestFields.java @@ -0,0 +1,210 @@ +package com.eischet.ews.api.http; + +import com.eischet.ews.api.core.exception.http.EWSHttpException; +import com.eischet.ews.api.http.ExchangeHttpClient; + +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +/** + * Helper class for implementing an ExchangeHttpClient.Request. + * + * This class contains all the fields that the Exchange API expects it to have; it's up to an implementation to actually + * turn these into HTTP requests using whichever client is used (and to fill back the results). + */ +public abstract class RequestFields implements ExchangeHttpClient.Request { + + // request properties + + private URL url; + private String requestMethod; + private int timeout; + private String contentType; + private String contentEncoding; + private String accept; + private String userAgent; + + private boolean allowAuthentication; + private boolean allowAutoRedirect; + private boolean preAuthenticate; + private boolean acceptGzipEncoding; + private boolean useDefaultCredentials; + + private final Map httpHeaders = new HashMap<>(1); + + // response properties + + private int responseCode; + private String responseContentType; + private String responseText; + + @Override + public URL getUrl() { + return url; + } + + @Override + public void setUrl(final URL url) { + this.url = url; + } + + @Override + public String getRequestMethod() { + return requestMethod; + } + + @Override + public void setRequestMethod(final String requestMethod) { + this.requestMethod = requestMethod; + } + + public boolean isAllowAutoRedirect() { + return allowAutoRedirect; + } + + @Override + public void setAllowAutoRedirect(final boolean allowAutoRedirect) { + this.allowAutoRedirect = allowAutoRedirect; + } + + public boolean isPreAuthenticate() { + return preAuthenticate; + } + + @Override + public void setPreAuthenticate(final boolean preAuthenticate) { + this.preAuthenticate = preAuthenticate; + } + + public int getTimeout() { + return timeout; + } + + @Override + public void setTimeout(final int timeout) { + this.timeout = timeout; + } + + public String getContentType() { + return contentType; + } + + @Override + public void setContentType(final String contentType) { + this.contentType = contentType; + } + + public String getAccept() { + return accept; + } + + @Override + public void setAccept(final String accept) { + this.accept = accept; + } + + public String getUserAgent() { + return userAgent; + } + + @Override + public void setUserAgent(final String userAgent) { + this.userAgent = userAgent; + } + + public boolean isAcceptGzipEncoding() { + return acceptGzipEncoding; + } + + @Override + public void setAcceptGzipEncoding(final boolean acceptGzipEncoding) { + this.acceptGzipEncoding = acceptGzipEncoding; + } + + public Map getHttpHeaders() { + return httpHeaders; + } + + public boolean isUseDefaultCredentials() { + return useDefaultCredentials; + } + + @Override + public void setUseDefaultCredentials(final boolean useDefaultCredentials) { + this.useDefaultCredentials = useDefaultCredentials; + } + + @Override + public int getResponseCode() { + return responseCode; + } + + public void setResponseCode(final int responseCode) { + this.responseCode = responseCode; + } + + public boolean isAllowAuthentication() { + return allowAuthentication; + } + + @Override + public void setAllowAuthentication(final boolean allowAuthentication) { + this.allowAuthentication = allowAuthentication; + } + + @Override + public void setHeaders(final Map httpHeaders) { + this.httpHeaders.clear(); + this.httpHeaders.putAll(httpHeaders); + } + + @Override + public String getResponseHeaderField(final String headerName) throws EWSHttpException { + return httpHeaders.get(headerName); + } + + @Override + public Map getResponseHeaders() throws EWSHttpException { + return new HashMap<>(httpHeaders); + } + + @Override + public String getResponseContentType() { + return responseContentType; + } + + public void setResponseContentType(final String responseContentType) { + this.responseContentType = responseContentType; + } + + @Override + public String getResponseText() { + return responseText; + } + + public void setResponseText(final String responseText) { + this.responseText = responseText; + } + + @Override + public String getContentEncoding() { + return contentEncoding; + } + + public void setContentEncoding(final String contentEncoding) { + this.contentEncoding = contentEncoding; + } + + @Override + public Map getRequestProperty() throws EWSHttpException { + // the old Apache HTTP 4 client works differently, adding headers to the Apache POST object in prepareConnection! + // There, this method returns the actual headers of the POST object, which are different from the plain httpHeaders set + // by the API. I don't think that this distinction really matters, so they're the same here. + return getHttpHeaders(); + } + + public void setHeader(final String headerName, final String headerValue) { + httpHeaders.put(headerName, headerValue); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/messaging/PhoneCall.java b/ews-api/src/main/java/com/eischet/ews/api/messaging/PhoneCall.java new file mode 100644 index 000000000..dda633a9d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/messaging/PhoneCall.java @@ -0,0 +1,203 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.messaging; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.service.PhoneCallState; +import com.eischet.ews.api.core.enumeration.service.error.ConnectionFailureCause; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; + +/** + * Represents a phone call. + */ +public final class PhoneCall extends ComplexProperty { + + /** + * The Constant successfullResponseText. + */ + private final static String SuccessfullResponseText = "OK"; + + /** + * The Constant successfullResponseCode. + */ + private final static int SuccessfullResponseCode = 200; + + /** + * The service. + */ + private final ExchangeService service; + + /** + * The state. + */ + private PhoneCallState state; + + /** + * The connection failure cause. + */ + private ConnectionFailureCause connectionFailureCause; + + /** + * The sip response text. + */ + private String sipResponseText; + + /** + * The sip response code. + */ + private int sipResponseCode; + + /** + * The id. + */ + private PhoneCallId id; + + /** + * PhoneCall Constructor. + * + * @param service the service + */ + public PhoneCall(ExchangeService service) { + EwsUtilities.ewsAssert(service != null, "PhoneCall.ctor", "service is null"); + + this.service = service; + this.state = PhoneCallState.Connecting; + this.connectionFailureCause = ConnectionFailureCause.None; + this.sipResponseText = PhoneCall.SuccessfullResponseText; + this.sipResponseCode = PhoneCall.SuccessfullResponseCode; + } + + /** + * PhoneCall Constructor. + * + * @param service the service + * @param id the id + */ + protected PhoneCall(ExchangeService service, PhoneCallId id) { + this(service); + this.id = id; + } + + /** + * Refreshes the state of this phone call. + * + * @throws Exception the exception + */ + public void refresh() throws Exception { + PhoneCall phoneCall = service.getUnifiedMessaging() + .getPhoneCallInformation(this.id); + this.state = phoneCall.getState(); + this.connectionFailureCause = phoneCall.getConnectionFailureCause(); + this.sipResponseText = phoneCall.getSipResponseText(); + this.sipResponseCode = phoneCall.getSipResponseCode(); + } + + /** + * Disconnects this phone call. + * + * @throws Exception the exception + */ + public void disconnect() throws Exception { + // If call is already disconnected, throw exception + // + if (this.state == PhoneCallState.Disconnected) { + throw new ServiceLocalException("The phone call has already been disconnected."); + } + + this.service.getUnifiedMessaging().disconnectPhoneCall(this.id); + this.state = PhoneCallState.Disconnected; + } + + /** + * Tries to read an element from XML. + * + * @param reader the reader + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.PhoneCallState)) { + this.state = reader.readElementValue(PhoneCallState.class); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.ConnectionFailureCause)) { + this.connectionFailureCause = reader + .readElementValue(ConnectionFailureCause.class); + return true; + } else if (reader.getLocalName() + .equals(XmlElementNames.SIPResponseText)) { + this.sipResponseText = reader.readElementValue(); + return true; + } else if (reader.getLocalName() + .equals(XmlElementNames.SIPResponseCode)) { + this.sipResponseCode = reader.readElementValue(Integer.class); + return true; + } else { + return false; + } + + } + + /** + * Gets a value indicating the last known state of this phone call. + * + * @return the state + */ + public PhoneCallState getState() { + return state; + } + + /** + * Gets the SIP response text of this phone call. + * + * @return the sip response text + */ + public String getSipResponseText() { + return sipResponseText; + } + + /** + * Gets the SIP response code of this phone call. + * + * @return the sip response code + */ + public int getSipResponseCode() { + return sipResponseCode; + } + + /** + * Gets a value indicating the reason why this phone call failed to connect. + * + * @return the connection failure cause + */ + public ConnectionFailureCause getConnectionFailureCause() { + return connectionFailureCause; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/messaging/PhoneCallId.java b/ews-api/src/main/java/com/eischet/ews/api/messaging/PhoneCallId.java new file mode 100644 index 000000000..a10436653 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/messaging/PhoneCallId.java @@ -0,0 +1,107 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.messaging; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; + +/** + * Represents the Id of a phone call. + */ +public final class PhoneCallId extends ComplexProperty { + + /** + * The id. + */ + private String id; + + /** + * Initializes a new instance of the PhoneCallId class. + */ + public PhoneCallId() { + } + + /** + * Initializes a new instance of the PhoneCallId class. + * + * @param id the id + */ + protected PhoneCallId(String id) { + this.id = id; + } + + /** + * Reads attribute from XML. + * + * @param reader the reader + */ + @Override + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.id = reader.readAttributeValue(XmlAttributeNames.Id); + } + + /** + * Writes attribute to XML. + * + * @param writer the writer + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.Id, this.id); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { + this.writeToXml(writer, XmlElementNames.PhoneCallId); + } + + /** + * Gets the Id of the phone call. + * + * @return the id + */ + protected String getId() { + return id; + } + + /** + * Sets the id. + * + * @param id the new id + */ + protected void setId(String id) { + this.id = id; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/messaging/UnifiedMessaging.java b/ews-api/src/main/java/com/eischet/ews/api/messaging/UnifiedMessaging.java new file mode 100644 index 000000000..50bf203f2 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/messaging/UnifiedMessaging.java @@ -0,0 +1,106 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.messaging; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.request.DisconnectPhoneCallRequest; +import com.eischet.ews.api.core.request.GetPhoneCallRequest; +import com.eischet.ews.api.core.request.PlayOnPhoneRequest; +import com.eischet.ews.api.core.response.GetPhoneCallResponse; +import com.eischet.ews.api.core.response.PlayOnPhoneResponse; +import com.eischet.ews.api.property.complex.ItemId; + +/** + * Represents the Unified Messaging functionalities. + */ +public final class UnifiedMessaging { + + /** + * The service. + */ + private final ExchangeService service; + + /** + * Constructor. + * + * @param service the service + */ + public UnifiedMessaging(ExchangeService service) { + this.service = service; + } + + /** + * Calls a phone and reads a message to the person who picks up. + * + * @param itemId the item id + * @param dialString the dial string + * @return An object providing status for the phone call. + * @throws Exception the exception + */ + public PhoneCall playOnPhone(ItemId itemId, String dialString) + throws Exception { + EwsUtilities.validateParam(itemId, "itemId"); + EwsUtilities.validateParam(dialString, "dialString"); + + PlayOnPhoneRequest request = new PlayOnPhoneRequest(service); + request.setDialString(dialString); + request.setItemId(itemId); + PlayOnPhoneResponse serviceResponse = request.execute(); + + PhoneCall callInformation = new PhoneCall(service, serviceResponse + .getPhoneCallId()); + + return callInformation; + } + + /** + * Retrieves information about a current phone call. + * + * @param id the id + * @return An object providing status for the phone call. + * @throws Exception the exception + */ + protected PhoneCall getPhoneCallInformation(PhoneCallId id) + throws Exception { + GetPhoneCallRequest request = new GetPhoneCallRequest(service); + request.setId(id); + GetPhoneCallResponse response = request.execute(); + + return response.getPhoneCall(); + } + + /** + * Disconnects a phone call. + * + * @param id the id + * @throws Exception the exception + */ + protected void disconnectPhoneCall(PhoneCallId id) throws Exception { + DisconnectPhoneCallRequest request = new DisconnectPhoneCallRequest( + service); + request.setId(id); + request.execute(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/AbstractAsyncCallback.java b/ews-api/src/main/java/com/eischet/ews/api/misc/AbstractAsyncCallback.java new file mode 100644 index 000000000..d59e15265 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/AbstractAsyncCallback.java @@ -0,0 +1,56 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import java.util.concurrent.Future; + +public abstract class AbstractAsyncCallback implements Runnable, Callback { + + Future task; + static boolean callbackProcessed = false; + + AbstractAsyncCallback() { + } + + AbstractAsyncCallback(Future t) { + this.task = t; + } + + public void run() { + while (!callbackProcessed) { + + if (task.isDone()) { + processMe(task); + callbackProcessed = true; + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + } + break; + } + + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/AbstractFolderIdWrapper.java b/ews-api/src/main/java/com/eischet/ews/api/misc/AbstractFolderIdWrapper.java new file mode 100644 index 000000000..344e8f1bf --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/AbstractFolderIdWrapper.java @@ -0,0 +1,69 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.service.folder.Folder; + +/** + * Represents the abstraction of a folder Id. + */ +public abstract class AbstractFolderIdWrapper { + + /** + * Obtains the Folder object associated with the wrapper. + * + * @return The Folder object associated with the wrapper. + */ + public Folder getFolder() { + return null; + } + + /** + * Initializes a new instance of AbstractFolderIdWrapper. + */ + protected AbstractFolderIdWrapper() { + } + + /** + * Writes the Id encapsulated in the wrapper to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + protected abstract void writeToXml(EwsServiceXmlWriter writer) + throws Exception; + + /** + * Validates folderId against specified version. + * + * @param version the version + * @throws ServiceVersionException the service version exception + */ + protected void validate(ExchangeVersion version) + throws ServiceVersionException { + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/AbstractItemIdWrapper.java b/ews-api/src/main/java/com/eischet/ews/api/misc/AbstractItemIdWrapper.java new file mode 100644 index 000000000..4227e74c4 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/AbstractItemIdWrapper.java @@ -0,0 +1,57 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.service.item.Item; + +/** + * Represents the abstraction of an item Id. + */ +abstract class AbstractItemIdWrapper { + + /** + * Initializes a new instance of the class. + */ + protected AbstractItemIdWrapper() { + } + + /** + * Obtains the ItemBase object associated with the wrapper. + * + * @return The ItemBase object associated with the wrapper + */ + public Item getItem() { + return null; + } + + /** + * Writes the Id encapsulated in the wrapper to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + protected abstract void writeToXml(EwsServiceXmlWriter writer) + throws Exception; +} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/AsyncCallback.java b/ews-api/src/main/java/com/eischet/ews/api/misc/AsyncCallback.java similarity index 87% rename from src/main/java/microsoft/exchange/webservices/data/misc/AsyncCallback.java rename to ews-api/src/main/java/com/eischet/ews/api/misc/AsyncCallback.java index 19c047b7e..29d3819f3 100644 --- a/src/main/java/microsoft/exchange/webservices/data/misc/AsyncCallback.java +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/AsyncCallback.java @@ -21,25 +21,24 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.misc; +package com.eischet.ews.api.misc; import java.util.concurrent.Future; public abstract class AsyncCallback extends AbstractAsyncCallback { - AsyncCallback() { + AsyncCallback() { - } + } - void setTask(Future task) { + void setTask(Future task) { - this.task = task; - } - - Future getTask() { - return this.task; - } + this.task = task; + } + Future getTask() { + return this.task; + } } diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/AsyncCallbackImplementation.java b/ews-api/src/main/java/com/eischet/ews/api/misc/AsyncCallbackImplementation.java similarity index 78% rename from src/main/java/microsoft/exchange/webservices/data/misc/AsyncCallbackImplementation.java rename to ews-api/src/main/java/com/eischet/ews/api/misc/AsyncCallbackImplementation.java index 4bee469d8..903010312 100644 --- a/src/main/java/microsoft/exchange/webservices/data/misc/AsyncCallbackImplementation.java +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/AsyncCallbackImplementation.java @@ -21,21 +21,19 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.misc; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +package com.eischet.ews.api.misc; import java.util.concurrent.Future; +import java.util.logging.Logger; public class AsyncCallbackImplementation extends AsyncCallback { - private static final Log LOG = LogFactory.getLog(AsyncCallbackImplementation.class); + private static final Logger LOG = Logger.getLogger(AsyncCallbackImplementation.class.getCanonicalName()); - @Override - public Object processMe(Future task) { - LOG.debug("In Async Callback" + task.isDone()); - return null; - } + @Override + public Object processMe(Future task) { + LOG.fine(() -> "In Async Callback" + task.isDone()); + return null; + } } diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/AsyncExecutor.java b/ews-api/src/main/java/com/eischet/ews/api/misc/AsyncExecutor.java new file mode 100644 index 000000000..fd171aa8a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/AsyncExecutor.java @@ -0,0 +1,45 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import java.util.Objects; +import java.util.concurrent.*; + +public class AsyncExecutor extends ThreadPoolExecutor implements ExecutorService { + final static ArrayBlockingQueue queue = new ArrayBlockingQueue(1); + + public AsyncExecutor() { + super(1, 5, 10, TimeUnit.SECONDS, queue); + } + + public Future submit(Callable task, AsyncCallback callback) { + RunnableFuture ftask = newTaskFor(Objects.requireNonNull(task)); + execute(ftask); + if (callback != null) { + callback.setTask(ftask); + } + new Thread(callback).start(); + return ftask; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/AsyncRequestResult.java b/ews-api/src/main/java/com/eischet/ews/api/misc/AsyncRequestResult.java new file mode 100644 index 000000000..95ec74422 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/AsyncRequestResult.java @@ -0,0 +1,183 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.request.ServiceRequestBase; +import com.eischet.ews.api.core.request.SimpleServiceRequestBase; +import com.eischet.ews.api.core.request.WaitHandle; +import com.eischet.ews.api.http.ExchangeHttpClient; + +import java.util.concurrent.*; + +public class AsyncRequestResult implements IAsyncResult { + + ServiceRequestBase serviceRequest; + ExchangeHttpClient.Request webRequest; + AsyncCallback wasasyncCallback; + IAsyncResult webAsyncResult; + Object asyncState; + Future task; + + AsyncRequestResult(Future task) { + this.task = task; + } + + + public AsyncRequestResult(ServiceRequestBase serviceRequest, + ExchangeHttpClient.Request webRequest, Future task, + Object asyncState) throws Exception { + EwsUtilities.validateParam(serviceRequest, "serviceRequest"); + EwsUtilities.validateParam(webRequest, "webRequest"); + EwsUtilities.validateParam(task, "task"); + this.serviceRequest = serviceRequest; + this.webRequest = webRequest; + this.asyncState = asyncState; + this.task = task; + + } + + public void setServiceRequestBase(ServiceRequestBase serviceRequest) { + this.serviceRequest = serviceRequest; + } + + private ServiceRequestBase getServiceRequest() { + return this.serviceRequest; + } + + public void setHttpWebRequest(ExchangeHttpClient.Request webRequest) { + this.webRequest = webRequest; + } + + public ExchangeHttpClient.Request getHttpWebRequest() { + return this.webRequest; + } + + public FutureTask getTask() { + return (FutureTask) this.task; + } + + public static T extractServiceRequest( + ExchangeService exchangeService, Future asyncResult) throws Exception { + EwsUtilities.validateParam(asyncResult, "asyncResult"); + AsyncRequestResult asyncRequestResult = (AsyncRequestResult) asyncResult; + if (asyncRequestResult == null) { + /** + * String.InvalidAsyncResult is copied from the error message + * HttpWebRequest.EndGetResponse() Just use this simple string for + * all kinds of invalid IAsyncResult parameters. + */ + throw new ArgumentException("Invalid AsyncResult.", + "asyncResult"); + } + // Validate the serivce request. + if (asyncRequestResult.serviceRequest == null) { + throw new ArgumentException("Invalid AsyncResult.", + "asyncResult"); + } + // Validate the service object + if (!asyncRequestResult.serviceRequest.getService().equals( + exchangeService)) { + throw new ArgumentException("Invalid AsyncResult.", + "asyncResult"); + } + T serviceRequest = (T) asyncRequestResult.getServiceRequest(); + // Validate the request type + if (serviceRequest == null) { + throw new ArgumentException("Invalid AsyncResult.", + "asyncResult"); + } + return serviceRequest; + + } + + + @Override + public boolean cancel(boolean arg0) { + // TODO Auto-generated method stub + return false; + } + + + @Override + public Object get(long timeout, TimeUnit unit) + throws InterruptedException, ExecutionException, + TimeoutException { + // TODO Auto-generated method stub + return null; + } + + + @Override + public boolean isCancelled() { + // TODO Auto-generated method stub + return false; + } + + + @Override + public boolean isDone() { + // TODO Auto-generated method stub + return false; + } + + + @Override + public Object getAsyncState() { + // TODO Auto-generated method stub + return null; + } + + + @Override + public WaitHandle getAsyncWaitHanle() { + // TODO Auto-generated method stub + return null; + } + + + @Override + public boolean getCompleteSynchronously() { + // TODO Auto-generated method stub + return false; + } + + + @Override + public boolean getIsCompleted() { + // TODO Auto-generated method stub + return false; + } + + + @Override + public Object get() throws InterruptedException, ExecutionException { + // TODO Auto-generated method stub + return this.task.get(); + } + + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/CalendarActionResults.java b/ews-api/src/main/java/com/eischet/ews/api/misc/CalendarActionResults.java new file mode 100644 index 000000000..14ad732c8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/CalendarActionResults.java @@ -0,0 +1,128 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.service.item.*; + +/** + * Represents the results of an action performed on a calendar item or meeting + * message, such as accepting, tentatively accepting or declining a meeting + * request. + */ +public final class CalendarActionResults { + + /** + * The appointment. + */ + private final Appointment appointment; + + /** + * The meeting request. + */ + private final MeetingRequest meetingRequest; + + /** + * The meeting response. + */ + private final MeetingResponse meetingResponse; + + /** + * The meeting cancellation. + */ + private final MeetingCancellation meetingCancellation; + + /** + * Initializes a new instance of the class. + * + * @param items the item + */ + public CalendarActionResults(Iterable items) { + this.appointment = EwsUtilities.findFirstItemOfType(Appointment.class, items); + this.meetingRequest = EwsUtilities.findFirstItemOfType( + MeetingRequest.class, items); + this.meetingResponse = EwsUtilities.findFirstItemOfType( + MeetingResponse.class, items); + this.meetingCancellation = EwsUtilities.findFirstItemOfType( + MeetingCancellation.class, items); + } + + /** + * Gets the meeting that was accepted, tentatively accepted or declined. + *

+ * When a meeting is accepted or tentatively accepted via an Appointment + * object, EWS recreates the meeting, and Appointment represents that new + * version. When a meeting is accepted or tentatively accepted via a + * MeetingRequest object, EWS creates an associated meeting in the + * attendee's calendar and Appointment represents that meeting. When + * declining a meeting via an Appointment object, EWS moves the appointment + * to the attendee's Deleted Items folder and Appointment represents that + * moved copy. When declining a meeting via a MeetingRequest object, EWS + * creates an associated meeting in the attendee's Deleted Items folder, and + * Appointment represents that meeting. When a meeting is declined via + * either an Appointment or a MeetingRequest object from the Deleted Items + * folder, Appointment is null. + * + * @return appointment + */ + public Appointment getAppointment() { + return this.appointment; + } + + /** + * Gets the meeting request that was moved to the Deleted Items folder as a + * result of an attendee accepting, tentatively accepting or declining a + * meeting request. If the meeting request is accepted, tentatively accepted + * or declined from the Deleted Items folder, it is permanently deleted and + * MeetingRequest is null. + * + * @return meetingRequest + */ + public MeetingRequest getMeetingRequest() { + return this.meetingRequest; + } + + /** + * Gets the copy of the response that is sent to the organizer of a meeting + * when the meeting is accepted, tentatively accepted or declined by an + * attendee. MeetingResponse is null if the attendee chose not to send a + * response. + * + * @return meetingResponse + */ + public MeetingResponse getMeetingResponse() { + return this.meetingResponse; + } + + /** + * Gets the copy of the meeting cancellation message sent by the organizer + * to the attendees of a meeting when the meeting is cancelled. + * + * @return meetingCancellation + */ + public MeetingCancellation getMeetingCancellation() { + return this.meetingCancellation; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/CallableMethod.java b/ews-api/src/main/java/com/eischet/ews/api/misc/CallableMethod.java new file mode 100644 index 000000000..2c047eb8f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/CallableMethod.java @@ -0,0 +1,58 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.exception.http.EWSHttpException; +import com.eischet.ews.api.core.exception.http.HttpErrorException; +import com.eischet.ews.api.http.ExchangeHttpClient; + +import java.io.IOException; +import java.util.concurrent.Callable; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class CallableMethod implements Callable { + + private static final Logger LOG = Logger.getLogger(CallableMethod.class.getCanonicalName()); + + ExchangeHttpClient.Request request; + + public CallableMethod(ExchangeHttpClient.Request request) { + this.request = request; + } + + protected ExchangeHttpClient.Request executeMethod() throws EWSHttpException, HttpErrorException, IOException { + request.executeRequest(); + return request; + } + + public ExchangeHttpClient.Request call() { + try { + return executeMethod(); + } catch (EWSHttpException | IOException | HttpErrorException e) { + LOG.log(Level.SEVERE, "error executing web request", e); + } + return request; + } +} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/Callback.java b/ews-api/src/main/java/com/eischet/ews/api/misc/Callback.java similarity index 93% rename from src/main/java/microsoft/exchange/webservices/data/misc/Callback.java rename to ews-api/src/main/java/com/eischet/ews/api/misc/Callback.java index f3938fa15..45acdf1c2 100644 --- a/src/main/java/microsoft/exchange/webservices/data/misc/Callback.java +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/Callback.java @@ -21,11 +21,11 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.misc; +package com.eischet.ews.api.misc; import java.util.concurrent.Future; public interface Callback { - T processMe(Future task); + T processMe(Future task); } diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/ConversationAction.java b/ews-api/src/main/java/com/eischet/ews/api/misc/ConversationAction.java new file mode 100644 index 000000000..044b7f68b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/ConversationAction.java @@ -0,0 +1,384 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ConversationActionType; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.DeleteMode; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.property.complex.ConversationId; +import com.eischet.ews.api.property.complex.StringList; + +import java.time.LocalDateTime; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * ConversationAction class that represents + * ConversationActionType in the request XML. + * This class really is meant for representing + * single ConversationAction that needs to + * be taken on a conversation. + */ +public class ConversationAction { + + private static final Logger LOG = Logger.getLogger(ConversationAction.class.getCanonicalName()); + + private ConversationActionType action; + private ConversationId conversationId; + private boolean processRightAway; + + private boolean enableAlwaysDelete; + private StringList categories; + private FolderIdWrapper moveFolderId; + private FolderIdWrapper contextFolderId; + private DeleteMode deleteType; + private Boolean isRead; + private LocalDateTime conversationLastSyncTime; + + /** + * Gets conversation action + * + * @return action + */ + protected ConversationActionType getAction() { + return this.action; + } + + /** + * Sets conversation action + */ + public void setAction(ConversationActionType value) { + this.action = value; + } + + /** + * Gets conversation id + * + * @return conversationId + */ + protected ConversationId getConversationId() { + return this.conversationId; + } + + /** + * Sets conversation id + */ + public void setConversationId(ConversationId value) { + this.conversationId = value; + } + + /** + * Gets ProcessRightAway + * + * @return processRightAway + */ + protected boolean getProcessRightAway() { + return this.processRightAway; + } + + /** + * Sets ProcessRightAway + */ + public void setProcessRightAway(boolean value) { + this.processRightAway = value; + } + + + /** + * Gets conversation categories for Always Categorize action + * + * @return categories + */ + protected StringList getCategories() { + return this.categories; + } + + /** + * Sets conversation categories for Always Categorize actions + */ + public void setCategories(StringList value) { + this.categories = value; + } + + /** + * Gets Enable Always Delete value for Always Delete action + * + * @return enableAlwaysDelete + */ + protected boolean getEnableAlwaysDelete() { + return this.enableAlwaysDelete; + } + + /** + * Sets Enable Always Delete value for Always Delete action + */ + public void setEnableAlwaysDelete(boolean value) { + this.enableAlwaysDelete = value; + } + + /** + * IsRead + * + * @return isRead + */ + protected Boolean getIsRead() { + return this.isRead; + } + + /** + * IsRead + */ + public void setIsRead(Boolean value) { + this.isRead = value; + } + + /** + * DeleteType + * + * @return deleteType + */ + protected DeleteMode getDeleteType() { + return this.deleteType; + } + + /** + * DeleteType + */ + public void setDeleteType(DeleteMode value) { + this.deleteType = value; + } + + /** + * ConversationLastSyncTime is used in one + * time action to determine the item + * on which to take the action. + * + * @return conversationLastSyncTime + */ + protected LocalDateTime getConversationLastSyncTime() { + return this.conversationLastSyncTime; + } + + /** + * ConversationLastSyncTime is used in + * one time action to determine the item + * on which to take the action. + */ + public void setConversationLastSyncTime(LocalDateTime value) { + this.conversationLastSyncTime = value; + } + + /** + * Gets folder id ContextFolder + * + * @return contextFolderId + */ + protected FolderIdWrapper getContextFolderId() { + return this.contextFolderId; + } + + /** + * Sets folder id ContextFolder + */ + public void setContextFolderId(FolderIdWrapper value) { + this.contextFolderId = value; + } + + /** + * Gets folder id for Move action + * + * @return moveFolderId + */ + protected FolderIdWrapper getDestinationFolderId() { + return this.moveFolderId; + } + + /** + * Sets folder id for Move action + */ + public void setDestinationFolderId(FolderIdWrapper value) { + this.moveFolderId = value; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + protected String getXmlElementName() { + return XmlElementNames.ApplyConversationAction; + } + + /** + * Validate request. + */ + public void validate() throws Exception { + EwsUtilities.validateParam(this.conversationId, "conversationId"); + } + + /** + * Writes XML elements. + * + * @param writer The writer. + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) + throws Exception { + writer.writeStartElement( + XmlNamespace.Types, + XmlElementNames.ConversationAction); + try { + String actionValue = null; + if (this.getAction() == ConversationActionType.AlwaysCategorize) { + actionValue = XmlElementNames.AlwaysCategorize; + } else if (this.getAction() == ConversationActionType.AlwaysDelete) { + actionValue = XmlElementNames.AlwaysDelete; + } else if (this.getAction() == ConversationActionType.AlwaysMove) { + actionValue = XmlElementNames.AlwaysMove; + } else if (this.getAction() == ConversationActionType.Delete) { + actionValue = XmlElementNames.Delete; + } else if (this.getAction() == ConversationActionType.Copy) { + actionValue = XmlElementNames.Copy; + } else if (this.getAction() == ConversationActionType.Move) { + actionValue = XmlElementNames.Move; + } else if (this.getAction() == ConversationActionType.SetReadState) { + actionValue = XmlElementNames.SetReadState; + } else { + throw new ArgumentException("ConversationAction"); + } + + // Emit the action element + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.Action, + actionValue); + + // Emit the conversation id element + this.getConversationId().writeToXml( + writer, + XmlNamespace.Types, + XmlElementNames.ConversationId); + + if (this.getAction() == ConversationActionType.AlwaysCategorize || + this.getAction() == ConversationActionType.AlwaysDelete || + this.getAction() == ConversationActionType.AlwaysMove) { + // Emit the ProcessRightAway element + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.ProcessRightAway, + EwsUtilities.boolToXSBool(this.getProcessRightAway())); + } + + if (this.getAction() == ConversationActionType.AlwaysCategorize) { + // Emit the categories element + if (this.getCategories() != null && this.getCategories().getSize() > 0) { + this.getCategories().writeToXml( + writer, + XmlNamespace.Types, + XmlElementNames.Categories); + } + } else if (this.getAction() == ConversationActionType.AlwaysDelete) { + // Emit the EnableAlwaysDelete element + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.EnableAlwaysDelete, + EwsUtilities.boolToXSBool(this. + getEnableAlwaysDelete())); + } else if (this.getAction() == ConversationActionType.AlwaysMove) { + // Emit the Move Folder Id + if (this.getDestinationFolderId() != null) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.DestinationFolderId); + this.getDestinationFolderId().writeToXml(writer); + writer.writeEndElement(); + } + } else { + if (this.getContextFolderId() != null) { + writer.writeStartElement( + XmlNamespace.Types, + XmlElementNames.ContextFolderId); + + this.getContextFolderId().writeToXml(writer); + + writer.writeEndElement(); + } + + if (this.getConversationLastSyncTime() != null) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.ConversationLastSyncTime, + this.getConversationLastSyncTime()); + } + + if (this.getAction() == ConversationActionType.Copy) { + EwsUtilities.ewsAssert(this.getDestinationFolderId() != null, + "ApplyconversationActionRequest", + "DestinationFolderId should be set when performing copy action"); + + writer.writeStartElement( + XmlNamespace.Types, + XmlElementNames.DestinationFolderId); + this.getDestinationFolderId().writeToXml(writer); + writer.writeEndElement(); + } else if (this.getAction() == ConversationActionType.Move) { + EwsUtilities.ewsAssert(this.getDestinationFolderId() != null, + "ApplyconversationActionRequest", + "DestinationFolderId should be set when performing move action"); + + writer.writeStartElement( + XmlNamespace.Types, + XmlElementNames.DestinationFolderId); + this.getDestinationFolderId().writeToXml(writer); + writer.writeEndElement(); + } else if (this.getAction() == ConversationActionType.Delete) { + EwsUtilities.ewsAssert(this.getDeleteType() != null, + "ApplyconversationActionRequest", + "DeleteType should be specified when deleting a conversation."); + + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.DeleteType, + this.getDeleteType()); + } else if (this.getAction() == ConversationActionType.SetReadState) { + EwsUtilities.ewsAssert(this.getIsRead() != null, + "ApplyconversationActionRequest", + "IsRead should be specified when marking/unmarking a conversation as read."); + + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsRead, + this.getIsRead()); + } + } + } catch (Exception e) { + LOG.log(Level.SEVERE, "error writing XML", e); + } finally { + writer.writeEndElement(); + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/DelegateInformation.java b/ews-api/src/main/java/com/eischet/ews/api/misc/DelegateInformation.java new file mode 100644 index 000000000..6bc98331b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/DelegateInformation.java @@ -0,0 +1,81 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.enumeration.service.MeetingRequestsDeliveryScope; +import com.eischet.ews.api.core.response.DelegateUserResponse; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Represents the results of a GetDelegates operation. + */ +public final class DelegateInformation { + + /** + * The delegate user response. + */ + private final Collection delegateUserResponses; + + /** + * The meeting reqests delivery scope. + */ + private final MeetingRequestsDeliveryScope meetingReqestsDeliveryScope; + + /** + * Initializes a DelegateInformation object. + * + * @param delegateUserResponses the delegate user response + * @param meetingReqestsDeliveryScope the meeting reqests delivery scope + */ + public DelegateInformation(List delegateUserResponses, + MeetingRequestsDeliveryScope meetingReqestsDeliveryScope) { + this.delegateUserResponses = new ArrayList( + delegateUserResponses); + this.meetingReqestsDeliveryScope = meetingReqestsDeliveryScope; + } + + /** + * Gets a list of response for each of the delegate users concerned by the + * operation. + * + * @return the delegate user response + */ + public Collection getDelegateUserResponses() { + return delegateUserResponses; + } + + /** + * Gets a value indicating if and how meeting request are delivered to + * delegates. + * + * @return the meeting reqests delivery scope + */ + public MeetingRequestsDeliveryScope getMeetingReqestsDeliveryScope() { + return meetingReqestsDeliveryScope; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/EwsTraceListener.java b/ews-api/src/main/java/com/eischet/ews/api/misc/EwsTraceListener.java new file mode 100644 index 000000000..17f4558ce --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/EwsTraceListener.java @@ -0,0 +1,50 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + + +import java.util.logging.Logger; + +/** + * EwsTraceListener logs request/response. + */ +public class EwsTraceListener implements ITraceListener { + + private final Logger log = Logger.getLogger(EwsTraceListener.class.getCanonicalName()); + + public EwsTraceListener() { + } + + /** + * Handles a trace message. + * + * @param traceType The trace type + * @param traceMessage The trace message + */ + @Override + public void trace(String traceType, String traceMessage) { + log.finest(() -> traceType + " - " + traceMessage); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/ExpandGroupResults.java b/ews-api/src/main/java/com/eischet/ews/api/misc/ExpandGroupResults.java new file mode 100644 index 000000000..d5817020a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/ExpandGroupResults.java @@ -0,0 +1,130 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.property.complex.EmailAddress; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; + +/** + * Represents the results of an ExpandGroup operation. + */ +public final class ExpandGroupResults implements Iterable { + + /** + * True, if all members are returned. EWS always returns true on ExpandDL, + * i.e. all members are returned. + */ + private boolean includesAllMembers; + + /** + * DL members. + */ + private final Collection members = new ArrayList(); + + /** + * Initializes a new instance of the class. + */ + public ExpandGroupResults() { + } + + /** + * Gets the number of members that were returned by the ExpandGroup + * operation. Count might be less than the total number of members in the + * group, in which case the value of the IncludesAllMembers is false. + * + * @return the count + */ + public int getCount() { + return this.getMembers().size(); + } + + /** + * Gets a value indicating whether all the members of the group have been + * returned by ExpandGroup. + * + * @return the includes all members + */ + public boolean getIncludesAllMembers() { + return this.includesAllMembers; + } + + /** + * Gets the members of the expanded group. + * + * @return the members + */ + public Collection getMembers() { + return this.members; + } + + /** + * Gets the members of the expanded group. + * + * @param reader the reader + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader) throws Exception { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.DLExpansion); + if (!reader.isEmptyElement()) { + int totalItemsInView = reader.readAttributeValue(Integer.class, + XmlAttributeNames.TotalItemsInView); + this.includesAllMembers = reader.readAttributeValue(Boolean.class, + XmlAttributeNames.IncludesLastItemInRange); + + for (int i = 0; i < totalItemsInView; i++) { + EmailAddress emailAddress = new EmailAddress(); + + reader.readStartElement(XmlNamespace.Types, + XmlElementNames.Mailbox); + emailAddress.loadFromXml(reader, XmlElementNames.Mailbox); + + this.getMembers().add(emailAddress); + } + + reader.readEndElement(XmlNamespace.Messages, + XmlElementNames.DLExpansion); + } else { + reader.read(); + } + } + + /** + * Returns an iterator over a set of elements of type T. + * + * @return an Iterator. + */ + @Override + public Iterator iterator() { + + return members.iterator(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/FolderIdWrapper.java b/ews-api/src/main/java/com/eischet/ews/api/misc/FolderIdWrapper.java new file mode 100644 index 000000000..4bc155d35 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/FolderIdWrapper.java @@ -0,0 +1,73 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.property.complex.FolderId; + +/** + * Represents a folder Id provided by a FolderId object. + */ +public class FolderIdWrapper extends AbstractFolderIdWrapper { + + /** + * The FolderId object providing the Id. + */ + private final FolderId folderId; + + /** + * Initializes a new instance of FolderIdWrapper. + * + * @param folderId the folder id + */ + public FolderIdWrapper(FolderId folderId) { + EwsUtilities.ewsAssert(folderId != null, "FolderIdWrapper.ctor", "folderId is null"); + this.folderId = folderId; + } + + /** + * Writes the Id encapsulated in the wrapper to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer) + throws Exception { + this.folderId.writeToXml(writer); + } + + /** + * Validates folderId against specified version. + * + * @param version the version + * @throws ServiceVersionException the service version exception + */ + protected void validate(ExchangeVersion version) + throws ServiceVersionException { + this.folderId.validate(version); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/FolderIdWrapperList.java b/ews-api/src/main/java/com/eischet/ews/api/misc/FolderIdWrapperList.java new file mode 100644 index 000000000..6219857a5 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/FolderIdWrapperList.java @@ -0,0 +1,159 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.folder.Folder; +import com.eischet.ews.api.property.complex.FolderId; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Represents a list a abstracted folder Ids. + */ +public class FolderIdWrapperList implements Iterable { + + /** + * The ids. + */ + private final List ids = new + ArrayList(); + + /** + * Adds the specified folder. + * + * @param folder the folder + * @throws ServiceLocalException the service local exception + */ + public void add(Folder folder) throws ExchangeXmlException { + this.ids.add(new FolderWrapper(folder)); + } + + /** + * Adds the range. + * + * @param folders the folder + */ + protected void addRangeFolder(Iterable folders) throws ExchangeXmlException { + if (folders != null) { + for (Folder folder : folders) { + this.add(folder); + } + } + } + + /** + * Adds the specified folder id. + * + * @param folderId the folder id + */ + public void add(FolderId folderId) { + this.ids.add(new FolderIdWrapper(folderId)); + } + + /** + * Adds the range of folder ids. + * + * @param folderIds the folder ids + */ + public void addRangeFolderId(Iterable folderIds) { + if (folderIds != null) { + for (FolderId folderId : folderIds) { + this.add(folderId); + } + } + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param ewsNamesapce the ews namesapce + * @param xmlElementName the xml element name + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer, XmlNamespace ewsNamesapce, String xmlElementName) throws Exception { + if (this.getCount() > 0) { + writer.writeStartElement(ewsNamesapce, xmlElementName); + + for (AbstractFolderIdWrapper folderIdWrapper : this.ids) { + folderIdWrapper.writeToXml(writer); + } + + writer.writeEndElement(); + } + } + + /** + * Gets the id count. + * + * @return the count + */ + public int getCount() { + return this.ids.size(); + } + + /** + * Gets the at + * the specified index. + * + * @param i the i + * @return the index + */ + public AbstractFolderIdWrapper getFolderIdWrapperList(int i) { + return this.ids.get(i); + } + + /** + * Validates list of folderIds against a specified request version. + * + * @param version the version + * @throws ServiceVersionException the service version exception + */ + public void validate(ExchangeVersion version) + throws ServiceVersionException { + for (AbstractFolderIdWrapper folderIdWrapper : this.ids) { + folderIdWrapper.validate(version); + } + } + + /* + * (non-Javadoc) + * + * @see java.lang.Iterable#iterator() + */ + @Override + public Iterator iterator() { + return ids.iterator(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/FolderWrapper.java b/ews-api/src/main/java/com/eischet/ews/api/misc/FolderWrapper.java new file mode 100644 index 000000000..2ba56fe60 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/FolderWrapper.java @@ -0,0 +1,71 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.folder.Folder; + +/** + * Represents a folder Id provided by a Folder object. + */ +class FolderWrapper extends AbstractFolderIdWrapper { + + /** + * The Folder object providing the Id. + */ + private final Folder folder; + + /** + * Initializes a new instance of FolderWrapper. + * + * @param folder the folder + */ + protected FolderWrapper(Folder folder) throws ExchangeXmlException { + EwsUtilities.ewsAssert(folder != null, "FolderWrapper.ctor", "folder is null"); + EwsUtilities.ewsAssert(!folder.isNew(), "FolderWrapper.ctor", "folder does not have an Id"); + this.folder = folder; + } + + /** + * Obtains the Folder object associated with the wrapper. + * + * @return The Folder object associated with the wrapper + */ + public Folder getFolder() { + return this.folder; + } + + /** + * Writes the Id encapsulated in the wrapper to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { + this.folder.getId().writeToXml(writer); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/HangingTraceStream.java b/ews-api/src/main/java/com/eischet/ews/api/misc/HangingTraceStream.java new file mode 100644 index 000000000..249fcbd6f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/HangingTraceStream.java @@ -0,0 +1,154 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.misc.TraceFlags; +import com.eischet.ews.api.core.request.HangingServiceRequestBase; + +import javax.xml.stream.XMLStreamException; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * A stream that traces everything it returns from its Read() call. + * That trace may be retrieved at the end of the stream. + */ +public class HangingTraceStream extends InputStream { + + private static final Logger LOG = Logger.getLogger(HangingTraceStream.class.getCanonicalName()); + + private final InputStream underlyingStream; + private final ExchangeService service; + private ByteArrayOutputStream responseCopy; + + /** + * Initializes a new instance of the HangingTraceStream class. + * + * @param stream The stream. + * @param service the service. + */ + public HangingTraceStream(final InputStream stream, final ExchangeService service) { + this.underlyingStream = stream; + this.service = service; + } + + /** + * Gets a value indicating whether the current stream supports reading. + * + * @return true + */ + public boolean getCanRead() { + return true; + } + + /** + * Gets a value indicating whether the current stream supports seeking. + * + * @return false + */ + public boolean getCanSeek() { + return false; + } + + /** + * Gets a value indicating whether the current stream supports writing. + * + * @return false + */ + public boolean getCanWrite() { + return false; + } + + /** + * When overridden in a derived class, clears all buffers + * for this stream and causes any buffered data to be + * written to the underlying device. + *@exception An I/O error occurs. + */ + /* + * @Override public void close() { // no-op } + */ + + /** + * When overridden in a derived class, reads a sequence of + * bytes from the current stream and advances the + * position within the stream by the number of bytes read. + * + * @param buffer An array of bytes. When this method returns, the buffer + * contains the specified byte array with the values between + * @param offset The zero-based byte offset in at which to + * begin storing the data read from the current stream. + * @param count The maximum number of bytes to be read from the current stream. + * @return The total number of bytes read into the buffer. + * This can be less than the number of bytes requested if that + * many bytes are not currently available, or zero (0) + * if the end of the stream has been reached. + * @throws IOException The sum of offset and count is larger than the buffer length. + */ + @Override + public int read(byte[] buffer, int offset, int count) throws IOException { + count = HangingServiceRequestBase.BUFFER_SIZE; + final int retVal = underlyingStream.read(buffer, offset, count); + + if (HangingServiceRequestBase.isLogAllWireBytes()) { + final String readString = new String(buffer, offset, count, StandardCharsets.UTF_8); + final String logMessage = String.format( + "HangingTraceStream ID [%d] returned %d bytes. Bytes returned: [%s]", + hashCode(), retVal, readString); + + try { + service.traceMessage(TraceFlags.DebugMessage, logMessage); + } catch (final XMLStreamException e) { + LOG.log(Level.SEVERE, "error reading XML", e); + } + } + + if (responseCopy != null) { + responseCopy.write(buffer, offset, retVal); + } + + return retVal; + } + + /** + * Sets the response copy. + * + * @param responseCopy a copy of response + */ + public void setResponseCopy(final ByteArrayOutputStream responseCopy) { + this.responseCopy = responseCopy; + } + + @Override + public int read() throws IOException { + return 0; + } + +} + diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/IAsyncResult.java b/ews-api/src/main/java/com/eischet/ews/api/misc/IAsyncResult.java similarity index 82% rename from src/main/java/microsoft/exchange/webservices/data/misc/IAsyncResult.java rename to ews-api/src/main/java/com/eischet/ews/api/misc/IAsyncResult.java index 27499621e..26e8c7a41 100644 --- a/src/main/java/microsoft/exchange/webservices/data/misc/IAsyncResult.java +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/IAsyncResult.java @@ -21,9 +21,9 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.misc; +package com.eischet.ews.api.misc; -import microsoft.exchange.webservices.data.core.request.WaitHandle; +import com.eischet.ews.api.core.request.WaitHandle; import java.util.concurrent.Future; @@ -33,11 +33,11 @@ public interface IAsyncResult extends Future { - public Object getAsyncState(); + Object getAsyncState(); - public WaitHandle getAsyncWaitHanle(); + WaitHandle getAsyncWaitHanle(); - public boolean getCompleteSynchronously(); + boolean getCompleteSynchronously(); - public boolean getIsCompleted(); + boolean getIsCompleted(); } diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/IFunction.java b/ews-api/src/main/java/com/eischet/ews/api/misc/IFunction.java similarity index 88% rename from src/main/java/microsoft/exchange/webservices/data/misc/IFunction.java rename to ews-api/src/main/java/com/eischet/ews/api/misc/IFunction.java index b4216b153..7b5484513 100644 --- a/src/main/java/microsoft/exchange/webservices/data/misc/IFunction.java +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/IFunction.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.misc; +package com.eischet.ews.api.misc; /** * The Interface FuncInterface. @@ -29,13 +29,14 @@ * @param the generic type * @param the generic type */ +@FunctionalInterface public interface IFunction { - /** - * Func. - * - * @param arg the arg - * @return the t result - */ - TResult func(T arg); + /** + * Func. + * + * @param arg the arg + * @return the t result + */ + TResult func(T arg); } diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/IFunctions.java b/ews-api/src/main/java/com/eischet/ews/api/misc/IFunctions.java new file mode 100644 index 000000000..42b7d419a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/IFunctions.java @@ -0,0 +1,106 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsUtilities; + +import java.time.LocalDateTime; +import java.util.Base64; +import java.util.UUID; + +/** + * Class with re-usable function implementations. + */ + +public final class IFunctions { + + private IFunctions() { + throw new UnsupportedOperationException(); + } + + public static class ToString implements IFunction { + public static final ToString INSTANCE = new ToString(); + + public String func(final Object o) { + return String.valueOf(o); + } + } + + public static class ToBoolean implements IFunction { + public static final ToBoolean INSTANCE = new ToBoolean(); + + public Boolean func(final String s) { + return Boolean.parseBoolean(s); + } + } + + public static class StringToObject implements IFunction { + public static final StringToObject INSTANCE = new StringToObject(); + + public Object func(final String o) { + return o; + } + } + + public static class ToUUID implements IFunction { + public static final ToUUID INSTANCE = new ToUUID(); + + public Object func(final String s) { + return UUID.fromString(s); + } + } + + public static class Base64Decoder implements IFunction { + public static final Base64Decoder INSTANCE = new Base64Decoder(); + + public Object func(final String s) { + return Base64.getMimeDecoder().decode(s); + } + } + + public static class Base64Encoder implements IFunction { + public static final Base64Encoder INSTANCE = new Base64Encoder(); + + public String func(final Object o) { + return Base64.getMimeEncoder().encodeToString((byte[]) o); + } + } + + public static class ToLowerCase implements IFunction { + public static final ToLowerCase INSTANCE = new ToLowerCase(); + + public String func(final Object o) { + return o == null ? null : o.toString().toLowerCase(); + } + } + + public static class DateTimeToXSDateTime implements IFunction { + public static final DateTimeToXSDateTime INSTANCE = new DateTimeToXSDateTime(); + + public String func(final Object o) { + return EwsUtilities.dateTimeToXSDateTime((LocalDateTime) o); + } + } + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/ITraceListener.java b/ews-api/src/main/java/com/eischet/ews/api/misc/ITraceListener.java similarity index 82% rename from src/main/java/microsoft/exchange/webservices/data/misc/ITraceListener.java rename to ews-api/src/main/java/com/eischet/ews/api/misc/ITraceListener.java index 390df929c..6b351be79 100644 --- a/src/main/java/microsoft/exchange/webservices/data/misc/ITraceListener.java +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/ITraceListener.java @@ -21,19 +21,20 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.misc; +package com.eischet.ews.api.misc; /** * ITraceListener handles message tracing. */ +@FunctionalInterface public interface ITraceListener { - /** - * Handles a trace message. - * - * @param traceType Type of trace message. - * @param traceMessage The trace message. - */ - void trace(String traceType, String traceMessage); + /** + * Handles a trace message. + * + * @param traceType Type of trace message. + * @param traceMessage The trace message. + */ + void trace(String traceType, String traceMessage); } diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/ImpersonatedUserId.java b/ews-api/src/main/java/com/eischet/ews/api/misc/ImpersonatedUserId.java new file mode 100644 index 000000000..f65bb564c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/ImpersonatedUserId.java @@ -0,0 +1,132 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ConnectingIdType; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; + +/** + * Represents an impersonated user Id. + */ +public final class ImpersonatedUserId { + + /** + * The id type. + */ + private ConnectingIdType idType; + + /** + * The id. + */ + private String id; + + /** + * Instantiates a new impersonated user id. + */ + public ImpersonatedUserId() { + } + + /** + * Initializes a new instance of ConnectingId. + * + * @param idType The type of this Id. + * @param id The user Id. + */ + public ImpersonatedUserId(ConnectingIdType idType, String id) { + this(); + this.idType = idType; + this.id = id; + } + + /** + * Writes to XML. + * + * @param writer The writer + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer) throws Exception { + if (this.id == null || this.id.isEmpty()) { + throw new Exception("The Id property must be set."); + } + + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.ExchangeImpersonation); + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.ConnectingSID); + + // For 2007 SP1, use PrimarySmtpAddress for type SmtpAddress + String connectingIdTypeLocalName = (this.idType == + ConnectingIdType.SmtpAddress) && + (writer.getService().getRequestedServerVersion() == + ExchangeVersion.Exchange2007_SP1) ? + XmlElementNames.PrimarySmtpAddress : + this.getIdType().toString(); + + writer.writeElementValue(XmlNamespace.Types, connectingIdTypeLocalName, + this.id); + + writer.writeEndElement(); // ConnectingSID + writer.writeEndElement(); // ExchangeImpersonation + } + + /** + * Gets the type of the Id. + * + * @return the id type + */ + public ConnectingIdType getIdType() { + return idType; + } + + /** + * Sets the id type. + * + * @param idType the new id type + */ + public void setIdType(ConnectingIdType idType) { + this.idType = idType; + } + + /** + * Gets the user Id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets the id. + * + * @param id the new id + */ + public void setId(String id) { + this.id = id; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/ItemIdWrapper.java b/ews-api/src/main/java/com/eischet/ews/api/misc/ItemIdWrapper.java new file mode 100644 index 000000000..2f8acdae8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/ItemIdWrapper.java @@ -0,0 +1,61 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.property.complex.ItemId; + +/** + * Represents an item Id provided by a ItemId object. + */ +class ItemIdWrapper extends AbstractItemIdWrapper { + + /** + * The ItemId object providing the Id. + */ + private final ItemId itemId; + + /** + * Initializes a new instance of ItemIdWrapper. + * + * @param itemId the item id + */ + protected ItemIdWrapper(ItemId itemId) { + EwsUtilities.ewsAssert(itemId != null, "ItemIdWrapper.ctor", "itemId is null"); + this.itemId = itemId; + } + + /** + * Writes the Id encapsulated in the wrapper to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { + this.itemId.writeToXml(writer); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/ItemIdWrapperList.java b/ews-api/src/main/java/com/eischet/ews/api/misc/ItemIdWrapperList.java new file mode 100644 index 000000000..43340efe2 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/ItemIdWrapperList.java @@ -0,0 +1,146 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.property.complex.ItemId; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Represents a list a abstracted item Ids. + */ +public class ItemIdWrapperList implements Iterable { + + /** + * The item ids. + */ + private final List itemIds = + new ArrayList(); + + /** + * Initializes a new instance of the class. + */ + public ItemIdWrapperList() { + } + + /** + * Adds the specified item. + * + * @param item the item + * @throws ServiceLocalException the service local exception + */ + protected void add(Item item) throws ExchangeXmlException { + this.itemIds.add(new ItemWrapper(item)); + + } + + /** + * Adds the specified item. + * + * @param items the item + */ + public void addRangeItem(Iterable items) throws ExchangeXmlException { + for (Item item : items) { + this.add(item); + } + } + + /** + * Adds the range. + * + * @param itemIds the item ids + */ + public void addRange(Iterable itemIds) { + for (ItemId itemId : itemIds) { + this.add(itemId); + } + } + + /** + * Adds the specified item id. + * + * @param itemId the item id + */ + protected void add(ItemId itemId) { + this.itemIds.add(new ItemIdWrapper(itemId)); + + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param ewsNamesapce the ews namesapce + * @param xmlElementName the xml element name + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer, XmlNamespace ewsNamesapce, String xmlElementName) throws Exception { + if (this.getCount() > 0) { + writer.writeStartElement(ewsNamesapce, xmlElementName); + + for (AbstractItemIdWrapper itemIdWrapper : this.itemIds) { + itemIdWrapper.writeToXml(writer); + } + + writer.writeEndElement(); + } + } + + /** + * Gets the count. + * + * @return the count + */ + public int getCount() { + return this.itemIds.size(); + } + + /** + * Gets the item at the specified index. + * + * @param i the i + * @return the item id wrapper list + */ + public Item getItemIdWrapperList(int i) { + return this.itemIds.get(i).getItem(); + } + + /** + * Gets an Iterator that iterates through the elements of the collection. + * + * @return An IEnumerator for the collection + */ + @Override + public Iterator iterator() { + + return itemIds.iterator(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/ItemWrapper.java b/ews-api/src/main/java/com/eischet/ews/api/misc/ItemWrapper.java new file mode 100644 index 000000000..9d63cfe61 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/ItemWrapper.java @@ -0,0 +1,73 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.item.Item; + +/** + * Represents an item Id provided by a ItemBase object. + */ +class ItemWrapper extends AbstractItemIdWrapper { + + /** + * The ItemBase object providing the Id. + */ + private final Item item; + + /** + * Initializes a new instance of ItemWrapper. + * + * @param item the item + */ + protected ItemWrapper(final Item item) throws ExchangeXmlException { + EwsUtilities.ewsAssert(item != null, "ItemWrapper.ctor", "item is null"); + EwsUtilities.ewsAssert(!item.isNew(), "ItemWrapper.ctor", "item does not have an Id"); + this.item = item; + } + + /** + * Obtains the ItemBase object associated with the wrapper. + * + * @return The ItemBase object associated with the wrapper + */ + public Item getItem() { + return this.item; + } + + /** + * Writes the Id encapsulated in the wrapper to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + @Override + protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { + this.item.getId().writeToXml(writer); + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/MapiTypeConverter.java b/ews-api/src/main/java/com/eischet/ews/api/misc/MapiTypeConverter.java new file mode 100644 index 000000000..a5c8e2b20 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/MapiTypeConverter.java @@ -0,0 +1,309 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ILazyMember; +import com.eischet.ews.api.core.LazyMember; +import com.eischet.ews.api.core.enumeration.property.MapiPropertyType; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * Utility class to convert between MAPI Property type values and strings. + */ +public class MapiTypeConverter { + + private static final IFunction DATE_TIME_PARSER = new IFunction() { + public Object func(final String s) { + return parseDateTime(s); + } + }; + + private static final IFunction MAPI_VALUE_PARSER = new IFunction() { + public Object func(final String s) { + return MapiTypeConverter.parseMapiIntegerValue(s); + } + }; + + /** + * The mapi type converter map. + */ + private static final LazyMember MAPI_TYPE_CONVERTER_MAP = + new LazyMember(new ILazyMember() { + @Override + public MapiTypeConverterMap createInstance() { + MapiTypeConverterMap map = new MapiTypeConverterMap(); + + map.put(MapiPropertyType.ApplicationTime, new MapiTypeConverterMapEntry(Double.class)); + + MapiTypeConverterMapEntry mapitype = new MapiTypeConverterMapEntry(Double.class); + mapitype.setIsArray(true); + map.put(MapiPropertyType.ApplicationTimeArray, mapitype); + + mapitype = new MapiTypeConverterMapEntry(Byte[].class); + mapitype.setParse(IFunctions.Base64Decoder.INSTANCE); + mapitype.setConvertToString(IFunctions.Base64Encoder.INSTANCE); + map.put(MapiPropertyType.Binary, mapitype); + + mapitype = new MapiTypeConverterMapEntry(Byte[].class); + mapitype.setParse(IFunctions.Base64Decoder.INSTANCE); + mapitype.setConvertToString(IFunctions.Base64Encoder.INSTANCE); + mapitype.setIsArray(true); + map.put(MapiPropertyType.BinaryArray, mapitype); + + mapitype = new MapiTypeConverterMapEntry(Boolean.class); + mapitype.setParse(IFunctions.ToBoolean.INSTANCE); + mapitype.setConvertToString(IFunctions.ToLowerCase.INSTANCE); + map.put(MapiPropertyType.Boolean, mapitype); + + mapitype = new MapiTypeConverterMapEntry(UUID.class); + mapitype.setParse(IFunctions.ToUUID.INSTANCE); + mapitype.setConvertToString(IFunctions.ToString.INSTANCE); + map.put(MapiPropertyType.CLSID, mapitype); + + mapitype = new MapiTypeConverterMapEntry(UUID.class); + mapitype.setParse(IFunctions.ToUUID.INSTANCE); + mapitype.setConvertToString(IFunctions.ToString.INSTANCE); + mapitype.setIsArray(true); + map.put(MapiPropertyType.CLSIDArray, mapitype); + + map.put(MapiPropertyType.Currency, new MapiTypeConverterMapEntry(Long.class)); + + mapitype = new MapiTypeConverterMapEntry(Long.class); + mapitype.setIsArray(true); + map.put(MapiPropertyType.CurrencyArray, mapitype); + + map.put(MapiPropertyType.Double, new MapiTypeConverterMapEntry(Double.class)); + + mapitype = new MapiTypeConverterMapEntry(Double.class); + mapitype.setIsArray(true); + map.put(MapiPropertyType.DoubleArray, mapitype); + + map.put(MapiPropertyType.Error, new MapiTypeConverterMapEntry(Integer.class)); + map.put(MapiPropertyType.Float, new MapiTypeConverterMapEntry(Float.class)); + + mapitype = new MapiTypeConverterMapEntry(Float.class); + mapitype.setIsArray(true); + map.put(MapiPropertyType.FloatArray, mapitype); + + mapitype = new MapiTypeConverterMapEntry(Integer.class); + mapitype.setParse(MAPI_VALUE_PARSER); + map.put(MapiPropertyType.Integer, mapitype); + + mapitype = new MapiTypeConverterMapEntry(Integer.class); + mapitype.setIsArray(true); + map.put(MapiPropertyType.IntegerArray, mapitype); + + map.put(MapiPropertyType.Long, new MapiTypeConverterMapEntry(Long.class)); + + mapitype = new MapiTypeConverterMapEntry(Long.class); + mapitype.setIsArray(true); + map.put(MapiPropertyType.LongArray, mapitype); + + mapitype = new MapiTypeConverterMapEntry(String.class); + mapitype.setParse(IFunctions.StringToObject.INSTANCE); + map.put(MapiPropertyType.Object, mapitype); + + mapitype = new MapiTypeConverterMapEntry(String.class); + mapitype.setParse(IFunctions.StringToObject.INSTANCE); + mapitype.setIsArray(true); + map.put(MapiPropertyType.ObjectArray, mapitype); + + map.put(MapiPropertyType.Short, new MapiTypeConverterMapEntry(Short.class)); + + mapitype = new MapiTypeConverterMapEntry(Short.class); + mapitype.setIsArray(true); + map.put(MapiPropertyType.ShortArray, mapitype); + + mapitype = new MapiTypeConverterMapEntry(String.class); + mapitype.setParse(IFunctions.StringToObject.INSTANCE); + map.put(MapiPropertyType.String, mapitype); + + mapitype = new MapiTypeConverterMapEntry(String.class); + mapitype.setParse(IFunctions.StringToObject.INSTANCE); + mapitype.setIsArray(true); + map.put(MapiPropertyType.StringArray, mapitype); + + mapitype = new MapiTypeConverterMapEntry(Date.class); + mapitype.setParse(DATE_TIME_PARSER); + mapitype.setConvertToString(IFunctions.DateTimeToXSDateTime.INSTANCE); + map.put(MapiPropertyType.SystemTime, mapitype); + + mapitype = new MapiTypeConverterMapEntry(Date.class); + mapitype.setParse(DATE_TIME_PARSER); + mapitype.setConvertToString(IFunctions.DateTimeToXSDateTime.INSTANCE); + mapitype.setIsArray(true); + map.put(MapiPropertyType.SystemTimeArray, mapitype); + + return map; + } + }); + + + /** + * Converts the string list to array. + * + * @param mapiPropType Type of the MAPI property. + * @param strings the strings + * @return Array of objects. + * @throws Exception the exception + */ + public static List convertToValue(MapiPropertyType mapiPropType, Iterator strings) throws ExchangeXmlException { + EwsUtilities.validateParam(strings, "strings"); + + MapiTypeConverterMapEntry typeConverter = getMapiTypeConverterMap() + .get(mapiPropType); + List array = new ArrayList<>(); + + int index = 0; + + while (strings.hasNext()) { + Object value = typeConverter.convertToValueOrDefault(strings.next()); + array.add(index, value); + } + return array; + } + + /** + * Converts a string to value consistent with MAPI type. + * + * @param mapiPropType the mapi prop type + * @param stringValue the string value + * @return the object + */ + public static Object convertToValue(MapiPropertyType mapiPropType, String stringValue) throws ExchangeXmlException { + return getMapiTypeConverterMap().get(mapiPropType).convertToValue(stringValue); + + } + + /** + * Converts a value to a string. + * + * @param mapiPropType the mapi prop type + * @param value the value + * @return String value. + */ + public static String convertToString(MapiPropertyType mapiPropType, Object value) { + /* + * if(! (value instanceof FuncInterface)){ return null; } + */ + return (value == null) ? "" : getMapiTypeConverterMap().get( + mapiPropType).getConvertToString().func(value); + } + + /** + * Change value to a value of compatible type. + * + * @param mapiType the mapi type + * @param value the value + * @return the object + * @throws Exception the exception + */ + public static Object changeType(MapiPropertyType mapiType, Object value) + throws Exception { + EwsUtilities.validateParam(value, "value"); + + return getMapiTypeConverterMap().get(mapiType).changeType(value); + } + + /** + * Converts a MAPI Integer value. + * Usually the value is an integer but there are cases where the value has been "schematized" to an + * Enumeration value (e.g. NoData) which we have no choice but to fallback and represent as a string. + * + * @param s The string value. + * @return Integer value or the original string if the value could not be parsed as such. + */ + protected static Object parseMapiIntegerValue(String s) { + try { + return Integer.parseInt(s.trim()); + } catch (NumberFormatException e) { + return s; + } + } + + /** + * Determines whether MapiPropertyType is an array type. + * + * @param mapiType the mapi type + * @return true, if is array type + */ + public static boolean isArrayType(MapiPropertyType mapiType) { + return getMapiTypeConverterMap().get(mapiType).getIsArray(); + } + + /** + * Gets the MAPI type converter map. + * + * @return the mapi type converter map + */ + public static Map + getMapiTypeConverterMap() { + + return MAPI_TYPE_CONVERTER_MAP.getMember(); + } + + + private static Object parseDateTime(String s) { + String utcPattern = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + String errMsg = String.format("Date String %s not in " + "valid UTC/local format", s); + DateFormat utcFormatter = new SimpleDateFormat(utcPattern); + Date dt; + + if (s.endsWith("Z")) { + try { + dt = utcFormatter.parse(s); + } catch (ParseException e) { + s = s.substring(0, 10) + "T12:00:00Z"; + try { + dt = utcFormatter.parse(s); + } catch (ParseException e1) { + throw new IllegalArgumentException(errMsg, e); + } + } + } else if (s.endsWith("z")) { + // String in UTC format yyyy-MM-ddTHH:mm:ssZ + utcFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'z'"); + try { + dt = utcFormatter.parse(s); + } catch (ParseException e) { + throw new IllegalArgumentException(e); + } + } else { + utcFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); + try { + dt = utcFormatter.parse(s); + } catch (ParseException e) { + throw new IllegalArgumentException(e); + } + } + return dt; + } + +} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/MapiTypeConverterMap.java b/ews-api/src/main/java/com/eischet/ews/api/misc/MapiTypeConverterMap.java similarity index 80% rename from src/main/java/microsoft/exchange/webservices/data/misc/MapiTypeConverterMap.java rename to ews-api/src/main/java/com/eischet/ews/api/misc/MapiTypeConverterMap.java index 5b1f6bb4b..bfea3a956 100644 --- a/src/main/java/microsoft/exchange/webservices/data/misc/MapiTypeConverterMap.java +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/MapiTypeConverterMap.java @@ -21,9 +21,9 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.misc; +package com.eischet.ews.api.misc; -import microsoft.exchange.webservices.data.core.enumeration.property.MapiPropertyType; +import com.eischet.ews.api.core.enumeration.property.MapiPropertyType; import java.util.HashMap; @@ -31,11 +31,11 @@ * The Class MapiTypeConverterMap. */ public class MapiTypeConverterMap extends - HashMap { + HashMap { - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; } diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/MapiTypeConverterMapEntry.java b/ews-api/src/main/java/com/eischet/ews/api/misc/MapiTypeConverterMapEntry.java new file mode 100644 index 000000000..fc2286f1d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/MapiTypeConverterMapEntry.java @@ -0,0 +1,323 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ILazyMember; +import com.eischet.ews.api.core.LazyMember; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.misc.ArgumentNullException; +import com.eischet.ews.api.core.exception.misc.FormatException; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents an entry in the MapiTypeConverter map. + */ +public class MapiTypeConverterMapEntry { + + private static final Logger LOG = Logger.getLogger(MapiTypeConverterMapEntry.class.getCanonicalName()); + + /** + * Map CLR types used for MAPI property to matching default values. + */ + private static final LazyMember, Object>> defaultValueMap = new LazyMember, Object>>( + new ILazyMember, Object>>() { + public Map, Object> createInstance() { + + Map, Object> map = new HashMap, Object>(); + + map.put(Boolean.class, false); + map.put(Byte[].class, null); + map.put(Short.class, (short) 0); + map.put(Integer.class, 0); + map.put(Long.class, 0L); + map.put(Float.class, 0.0f); + map.put(Double.class, 0.0d); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + map.put(Date.class, formatter.parse("0001-01-01 12:00:00")); + } catch (ParseException e) { + LOG.log(Level.SEVERE, "error parsing the default date", e); + } + map.put(UUID.class, UUID.fromString("00000000-0000-0000-0000-000000000000")); + map.put(String.class, null); + + return map; + + } + }); + /** + * The is array. + */ + boolean isArray; + + /** + * The type. + */ + Class type; + + /** + * The convert to string. + */ + IFunction convertToString; + + /** + * The parse. + */ + IFunction parse; + + /** + * Initializes a new instance of the MapiTypeConverterMapEntry class. + * + * @param type The type. y default, converting a type to string is done by + * calling value.ToString. Instances can override this behavior. + *

+ * By default, converting a string to the appropriate value type + * is done by calling Convert.ChangeType Instances may override + * this behavior. + */ + public MapiTypeConverterMapEntry(Class type) { + EwsUtilities.ewsAssert(defaultValueMap.getMember().containsKey(type), "MapiTypeConverterMapEntry ctor", + "No default value entry for type " + type.getName()); + + this.type = type; + this.convertToString = IFunctions.ToString.INSTANCE; + this.parse = IFunctions.StringToObject.INSTANCE; + } + + /** + * Change value to a value of compatible type. + *

+ * The type of a simple value should match exactly or be convertible to the + * appropriate type. An array value has to be a single dimension (rank), + * contain at least one value and contain elements that exactly match the + * expected type. (We could relax this last requirement so that, for + * example, you could pass an array of Int32 that could be converted to an + * array of Double but that seems like overkill). + * + * @param value The value. + * @return New value. + */ + public Object changeType(Object value) throws ExchangeValidationException { + if (this.getIsArray()) { + this.validateValueAsArray(value); + return value; + } else if (value.getClass() == this.getType()) { + return value; + } else { + try { + if (this.getType().isInstance(Integer.valueOf(0))) { + Object o = null; + o = Integer.parseInt(value + ""); + return o; + } else if (this.getType().isInstance(new Date())) { + DateFormat df = new SimpleDateFormat( + "yyyy-MM-dd'T'HH:mm:ss'Z'"); + try { + return df.parse(value + ""); + } catch (ParseException e) { + throw new ExchangeValidationException("error parsing as date value: " + value, e); + } + } else if (this.getType().isInstance(Boolean.valueOf(false))) { + Object o = null; + o = Boolean.parseBoolean(value + ""); + return o; + } else if (this.getType().isInstance(String.class)) { + return value; + } + return null; + } catch (ClassCastException ex) { + throw new ArgumentException(String.format( + "The value '%s' of type %s can't be converted to a value of type %s.", "%s", "%s" + , this.getType()), ex); + } + } + } + + /** + * Converts a string to value consistent with type. + *

+ * For array types, this method is called for each array element. + * + * @param stringValue String to convert to a value. + * @return value + * @throws ServiceXmlDeserializationException the service xml deserialization exception + * @throws FormatException the format exception + */ + public Object convertToValue(String stringValue) throws ExchangeXmlException { + try { + return this.getParse().func(stringValue); + } catch (ClassCastException | NumberFormatException ex) { + throw new ExchangeXmlException(String.format("The value '%s' couldn't be converted to type %s.", stringValue, this.getType()), ex); + } + + } + + /** + * Converts a string to value consistent with type (or uses the default value if the string is null or empty). + * + * @param stringValue to convert to a value. + * @return Value. + */ + public Object convertToValueOrDefault(final String stringValue) throws ExchangeXmlException { + return (stringValue != null && !stringValue.isEmpty()) + ? getDefaultValue() : convertToValue(stringValue); + } + + /** + * Validates array value. + * + * @param value the value + * @throws ArgumentException the argument exception + * @throws ArgumentNullException the argument exception + */ + private void validateValueAsArray(Object value) throws ArgumentException, ArgumentNullException { + if (value == null) { + throw new ArgumentNullException("value"); + } + + if (value instanceof ArrayList) { + ArrayList arrayList = (ArrayList) value; + if (arrayList.isEmpty()) { + throw new ArgumentException("The Array value must have at least one element."); + } + + if (arrayList.get(0).getClass() != this.getType()) { + throw new ArgumentException(String.format("Type %s can't be used as an array of type %s.", value.getClass(), + this.getType())); + } + } + } + + /** + * Gets the dim. If `array' is an array object returns its dimensions; + * otherwise returns 0 + * + * @param array the array + * @return the dim + */ + public static int getDim(Object array) { + int dim = 0; + Class cls = array.getClass(); + while (cls.isArray()) { + dim++; + cls = cls.getComponentType(); + } + return dim; + } + + /** + * Gets the type. + * + * @return the type + */ + + public Class getType() { + return this.type; + } + + /** + * Sets the type. + * + * @param cls the new type + */ + public void setType(Class cls) { + type = cls; + } + + /** + * Gets a value indicating whether this instance is array. + * + * @return the checks if is array + */ + public boolean getIsArray() { + return isArray; + + } + + /** + * Sets the checks if is array. + * + * @param value the new checks if is array + */ + protected void setIsArray(boolean value) { + isArray = value; + } + + /** + * Gets the string to object converter. For array types, this method is + * called for each array element. + * + * @return the convert to string + */ + protected IFunction getConvertToString() { + return convertToString; + } + + /** + * Sets the string to object converter. + * + * @param value the value + */ + protected void setConvertToString(IFunction value) { + convertToString = value; + } + + /** + * Gets the string parser. For array types, this method is called for each + * array element. + * + * @return the parses the + */ + protected IFunction getParse() { + return parse; + } + + /** + * Sets the string parser. + * + * @param value the value + */ + protected void setParse(IFunction value) { + parse = value; + } + + /** + * Gets the default value for the type. + * + * @return Type + */ + protected Object getDefaultValue() { + return defaultValueMap.getMember().get(this.type); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/MobilePhone.java b/ews-api/src/main/java/com/eischet/ews/api/misc/MobilePhone.java new file mode 100644 index 000000000..af3a26fa3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/MobilePhone.java @@ -0,0 +1,93 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.ISelfValidate; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; + +/** + * Represents a mobile phone. + */ +public final class MobilePhone implements ISelfValidate { + + /** + * Name of the mobile phone. + */ + private String name; + + /** + * Phone number of the mobile phone. + */ + private String phoneNumber; + + public MobilePhone() { + } + + /** + * Initializes a new instance of the MobilePhone class. + * + * @param name The name associated with the mobile phone. + * @param phoneNumber The mobile phone number. + */ + public MobilePhone(String name, String phoneNumber) { + this.name = name; + this.phoneNumber = phoneNumber; + } + + /** + * Gets or sets the name associated with this mobile phone. + */ + public String getName() { + return this.name; + } + + public void setName(String value) { + this.name = value; + } + + + /** + * Gets or sets the number of this mobile phone. + */ + public String getPhoneNumber() { + return this.phoneNumber; + } + + public void setPhoneNumber(String value) { + this.phoneNumber = value; + } + + + /** + * Validates this instance. + * + * @throws ExchangeValidationException on validation error + */ + public void validate() throws ExchangeValidationException { + if (this.getPhoneNumber() == null || this.getPhoneNumber().isEmpty()) { + throw new ExchangeValidationException( + "PhoneNumber cannot be empty."); + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/NameResolution.java b/ews-api/src/main/java/com/eischet/ews/api/misc/NameResolution.java new file mode 100644 index 000000000..86830b1ff --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/NameResolution.java @@ -0,0 +1,110 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.service.item.Contact; +import com.eischet.ews.api.property.complex.EmailAddress; + +/** + * Represents a suggested name resolution. + */ +public final class NameResolution { + + /** + * The owner. + */ + private final NameResolutionCollection owner; + + /** + * The mailbox. + */ + private final EmailAddress mailbox = new EmailAddress(); + + /** + * The contact. + */ + private Contact contact; + + /** + * Initializes a new instance of the class. + * + * @param owner the owner + */ + protected NameResolution(NameResolutionCollection owner) { + EwsUtilities.ewsAssert(owner != null, "NameResolution.ctor", "owner is null."); + + this.owner = owner; + } + + /** + * Loads from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + protected void loadFromXml(EwsServiceXmlReader reader) throws Exception { + reader.readStartElement(XmlNamespace.Types, XmlElementNames.Resolution); + reader.readStartElement(XmlNamespace.Types, XmlElementNames.Mailbox); + this.mailbox.loadFromXml(reader, XmlElementNames.Mailbox); + + reader.read(); + if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.Contact)) { + this.contact = new Contact(this.owner.getSession()); + this.contact.loadFromXml(reader, true /* clearPropertyBag */, + PropertySet.FirstClassProperties, + false /* summaryPropertiesOnly */); + + reader.readEndElement(XmlNamespace.Types, + XmlElementNames.Resolution); + } else { + reader.ensureCurrentNodeIsEndElement(XmlNamespace.Types, + XmlElementNames.Resolution); + } + } + + /** + * Gets the mailbox of the suggested resolved name. + * + * @return the mailbox + */ + public EmailAddress getMailbox() { + return this.mailbox; + } + + /** + * Gets the contact information of the suggested resolved name. This + * property is only available when ResolveName is called with + * returnContactDetails = true. + * + * @return the contact + */ + public Contact getContact() { + return this.contact; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/NameResolutionCollection.java b/ews-api/src/main/java/com/eischet/ews/api/misc/NameResolutionCollection.java new file mode 100644 index 000000000..9b7610915 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/NameResolutionCollection.java @@ -0,0 +1,146 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.misc.ArgumentOutOfRangeException; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Represents a list of suggested name resolutions. + */ +public final class NameResolutionCollection implements + Iterable { + + /** + * The service. + */ + private final ExchangeService service; + + /** + * The includes all resolutions. + */ + private boolean includesAllResolutions; + + /** + * The item. + */ + private final List items = new ArrayList(); + + /** + * Represents a list of suggested name resolutions. + * + * @param service the service + */ + public NameResolutionCollection(ExchangeService service) { + EwsUtilities.ewsAssert(service != null, "NameResolutionSet.ctor", "service is null."); + this.service = service; + } + + /** + * Loads from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader) throws Exception { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.ResolutionSet); + int totalItemsInView = reader.readAttributeValue(Integer.class, + XmlAttributeNames.TotalItemsInView); + this.includesAllResolutions = reader.readAttributeValue(Boolean.class, + XmlAttributeNames.IncludesLastItemInRange); + + for (int i = 0; i < totalItemsInView; i++) { + NameResolution nameResolution = new NameResolution(this); + nameResolution.loadFromXml(reader); + this.items.add(nameResolution); + } + + reader.readEndElement(XmlNamespace.Messages, + XmlElementNames.ResolutionSet); + } + + /** + * Gets the session. + * + * @return the session + */ + protected ExchangeService getSession() { + return this.service; + } + + /** + * Gets the total number of elements in the list. + * + * @return the count + */ + public int getCount() { + return this.items.size(); + } + + /** + * Gets a value indicating whether more suggested resolutions are available. + * ResolveName only returns a maximum of 100 name resolutions. When + * IncludesAllResolutions is false, there were more than 100 matching names + * on the server. To narrow the search, provide a more precise name to + * ResolveName. + * + * @return the includes all resolutions + */ + public boolean getIncludesAllResolutions() { + return this.includesAllResolutions; + } + + /** + * Gets the name resolution at the specified index. + * + * @param index the index + * @return The name resolution at the speicfied index. + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public NameResolution nameResolutionCollection(int index) + throws ArgumentOutOfRangeException { + if (index < 0 || index >= this.getCount()) { + throw new ArgumentOutOfRangeException("index", "index is out of range."); + } + + return this.items.get(index); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Iterable#iterator() + */ + @Override + public Iterator iterator() { + + return items.iterator(); + } +} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/OutParam.java b/ews-api/src/main/java/com/eischet/ews/api/misc/OutParam.java similarity index 91% rename from src/main/java/microsoft/exchange/webservices/data/misc/OutParam.java rename to ews-api/src/main/java/com/eischet/ews/api/misc/OutParam.java index 4f658d166..c3cd196e7 100644 --- a/src/main/java/microsoft/exchange/webservices/data/misc/OutParam.java +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/OutParam.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.misc; +package com.eischet.ews.api.misc; /** * The Class OutParam. @@ -30,9 +30,9 @@ */ public class OutParam extends Param { - /** - * Instantiates a new out param. - */ - public OutParam() { - } + /** + * Instantiates a new out param. + */ + public OutParam() { + } } diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/Param.java b/ews-api/src/main/java/com/eischet/ews/api/misc/Param.java similarity index 77% rename from src/main/java/microsoft/exchange/webservices/data/misc/Param.java rename to ews-api/src/main/java/com/eischet/ews/api/misc/Param.java index 0a43e3efc..c857818af 100644 --- a/src/main/java/microsoft/exchange/webservices/data/misc/Param.java +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/Param.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.misc; +package com.eischet.ews.api.misc; /** * The Class Param. @@ -30,27 +30,27 @@ */ abstract class Param { - /** - * The param. - */ - private T param; + /** + * The param. + */ + private T param; - /** - * Gets the param. - * - * @return the param - */ - public T getParam() { - return param; - } + /** + * Gets the param. + * + * @return the param + */ + public T getParam() { + return param; + } - /** - * Sets the param. - * - * @param param the new param - */ - public void setParam(T param) { - this.param = param; - } + /** + * Sets the param. + * + * @param param the new param + */ + public void setParam(T param) { + this.param = param; + } } diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/RefParam.java b/ews-api/src/main/java/com/eischet/ews/api/misc/RefParam.java similarity index 86% rename from src/main/java/microsoft/exchange/webservices/data/misc/RefParam.java rename to ews-api/src/main/java/com/eischet/ews/api/misc/RefParam.java index 9cf7941b9..1ec8ab03c 100644 --- a/src/main/java/microsoft/exchange/webservices/data/misc/RefParam.java +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/RefParam.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.misc; +package com.eischet.ews.api.misc; /** * The Class RefParam. @@ -30,12 +30,12 @@ */ public class RefParam extends Param { - /** - * Instantiates a new ref param. - * - * @param param the param - */ - public RefParam(T param) { - this.setParam(param); - } + /** + * Instantiates a new ref param. + * + * @param param the param + */ + public RefParam(T param) { + this.setParam(param); + } } diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/SoapFaultDetails.java b/ews-api/src/main/java/com/eischet/ews/api/misc/SoapFaultDetails.java new file mode 100644 index 000000000..7f75d11da --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/SoapFaultDetails.java @@ -0,0 +1,415 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.EwsXmlReader; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.misc.error.ServiceError; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents SoapFault details. + */ +public class SoapFaultDetails { + + private static final Logger LOG = Logger.getLogger(SoapFaultDetails.class.getCanonicalName()); + + /** + * The fault code. + */ + private String faultCode; + + /** + * The fault string. + */ + private String faultString; + + /** + * The fault actor. + */ + private String faultActor; + + /** + * The response code. + */ + private ServiceError responseCode = ServiceError.ErrorInternalServerError; + + /** + * The message. + */ + private String message; + + /** + * The error code. + */ + private ServiceError errorCode = ServiceError.NoError; + + /** + * The exception type. + */ + private String exceptionType; + + /** + * The line number. + */ + private int lineNumber; + + /** + * The position within line. + */ + private int positionWithinLine; + + /** + * Dictionary of key/value pairs from the MessageXml node in the fault. + * Usually empty but there are a few cases where SOAP faults may include + * MessageXml details (e.g. CASOverBudgetException includes BackoffTime + * value). + */ + private Map errorDetails = new HashMap(); + + /** + * Parses the. + * + * @param reader the reader + * @param soapNamespace the soap namespace + * @return the soap fault details + * @throws Exception the exception + */ + public static SoapFaultDetails parse(EwsXmlReader reader, XmlNamespace soapNamespace) throws Exception { + SoapFaultDetails soapFaultDetails = new SoapFaultDetails(); + + do { + reader.read(); + if (reader.getNodeType().equals( + new XmlNodeType(XmlNodeType.START_ELEMENT))) { + String localName = reader.getLocalName(); + if (localName.equals(XmlElementNames.SOAPFaultCodeElementName)) { + soapFaultDetails.setFaultCode(reader.readElementValue()); + } else if (localName + .equals(XmlElementNames.SOAPFaultStringElementName)) { + soapFaultDetails.setFaultString(reader.readElementValue()); + } else if (localName + .equals(XmlElementNames.SOAPFaultActorElementName)) { + soapFaultDetails.setFaultActor(reader.readElementValue()); + } else if (localName + .equals(XmlElementNames.SOAPDetailElementName)) { + soapFaultDetails.parseDetailNode(reader); + } + } + } while (!reader.isEndElement(soapNamespace, + XmlElementNames.SOAPFaultElementName)); + + return soapFaultDetails; + } + + /** + * Parses the detail node. + * + * @param reader the reader + * @throws Exception the exception + */ + private void parseDetailNode(EwsXmlReader reader) throws Exception { + do { + reader.read(); + if (reader.getNodeType().equals( + new XmlNodeType(XmlNodeType.START_ELEMENT))) { + String localName = reader.getLocalName(); + if (localName + .equals(XmlElementNames.EwsResponseCodeElementName)) { + try { + this.setResponseCode(reader + .readElementValue(ServiceError.class)); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error parsing details", e); + + // ServiceError couldn't be mapped to enum value, treat + // as an ISE + this + .setResponseCode(ServiceError. + ErrorInternalServerError); + } + + } else if (localName + .equals(XmlElementNames.EwsMessageElementName)) { + this.setMessage(reader.readElementValue()); + } else if (localName.equals(XmlElementNames.EwsLineElementName)) { + this.setLineNumber(reader.readElementValue(Integer.class)); + } else if (localName + .equals(XmlElementNames.EwsPositionElementName)) { + this.setPositionWithinLine(reader + .readElementValue(Integer.class)); + } else if (localName + .equals(XmlElementNames.EwsErrorCodeElementName)) { + try { + this.setErrorCode(reader + .readElementValue(ServiceError.class)); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error parsing details", e); + + // ServiceError couldn't be mapped to enum value, treat + // as an ISE + this + .setErrorCode(ServiceError. + ErrorInternalServerError); + } + + } else if (localName + .equals(XmlElementNames.EwsExceptionTypeElementName)) { + try { + this.setExceptionType(reader.readElementValue()); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error parsing details", e); + this.setExceptionType(null); + } + } else if (localName.equals(XmlElementNames.MessageXml)) { + this.parseMessageXml(reader); + } + } + } while (!reader.isEndElement(XmlNamespace.NotSpecified, + XmlElementNames.SOAPDetailElementName)); + } + + /** + * Parses the message xml. + * + * @param reader the reader + * @throws Exception the exception + * @throws ServiceXmlDeserializationException the service xml deserialization exception + */ + private void parseMessageXml(EwsXmlReader reader) throws Exception, ServiceXmlDeserializationException, Exception { + // E14:172881: E12 and E14 return the MessageXml element in different + // namespaces (types namespace for E12, errors namespace in E14). To + // avoid this problem, the parser will match the namespace from the + // start and end elements. + XmlNamespace elementNS = EwsUtilities.getNamespaceFromUri(reader.getNamespaceUri()); + + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.isStartElement() && !reader.isEmptyElement()) { + String localName = reader.getLocalName(); + if (localName.equals(XmlElementNames.Value)) { + this.errorDetails.put(reader + .readAttributeValue(XmlAttributeNames.Name), + reader.readElementValue()); + } + } + } while (!reader + .isEndElement(elementNS, XmlElementNames.MessageXml)); + } else { + reader.read(); + } + + } + + /** + * Gets the fault code. + * + * @return the fault code + */ + protected String getFaultCode() { + return faultCode; + } + + /** + * Sets the fault code. + * + * @param faultCode the new fault code + */ + protected void setFaultCode(String faultCode) { + this.faultCode = faultCode; + } + + /** + * Gets the fault string. + * + * @return the fault string + */ + public String getFaultString() { + return faultString; + } + + /** + * Sets the fault string. + * + * @param faultString the new fault string + */ + protected void setFaultString(String faultString) { + this.faultString = faultString; + } + + /** + * Gets the fault actor. + * + * @return the fault actor + */ + protected String getFaultActor() { + return faultActor; + } + + /** + * Sets the fault actor. + * + * @param faultActor the new fault actor + */ + protected void setFaultActor(String faultActor) { + this.faultActor = faultActor; + } + + /** + * Gets the response code. + * + * @return the response code + */ + public ServiceError getResponseCode() { + return responseCode; + } + + /** + * Sets the response code. + * + * @param responseCode the new response code + */ + protected void setResponseCode(ServiceError responseCode) { + this.responseCode = responseCode; + } + + /** + * Gets the message. + * + * @return the message + */ + protected String getMessage() { + return message; + } + + /** + * Sets the message. + * + * @param message the new message + */ + protected void setMessage(String message) { + this.message = message; + } + + /** + * Gets the error code. + * + * @return the error code + */ + protected ServiceError getErrorCode() { + return errorCode; + } + + /** + * Sets the error code. + * + * @param errorCode the new error code + */ + protected void setErrorCode(ServiceError errorCode) { + this.errorCode = errorCode; + } + + /** + * Gets the exception type. + * + * @return the exception type + */ + protected String getExceptionType() { + return exceptionType; + } + + /** + * Sets the exception type. + * + * @param exceptionType the new exception type + */ + protected void setExceptionType(String exceptionType) { + this.exceptionType = exceptionType; + } + + /** + * Gets the line number. + * + * @return the line number + */ + protected int getLineNumber() { + return lineNumber; + } + + /** + * Sets the line number. + * + * @param lineNumber the new line number + */ + protected void setLineNumber(int lineNumber) { + this.lineNumber = lineNumber; + } + + /** + * Gets the position within line. + * + * @return the position within line + */ + protected int getPositionWithinLine() { + return positionWithinLine; + } + + /** + * Sets the position within line. + * + * @param positionWithinLine the new position within line + */ + protected void setPositionWithinLine(int positionWithinLine) { + this.positionWithinLine = positionWithinLine; + } + + /** + * Gets the error details. + * + * @return the error details + */ + public Map getErrorDetails() { + return errorDetails; + } + + /** + * Sets the error details. + * + * @param errorDetails the error details + */ + protected void setErrorDetails(Map errorDetails) { + this.errorDetails = errorDetails; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/Time.java b/ews-api/src/main/java/com/eischet/ews/api/misc/Time.java new file mode 100644 index 000000000..9bcdffb91 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/Time.java @@ -0,0 +1,193 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.exception.misc.ArgumentException; + +import java.time.LocalTime; + +/** + * Represents time. + */ +public final class Time { + + /** + * The hours. + */ + private int hours; + + /** + * The minutes. + */ + private int minutes; + + /** + * The seconds. + */ + private int seconds; + + /** + * Initializes a new instance of Time. + */ + protected Time() { + } + + /** + * Initializes a new instance of Time. + * + * @param minutes The number of minutes since 12:00AM. + * @throws ArgumentException the argument exception + */ + + protected Time(int minutes) throws ArgumentException { + this(); + if (minutes < 0 || minutes >= 1440) { + throw new ArgumentException(String.format("%s,%s", "minutes must be between 0 and 1439, inclusive.", "minutes")); + } + + this.hours = minutes / 60; + this.minutes = minutes % 60; + this.seconds = 0; + } + + /** + * Initializes a new instance of Time. + * + * @param dateTime the date time + * @throws ArgumentException the argument exception + */ + public Time(LocalTime dateTime) throws ArgumentException { + if (dateTime != null) { + setHours(dateTime.getHour()); + setMinutes(dateTime.getMinute()); + setSeconds(dateTime.getSecond()); + } + } + + /** + * Initializes a new instance of Time. + * + * @param hours the hours + * @param minutes the minutes + * @param seconds the seconds + */ + protected Time(int hours, int minutes, int seconds) { + this(); + this.hours = hours; + this.minutes = minutes; + this.seconds = seconds; + } + + /** + * Convert Time to XML Schema time. + * + * @return String in XML Schema time format + */ + + public String toXSTime() { + return String.format("%s,%s,%s,%s", "{0:00}:{1:00}:{2:00}", + this.getHours(), this + .getMinutes(), this.getSeconds()); + } + + /** + * Converts the time into a number of minutes since 12:00AM. + * + * @return The number of minutes since 12:00AM the time represents. + */ + + protected int convertToMinutes() { + return this.getMinutes() + (this.getHours() * 60); + } + + /** + * Gets the hours. + * + * @return the hours + */ + protected int getHours() { + return this.hours; + } + + /** + * sets the hours. + * + * @param value the new hours + * @throws ArgumentException the argument exception + */ + + protected void setHours(int value) throws ArgumentException { + if (value >= 0 && value < 24) { + this.hours = value; + } else { + throw new ArgumentException("Hour must be between 0 and 23."); + } + } + + /** + * Gets the minutes. + * + * @return the minutes + */ + protected int getMinutes() { + return this.minutes; + } + + /** + * Sets the minutes. + * + * @param value the new minutes + * @throws ArgumentException the argument exception + */ + protected void setMinutes(int value) throws ArgumentException { + if (value >= 0 && value < 60) { + this.minutes = value; + } else { + throw new ArgumentException("Minute must be between 0 and 59."); + } + } + + /** + * Gets the seconds. + * + * @return the seconds + */ + protected int getSeconds() { + return this.seconds; + } + + /** + * Sets the seconds. + * + * @param value the new seconds + * @throws ArgumentException the argument exception + */ + protected void setSeconds(int value) throws ArgumentException { + if (value >= 0 && value < 60) { + this.seconds = value; + } else { + throw new ArgumentException("Second must be between 0 and 59."); + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/TimeSpan.java b/ews-api/src/main/java/com/eischet/ews/api/misc/TimeSpan.java new file mode 100644 index 000000000..048674ebd --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/TimeSpan.java @@ -0,0 +1,499 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.exception.misc.FormatException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.util.logging.Logger; + +/** + * The Class TimeSpan. + */ +public class TimeSpan implements Comparable, java.io.Serializable, Cloneable { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + /** + * The time. + */ + private long time = 0; + + /** + * Constant for milliseconds unit and conversion. + */ + public static final int MILLISECONDS = 1; + + /** + * Constant for seconds unit and conversion. + */ + public static final int SECONDS = MILLISECONDS * 1000; + + /** + * Constant for minutes unit and conversion. + */ + public static final int MINUTES = SECONDS * 60; + + /** + * Constant for hours unit and conversion. + */ + public static final int HOURS = MINUTES * 60; + + /** + * Constant for days unit and conversion. + */ + public static final int DAYS = HOURS * 24; + + /** + * Represents the Maximum TimeSpan value. + */ + public static final TimeSpan MAX_VALUE = new TimeSpan(Long.MAX_VALUE); + + /** + * Represents the Minimum TimeSpan value. + */ + public static final TimeSpan MIN_VALUE = new TimeSpan(Long.MIN_VALUE); + + /** + * Represents the TimeSpan with a value of zero. + */ + public static final TimeSpan ZERO = new TimeSpan(0L); + + /** + * Creates a new instance of TimeSpan based on the number of milliseconds + * entered. + * + * @param time the number of milliseconds for this TimeSpan. + */ + public TimeSpan(long time) { + this.time = time; + } + + /** + * Creates a new TimeSpan object based on the unit and value entered. + * + * @param units the type of unit to use to create a TimeSpan instance. + * @param value the number of units to use to create a TimeSpan instance. + */ + public TimeSpan(int units, long value) { + this.time = TimeSpan.toMilliseconds(units, value); + } + + /* + * public static TimeSpan fromMinutes(int value) { int l = value*60*100; + * return l; } + */ + + /** + * Subtracts two Date objects creating a new TimeSpan object. + * + * @param date1 Date to use as the base value. + * @param date2 Date to subtract from the base value. + * @return a TimeSpan object representing the difference bewteen the two + * Date objects. + */ + public static TimeSpan subtract(java.util.Date date1, + java.util.Date date2) { + return new TimeSpan(date1.getTime() - date2.getTime()); + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. Comparison is based + * on the number of milliseconds in this TimeSpan. + * + * @param o the Object to be compared. + * @return a negative integer, zero, or a positive integer as this object is + * less than, equal to, or greater than the specified object. + */ + public int compareTo(TimeSpan o) { + TimeSpan compare = o; + if (this.time == compare.time) { + return 0; + } + if (this.time > compare.time) { + return +1; + } + return -1; + } + + /** + * Indicates whether some other object is "equal to" this one. Comparison is + * based on the number of milliseconds in this TimeSpan. + * + * @param obj the reference object with which to compare. + * @return if the obj argument is a TimeSpan object with the exact same + * number of milliseconds. otherwise. + */ + public boolean equals(Object obj) { + if (obj instanceof TimeSpan) { + TimeSpan compare = (TimeSpan) obj; + return this.time == compare.time; + } + return false; + } + + /** + * Returns a hash code value for the object. This method is supported for + * the benefit of hashtables such as those provided by + * java.util.Hashtable. The method uses the same algorithm as + * found in the Long class. + * + * @return a hash code value for this object. + * @see Object#equals(Object) + * @see java.util.Hashtable + */ + public int hashCode() { + return Long.valueOf(this.time).hashCode(); + } + + /** + * Returns a string representation of the object in the format. + * "[-]d.hh:mm:ss.ff" where "-" is an optional sign for negative TimeSpan + * values, the "d" component is days, "hh" is hours, "mm" is minutes, "ss" + * is seconds, and "ff" is milliseconds + * + * @return a string containing the number of milliseconds. + */ + public String toString() { + StringBuffer sb = new StringBuffer(); + long millis = this.time; + if (millis < 0) { + sb.append("-"); + millis = -millis; + } + + long day = millis / TimeSpan.DAYS; + + if (day != 0) { + sb.append(day); + sb.append("d."); + millis = millis % TimeSpan.DAYS; + } + + sb.append(millis / TimeSpan.HOURS); + millis = millis % TimeSpan.HOURS; + sb.append("h:"); + sb.append(millis / TimeSpan.MINUTES); + millis = millis % TimeSpan.MINUTES; + sb.append("m:"); + sb.append(millis / TimeSpan.SECONDS); + sb.append("s"); + millis = millis % TimeSpan.SECONDS; + if (millis != 0) { + sb.append("."); + sb.append(millis); + sb.append("ms"); + } + return sb.toString(); + } + + /** + * Returns a clone of this TimeSpan. + * + * @return a clone of this TimeSpan. + */ + public Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException e) { + throw new InternalError(); + } + } + + /** + * Indicates whether the value of the TimeSpan is positive. + * + * @return if the value of the TimeSpan is greater than + * zero. otherwise. + */ + public boolean isPositive() { + return this.compareTo(TimeSpan.ZERO) > 0; + } + + /** + * Indicates whether the value of the TimeSpan is negative. + * + * @return if the value of the TimeSpan is less than zero. + * otherwise. + */ + public boolean isNegative() { + return this.compareTo(TimeSpan.ZERO) < 0; + } + + /** + * Indicates whether the value of the TimeSpan is zero. + * + * @return if the value of the TimeSpan is equal to zero. + * otherwise. + */ + public boolean isZero() { + return this.equals(TimeSpan.ZERO); + } + + /** + * Gets the number of milliseconds. + * + * @return the number of milliseconds. + */ + public long getMilliseconds() { + return (((this.time % TimeSpan.HOURS) % TimeSpan.MINUTES) % TimeSpan.MILLISECONDS) + / TimeSpan.MILLISECONDS; + } + + /** + * Gets the number of milliseconds. + * + * @return the number of milliseconds. + */ + public long getTotalMilliseconds() { + return this.time; + } + + /** + * Gets the number of seconds (truncated). + * + * @return the number of seconds. + */ + public long getSeconds() { + return ((this.time % TimeSpan.HOURS) % TimeSpan.MINUTES) / TimeSpan.SECONDS; + } + + /** + * Gets the number of seconds including fractional seconds. + * + * @return the number of seconds. + */ + public double getTotalSeconds() { + return this.time / 1000.0d; + } + + /** + * Gets the number of minutes (truncated). + * + * @return the number of minutes. + */ + public long getMinutes() { + return (this.time % TimeSpan.HOURS) / TimeSpan.MINUTES;// (this.time/1000)/60; + } + + /** + * Gets the number of minutes including fractional minutes. + * + * @return the number of minutes. + */ + public double getTotalMinutes() { + return (this.time / 1000.0d) / 60.0d; + } + + /** + * Gets the number of hours (truncated). + * + * @return the number of hours. + */ + public long getHours() { + return ((this.time / 1000) / 60) / 60; + } + + /** + * Gets the number of hours including fractional hours. + * + * @return the number of hours. + */ + public double getTotalHours() { + return ((this.time / 1000.0d) / 60.0d) / 60.0d; + } + + /** + * Gets the number of days (truncated). + * + * @return the number of days. + */ + public long getDays() { + return (((this.time / 1000) / 60) / 60) / 24; + } + + /** + * Gets the number of days including fractional days. + * + * @return the number of days. + */ + public double getTotalDays() { + return (((this.time / 1000.0d) / 60.0d) / 60.0d) / 24.0d; + } + + /** + * Adds a TimeSpan to this TimeSpan. + * + * @param timespan the TimeSpan to add to this TimeSpan. + */ + public void add(TimeSpan timespan) { + add(TimeSpan.MILLISECONDS, timespan.time); + } + + /** + * Adds a number of units to this TimeSpan. + * + * @param units the type of unit to add to this TimeSpan. + * @param value the number of units to add to this TimeSpan. + */ + public void add(int units, long value) { + this.time += TimeSpan.toMilliseconds(units, value); + } + + /** + * Compares two TimeSpan objects. + * + * @param first first TimeSpan to use in the compare. + * @param second second TimeSpan to use in the compare. + * @return a negative integer, zero, or a positive integer as the first + * TimeSpan is less than, equal to, or greater than the second + * TimeSpan. + */ + public static int compare(TimeSpan first, TimeSpan second) { + if (first.time == second.time) { + return 0; + } + if (first.time > second.time) { + return +1; + } + return -1; + } + + /** + * Returns a TimeSpan whose value is the absolute value of this TimeSpan. + * + * @return a TimeSpan whose value is the absolute value of this TimeSpan. + */ + public TimeSpan duration() { + return new TimeSpan(Math.abs(this.time)); + } + + /** + * Returns a TimeSpan whose value is the negated value of this TimeSpan. + * + * @return a TimeSpan whose value is the negated value of this TimeSpan. + */ + public TimeSpan negate() { + return new TimeSpan(-this.time); + } + + /** + * Subtracts a TimeSpan from this TimeSpan. + * + * @param timespan the TimeSpan to subtract from this TimeSpan. + */ + public void subtract(TimeSpan timespan) { + subtract(TimeSpan.MILLISECONDS, timespan.time); + } + + /** + * Subtracts a number of units from this TimeSpan. + * + * @param units the type of unit to subtract from this TimeSpan. + * @param value the number of units to subtract from this TimeSpan. + */ + public void subtract(int units, long value) { + add(units, -value); + } + + /** + * To milliseconds. + * + * @param units the units + * @param value the value + * @return the long + */ + private static long toMilliseconds(int units, long value) { + long millis; + switch (units) { + case TimeSpan.MILLISECONDS: + case TimeSpan.SECONDS: + case TimeSpan.MINUTES: + case TimeSpan.HOURS: + case TimeSpan.DAYS: + millis = value * units; + break; + default: + throw new IllegalArgumentException("Unrecognized units: " + units); + } + return millis; + } + + public static TimeSpan parse(String s) throws ExchangeXmlException { + String str = s.trim(); + String[] st1 = str.split("\\."); + int days = 0, millsec = 0, totMillSec = 0; + String data = str; + switch (st1.length) { + case 1: + data = str; + break; + case 2: + if (st1[0].split(":").length > 1) { + millsec = Integer.parseInt(st1[1]); + data = st1[0]; + } else { + days = Integer.parseInt(st1[0]); + data = st1[1]; + } + break; + case 3: + days = Integer.parseInt(st1[0]); + data = st1[1]; + millsec = Integer.parseInt(st1[2]); + break; + default: + throw new FormatException("Bad Format for TimeSpan: " + s); + + } + String[] st = data.split(":"); + switch (st.length) { + case 1: + totMillSec = Integer.parseInt(str) * 24 * 60 * 60 * 1000; + break; + case 2: + totMillSec = (Integer.parseInt(st[0]) * 60 * 60 * 1000) + (Integer.parseInt(st[1]) * 60 * 1000); + break; + case 3: + totMillSec = (Integer.parseInt(st[0]) * 60 * 60 * 1000) + (Integer.parseInt(st[1]) * 60 * 1000) + ( + Integer.parseInt(st[2]) * 1000); + break; + case 4: + totMillSec = + (Integer.parseInt(st[0]) * 24 * 60 * 60 * 1000) + (Integer.parseInt(st[1]) * 60 * 60 * 1000) + ( + Integer.parseInt(st[2]) * 60 * 1000) + (Integer.parseInt(st[3]) * 1000); + break; + default: + throw new FormatException("Bad Format/Overflow"); + } + totMillSec += (days * 24 * 60 * 60 * 1000) + millsec; + return new TimeSpan(totMillSec); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/UserConfiguration.java b/ews-api/src/main/java/com/eischet/ews/api/misc/UserConfiguration.java new file mode 100644 index 000000000..d0e011e90 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/UserConfiguration.java @@ -0,0 +1,633 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.UserConfigurationProperties; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.exception.misc.InvalidOperationException; +import com.eischet.ews.api.core.exception.service.local.PropertyException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.FolderId; +import com.eischet.ews.api.property.complex.ItemId; +import com.eischet.ews.api.property.complex.UserConfigurationDictionary; +import com.eischet.ews.api.security.XmlNodeType; + +import javax.xml.stream.XMLStreamException; +import java.util.Base64; +import java.util.EnumSet; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents an object that can be used to store user-defined configuration + * settings. + */ +public class UserConfiguration { + + private static final Logger LOG = Logger.getLogger(UserConfiguration.class.getCanonicalName()); + + /** + * The object version. + */ + private static final ExchangeVersion ObjectVersion = ExchangeVersion.Exchange2010; + + /* + * For consistency with ServiceObject behavior, access to ItemId is + * permitted for a new object. + */ + + /** + * The Constant PropertiesAvailableForNewObject. + */ + private final static EnumSet + PropertiesAvailableForNewObject = + EnumSet.of(UserConfigurationProperties.BinaryData, + UserConfigurationProperties.Dictionary, + UserConfigurationProperties.XmlData); + + private final UserConfigurationProperties NoProperties = UserConfigurationProperties.values()[0]; + private final ExchangeService service; + private String name; + private FolderId parentFolderId = null; + private ItemId itemId = null; + private UserConfigurationDictionary dictionary = null; + private byte[] xmlData = null; + private byte[] binaryData = null; + private EnumSet propertiesAvailableForAccess; + private EnumSet updatedProperties; + + /** + * Indicates whether changes trigger an update or create operation. + */ + private boolean isNew = false; + + /** + * Initializes a new instance of class. + * + * @param service The service to which the user configuration is bound. + * @throws Exception the exception + */ + public UserConfiguration(ExchangeService service) throws Exception { + this(service, PropertiesAvailableForNewObject); + } + + /** + * Writes a byte array to Xml. + * + * @param writer the writer + * @param byteArray byte array to write + * @param xmlElementName name of the Xml element + */ + private static void writeByteArrayToXml(EwsServiceXmlWriter writer, + byte[] byteArray, String xmlElementName) throws ExchangeXmlException { + EwsUtilities.ewsAssert(writer != null, "UserConfiguration.WriteByteArrayToXml", "writer is null"); + EwsUtilities.ewsAssert(xmlElementName != null, "UserConfiguration.WriteByteArrayToXml", + "xmlElementName is null"); + + writer.writeStartElement(XmlNamespace.Types, xmlElementName); + + if (byteArray != null && byteArray.length > 0) { + writer.writeValue(Base64.getMimeEncoder().encodeToString(byteArray), xmlElementName); + } + + writer.writeEndElement(); + } + + + /** + * Writes to Xml. + * + * @param writer The writer. + * @param xmlNamespace The XML namespace. + * @param name The user configuration name. + * @param parentFolderId The Id of the folder containing the user configuration. + * @throws Exception the exception + */ + public static void writeUserConfigurationNameToXml(EwsServiceXmlWriter writer, XmlNamespace xmlNamespace, + String name, FolderId parentFolderId) throws Exception { + EwsUtilities.ewsAssert(writer != null, "UserConfiguration.WriteUserConfigurationNameToXml", + "writer is null"); + EwsUtilities.ewsAssert(name != null, "UserConfiguration.WriteUserConfigurationNameToXml", "name is null"); + EwsUtilities.ewsAssert(parentFolderId != null, "UserConfiguration.WriteUserConfigurationNameToXml", + "parentFolderId is null"); + + writer.writeStartElement(xmlNamespace, XmlElementNames.UserConfigurationName); + + writer.writeAttributeValue(XmlAttributeNames.Name, name); + + parentFolderId.writeToXml(writer); + + writer.writeEndElement(); + } + + /** + * Initializes a new instance of class. + * + * @param service The service to which the user configuration is bound. + * @param requestedProperties The property requested for this user configuration. + * @throws Exception the exception + */ + public UserConfiguration(ExchangeService service, EnumSet requestedProperties) + throws Exception { + EwsUtilities.validateParam(service, "service"); + + if (service.getRequestedServerVersion().ordinal() < UserConfiguration.ObjectVersion.ordinal()) { + throw new ServiceVersionException(String.format( + "The object type %s is only valid for Exchange Server version %s or later versions.", this + .getClass().getName(), UserConfiguration.ObjectVersion)); + } + + this.service = service; + this.isNew = true; + + this.initializeProperties(requestedProperties); + } + + /** + * Gets the name of the user configuration. + * + * @return the name + */ + public String getName() { + return this.name; + } + + /** + * Sets the name. + * + * @param value the new name + */ + public void setName(String value) { + this.name = value; + } + + /** + * Gets the Id of the folder containing the user configuration. + * + * @return the parent folder id + */ + public FolderId getParentFolderId() { + return this.parentFolderId; + } + + /** + * Sets the parent folder id. + * + * @param value the new parent folder id + */ + public void setParentFolderId(FolderId value) { + this.parentFolderId = value; + } + + /** + * Gets the Id of the user configuration. + * + * @return the item id + */ + public ItemId getItemId() { + return this.itemId; + } + + /** + * Gets the dictionary of the user configuration. + * + * @return the dictionary + */ + public UserConfigurationDictionary getDictionary() { + return this.dictionary; + } + + /** + * Gets the xml data of the user configuration. + * + * @return the xml data + * @throws PropertyException the property exception + */ + public byte[] getXmlData() throws PropertyException { + + this.validatePropertyAccess(UserConfigurationProperties.XmlData); + + return this.xmlData; + } + + /** + * Sets the xml data. + * + * @param value the new xml data + */ + public void setXmlData(byte[] value) { + this.xmlData = value; + + this.markPropertyForUpdate(UserConfigurationProperties.XmlData); + } + + /** + * Gets the binary data of the user configuration. + * + * @return the binary data + * @throws PropertyException the property exception + */ + public byte[] getBinaryData() throws PropertyException { + this.validatePropertyAccess(UserConfigurationProperties.BinaryData); + + return this.binaryData; + + } + + /** + * Sets the binary data. + * + * @param value the new binary data + */ + public void setBinaryData(byte[] value) { + this.binaryData = value; + this.markPropertyForUpdate(UserConfigurationProperties.BinaryData); + } + + /** + * Gets a value indicating whether this user configuration has been + * modified. + * + * @return the checks if is dirty + */ + public boolean getIsDirty() { + return (!this.updatedProperties.contains(NoProperties)) + || this.dictionary.getIsDirty(); + } + + /** + * Binds to an existing user configuration and loads the specified + * property. Calling this method results in a call to EWS. + * + * @param service The service to which the user configuration is bound. + * @param name The name of the user configuration. + * @param parentFolderId The Id of the folder containing the user configuration. + * @param properties The property to load. + * @return A user configuration instance. + * @throws IndexOutOfBoundsException the index out of bounds exception + * @throws Exception the exception + */ + public static UserConfiguration bind(ExchangeService service, String name, + FolderId parentFolderId, UserConfigurationProperties properties) + throws IndexOutOfBoundsException, Exception { + + UserConfiguration result = service.getUserConfiguration(name, + parentFolderId, properties); + result.isNew = false; + return result; + } + + /** + * Binds to an existing user configuration and loads the specified + * property. + * + * @param service The service to which the user configuration is bound. + * @param name The name of the user configuration. + * @param parentFolderName The name of the folder containing the user configuration. + * @param properties The property to load. + * @return A user configuration instance. + * @throws IndexOutOfBoundsException the index out of bounds exception + * @throws Exception the exception + */ + public static UserConfiguration bind(ExchangeService service, String name, + WellKnownFolderName parentFolderName, + UserConfigurationProperties properties) + throws IndexOutOfBoundsException, Exception { + return UserConfiguration.bind(service, name, new FolderId( + parentFolderName), properties); + } + + /** + * Saves the user configuration. Calling this method results in a call to + * EWS. + * + * @param name The name of the user configuration. + * @param parentFolderId The Id of the folder in which to save the user configuration. + * @throws Exception the exception + */ + public void save(String name, FolderId parentFolderId) throws Exception { + EwsUtilities.validateParam(name, "name"); + EwsUtilities.validateParam(parentFolderId, "parentFolderId"); + + parentFolderId.validate(this.service.getRequestedServerVersion()); + + if (!this.isNew) { + throw new InvalidOperationException( + "Calling Save isn't allowed because this user configuration isn't new. To apply local changes to this user configuration, call Update instead."); + } + + this.parentFolderId = parentFolderId; + this.name = name; + + this.service.createUserConfiguration(this); + + this.isNew = false; + + this.resetIsDirty(); + } + + /** + * Saves the user configuration. Calling this method results in a call to + * EWS. + * + * @param name The name of the user configuration. + * @param parentFolderName The name of the folder in which to save the user + * configuration. + * @throws Exception the exception + */ + public void save(String name, WellKnownFolderName parentFolderName) + throws Exception { + this.save(name, new FolderId(parentFolderName)); + } + + /** + * Updates the user configuration by applying local changes to the Exchange + * server. Calling this method results in a call to EWS + * + * @throws Exception the exception + */ + + public void update() throws Exception { + if (this.isNew) { + throw new InvalidOperationException( + "This user configuration can't be updated because it's never been saved."); + } + + if (this.isPropertyUpdated(UserConfigurationProperties.BinaryData) + || this + .isPropertyUpdated(UserConfigurationProperties. + Dictionary) + || this.isPropertyUpdated(UserConfigurationProperties. + XmlData)) { + + this.service.updateUserConfiguration(this); + } + + this.resetIsDirty(); + } + + /** + * Deletes the user configuration. Calling this method results in a call to + * EWS. + * + * @throws Exception the exception + */ + public void delete() throws Exception { + if (this.isNew) { + throw new InvalidOperationException( + "This user configuration object can't be deleted because it's never been saved."); + } else { + this.service + .deleteUserConfiguration(this.name, this.parentFolderId); + } + } + + /** + * Loads the specified property on the user configuration. Calling this + * method results in a call to EWS. + * + * @param properties The property to load. + * @throws Exception the exception + */ + public void load(UserConfigurationProperties properties) throws Exception { + this.initializeProperties(EnumSet.of(properties)); + this.service.loadPropertiesForUserConfiguration(this, properties); + } + + /** + * Writes to XML. + * + * @param writer The writer. + * @param xmlNamespace The XML namespace. + * @param xmlElementName Name of the XML element. + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer, XmlNamespace xmlNamespace, String xmlElementName) throws Exception { + EwsUtilities.ewsAssert(writer != null, "UserConfiguration.WriteToXml", "writer is null"); + EwsUtilities.ewsAssert(xmlElementName != null, "UserConfiguration.WriteToXml", "xmlElementName is null"); + + writer.writeStartElement(xmlNamespace, xmlElementName); + + // Write the UserConfigurationName element + writeUserConfigurationNameToXml(writer, XmlNamespace.Types, this.name, + this.parentFolderId); + + // Write the Dictionary element + if (this.isPropertyUpdated(UserConfigurationProperties.Dictionary)) { + this.dictionary.writeToXml(writer, XmlElementNames.Dictionary); + } + + // Write the XmlData element + if (this.isPropertyUpdated(UserConfigurationProperties.XmlData)) { + this.writeXmlDataToXml(writer); + } + + // Write the BinaryData element + if (this.isPropertyUpdated(UserConfigurationProperties.BinaryData)) { + this.writeBinaryDataToXml(writer); + } + + writer.writeEndElement(); + } + + /** + * Determines whether the specified property was updated. + * + * @param property property to evaluate. + * @return Boolean indicating whether to send the property Xml. + */ + private boolean isPropertyUpdated(UserConfigurationProperties property) { + boolean isPropertyDirty = false; + boolean isPropertyEmpty = false; + + switch (property) { + case Dictionary: + isPropertyDirty = this.getDictionary().getIsDirty(); + isPropertyEmpty = this.getDictionary().getCount() == 0; + break; + case XmlData: + isPropertyDirty = this.updatedProperties.contains(property); + isPropertyEmpty = (this.xmlData == null) || + (this.xmlData.length == 0); + break; + case BinaryData: + isPropertyDirty = this.updatedProperties.contains(property); + isPropertyEmpty = (this.binaryData == null) || + (this.binaryData.length == 0); + break; + default: + EwsUtilities.ewsAssert(false, "UserConfiguration.IsPropertyUpdated", + "property not supported: " + property); + break; + } + + // Consider the property updated, if it's been modified, and either + // . there's a value or + // . there's no value but the operation is update. + return isPropertyDirty && ((!isPropertyEmpty) || (!this.isNew)); + } + + /** + * Writes the XmlData property to Xml. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + private void writeXmlDataToXml(EwsServiceXmlWriter writer) + throws XMLStreamException, ServiceXmlSerializationException, ExchangeXmlException { + EwsUtilities.ewsAssert(writer != null, "UserConfiguration.WriteXmlDataToXml", "writer is null"); + + writeByteArrayToXml(writer, this.xmlData, XmlElementNames.XmlData); + } + + /** + * Writes the BinaryData property to Xml. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + private void writeBinaryDataToXml(EwsServiceXmlWriter writer) + throws XMLStreamException, ServiceXmlSerializationException, ExchangeXmlException { + EwsUtilities.ewsAssert(writer != null, "UserConfiguration.WriteBinaryDataToXml", "writer is null"); + + writeByteArrayToXml(writer, this.binaryData, + XmlElementNames.BinaryData); + } + + + /** + * Loads from XML. + * + * @param reader The reader. + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader) throws Exception { + EwsUtilities.ewsAssert(reader != null, "UserConfiguration.loadFromXml", "reader is null"); + + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.UserConfiguration); + reader.read(); // Position at first property element + + do { + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + if (reader.getLocalName().equals( + XmlElementNames.UserConfigurationName)) { + String responseName = reader + .readAttributeValue(XmlAttributeNames.Name); + + EwsUtilities.ewsAssert(this.name.equals(responseName), "UserConfiguration.loadFromXml", + "UserConfigurationName does not match: Expected: " + this.name + + " Name in response: " + responseName); + + reader.skipCurrentElement(); + } else if (reader.getLocalName().equals(XmlElementNames.ItemId)) { + this.itemId = new ItemId(); + this.itemId.loadFromXml(reader, XmlElementNames.ItemId); + } else if (reader.getLocalName().equals( + XmlElementNames.Dictionary)) { + this.dictionary.loadFromXml(reader, + XmlElementNames.Dictionary); + } else if (reader.getLocalName().equals(XmlElementNames.XmlData)) { + this.xmlData = Base64.getMimeDecoder().decode(reader.readElementValue()); + } else if (reader.getLocalName().equals(XmlElementNames.BinaryData)) { + this.binaryData = Base64.getMimeDecoder().decode(reader.readElementValue()); + } else { + EwsUtilities.ewsAssert(false, "UserConfiguration.loadFromXml", + "Xml element not supported: " + reader.getLocalName()); + } + } + + // If XmlData was loaded, read is skipped because GetXmlData + // positions the reader at the next property. + reader.read(); + } while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.UserConfiguration)); + } + + /** + * Initializes property. + * + * @param requestedProperties The property requested for this UserConfiguration. + */ + // / InitializeProperties is called in 3 cases: + // / . Create new object: From the UserConfiguration constructor. + // / . Bind to existing object: Again from the constructor. The constructor + // is called eventually by the GetUserConfiguration request. + // / . Refresh property: From the Load method. + private void initializeProperties( + EnumSet requestedProperties) { + this.itemId = null; + this.dictionary = new UserConfigurationDictionary(); + this.xmlData = null; + this.binaryData = null; + this.propertiesAvailableForAccess = requestedProperties; + + this.resetIsDirty(); + } + + /** + * Resets flags to indicate that property haven't been modified. + */ + private void resetIsDirty() { + try { + this.updatedProperties = EnumSet.of(NoProperties); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error reseting dirty flag", e); + } + this.dictionary.setIsDirty(false); + } + + /** + * Determines whether the specified property may be accessed. + * + * @param property Property to access. + * @throws PropertyException the property exception + */ + private void validatePropertyAccess(UserConfigurationProperties property) + throws PropertyException { + if (!this.propertiesAvailableForAccess.contains(property)) { + throw new PropertyException("You must load or assign this property before you can read its value.", property + .toString()); + } + } + + /** + * Adds the passed property to updatedProperties. + * + * @param property Property to update. + */ + private void markPropertyForUpdate(UserConfigurationProperties property) { + this.updatedProperties.add(property); + this.propertiesAvailableForAccess.add(property); + + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/availability/AttendeeInfo.java b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/AttendeeInfo.java new file mode 100644 index 000000000..c90b19e2a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/AttendeeInfo.java @@ -0,0 +1,183 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc.availability; + +import com.eischet.ews.api.ISelfValidate; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.availability.MeetingAttendeeType; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; + +/** + * Represents information about an attendee for which to request availability + * information. + */ +public final class AttendeeInfo implements ISelfValidate { + + /** + * The smtp address. + */ + private String smtpAddress; + + /** + * The attendee type. + */ + private MeetingAttendeeType attendeeType = MeetingAttendeeType.Required; + + /** + * The exclude conflicts. + */ + private boolean excludeConflicts; + + /** + * Initializes a new instance of the AttendeeInfo class. + */ + public AttendeeInfo() { + } + + /** + * Initializes a new instance of the AttendeeInfo class. + * + * @param smtpAddress the smtp address + * @param attendeeType the attendee type + * @param excludeConflicts the exclude conflicts + */ + public AttendeeInfo(String smtpAddress, MeetingAttendeeType attendeeType, + boolean excludeConflicts) { + this(); + this.smtpAddress = smtpAddress; + this.attendeeType = attendeeType; + this.excludeConflicts = excludeConflicts; + } + + /** + * Initializes a new instance of the AttendeeInfo class. + * + * @param smtpAddress the smtp address + */ + public AttendeeInfo(String smtpAddress) { + this(smtpAddress, MeetingAttendeeType.Required, false); + this.smtpAddress = smtpAddress; + } + + /** + * Defines an implicit conversion between a string representing an SMTP + * address and AttendeeInfo. + * + * @param smtpAddress the smtp address + * @return An AttendeeInfo initialized with the specified SMTP address. + */ + public static AttendeeInfo getAttendeeInfoFromString(String smtpAddress) { + return new AttendeeInfo(smtpAddress); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer) throws Exception { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.MailboxData); + + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Email); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Address, + this.smtpAddress); + writer.writeEndElement(); // Email + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.AttendeeType, this.attendeeType); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.ExcludeConflicts, this.excludeConflicts); + + writer.writeEndElement(); // MailboxData + } + + /** + * Gets the SMTP address of this attendee. + * + * @return the smtp address + */ + public String getSmtpAddress() { + return smtpAddress; + } + + /** + * Sets the smtp address. + * + * @param smtpAddress the new smtp address + */ + public void setSmtpAddress(String smtpAddress) { + this.smtpAddress = smtpAddress; + } + + /** + * Gets the type of this attendee. + * + * @return the attendee type + */ + public MeetingAttendeeType getAttendeeType() { + return attendeeType; + } + + /** + * Sets the attendee type. + * + * @param attendeeType the new attendee type + */ + public void setAttendeeType(MeetingAttendeeType attendeeType) { + this.attendeeType = attendeeType; + } + + /** + * Gets a value indicating whether times when this attendee is not + * available should be returned. + * + * @return true, if is exclude conflicts + */ + public boolean isExcludeConflicts() { + return excludeConflicts; + } + + /** + * Sets the exclude conflicts. + * + * @param excludeConflicts the new exclude conflicts + */ + public void setExcludeConflicts(boolean excludeConflicts) { + this.excludeConflicts = excludeConflicts; + } + + /** + * Validates this instance. + * + */ + public void validate() throws ExchangeValidationException { + EwsUtilities.validateParam(this.smtpAddress, "SmtpAddress"); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/availability/AvailabilityOptions.java b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/AvailabilityOptions.java new file mode 100644 index 000000000..891fa7864 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/AvailabilityOptions.java @@ -0,0 +1,404 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc.availability; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.availability.FreeBusyViewType; +import com.eischet.ews.api.core.enumeration.availability.SuggestionQuality; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.request.GetUserAvailabilityRequest; + +import java.time.LocalDateTime; + + +/** + * Represents the options of a GetAvailability request. + */ +public final class AvailabilityOptions { + + /** + * The merged free busy interval. + */ + private int mergedFreeBusyInterval = 30; + + /** + * The requested free busy view. + */ + private FreeBusyViewType requestedFreeBusyView = FreeBusyViewType.Detailed; + + /** + * The good suggestion threshold. + */ + private int goodSuggestionThreshold = 25; + + /** + * The maximum suggestions per day. + */ + private int maximumSuggestionsPerDay = 10; + + /** + * The maximum non work hours suggestions per day. + */ + private int maximumNonWorkHoursSuggestionsPerDay = 0; + + /** + * The meeting duration. + */ + private int meetingDuration = 60; + + /** + * The minimum suggestion quality. + */ + private SuggestionQuality minimumSuggestionQuality = SuggestionQuality.Fair; + + /** + * The detailed suggestions window. + */ + private TimeWindow detailedSuggestionsWindow; + + /** + * The current meeting time. + */ + private LocalDateTime currentMeetingTime; + + /** + * The global object id. + */ + private String globalObjectId; + + /** + * Validates this instance against the specified time window. + * + * @param timeWindow the time window + * @throws Exception the exception + */ + public void validate(long timeWindow) throws Exception { + if (this.mergedFreeBusyInterval > timeWindow) { + throw new IllegalArgumentException( + "MergedFreeBusyInterval must be smaller than the specified time window."); + } + + EwsUtilities.validateParamAllowNull(this.detailedSuggestionsWindow, "DetailedSuggestionsWindow"); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param request the request + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer, GetUserAvailabilityRequest request) throws Exception { + if (request.isFreeBusyViewRequested()) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.FreeBusyViewOptions); + + request.getTimeWindow().writeToXmlUnscopedDatesOnly(writer, + XmlElementNames.TimeWindow); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.MergedFreeBusyIntervalInMinutes, + this.mergedFreeBusyInterval); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.RequestedView, this.requestedFreeBusyView); + + writer.writeEndElement(); // FreeBusyViewOptions + } + + if (request.isSuggestionsViewRequested()) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.SuggestionsViewOptions); + + writer + .writeElementValue(XmlNamespace.Types, + XmlElementNames.GoodThreshold, + this.goodSuggestionThreshold); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.MaximumResultsByDay, + this.maximumSuggestionsPerDay); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.MaximumNonWorkHourResultsByDay, + this.maximumNonWorkHoursSuggestionsPerDay); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.MeetingDurationInMinutes, + this.meetingDuration); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.MinimumSuggestionQuality, + this.minimumSuggestionQuality); + + TimeWindow timeWindowToSerialize = + this.detailedSuggestionsWindow == null ? request + .getTimeWindow() : + this.detailedSuggestionsWindow; + + timeWindowToSerialize.writeToXmlUnscopedDatesOnly(writer, + XmlElementNames.DetailedSuggestionsWindow); + + if (this.currentMeetingTime != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.CurrentMeetingTime, + this.currentMeetingTime); + } + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.GlobalObjectId, this.globalObjectId); + + writer.writeEndElement(); // SuggestionsViewOptions + } + } + + /** + * Initializes a new instance of the AvailabilityOptions class. + */ + public AvailabilityOptions() { + } + + /** + * Gets the time difference between two successive slots in a + * FreeBusyMerged view. MergedFreeBusyInterval must be between 5 and 1440. + * The default value is 30. + * + * @return the merged free busy interval + */ + public int getMergedFreeBusyInterval() { + return this.mergedFreeBusyInterval; + } + + /** + * Sets the merged free busy interval. + * + * @param value the new merged free busy interval + */ + public void setMergedFreeBusyInterval(int value) { + if (value < 5 || value > 1440) { + throw new IllegalArgumentException(String.format("%s,%s,%s,%s", "%s must be between %d and %d.", + "MergedFreeBusyInterval", 5, 1440)); + } + + this.mergedFreeBusyInterval = value; + } + + /** + * Gets the requested type of free/busy view. The default value is + * FreeBusyViewType.Detailed. + * + * @return the requested free busy view + */ + public FreeBusyViewType getRequestedFreeBusyView() { + return this.requestedFreeBusyView; + } + + /** + * Sets the requested free busy view. + * + * @param value the new requested free busy view + */ + public void setRequestedFreeBusyView(FreeBusyViewType value) { + this.requestedFreeBusyView = value; + } + + /** + * Gets the percentage of attendees that must have the time period + * open for the time period to qualify as a good suggested meeting time. + * GoodSuggestionThreshold must be between 1 and 49. The default value is + * 25. + * + * @return the good suggestion threshold + */ + public int getGoodSuggestionThreshold() { + return this.goodSuggestionThreshold; + } + + /** + * Sets the good suggestion threshold. + * + * @param value the new good suggestion threshold + */ + public void setGoodSuggestionThreshold(int value) { + if (value < 1 || value > 49) { + throw new IllegalArgumentException(String.format("%s must be between %d and %d.", + "GoodSuggestionThreshold", 1, 49)); + } + + this.goodSuggestionThreshold = value; + } + + /** + * Gets the number of suggested meeting times that should be + * returned per day. MaximumSuggestionsPerDay must be between 0 and 48. The + * default value is 10. + * + * @return the maximum suggestions per day + */ + public int getMaximumSuggestionsPerDay() { + return this.maximumSuggestionsPerDay; + } + + /** + * Sets the maximum suggestions per day. + * + * @param value the new maximum suggestions per day + */ + public void setMaximumSuggestionsPerDay(int value) { + if (value < 0 || value > 48) { + throw new IllegalArgumentException(String.format("%s,%s,%s,%s", "%s must be between %d and %d.", + "MaximumSuggestionsPerDay", 0, 48)); + } + + this.maximumSuggestionsPerDay = value; + } + + /** + * Gets the number of suggested meeting times outside regular + * working hours per day. MaximumNonWorkHoursSuggestionsPerDay must be + * between 0 and 48. The default value is 0. + * + * @return the maximum non work hours suggestions per day + */ + public int getMaximumNonWorkHoursSuggestionsPerDay() { + return this.maximumNonWorkHoursSuggestionsPerDay; + } + + /** + * Sets the maximum non work hours suggestions per day. + * + * @param value the new maximum non work hours suggestions per day + */ + public void setMaximumNonWorkHoursSuggestionsPerDay(int value) { + if (value < 0 || value > 48) { + throw new IllegalArgumentException(String.format("%s must be between %d and %d.", + "MaximumNonWorkHoursSuggestionsPerDay", 0, 48)); + } + + this.maximumNonWorkHoursSuggestionsPerDay = value; + } + + /** + * Gets the duration, in minutes, of the meeting for which to obtain + * suggestions. MeetingDuration must be between 30 and 1440. The default + * value is 60. + * + * @return the meeting duration + */ + public int getMeetingDuration() { + return this.meetingDuration; + } + + /** + * Sets the meeting duration. + * + * @param value the new meeting duration + */ + public void setMeetingDuration(int value) { + if (value < 30 || value > 1440) { + throw new IllegalArgumentException(String.format("%s,%s,%s,%s", "%s must be between %d and %d.", "MeetingDuration", + 30, 1440)); + } + + this.meetingDuration = value; + } + + /** + * Gets the minimum quality of suggestions that should be returned. + * The default is SuggestionQuality.Fair. + * + * @return the minimum suggestion quality + */ + public SuggestionQuality getMinimumSuggestionQuality() { + return this.minimumSuggestionQuality; + } + + /** + * Sets the minimum suggestion quality. + * + * @param value the new minimum suggestion quality + */ + public void setMinimumSuggestionQuality(SuggestionQuality value) { + this.minimumSuggestionQuality = value; + } + + /** + * Gets the time window for which detailed information about + * suggested meeting times should be returned. + * + * @return the detailed suggestions window + */ + public TimeWindow getDetailedSuggestionsWindow() { + return this.detailedSuggestionsWindow; + } + + /** + * Sets the detailed suggestions window. + * + * @param value the new detailed suggestions window + */ + public void setDetailedSuggestionsWindow(TimeWindow value) { + this.detailedSuggestionsWindow = value; + } + + /** + * Gets the start time of a meeting that you want to update with the + * suggested meeting times. + * + * @return the current meeting time + */ + public LocalDateTime getCurrentMeetingTime() { + return this.currentMeetingTime; + } + + /** + * Sets the current meeting time. + * + * @param value the new current meeting time + */ + public void setCurrentMeetingTime(LocalDateTime value) { + this.currentMeetingTime = value; + } + + /** + * Gets the global object Id of a meeting that will be modified + * based on the data returned by GetUserAvailability. + * + * @return the global object id + */ + public String getGlobalObjectId() { + return this.globalObjectId; + } + + /** + * Sets the global object id. + * + * @param value the new global object id + */ + public void setGlobalObjectId(String value) { + this.globalObjectId = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/availability/GetUserAvailabilityResults.java b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/GetUserAvailabilityResults.java new file mode 100644 index 000000000..5308d5a7d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/GetUserAvailabilityResults.java @@ -0,0 +1,112 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc.availability; + +import com.eischet.ews.api.core.exception.service.remote.ServiceResponseException; +import com.eischet.ews.api.core.response.AttendeeAvailability; +import com.eischet.ews.api.core.response.ServiceResponseCollection; +import com.eischet.ews.api.core.response.SuggestionsResponse; +import com.eischet.ews.api.property.complex.availability.Suggestion; + +import java.util.Collection; + +/** + * Represents the results of a GetUserAvailability operation. + */ +public final class GetUserAvailabilityResults { + + /** + * The attendees availability. + */ + private ServiceResponseCollection + attendeesAvailability; + + /** + * The suggestions response. + */ + private SuggestionsResponse suggestionsResponse; + + /** + * Initializes a new instance of the GetUserAvailabilityResults class. + */ + public GetUserAvailabilityResults() { + } + + /** + * Gets the suggestions response for the requested meeting time. + * + * @return the suggestions response + */ + public SuggestionsResponse getSuggestionsResponse() { + return this.suggestionsResponse; + } + + /** + * Sets the suggestions response. + * + * @param value the new suggestions response + */ + public void setSuggestionsResponse(SuggestionsResponse value) { + this.suggestionsResponse = value; + } + + /** + * Gets a collection of AttendeeAvailability objects representing + * availability information for each of the specified attendees. + * + * @return the attendees availability + */ + public ServiceResponseCollection + getAttendeesAvailability() { + return this.attendeesAvailability; + } + + /** + * Sets the attendees availability. + * + * @param value the new attendees availability + */ + public void setAttendeesAvailability(ServiceResponseCollection value) { + this.attendeesAvailability = value; + } + + /** + * Gets a collection of suggested meeting times for the specified time + * period. + * + * @return the suggestions + * @throws ServiceResponseException the service response exception + */ + public Collection getSuggestions() + throws ServiceResponseException { + if (this.suggestionsResponse == null) { + return null; + } else { + this.suggestionsResponse.throwIfNecessary(); + + return this.suggestionsResponse.getSuggestions(); + } + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/availability/LegacyAvailabilityTimeZone.java b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/LegacyAvailabilityTimeZone.java new file mode 100644 index 000000000..dac4293de --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/LegacyAvailabilityTimeZone.java @@ -0,0 +1,148 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc.availability; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.time.DayOfTheWeek; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.TimeSpan; +import com.eischet.ews.api.property.complex.ComplexProperty; +import com.eischet.ews.api.property.complex.time.TimeZoneDefinition; + +import java.util.UUID; + +/** + * Represents a time zone as used by GetUserAvailabilityRequest. + */ +public final class LegacyAvailabilityTimeZone extends ComplexProperty { + + /** + * The bias. + */ + private TimeSpan bias; + + /** + * The standard time. + */ + private LegacyAvailabilityTimeZoneTime standardTime; + + /** + * The daylight time. + */ + private LegacyAvailabilityTimeZoneTime daylightTime; + + /** + * Initializes a new instance of the LegacyAvailabilityTimeZone class. + */ + public LegacyAvailabilityTimeZone() { + super(); + this.bias = new TimeSpan(0); + // If there are no adjustment rules (which is the + //case for UTC), we have to come up with two + // dummy time changes which both have a delta of + //zero and happen at two hard coded dates. This + // simulates a time zone in which there are no time changes. + this.daylightTime = new LegacyAvailabilityTimeZoneTime(); + this.daylightTime.setDelta(new TimeSpan(0)); + this.daylightTime.setDayOrder(1); + this.daylightTime.setDayOfTheWeek(DayOfTheWeek.Sunday); + this.daylightTime.setMonth(10); + this.daylightTime.setTimeOfDay(new TimeSpan(2 * 60 * 60 * 1000)); + this.daylightTime.setYear(0); + + this.standardTime = new LegacyAvailabilityTimeZoneTime(); + this.standardTime.setDelta(new TimeSpan(0)); + this.standardTime.setDayOrder(1); + this.standardTime.setDayOfTheWeek(DayOfTheWeek.Sunday); + this.standardTime.setMonth(3); + this.standardTime.setTimeOfDay(new TimeSpan(2 * 60 * 60 * 1000)); + this.daylightTime.setYear(0); + } + + /** + * To time zone info. + * + * @return the time zone + */ + public TimeZoneDefinition toTimeZoneInfo() { + + /*NumberFormat formatter = new DecimalFormat("00"); + String timeZoneId = this.bias.isNegative() ? "GMT+"+formatter. + format(this.bias.getHours())+":"+ + formatter.format(this.bias.getMinutes()) : + "GMT-"+formatter.format(this.bias.getHours())+":"+ + formatter.format(this.bias.getMinutes()); +*/ + TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(); + timeZoneDefinition.id = UUID.randomUUID().toString(); + timeZoneDefinition.name = "Custom time zone"; + return timeZoneDefinition; + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.Bias)) { + this.bias = new TimeSpan((long) + reader.readElementValue(Integer.class) * 60 * 1000); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.StandardTime)) { + this.standardTime = new LegacyAvailabilityTimeZoneTime(); + this.standardTime.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.DaylightTime)) { + this.daylightTime = new LegacyAvailabilityTimeZoneTime(); + this.daylightTime.loadFromXml(reader, reader.getLocalName()); + return true; + } else { + + return false; + } + + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.Bias, + (int) this.bias.getTotalMinutes()); + + this.standardTime.writeToXml(writer, XmlElementNames.StandardTime); + this.daylightTime.writeToXml(writer, XmlElementNames.DaylightTime); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/availability/LegacyAvailabilityTimeZoneTime.java b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/LegacyAvailabilityTimeZoneTime.java new file mode 100644 index 000000000..7f0647fc3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/LegacyAvailabilityTimeZoneTime.java @@ -0,0 +1,299 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc.availability; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.time.DayOfTheWeek; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.TimeSpan; +import com.eischet.ews.api.property.complex.ComplexProperty; + +/** + * Represents a custom time zone time change. + */ +final class LegacyAvailabilityTimeZoneTime extends ComplexProperty { + + /** + * The delta. + */ + private TimeSpan delta; + + /** + * The year. + */ + private int year; + + /** + * The month. + */ + private int month; + + /** + * The day order. + */ + private int dayOrder; + + /** + * The day of the week. + */ + private DayOfTheWeek dayOfTheWeek; + + /** + * The time of day. + */ + private TimeSpan timeOfDay; + + /** + * Initializes a new instance of the LegacyAvailabilityTimeZoneTime class. + */ + protected LegacyAvailabilityTimeZoneTime() { + super(); + } + + /** + * initializes a new instance of the LegacyAvailabilityTimeZoneTime class. + * + * @param reader + * the reader + * @return true, if successful + * @throws Exception + * the exception + */ + /* + * protected LegacyAvailabilityTimeZoneTime(TimeZone.TransitionTime + * transitionTime, TimeSpan delta) { this(); this.delta = delta; + * + * if (transitionTime.IsFixedDateRule) { // TimeZoneInfo doesn't support an + * actual year. Fixed date transitions occur at the same // date every year + * the adjustment rule the transition belongs to applies. The best thing // + * we can do here is use the current year. this.year = Date.Today.Year; + * this.month = transitionTime.Month; this.dayOrder = transitionTime.Day; + * this.timeOfDay = transitionTime.TimeOfDay.TimeOfDay; } else { // For + * floating rules, the mapping is direct. this.year = 0; this.month = + * transitionTime.Month; this.dayOfTheWeek = + * EwsUtilities.SystemToEwsDayOfTheWeek(transitionTime.DayOfWeek); + * this.dayOrder = transitionTime.Week; this.timeOfDay = + * transitionTime.TimeOfDay.TimeOfDay; } } + */ + + /** + * Converts this instance to TimeZoneInfo.TransitionTime. returns + * TimeZoneInfo.TransitionTime + * + */ + /* + * protected TimeZone.TransitionTime toTransitionTime() { if (this.year == + * 0) { return TimeZone.TransitionTime.createFloatingDateRule( new Date( + * Date.MinValue.Year, DateTime.MinValue.Month, DateTime.MinValue.Day, + * this.timeOfDay.Hours, this.timeOfDay.Minutes, this.timeOfDay.Seconds), + * this.month, this.dayOrder, + * EwsUtilities.ewsToSystemDayOfWeek(this.dayOfTheWeek)); } else { return + * TimeZone.TransitionTime.createFixedDateRule( new + * Date(this.timeOfDay.Ticks), this.month, this.dayOrder); } } + */ + + /** + * Tries to read element from XML. + * + * @param reader accepts EwsServiceXmlReader + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.Bias)) { + this.delta = new TimeSpan((long) reader.readElementValue(Integer.class) * 60 * 1000); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Time)) { + this.timeOfDay = TimeSpan.parse(reader.readElementValue()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.DayOrder)) { + this.dayOrder = reader.readElementValue(Integer.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.DayOfWeek)) { + this.dayOfTheWeek = reader.readElementValue(DayOfTheWeek.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Month)) { + this.month = reader.readElementValue(Integer.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Year)) { + this.year = reader.readElementValue(Integer.class); + return true; + } else { + return false; + } + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Bias, (int) this.delta.getMinutes()); + + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Time, EwsUtilities.timeSpanToXSTime(this.timeOfDay)); + + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.DayOrder, this.dayOrder); + + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Month, this.month); + + // Only write DayOfWeek if this is a recurring time change + if (this.getYear() == 0) { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.DayOfWeek, this.dayOfTheWeek); + } + + // Only emit year if it's non zero, otherwise AS returns + // "Request is invalid" + if (this.getYear() != 0) { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Year, this.getYear()); + } + } + + /** + * Gets if current time presents DST transition time + * + * @return month + */ + protected boolean getHasTransitionTime() { + return this.month >= 1 && this.month <= 12; + } + + + /** + * Gets the delta. + * + * @return the delta + */ + protected TimeSpan getDelta() { + return this.delta; + } + + /** + * Sets the delta. + * + * @param delta the new delta + */ + protected void setDelta(TimeSpan delta) { + this.delta = delta; + } + + /** + * Gets the time of day. + * + * @return the time of day + */ + protected TimeSpan getTimeOfDay() { + return this.timeOfDay; + } + + /** + * Sets the time of day. + * + * @param timeOfDay the new time of day + */ + protected void setTimeOfDay(TimeSpan timeOfDay) { + this.timeOfDay = timeOfDay; + } + + /** + * Gets a value that represents: - The day of the month when Year is + * non zero, - The index of the week in the month if Year is equal to zero. + * + * @return the day order + */ + protected int getDayOrder() { + return this.dayOrder; + } + + /** + * Sets the day order. + * + * @param dayOrder the new day order + */ + protected void setDayOrder(int dayOrder) { + this.dayOrder = dayOrder; + } + + /** + * Gets the month. + * + * @return the month + */ + protected int getMonth() { + return this.month; + } + + /** + * Sets the month. + * + * @param month the new month + */ + protected void setMonth(int month) { + this.month = month; + } + + /** + * Gets the day of the week. + * + * @return the day of the week + */ + protected DayOfTheWeek getDayOfTheWeek() { + return this.dayOfTheWeek; + } + + /** + * Sets the day of the week. + * + * @param dayOfTheWeek the new day of the week + */ + protected void setDayOfTheWeek(DayOfTheWeek dayOfTheWeek) { + this.dayOfTheWeek = dayOfTheWeek; + } + + /** + * Gets the year. If Year is 0, the time change occurs every year + * according to a recurring pattern; otherwise, the time change occurs at + * the date specified by Day, Month, Year. + * + * @return the year + */ + protected int getYear() { + return this.year; + } + + /** + * Sets the year. + * + * @param year the new year + */ + protected void setYear(int year) { + this.year = year; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/availability/OofReply.java b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/OofReply.java new file mode 100644 index 000000000..3eae2a272 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/OofReply.java @@ -0,0 +1,184 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc.availability; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import javax.xml.stream.XMLStreamException; + +/** + * Represents an Out of Office response. + */ +public final class OofReply { + + /** + * The culture. + */ + private String culture = "en-US"; + + /** + * The message. + */ + private String message; + + /** + * Writes an empty OofReply to XML. + * + * @param writer the writer + * @param xmlElementName the xml element name + */ + public static void writeEmptyReplyToXml(EwsServiceXmlWriter writer, String xmlElementName) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, xmlElementName); + writer.writeEndElement(); // xmlElementName + } + + /** + * Initializes a new instance of the class. + */ + public OofReply() { + } + + /** + * Initializes a new instance of the class. + * + * @param message the message + */ + public OofReply(String message) { + this.message = message; + } + + /** + * Initializes a new instance of the class. + * + * @param message the message + * @return the oof reply from string + */ + public static OofReply getOofReplyFromString(String message) { + return new OofReply(message); + } + + /** + * Gets the string from oof reply. + * + * @param oofReply the oof reply + * @return the string from oof reply + * @throws Exception the exception + */ + public static String getStringFromOofReply(OofReply oofReply) + throws Exception { + EwsUtilities.validateParam(oofReply, "oofReply"); + return oofReply.message; + } + + /** + * Loads from XML. + * + * @param reader the reader + * @param xmlElementName the xml element name + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader, String xmlElementName) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, xmlElementName); + + if (reader.hasAttributes()) { + this.setCulture(reader.readAttributeValue("xml:lang")); + } + + this.message = reader.readElementValue(XmlNamespace.Types, XmlElementNames.Message); + + reader.readEndElement(XmlNamespace.Types, xmlElementName); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param xmlElementName the xml element name + */ + public void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, xmlElementName); + + if (this.culture != null) { + writer.writeAttributeValue("xml", "lang", this.culture); + } + + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Message, + this.message); + + writer.writeEndElement(); // xmlElementName + } + + /** + * Obtains a string representation of the reply. + * + * @return A string containing the reply message. + */ + public String toString() { + return this.message; + } + + /** + * Gets the culture of the reply. + * + * @return the culture + */ + public String getCulture() { + return this.culture; + + } + + /** + * Sets the culture. + * + * @param culture the new culture + */ + public void setCulture(String culture) { + this.culture = culture; + } + + /** + * Gets the the reply message. + * + * @return the message + */ + public String getMessage() { + return this.message; + } + + /** + * Sets the message. + * + * @param message the new message + */ + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/availability/TimeWindow.java b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/TimeWindow.java new file mode 100644 index 000000000..48559dc4e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/availability/TimeWindow.java @@ -0,0 +1,178 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc.availability; + +import com.eischet.ews.api.ISelfValidate; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.time.Duration; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Represents a time period. + */ +public class TimeWindow implements ISelfValidate { + + /** + * The start time. + */ + private LocalDateTime startTime; + + /** + * The end time. + */ + private LocalDateTime endTime; + + /** + * Initializes a new instance of the "TimeWindow" class. + */ + public TimeWindow() { + } + + /** + * Initializes a new instance of the "TimeWindow" class. + * + * @param startTime the start time + * @param endTime the end time + */ + public TimeWindow(LocalDateTime startTime, LocalDateTime endTime) { + this(); + this.startTime = startTime; + this.endTime = endTime; + } + + /** + * Gets the start time. + * + * @return the start time + */ + public LocalDateTime getStartTime() { + return startTime; + } + + /** + * Sets the start time. + * + * @param startTime the new start time + */ + public void setStartTime(LocalDateTime startTime) { + this.startTime = startTime; + } + + /** + * Gets the end time. + * + * @return the end time + */ + public LocalDateTime getEndTime() { + return endTime; + } + + /** + * Sets the end time. + * + * @param endTime the new end time + */ + public void setEndTime(LocalDateTime endTime) { + this.endTime = endTime; + } + + /** + * Loads from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, XmlElementNames.Duration); + this.startTime = reader.readElementValueAsDateTime(XmlNamespace.Types, XmlElementNames.StartTime); + this.endTime = reader.readElementValueAsDateTime(XmlNamespace.Types, XmlElementNames.EndTime); + reader.readEndElement(XmlNamespace.Types, XmlElementNames.Duration); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param xmlElementName the xml element name + * @param startTime the start time + * @param endTime the end time + */ + private static void writeToXml(EwsServiceXmlWriter writer, + String xmlElementName, Object startTime, Object endTime) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, xmlElementName); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.StartTime, startTime); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.EndTime, endTime); + writer.writeEndElement(); // xmlElementName + } + + /** + * Writes to XML without scoping the dates and without emitting times. + * + * @param writer the writer + * @param xmlElementName the xml element name + */ + protected void writeToXmlUnscopedDatesOnly(EwsServiceXmlWriter writer, String xmlElementName) throws ExchangeXmlException { + final String DateOnlyFormat = "yyyy-MM-dd'T'00:00:00"; + + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateOnlyFormat); + + //DateFormat formatter = new SimpleDateFormat(DateOnlyFormat); + //formatter.setTimeZone(TimeZone.getTimeZone("UTC")); + + String start = formatter.format(this.startTime); + String end = formatter.format(this.endTime); + TimeWindow.writeToXml(writer, xmlElementName, start, end); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param xmlElementName the xml element name + */ + public void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) throws ExchangeXmlException { + TimeWindow.writeToXml(writer, xmlElementName, startTime, endTime); + } + + /** + * Gets the duration. + * + * @return the duration + */ + public long getDuration() { + return Duration.between(startTime, endTime).toMillis(); + } + + /** + * Validates this instance. + */ + public void validate() { + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/id/AlternateId.java b/ews-api/src/main/java/com/eischet/ews/api/misc/id/AlternateId.java new file mode 100644 index 000000000..0961bee79 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/id/AlternateId.java @@ -0,0 +1,207 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc.id; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.IdFormat; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents an Id expressed in a specific format. + */ +public class AlternateId extends AlternateIdBase { + + /** + * Name of schema type used for AlternateId. + */ + public final static String SchemaTypeName = "AlternateIdType"; + + /** + * Id. + */ + private String id; + + /** + * SMTP address of the mailbox that the id belongs to. + */ + private String mailbox; + + /** + * Type (primary or archive) mailbox to which the Id belongs + */ + private boolean isArchive; + + /** + * Initializes a new instance of the class. + */ + public AlternateId() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param format the format + * @param id the id + * @param mailbox the mailbox + */ + public AlternateId(IdFormat format, String id, String mailbox) { + super(format); + this.setUniqueId(id); + this.setMailbox(mailbox); + } + + /** + * Initializes a new instance of the AlternateId class. + * + * @param format The format the Id is expressed in. + * @param id The Id. + * @param mailbox The SMTP address of the mailbox that the Id belongs to. + * @param isArchive Primary (false) or archive (true) mailbox. + */ + public AlternateId( + IdFormat format, + String id, + String mailbox, + boolean isArchive) { + super(format); + this.setUniqueId(id); + this.setMailbox(mailbox); + this.setIsArchive(isArchive); + } + + /** + * Gets the Id. + * + * @return the unique id + */ + public String getUniqueId() { + return this.id; + } + + /** + * Sets the unique id. + * + * @param id the new unique id + */ + public void setUniqueId(String id) { + this.id = id; + } + + /** + * Gets the mailbox to which the Id belongs. + * + * @return the mailbox + */ + public String getMailbox() { + return this.mailbox; + } + + /** + * Sets the mailbox. + * + * @param mailbox the new mailbox + */ + public void setMailbox(String mailbox) { + this.mailbox = mailbox; + } + + /** + * Gets the type (primary or archive) mailbox to which the Id belongs. + */ + public boolean getIsArchive() { + return this.isArchive; + } + + /** + * Sets the type (primary or archive) mailbox to which the Id belongs. + * + * @param isArchive the new isArchive + */ + public void setIsArchive(boolean isArchive) { + this.isArchive = isArchive; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.AlternateId; + } + + /** + * Gets the name of the XML element. + * + * @param writer the writer + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + writer.writeAttributeValue(XmlAttributeNames.Id, this.getUniqueId()); + writer.writeAttributeValue(XmlAttributeNames.Mailbox, + this.getMailbox()); + //.getMailbox() == null || this.getMailbox().isEmpty()) ? "" + //: this.getMailbox()); + if (this.getIsArchive()) { + writer.writeAttributeValue(XmlAttributeNames.IsArchive, true); + } + + } + + /** + * Gets the name of the XML element. + * + * @param reader the reader + */ + @Override + public void loadAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + super.loadAttributesFromXml(reader); + + this.setUniqueId(reader.readAttributeValue(XmlAttributeNames.Id)); + this.setMailbox(reader.readAttributeValue(XmlAttributeNames.Mailbox)); + String isArchive = reader.readAttributeValue( + XmlAttributeNames.IsArchive); + + if (!(isArchive == null || isArchive.isEmpty())) { + this.isArchive = reader.readAttributeValue(Boolean.class, + XmlAttributeNames.IsArchive); + } else { + this.isArchive = false; + } + } + + /** + * Validate this instance. + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + EwsUtilities.validateParam(this.getMailbox(), "mailbox"); + } +} + + diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/id/AlternateIdBase.java b/ews-api/src/main/java/com/eischet/ews/api/misc/id/AlternateIdBase.java new file mode 100644 index 000000000..30f9d1d36 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/id/AlternateIdBase.java @@ -0,0 +1,108 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc.id; + +import com.eischet.ews.api.ISelfValidate; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.enumeration.misc.IdFormat; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents the base class for Id expressed in a specific format. + */ +public abstract class AlternateIdBase implements ISelfValidate { + + /** + * Id format. + */ + private IdFormat format; + + /** + * Initializes a new instance of the class. + */ + protected AlternateIdBase() { + } + + /** + * Initializes a new instance of the class. + * + * @param format the format + */ + protected AlternateIdBase(IdFormat format) { + super(); + this.format = format; + } + + /** + * Gets the format in which the Id in expressed. + * + * @return the format + */ + public IdFormat getFormat() { + return this.format; + } + + /** + * Sets the format. + * + * @param format the new format + */ + public void setFormat(IdFormat format) { + this.format = format; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + protected abstract String getXmlElementName(); + + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.Format, this.getFormat()); + } + + public void loadAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.setFormat(reader.readAttributeValue(IdFormat.class, XmlAttributeNames.Format)); + } + + public void writeToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, this.getXmlElementName()); + this.writeAttributesToXml(writer); + writer.writeEndElement(); // this.GetXmlElementName() + } + + protected void internalValidate() throws ExchangeValidationException { + // nothing to do. + } + + public void validate() throws ExchangeValidationException { + this.internalValidate(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/id/AlternatePublicFolderId.java b/ews-api/src/main/java/com/eischet/ews/api/misc/id/AlternatePublicFolderId.java new file mode 100644 index 000000000..78cc5112a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/id/AlternatePublicFolderId.java @@ -0,0 +1,115 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc.id; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.IdFormat; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents the Id of a public folder expressed in a specific format. + */ +public class AlternatePublicFolderId extends AlternateIdBase { + + /** + * Name of schema type used for AlternatePublicFolderId element. + */ + public final static String SchemaTypeName = + "AlternatePublicFolderIdType"; + + private String folderId; + + /** + * Initializes a new instance of AlternatePublicFolderId. + */ + public AlternatePublicFolderId() { + super(); + } + + /** + * Initializes a new instance of AlternatePublicFolderId. + * + * @param format the format + * @param folderId the folder id + */ + public AlternatePublicFolderId(IdFormat format, String folderId) { + super(format); + this.setFolderId(folderId); + } + + /** + * The Id of the public folder. + * + * @return the folder id + */ + public String getFolderId() { + return this.folderId; + + } + + /** + * Sets the folder id. + * + * @param folderId the new folder id + */ + public void setFolderId(String folderId) { + this.folderId = folderId; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.AlternatePublicFolderId; + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + writer.writeAttributeValue(XmlAttributeNames.FolderId, this.getFolderId()); + } + + /** + * Loads the attribute from XML. + * + * @param reader the reader + */ + @Override + public void loadAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + super.loadAttributesFromXml(reader); + this.setFolderId(reader.readAttributeValue(XmlAttributeNames.FolderId)); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/misc/id/AlternatePublicFolderItemId.java b/ews-api/src/main/java/com/eischet/ews/api/misc/id/AlternatePublicFolderItemId.java new file mode 100644 index 000000000..d3199e879 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/misc/id/AlternatePublicFolderItemId.java @@ -0,0 +1,119 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc.id; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.IdFormat; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents the Id of a public folder item expressed in a specific format. + */ +public class AlternatePublicFolderItemId extends AlternatePublicFolderId { + + /** + * Schema type associated with AlternatePublicFolderItemId. + */ + public final static String SchemaTypeName = + "AlternatePublicFolderItemIdType"; + + /** + * Item id. + */ + private String itemId; + + /** + * Initializes a new instance of the class. + */ + public AlternatePublicFolderItemId() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param format the format + * @param folderId the folder id + * @param itemId the item id + */ + public AlternatePublicFolderItemId(IdFormat format, String folderId, + String itemId) { + super(format, folderId); + this.itemId = itemId; + } + + /** + * Gets The Id of the public folder item. + * + * @return the item id + */ + public String getItemId() { + return this.itemId; + } + + /** + * Sets the item id. + * + * @param itemId the new item id + */ + public void setItemId(String itemId) { + this.itemId = itemId; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.AlternatePublicFolderItemId; + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + writer.writeAttributeValue(XmlAttributeNames.ItemId, this.getItemId()); + } + + /** + * Loads the attribute from XML. + * + * @param reader the reader + */ + @Override + public void loadAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + super.loadAttributesFromXml(reader); + this.itemId = reader.readAttributeValue(XmlAttributeNames.ItemId); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/notification/FolderEvent.java b/ews-api/src/main/java/com/eischet/ews/api/notification/FolderEvent.java new file mode 100644 index 000000000..8341e55f3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/notification/FolderEvent.java @@ -0,0 +1,145 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.notification; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.notification.EventType; +import com.eischet.ews.api.property.complex.FolderId; + +import java.time.LocalDateTime; + + +/** + * Represents an event that applies to a folder. + */ +public class FolderEvent extends NotificationEvent { + + /** + * The folder id. + */ + private FolderId folderId; + + /** + * The old folder id. + */ + private FolderId oldFolderId; + + /** + * The new number of unread messages. This is is only meaningful when + * EventType is equal to EventType.Modified. For all other event types, it's + * null. + */ + private int unreadCount; + + /** + * Initializes a new instance. + * + * @param eventType the event type + * @param timestamp the timestamp + */ + protected FolderEvent(EventType eventType, LocalDateTime timestamp) { + super(eventType, timestamp); + } + + /** + * Load from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + protected void internalLoadFromXml(EwsServiceXmlReader reader) + throws Exception { + super.internalLoadFromXml(reader); + + this.folderId = new FolderId(); + this.folderId.loadFromXml(reader, reader.getLocalName()); + + reader.read(); + + setParentFolderId(new FolderId()); + getParentFolderId().loadFromXml(reader, XmlElementNames.ParentFolderId); + + switch (getEventType()) { + case Moved: + case Copied: + reader.read(); + + this.oldFolderId = new FolderId(); + this.oldFolderId.loadFromXml(reader, reader.getLocalName()); + + reader.read(); + + setParentFolderId(new FolderId()); + getParentFolderId().loadFromXml(reader, reader.getLocalName()); + break; + + case Modified: + reader.read(); + if (reader.isStartElement()) { + reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, + XmlElementNames.UnreadCount); + String str = reader.readValue(); + this.unreadCount = Integer.parseInt(str); + } + break; + + default: + break; + } + } + + /** + * Gets the Id of the folder this event applies to. + * + * @return folderId + */ + public FolderId getFolderId() { + return folderId; + } + + /** + * gets the Id of the folder that was moved or copied. OldFolderId is only + * meaningful when EventType is equal to either EventType.Moved or + * EventType.Copied. For all other event types, OldFolderId is null. + * + * @return oldFolderId + */ + public FolderId getOldFolderId() { + return oldFolderId; + } + + /** + * Gets the new number of unread messages. This is is only meaningful when + * EventType is equal to EventType.Modified. For all other event types, + * UnreadCount is null. + * + * @return unreadCount + */ + public int getUnreadCount() { + return unreadCount; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/notification/GetEventsResults.java b/ews-api/src/main/java/com/eischet/ews/api/notification/GetEventsResults.java new file mode 100644 index 000000000..b6ec6cb8b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/notification/GetEventsResults.java @@ -0,0 +1,259 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.notification; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.ILazyMember; +import com.eischet.ews.api.core.LazyMember; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.notification.EventType; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +/** + * Represents a collection of notification events. + */ +public final class GetEventsResults { + /** + * Watermark in event. + */ + private String newWatermark; + + /** + * Subscription id. + */ + private String subscriptionId; + + /** + * Previous watermark. + */ + private String previousWatermark; + + /** + * True if more events available for this subscription. + */ + private boolean moreEventsAvailable; + + /** + * Collection of notification events. + */ + private final Collection events = + new ArrayList(); + + /** + * Map XML element name to notification event type. If you add a new + * notification event type, you'll need to add a new entry to the Map here. + */ + private static final LazyMember> + xmlElementNameToEventTypeMap = + new LazyMember>( + new ILazyMember>() { + @Override + public Map createInstance() { + Map result = + new HashMap(); + result.put(XmlElementNames.CopiedEvent, EventType.Copied); + result.put(XmlElementNames.CreatedEvent, EventType.Created); + result.put(XmlElementNames.DeletedEvent, EventType.Deleted); + result.put(XmlElementNames.ModifiedEvent, + EventType.Modified); + result.put(XmlElementNames.MovedEvent, EventType.Moved); + result.put(XmlElementNames.NewMailEvent, EventType.NewMail); + result.put(XmlElementNames.StatusEvent, EventType.Status); + result.put(XmlElementNames.FreeBusyChangedEvent, + EventType.FreeBusyChanged); + return result; + } + }); + + /** + * Gets the XML element name to event type mapping. + * + * @return The XML element name to event type mapping. + */ + protected static Map getXmlElementNameToEventTypeMap() { + return GetEventsResults.xmlElementNameToEventTypeMap.getMember(); + } + + /** + * Initializes a new instance. + */ + public GetEventsResults() { + } + + /** + * Loads from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader) throws Exception { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.Notification); + + this.subscriptionId = reader.readElementValue(XmlNamespace.Types, + XmlElementNames.SubscriptionId); + this.previousWatermark = reader.readElementValue(XmlNamespace.Types, + XmlElementNames.PreviousWatermark); + this.moreEventsAvailable = reader.readElementValue(Boolean.class, + XmlNamespace.Types, XmlElementNames.MoreEvents); + + do { + reader.read(); + + if (reader.isStartElement()) { + String eventElementName = reader.getLocalName(); + EventType eventType; + + if (xmlElementNameToEventTypeMap.getMember().containsKey( + eventElementName)) { + eventType = xmlElementNameToEventTypeMap.getMember().get( + eventElementName); + this.newWatermark = reader.readElementValue( + XmlNamespace.Types, XmlElementNames.Watermark); + if (eventType == EventType.Status) { + // We don't need to return status events + reader.readEndElementIfNecessary(XmlNamespace.Types, + eventElementName); + } else { + this.loadNotificationEventFromXml(reader, + eventElementName, eventType); + } + } else { + reader.skipCurrentElement(); + } + + } + + } while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.Notification)); + } + + /** + * Loads a notification event from XML. + * + * @param reader the reader + * @param eventElementName the event element name + * @param eventType the event type + * @throws Exception the exception + */ + private void loadNotificationEventFromXml(EwsServiceXmlReader reader, + String eventElementName, EventType eventType) throws Exception { + LocalDateTime date = reader.readElementValue(LocalDateTime.class, XmlNamespace.Types, XmlElementNames.TimeStamp); + + NotificationEvent notificationEvent; + + reader.read(); + + if (reader.getLocalName().equals(XmlElementNames.FolderId)) { + notificationEvent = new FolderEvent(eventType, date); + } else { + notificationEvent = new ItemEvent(eventType, date); + } + + notificationEvent.loadFromXml(reader, eventElementName); + this.events.add(notificationEvent); + } + + /** + * Gets the Id of the subscription the collection is associated with. + * + * @return the subscription id + */ + protected String getSubscriptionId() { + return subscriptionId; + } + + /** + * Gets the subscription's previous watermark. + * + * @return the previous watermark + */ + protected String getPreviousWatermark() { + return previousWatermark; + } + + /** + * Gets the subscription's new watermark. + * + * @return the new watermark + */ + protected String getNewWatermark() { + return newWatermark; + } + + /** + * Gets a value indicating whether more events are available on the Exchange + * server. + * + * @return true, if is more events available + */ + protected boolean isMoreEventsAvailable() { + return moreEventsAvailable; + } + + /** + * Gets the collection of folder events. + * + * @return the folder events + */ + public Iterable getFolderEvents() { + Collection folderEvents = new ArrayList(); + for (Object event : this.events) { + if (event instanceof FolderEvent) { + folderEvents.add((FolderEvent) event); + } + } + return folderEvents; + } + + /** + * Gets the collection of item events. + * + * @return the item events + */ + public Iterable getItemEvents() { + Collection itemEvents = new ArrayList(); + for (Object event : this.events) { + if (event instanceof ItemEvent) { + itemEvents.add((ItemEvent) event); + } + } + return itemEvents; + } + + /** + * Gets the collection of all events. + * + * @return the all events + */ + public Collection getAllEvents() { + return this.events; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/notification/GetStreamingEventsResults.java b/ews-api/src/main/java/com/eischet/ews/api/notification/GetStreamingEventsResults.java new file mode 100644 index 000000000..1f8afe03c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/notification/GetStreamingEventsResults.java @@ -0,0 +1,163 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.notification; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.notification.EventType; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collection; + +/** + * Represents a collection of notification events. + */ +public final class GetStreamingEventsResults { + + /** + * Structure to track a subscription and its associated notification events. + */ + protected static class NotificationGroup { + /** + * Subscription Id + */ + protected String subscriptionId; + + /** + * Events in the response associated with the subscription id. + */ + protected Collection events; + } + + + /** + * Collection of notification events. + */ + private final Collection events = + new ArrayList(); + + /** + * Initializes a new instance of the class. + */ + public GetStreamingEventsResults() { + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @throws Exception + */ + public void loadFromXml(EwsServiceXmlReader reader) throws Exception { + reader.readStartElement(XmlNamespace.Messages, + XmlElementNames.Notification); + + do { + NotificationGroup notifications = new NotificationGroup(); + notifications.subscriptionId = reader.readElementValue( + XmlNamespace.Types, + XmlElementNames.SubscriptionId); + notifications.events = new ArrayList(); + + synchronized (this) { + this.events.add(notifications); + } + + do { + reader.read(); + + if (reader.isStartElement()) { + String eventElementName = reader.getLocalName(); + EventType eventType; + if (GetEventsResults.getXmlElementNameToEventTypeMap().containsKey(eventElementName)) { + eventType = GetEventsResults.getXmlElementNameToEventTypeMap(). + get(eventElementName); + if (eventType == EventType.Status) { + // We don't need to return status events + reader.readEndElementIfNecessary(XmlNamespace.Types, + eventElementName); + } else { + this.loadNotificationEventFromXml( + reader, + eventElementName, + eventType, + notifications); + } + } else { + reader.skipCurrentElement(); + } + } + } + while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.Notification)); + + reader.read(); + } + while (!reader.isEndElement(XmlNamespace.Messages, + XmlElementNames.Notifications)); + } + + /** + * Loads a notification event from XML. + * + * @param reader The reader. + * @param eventElementName Name of the event XML element. + * @param eventType Type of the event. + * @param notifications Collection of notification + * @throws Exception + */ + private void loadNotificationEventFromXml( + EwsServiceXmlReader reader, + String eventElementName, + EventType eventType, + NotificationGroup notifications) throws Exception { + LocalDateTime timestamp = reader.readElementValue(LocalDateTime.class, XmlNamespace.Types, XmlElementNames.TimeStamp); + + NotificationEvent notificationEvent; + + reader.read(); + + if (reader.getLocalName().equals(XmlElementNames.FolderId)) { + notificationEvent = new FolderEvent(eventType, timestamp); + } else { + notificationEvent = new ItemEvent(eventType, timestamp); + } + + notificationEvent.loadFromXml(reader, eventElementName); + notifications.events.add(notificationEvent); + } + + /** + * Gets the notification collection. + * + * @value The notification collection. + */ + protected Collection getNotifications() { + return this.events; + } +} + diff --git a/ews-api/src/main/java/com/eischet/ews/api/notification/ItemEvent.java b/ews-api/src/main/java/com/eischet/ews/api/notification/ItemEvent.java new file mode 100644 index 000000000..08013b970 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/notification/ItemEvent.java @@ -0,0 +1,120 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.notification; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.notification.EventType; +import com.eischet.ews.api.property.complex.FolderId; +import com.eischet.ews.api.property.complex.ItemId; + +import java.time.LocalDateTime; + +/** + * Represents an event that applies to an item. + */ +public final class ItemEvent extends NotificationEvent { + + /** + * Id of the item this event applies to. + */ + private ItemId itemId; + + /** + * Id of the item that moved or copied. This is only meaningful when + * EventType is equal to either EventType.Moved or EventType.Copied. For all + * other event types, it's null. + */ + private ItemId oldItemId; + + /** + * Initializes a new instance. + * + * @param eventType the event type + * @param timestamp the timestamp + */ + protected ItemEvent(EventType eventType, LocalDateTime timestamp) { + super(eventType, timestamp); + } + + /** + * Load from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + protected void internalLoadFromXml(EwsServiceXmlReader reader) + throws Exception { + super.internalLoadFromXml(reader); + + this.itemId = new ItemId(); + this.itemId.loadFromXml(reader, reader.getLocalName()); + + reader.read(); + + setParentFolderId(new FolderId()); + + getParentFolderId().loadFromXml(reader, XmlElementNames.ParentFolderId); + + EventType eventType = getEventType(); + switch (eventType) { + case Moved: + case Copied: + reader.read(); + + this.oldItemId = new ItemId(); + this.oldItemId.loadFromXml(reader, reader.getLocalName()); + + reader.read(); + + setOldParentFolderId(new FolderId()); + getOldParentFolderId().loadFromXml(reader, reader.getLocalName()); + break; + + default: + break; + } + } + + /** + * Gets the Id of the item this event applies to. + * + * @return itemId + */ + public ItemId getItemId() { + return itemId; + } + + /** + * Gets the Id of the item that was moved or copied. OldItemId is only + * meaningful when EventType is equal to either EventType.Moved or + * EventType.Copied. For all other event types, OldItemId is null. + * + * @return the old item id + */ + public ItemId getOldItemId() { + return oldItemId; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/notification/NotificationEvent.java b/ews-api/src/main/java/com/eischet/ews/api/notification/NotificationEvent.java new file mode 100644 index 000000000..22a9a6660 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/notification/NotificationEvent.java @@ -0,0 +1,151 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.notification; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.notification.EventType; +import com.eischet.ews.api.property.complex.FolderId; + +import java.time.LocalDateTime; + +/** + * Represents an event as exposed by push and pull notification. + */ +public abstract class NotificationEvent { + + /** + * Type of this event. + */ + private final EventType eventType; + + /** + * Date and time when the event occurred. + */ + private final LocalDateTime timestamp; + + /** + * Id of parent folder of the item or folder this event applies to. + */ + private FolderId parentFolderId; + + /** + * Id of the old parent folder of the item or folder this event applies to. + * This property is only meaningful when EventType is equal to either + * EventType.Moved or EventType.Copied. For all other event types, + * oldParentFolderId will be null + */ + private FolderId oldParentFolderId; + + /** + * Initializes a new instance. + * + * @param eventType the event type + * @param timestamp the timestamp + */ + protected NotificationEvent(EventType eventType, LocalDateTime timestamp) { + this.eventType = eventType; + this.timestamp = timestamp; + } + + /** + * Load from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + protected void internalLoadFromXml(EwsServiceXmlReader reader) throws Exception { + } + + /** + * Loads this NotificationEvent from XML. + * + * @param reader the reader + * @param xmlElementName the xml element name + * @throws Exception the exception + */ + protected void loadFromXml(EwsServiceXmlReader reader, + String xmlElementName) + throws Exception { + this.internalLoadFromXml(reader); + + reader.readEndElementIfNecessary(XmlNamespace.Types, xmlElementName); + } + + /** + * gets the eventType. + * + * @return the eventType. + */ + public EventType getEventType() { + return eventType; + } + + /** + * gets the timestamp. + * + * @return the timestamp. + */ + public LocalDateTime getTimestamp() { + return timestamp; + } + + /** + * gets the parentFolderId. + * + * @return the parentFolderId. + */ + public FolderId getParentFolderId() { + return parentFolderId; + } + + /** + * Sets the parentFolderId. + * + * @param parentFolderId the new parent folder id + */ + protected void setParentFolderId(FolderId parentFolderId) { + this.parentFolderId = parentFolderId; + } + + /** + * gets the oldParentFolderId. + * + * @return the oldParentFolderId. + */ + public FolderId getOldParentFolderId() { + return oldParentFolderId; + } + + /** + * Sets the oldParentFolderId. + * + * @param oldParentFolderId the new old parent folder id + */ + protected void setOldParentFolderId(FolderId oldParentFolderId) { + + this.oldParentFolderId = oldParentFolderId; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/notification/NotificationEventArgs.java b/ews-api/src/main/java/com/eischet/ews/api/notification/NotificationEventArgs.java new file mode 100644 index 000000000..b87d00596 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/notification/NotificationEventArgs.java @@ -0,0 +1,78 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.notification; + +/** + * Provides data to a StreamingSubscriptionConnection's + * OnNotificationEvent event. + */ +public class NotificationEventArgs { + private StreamingSubscription subscription; + private Iterable events; + + /** + * Initializes a new instance of the NotificationEventArgs class. + * + * @param subscription The subscription for which notification have been received. + * @param events The events that were received. + */ + protected NotificationEventArgs( + StreamingSubscription subscription, + Iterable events) { + this.setSubscription(subscription); + this.setEvents(events); + } + + /** + * Gets the subscription for which notification have been received. + */ + public StreamingSubscription getSubscription() { + return this.subscription; + + } + + /** + * Sets the events that were received. + */ + protected void setSubscription(StreamingSubscription value) { + this.subscription = value; + } + + /** + * Gets the events that were received. + */ + public Iterable getEvents() { + return this.events; + + } + + /** + * Sets the events that were received. + */ + protected void setEvents(Iterable value) { + this.events = value; + } + + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/notification/PullSubscription.java b/ews-api/src/main/java/com/eischet/ews/api/notification/PullSubscription.java new file mode 100644 index 000000000..81df6fdd5 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/notification/PullSubscription.java @@ -0,0 +1,137 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.notification; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.misc.AsyncCallback; +import com.eischet.ews.api.misc.IAsyncResult; + +/** + * Represents a pull subscription. + */ +public final class PullSubscription extends SubscriptionBase { + /** + * The more events available. + */ + private boolean moreEventsAvailable; + + /** + * Initializes a new instance. + * + * @param service the service + * @throws Exception the exception + */ + public PullSubscription(ExchangeService service) throws Exception { + super(service); + } + + /** + * Obtains a collection of events that occurred on the subscribed folder + * since the point in time defined by the Watermark property. When GetEvents + * succeeds, Watermark is updated. + * + * @return Returns a collection of events that occurred since the last + * watermark + * @throws Exception the exception + */ + public GetEventsResults getEvents() throws Exception { + GetEventsResults results = getService().getEvents(this.getId(), + this.getWaterMark()); + this.setWaterMark(results.getNewWatermark()); + this.moreEventsAvailable = results.isMoreEventsAvailable(); + return results; + } + + /** + * Begins an asynchronous request to obtain a collection of events that occurred on the subscribed + * folder since the point in time defined by the Watermark property + * + * @param callback The AsyncCallback delegate + * @param state An object that contains state information for this request + * @return An IAsyncResult that references the asynchronous request + * @throws Exception + */ + public IAsyncResult beginGetEvents(AsyncCallback callback, Object state) throws Exception { + return this.getService().beginGetEvents(callback, state, this.getId(), this.getWaterMark()); + } + + /** + * Ends an asynchronous request to obtain a collection of events that occurred on the subscribed + * folder since the point in time defined by the Watermark property. When EndGetEvents succeeds, + * Watermark is updated. + * + * @param asyncResult An IAsyncResult that references the asynchronous request. + * @return Returns a collection of events that occurred since the last watermark. + * @throws Exception + */ + public GetEventsResults endGetEvents(IAsyncResult asyncResult) throws Exception { + GetEventsResults results = this.getService().endGetEvents(asyncResult); + + this.setWaterMark(results.getNewWatermark()); + this.moreEventsAvailable = results.isMoreEventsAvailable(); + + return results; + } + + /** + * Unsubscribes from the pull subscription. + * + * @throws Exception the exception + */ + public void unsubscribe() throws Exception { + getService().unsubscribe(getId()); + } + + /** + * Begins an asynchronous request to unsubscribe from the pull subscription. + * + * @param callback The AsyncCallback delegate. + * @param state An object that contains state information for this request + * @return An IAsyncResult that references the asynchronous request + * @throws Exception + */ + public IAsyncResult beginUnsubscribe(AsyncCallback callback, Object state) throws Exception { + return this.getService().beginUnsubscribe(callback, state, this.getId()); + } + + /** + * Ends an asynchronous request to unsubscribe from the pull subscription. + * + * @param asyncResult An IAsyncResult that references the asynchronous request. + * @throws Exception + */ + public void endUnsubscribe(IAsyncResult asyncResult) throws Exception { + this.getService().endUnsubscribe(asyncResult); + } + + /** + * Gets a value indicating whether more events are available on the server. + * MoreEventsAvailable is undefined (null) until GetEvents is called. + * + * @return true, if is more events available + */ + public boolean isMoreEventsAvailable() { + return moreEventsAvailable; + } +} diff --git a/src/main/java/microsoft/exchange/webservices/data/notification/PushSubscription.java b/ews-api/src/main/java/com/eischet/ews/api/notification/PushSubscription.java similarity index 78% rename from src/main/java/microsoft/exchange/webservices/data/notification/PushSubscription.java rename to ews-api/src/main/java/com/eischet/ews/api/notification/PushSubscription.java index 13c534d36..ee0dd0013 100644 --- a/src/main/java/microsoft/exchange/webservices/data/notification/PushSubscription.java +++ b/ews-api/src/main/java/com/eischet/ews/api/notification/PushSubscription.java @@ -21,22 +21,22 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.notification; +package com.eischet.ews.api.notification; -import microsoft.exchange.webservices.data.core.ExchangeService; +import com.eischet.ews.api.core.ExchangeService; /** * Represents a push subscriptions.. */ public final class PushSubscription extends SubscriptionBase { - /** - * Initializes a new instance. - * - * @param service the service - * @throws Exception the exception - */ - public PushSubscription(ExchangeService service) throws Exception { - super(service); - } + /** + * Initializes a new instance. + * + * @param service the service + * @throws Exception the exception + */ + public PushSubscription(ExchangeService service) throws Exception { + super(service); + } } diff --git a/ews-api/src/main/java/com/eischet/ews/api/notification/StreamingSubscription.java b/ews-api/src/main/java/com/eischet/ews/api/notification/StreamingSubscription.java new file mode 100644 index 000000000..6a17cce4e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/notification/StreamingSubscription.java @@ -0,0 +1,82 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.notification; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.misc.AsyncCallback; +import com.eischet.ews.api.misc.IAsyncResult; + +/** + * Represents a streaming subscription. + */ +public final class StreamingSubscription extends SubscriptionBase { + + public StreamingSubscription(ExchangeService service) throws Exception { + super(service); + } + + /** + * Unsubscribes from the streaming subscription. + */ + public void unsubscribe() throws Exception { + this.getService().unsubscribe(this.getId()); + } + + /** + * Begins an asynchronous request to unsubscribe from the streaming subscription. + * + * @param callback The AsyncCallback delegate. + * @param state An object that contains state information for this request. + * @return An IAsyncResult that references the asynchronous request. + * @throws Exception + */ + public IAsyncResult beginUnsubscribe(AsyncCallback callback, Object state) throws Exception { + return this.getService().beginUnsubscribe(callback, state, this.getId()); + } + + /** + * Ends an asynchronous request to unsubscribe from the streaming subscription. + * + * @param asyncResult An IAsyncResult that references the asynchronous request. + */ + public void endUnsubscribe(IAsyncResult asyncResult) throws Exception { + this.getService().endUnsubscribe(asyncResult); + } + + /** + * Gets the service used to create this subscription. + */ + public ExchangeService getService() { + return super.getService(); + } + + + /** + * Gets a value indicating whether this subscription uses watermarks. + */ + @Override + protected boolean getUsesWatermark() { + return false; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/notification/StreamingSubscriptionConnection.java b/ews-api/src/main/java/com/eischet/ews/api/notification/StreamingSubscriptionConnection.java new file mode 100644 index 000000000..11652027a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/notification/StreamingSubscriptionConnection.java @@ -0,0 +1,570 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.notification; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.error.ServiceError; +import com.eischet.ews.api.core.enumeration.service.ServiceResult; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.misc.ArgumentNullException; +import com.eischet.ews.api.core.exception.misc.ArgumentOutOfRangeException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.remote.ServiceResponseException; +import com.eischet.ews.api.core.request.GetStreamingEventsRequest; +import com.eischet.ews.api.core.request.HangingRequestDisconnectEventArgs; +import com.eischet.ews.api.core.request.HangingServiceRequestBase; +import com.eischet.ews.api.core.response.GetStreamingEventsResponse; + +import java.io.Closeable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents a connection to an ongoing stream of events. + */ +public final class StreamingSubscriptionConnection implements Closeable, + HangingServiceRequestBase.IHandleResponseObject, + HangingServiceRequestBase.IHangingRequestDisconnectHandler { + + private static final Logger LOG = Logger.getLogger(StreamingSubscriptionConnection.class.getCanonicalName()); + + /** + * Mapping of streaming id to subscriptions currently on the connection. + */ + private Map subscriptions; + + /** + * connection lifetime, in minutes + */ + private final int connectionTimeout; + + /** + * ExchangeService instance used to make the EWS call. + */ + private ExchangeService session; + + /** + * Value indicating whether the class is disposed. + */ + private boolean isDisposed; + + /** + * Currently used instance of a GetStreamingEventsRequest connected to EWS. + */ + private GetStreamingEventsRequest currentHangingRequest; + + + public interface INotificationEventDelegate { + /** + * Represents a delegate that is invoked when notification are received + * from the server + * + * @param sender The StreamingSubscriptionConnection instance that received + * the events. + * @param args The event data. + */ + void notificationEventDelegate(Object sender, NotificationEventArgs args); + } + + + /** + * Notification events Occurs when notification are received from the + * server. + */ + private final List onNotificationEvent = new ArrayList(); + + /** + * Set event to happen when property Notify. + * + * @param notificationEvent notification event + */ + public void addOnNotificationEvent( + INotificationEventDelegate notificationEvent) { + onNotificationEvent.add(notificationEvent); + } + + /** + * Remove the event from happening when property Notify. + * + * @param notificationEvent notification event + */ + public void removeNotificationEvent( + INotificationEventDelegate notificationEvent) { + onNotificationEvent.remove(notificationEvent); + } + + /** + * Clears notification events list. + */ + public void clearNotificationEvent() { + onNotificationEvent.clear(); + } + + public interface ISubscriptionErrorDelegate { + + /** + * Represents a delegate that is invoked when an error occurs within a + * streaming subscription connection. + * + * @param sender The StreamingSubscriptionConnection instance within which + * the error occurred. + * @param args The event data. + */ + void subscriptionErrorDelegate(Object sender, + SubscriptionErrorEventArgs args); + } + + + /** + * Subscription events Occur when a subscription encounters an error. + */ + private final List onSubscriptionError = new ArrayList(); + + /** + * Set event to happen when property subscriptionError. + * + * @param subscriptionError subscription event + */ + public void addOnSubscriptionError( + ISubscriptionErrorDelegate subscriptionError) { + onSubscriptionError.add(subscriptionError); + } + + /** + * Remove the event from happening when property subscription. + * + * @param subscriptionError subscription event + */ + public void removeSubscriptionError( + ISubscriptionErrorDelegate subscriptionError) { + onSubscriptionError.remove(subscriptionError); + } + + /** + * Clears subscription events list. + */ + public void clearSubscriptionError() { + onSubscriptionError.clear(); + } + + /** + * Disconnect events Occurs when a streaming subscription connection is + * disconnected from the server. + */ + private final List onDisconnect = new ArrayList(); + + /** + * Set event to happen when property disconnect. + * + * @param disconnect disconnect event + */ + public void addOnDisconnect(ISubscriptionErrorDelegate disconnect) { + onDisconnect.add(disconnect); + } + + /** + * Remove the event from happening when property disconnect. + * + * @param disconnect disconnect event + */ + public void removeDisconnect(ISubscriptionErrorDelegate disconnect) { + onDisconnect.remove(disconnect); + } + + /** + * Clears disconnect events list. + */ + public void clearDisconnect() { + onDisconnect.clear(); + } + + /** + * Initializes a new instance of the StreamingSubscriptionConnection class. + * + * @param service The ExchangeService instance this connection uses to connect + * to the server. + * @param lifetime The maximum time, in minutes, the connection will remain open. + * Lifetime must be between 1 and 30. + * @throws Exception + */ + public StreamingSubscriptionConnection(ExchangeService service, int lifetime) + throws Exception { + EwsUtilities.validateParam(service, "service"); + + EwsUtilities.validateClassVersion(service, + ExchangeVersion.Exchange2010_SP1, this.getClass().getName()); + + if (lifetime < 1 || lifetime > 30) { + throw new ArgumentOutOfRangeException("lifetime"); + } + + this.session = service; + this.subscriptions = new HashMap(); + this.connectionTimeout = lifetime; + } + + /** + * Initializes a new instance of the StreamingSubscriptionConnection class. + * + * @param service The ExchangeService instance this connection uses to connect + * to the server. + * @param subscriptions Iterable subcriptions + * @param lifetime The maximum time, in minutes, the connection will remain open. + * Lifetime must be between 1 and 30. + * @throws Exception + */ + public StreamingSubscriptionConnection(ExchangeService service, + Iterable subscriptions, int lifetime) + throws Exception { + this(service, lifetime); + EwsUtilities.validateParamCollection(subscriptions.iterator(), "subscriptions"); + for (StreamingSubscription subscription : subscriptions) { + this.subscriptions.put(subscription.getId(), subscription); + } + } + + /** + * Adds a subscription to this connection. + * + * @param subscription The subscription to add. + * @throws Exception Thrown when AddSubscription is called while connected. + */ + public void addSubscription(StreamingSubscription subscription) + throws Exception { + this.throwIfDisposed(); + EwsUtilities.validateParam(subscription, "subscription"); + this.validateConnectionState(false, "Subscriptions can't be added to an open connection."); + + synchronized (this) { + if (this.subscriptions.containsKey(subscription.getId())) { + return; + } + this.subscriptions.put(subscription.getId(), subscription); + } + } + + /** + * Removes the specified streaming subscription from the connection. + * + * @param subscription The subscription to remove. + * @throws Exception Thrown when RemoveSubscription is called while connected. + */ + public void removeSubscription(StreamingSubscription subscription) + throws Exception { + this.throwIfDisposed(); + + EwsUtilities.validateParam(subscription, "subscription"); + + this.validateConnectionState(false, "Subscriptions can't be removed from an open connection."); + + synchronized (this) { + this.subscriptions.remove(subscription.getId()); + } + } + + /** + * Opens this connection so it starts receiving events from the server.This + * results in a long-standing call to EWS. + * + * @throws Exception + * @throws ServiceLocalException Thrown when Open is called while connected. + */ + public void open() throws ServiceLocalException, Exception { + synchronized (this) { + this.throwIfDisposed(); + + this.validateConnectionState(false, "The connection has already opened."); + + if (this.subscriptions.size() == 0) { + throw new ServiceLocalException( + "You must add at least one subscription to this connection before it can be opened."); + } + + this.currentHangingRequest = new GetStreamingEventsRequest( + this.session, this, this.subscriptions.keySet(), + this.connectionTimeout); + + this.currentHangingRequest.addOnDisconnectEvent(this); + + this.currentHangingRequest.internalExecute(); + } + } + + /** + * Called when the request is disconnected. + * + * @param sender The sender. + * @param args The Microsoft.Exchange.WebServices.Data. + * HangingRequestDisconnectEventArgs instance containing the + * event data. + */ + private void onRequestDisconnect(Object sender, + HangingRequestDisconnectEventArgs args) { + this.internalOnDisconnect(args.getException()); + } + + /** + * Closes this connection so it stops receiving events from the server.This + * terminates a long-standing call to EWS. + */ + public void close() { + synchronized (this) { + try { + this.throwIfDisposed(); + + this.validateConnectionState(true, "The connection is already closed."); + + // Further down in the stack, this will result in a + // call to our OnRequestDisconnect event handler, + // doing the necessary cleanup. + this.currentHangingRequest.disconnect(); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error closing connection", e); + } + } + } + + /** + * Internal helper method called when the request disconnects. + * + * @param ex The exception that caused the disconnection. May be null. + */ + private void internalOnDisconnect(Exception ex) { + if (!onDisconnect.isEmpty()) { + for (ISubscriptionErrorDelegate disconnect : onDisconnect) { + disconnect.subscriptionErrorDelegate(this, + new SubscriptionErrorEventArgs(null, ex)); + } + } + this.currentHangingRequest = null; + } + + /** + * Gets a value indicating whether this connection is opened + * + * @throws Exception + */ + public boolean getIsOpen() throws Exception { + + this.throwIfDisposed(); + if (this.currentHangingRequest == null) { + return false; + } else { + return this.currentHangingRequest.isConnected(); + } + + } + + /** + * Validates the state of the connection. + * + * @param isConnectedExpected Value indicating whether we expect to be currently connected. + * @param errorMessage The error message. + * @throws Exception + */ + private void validateConnectionState(boolean isConnectedExpected, + String errorMessage) throws Exception { + if ((isConnectedExpected && !this.getIsOpen()) + || (!isConnectedExpected && this.getIsOpen())) { + throw new ServiceLocalException(errorMessage); + } + } + + /** + * Handles the service response object. + * + * @param response The response. + * @throws ArgumentException + */ + private void handleServiceResponseObject(Object response) + throws ArgumentException { + GetStreamingEventsResponse gseResponse = (GetStreamingEventsResponse) response; + + if (gseResponse == null) { + throw new ArgumentNullException("GetStreamingEventsResponse must not be null", + "GetStreamingEventsResponse"); + } else { + if (gseResponse.getResult() == ServiceResult.Success + || gseResponse.getResult() == ServiceResult.Warning) { + if (gseResponse.getResults().getNotifications().size() > 0) { + // We got notification; dole them out. + this.issueNotificationEvents(gseResponse); + } else { + // // This was just a heartbeat, nothing to do here. + } + } else if (gseResponse.getResult() == ServiceResult.Error) { + if (gseResponse.getErrorSubscriptionIds() == null + || gseResponse.getErrorSubscriptionIds().size() == 0) { + // General error + this.issueGeneralFailure(gseResponse); + } else { + // subscription-specific errors + this.issueSubscriptionFailures(gseResponse); + } + } + } + } + + /** + * Issues the subscription failures. + * + * @param gseResponse The GetStreamingEvents response. + */ + private void issueSubscriptionFailures( + GetStreamingEventsResponse gseResponse) { + ServiceResponseException exception = new ServiceResponseException( + gseResponse); + + for (String id : gseResponse.getErrorSubscriptionIds()) { + StreamingSubscription subscription = null; + + synchronized (this) { + // Client can do any good or bad things in the below event + // handler + if (this.subscriptions != null + && this.subscriptions.containsKey(id)) { + subscription = this.subscriptions.get(id); + } + + } + if (subscription != null) { + SubscriptionErrorEventArgs eventArgs = new SubscriptionErrorEventArgs( + subscription, exception); + + if (!onSubscriptionError.isEmpty()) { + for (ISubscriptionErrorDelegate subError : onSubscriptionError) { + subError.subscriptionErrorDelegate(this, eventArgs); + } + } + } + if (gseResponse.getErrorCode() != ServiceError.ErrorMissedNotificationEvents) { + // Client can do any good or bad things in the above event + // handler + synchronized (this) { + if (this.subscriptions != null) { + // We are no longer servicing the subscription. + this.subscriptions.remove(id); + } + } + } + } + } + + /** + * Issues the general failure. + * + * @param gseResponse The GetStreamingEvents response. + */ + private void issueGeneralFailure(GetStreamingEventsResponse gseResponse) { + SubscriptionErrorEventArgs eventArgs = new SubscriptionErrorEventArgs( + null, new ServiceResponseException(gseResponse)); + + if (!onSubscriptionError.isEmpty()) { + for (ISubscriptionErrorDelegate subError : onSubscriptionError) { + subError.subscriptionErrorDelegate(this, eventArgs); + } + } + } + + /** + * Issues the notification events. + * + * @param gseResponse The GetStreamingEvents response. + */ + private void issueNotificationEvents(GetStreamingEventsResponse gseResponse) { + + for (GetStreamingEventsResults.NotificationGroup events : gseResponse + .getResults().getNotifications()) { + StreamingSubscription subscription = null; + + synchronized (this) { + // Client can do any good or bad things in the below event + // handler + if (this.subscriptions != null + && this.subscriptions + .containsKey(events.subscriptionId)) { + subscription = this.subscriptions + .get(events.subscriptionId); + } + } + if (subscription != null) { + NotificationEventArgs eventArgs = new NotificationEventArgs( + subscription, events.events); + + if (!onNotificationEvent.isEmpty()) { + for (INotificationEventDelegate notifyEvent : onNotificationEvent) { + notifyEvent.notificationEventDelegate(this, eventArgs); + } + } + } + } + } + + /** + * Frees resources associated with this StreamingSubscriptionConnection. + */ + public void dispose() { + synchronized (this) { + if (!this.isDisposed) { + if (this.currentHangingRequest != null) { + this.currentHangingRequest = null; + } + + this.subscriptions = null; + this.session = null; + + this.isDisposed = true; + } + } + } + + /** + * Throws if disposed. + * + * @throws Exception + */ + private void throwIfDisposed() throws Exception { + if (this.isDisposed) { + throw new Exception(this.getClass().getName()); + } + } + + @Override + public void handleResponseObject(Object response) throws ArgumentException { + this.handleServiceResponseObject(response); + } + + @Override + public void hangingRequestDisconnectHandler(Object sender, + HangingRequestDisconnectEventArgs args) { + this.onRequestDisconnect(sender, args); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/notification/SubscriptionBase.java b/ews-api/src/main/java/com/eischet/ews/api/notification/SubscriptionBase.java new file mode 100644 index 000000000..7afba27ba --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/notification/SubscriptionBase.java @@ -0,0 +1,165 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.notification; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; + +/** + * Represents the base class for event subscriptions. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class SubscriptionBase { + + /** + * The service. + */ + private final ExchangeService service; + + /** + * The id. + */ + private String id; + + /** + * The watermark. + */ + private String watermark; + + /** + * Instantiates a new subscription base. + * + * @param service the service + * @throws Exception the exception + */ + protected SubscriptionBase(ExchangeService service) throws Exception { + EwsUtilities.validateParam(service, "service"); + // EwsUtilities.validateParam(service, "service"); + + this.service = service; + } + + /** + * Instantiates a new subscription base. + * + * @param service the service + * @param id the id + * @throws Exception the exception + */ + protected SubscriptionBase(ExchangeService service, String id) + throws Exception { + this(service); + EwsUtilities.validateParam(id, "id"); + + this.id = id; + } + + /** + * Instantiates a new subscription base. + * + * @param service the service + * @param id the id + * @param watermark the watermark + * @throws Exception the exception + */ + protected SubscriptionBase(ExchangeService service, String id, + String watermark) throws Exception { + this(service, id); + this.watermark = watermark; + } + + /** + * Load from xml. + * + * @param reader the reader + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader) throws Exception { + this.id = reader.readElementValue(XmlNamespace.Messages, + XmlElementNames.SubscriptionId); + if (this.getUsesWatermark()) { + this.watermark = reader.readElementValue(XmlNamespace.Messages, + XmlElementNames.Watermark); + } + + } + + /** + * Gets the session. + * + * @return the session + */ + protected ExchangeService getService() { + return this.service; + } + + /** + * Gets the id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets the id. + * + * @param id the new id + */ + protected void setId(String id) { + this.id = id; + } + + /** + * Sets the water mark. + * + * @param watermark the new water mark + */ + protected void setWaterMark(String watermark) { + this.watermark = watermark; + } + + /** + * Gets the water mark. + * + * @return the water mark + */ + public String getWaterMark() { + return this.watermark; + } + + /** + * Gets whether or not this subscription uses watermarks. + */ + protected boolean getUsesWatermark() { + return true; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/notification/SubscriptionErrorEventArgs.java b/ews-api/src/main/java/com/eischet/ews/api/notification/SubscriptionErrorEventArgs.java new file mode 100644 index 000000000..a1922e24c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/notification/SubscriptionErrorEventArgs.java @@ -0,0 +1,87 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.notification; + +/** + * Provides data to a StreamingSubscriptionConnection's + * OnSubscriptionError and OnDisconnect events. + */ +public class SubscriptionErrorEventArgs { //TODO extends EventObject { + + private StreamingSubscription subscription; + private Exception exception; + + /** + * Initializes a new instance of the SubscriptionErrorEventArgs class. + * + * @param subscription The subscription for which an error occurred. + * If subscription is null, the error applies to the entire connection. + * @param exception The exception representing the error. + * If exception is null, the connection + * was cleanly closed by the server. + */ + protected SubscriptionErrorEventArgs( + StreamingSubscription subscription, + Exception exception) { + // super(subscription); //TODO need to check for EventObject + this.setSubscription(subscription); + this.setException(exception); + } + + /** + * Gets the subscription for which an error occurred. + * If Subscription is null, the error applies to the entire connection. + */ + public StreamingSubscription getSubscription() { + return this.subscription; + + } + + /** + * Sets the subscription for which an error occurred. + * If Subscription is null, the error applies to the entire connection. + */ + protected void setSubscription(StreamingSubscription value) { + this.subscription = value; + + } + + /** + * Gets the exception representing the error. If Exception is null, + * the connection was cleanly closed by the server. + */ + public Exception getException() { + return this.exception; + + } + + /** + * Sets the exception representing the error. If Exception is null, + * the connection was cleanly closed by the server. + */ + protected void setException(Exception value) { + this.exception = value; + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/AppointmentOccurrenceId.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/AppointmentOccurrenceId.java new file mode 100644 index 000000000..a80fcfc9e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/AppointmentOccurrenceId.java @@ -0,0 +1,97 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents the Id of an occurrence of a recurring appointment. + */ +public final class AppointmentOccurrenceId extends ItemId { + + /** + * Index of the occurrence. + */ + private int occurrenceIndex; + + /** + * Initializes a new instance. + * + * @param recurringMasterUniqueId the recurring master unique id + * @param occurrenceIndex the occurrence index + * @throws Exception the exception + */ + public AppointmentOccurrenceId(String recurringMasterUniqueId, + int occurrenceIndex) throws Exception { + super(recurringMasterUniqueId); + this.occurrenceIndex = occurrenceIndex; + } + + /** + * Gets the index of the occurrence. Note that the occurrence index + * starts at one not zero. + * + * @return the occurrence index + */ + public int getOccurrenceIndex() { + return occurrenceIndex; + } + + /** + * Sets the occurrence index. + * + * @param occurrenceIndex the new occurrence index + */ + public void setOccurrenceIndex(int occurrenceIndex) { + if (occurrenceIndex < 1) { + throw new IllegalArgumentException("OccurrenceIndex must be greater than 0."); + } + this.occurrenceIndex = occurrenceIndex; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.OccurrenceItemId; + } + + /** + * Gets the name of the XML element. + * + * @param writer the writer + */ + public void writeAttributesToXml(EwsServiceXmlWriter writer) + throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.RecurringMasterId, this.getUniqueId()); + writer.writeAttributeValue(XmlAttributeNames.InstanceIndex, this.getOccurrenceIndex()); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/Attachment.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/Attachment.java new file mode 100644 index 000000000..3809461f6 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/Attachment.java @@ -0,0 +1,417 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.BodyType; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.property.definition.PropertyDefinitionBase; + +import java.time.LocalDateTime; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents an attachment to an item. + */ +public abstract class Attachment extends ComplexProperty { + + private static final Logger LOG = Logger.getLogger(Attachment.class.getCanonicalName()); + + /** + * The owner. + */ + private final Item owner; + + /** + * The id. + */ + private String id; + + /** + * The name. + */ + private String name; + + /** + * The content type. + */ + private String contentType; + + /** + * The content id. + */ + private String contentId; + + /** + * The content location. + */ + private String contentLocation; + + /** + * The size. + */ + private int size; + + /** + * The last modified time. + */ + private LocalDateTime lastModifiedTime; + + /** + * The is inline. + */ + private boolean isInline; + + /** + * Initializes a new instance. + * + * @param owner The owner. + */ + protected Attachment(Item owner) { + this.owner = owner; + } + + /** + * Throws exception if this is not a new service object. + */ + protected void throwIfThisIsNotNew() { + if (!this.isNew()) { + throw new UnsupportedOperationException("Attachments can't be updated."); + } + } + + /** + * Sets value of field. + *

+ * We override the base implementation. Attachments cannot be modified so + * any attempts the change a property on an existing attachment is an error. + * + * @param the generic type + * @param field The field + * @param value The value. + * @return true, if successful + */ + public boolean canSetFieldValue(T field, T value) { + this.throwIfThisIsNotNew(); + return super.canSetFieldValue(field, value); + } + + /** + * Gets the Id of the attachment. + * + * @return the id + */ + public String getId() { + return this.id; + } + + /** + * Gets the name of the attachment. + * + * @return the name + */ + public String getName() { + return this.name; + } + + /** + * Sets the name. + * + * @param value the new name + */ + public void setName(String value) { + if (this.canSetFieldValue(this.name, value)) { + this.name = value; + this.changed(); + } + } + + /** + * Gets the content type of the attachment. + * + * @return the content type + */ + public String getContentType() { + return this.contentType; + } + + /** + * Sets the content type. + * + * @param value the new content type + */ + public void setContentType(String value) { + if (this.canSetFieldValue(this.contentType, value)) { + this.contentType = value; + this.changed(); + } + } + + /** + * Gets the content Id of the attachment. ContentId can be used as a + * custom way to identify an attachment in order to reference it from within + * the body of the item the attachment belongs to. + * + * @return the content id + */ + public String getContentId() { + return this.contentId; + } + + /** + * Sets the content id. + * + * @param value the new content id + */ + public void setContentId(String value) { + if (this.canSetFieldValue(this.contentId, value)) { + this.contentId = value; + this.changed(); + } + } + + /** + * Gets the content location of the attachment. ContentLocation can + * be used to associate an attachment with a Url defining its location on + * the Web. + * + * @return the content location + */ + public String getContentLocation() { + return this.contentLocation; + } + + /** + * Sets the content location. + * + * @param value the new content location + */ + public void setContentLocation(String value) { + if (this.canSetFieldValue(this.contentLocation, value)) { + this.contentLocation = value; + this.changed(); + } + } + + /** + * Gets the size of the attachment. + * + * @return the size + * @throws ServiceVersionException throws ServiceVersionException + */ + public int getSize() throws ExchangeXmlException { + EwsUtilities.validatePropertyVersion(this.getOwner().getService(), ExchangeVersion.Exchange2010, "Size"); + return this.size; + } + + /** + * Gets the date and time when this attachment was last modified. + * + * @return the last modified time + * @throws ServiceVersionException the service version exception + */ + public LocalDateTime getLastModifiedTime() throws ExchangeXmlException { + EwsUtilities.validatePropertyVersion(this.getOwner().getService(), ExchangeVersion.Exchange2010, "LastModifiedTime"); + return this.lastModifiedTime; + } + + /** + * Gets a value indicating whether this is an inline attachment. + * Inline attachments are not visible to end users. + * + * @return the checks if is inline + * @throws ServiceVersionException the service version exception + */ + public boolean getIsInline() throws ExchangeXmlException { + EwsUtilities.validatePropertyVersion(this.getOwner().getService(), ExchangeVersion.Exchange2010, "IsInline"); + return this.isInline; + } + + /** + * Sets the checks if is inline. + * + * @param value the new checks if is inline + * @throws ServiceVersionException the service version exception + */ + public void setIsInline(boolean value) throws ExchangeXmlException { + EwsUtilities.validatePropertyVersion(this.getOwner().getService(), + ExchangeVersion.Exchange2010, "IsInline"); + if (this.canSetFieldValue(this.isInline, value)) { + this.isInline = value; + this.changed(); + } + } + + /** + * True if the attachment has not yet been saved, false otherwise. + * + * @return true, if is new + */ + public boolean isNew() { + return (this.getId() == null || this.getId().isEmpty()); + } + + /** + * Gets the owner of the attachment. + * + * @return the owner + */ + public Item getOwner() { + return this.owner; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + public abstract String getXmlElementName(); + + /** + * Tries to read element from XML. + * + * @param reader The reader. + * @return True if element was read. + * @throws Exception the exception + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + + try { + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.AttachmentId)) { + try { + this.id = reader.readAttributeValue(XmlAttributeNames.Id); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error reading XML", e); + return false; + } + if (this.getOwner() != null) { + String rootItemChangeKey = reader + .readAttributeValue(XmlAttributeNames. + RootItemChangeKey); + if (null != rootItemChangeKey && + !rootItemChangeKey.isEmpty()) { + this.getOwner().getRootItemId().setChangeKey( + rootItemChangeKey); + } + } + reader.readEndElementIfNecessary(XmlNamespace.Types, + XmlElementNames.AttachmentId); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.Name)) { + this.name = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.ContentType)) { + this.contentType = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.ContentId)) { + this.contentId = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.ContentLocation)) { + this.contentLocation = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.Size)) { + this.size = reader.readElementValue(Integer.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.LastModifiedTime)) { + this.lastModifiedTime = reader.readElementValueAsDateTime(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.IsInline)) { + this.isInline = reader.readElementValue(Boolean.class); + return true; + } else { + return false; + } + } catch (Exception e) { + LOG.log(Level.SEVERE, "error reading XML", e); + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Name, this.getName()); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.ContentType, this.getContentType()); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.ContentId, this.getContentId()); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.ContentLocation, this.getContentLocation()); + if (writer.getService().getRequestedServerVersion().ordinal() > ExchangeVersion.Exchange2007_SP1.ordinal()) { + try { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.IsInline, this.getIsInline()); + } catch (ServiceVersionException e) { + throw new ExchangeXmlException("error checking for is inline: the Exchange Version is 2007_SP1 or higher and 2010 *at the same time*"); // TODO LOL fix this + } + } + } + + /** + * Load the attachment. + * + * @param bodyType Type of the body. + * @param additionalProperties The additional property. + * @throws Exception the exception + */ + protected void internalLoad(BodyType bodyType, + Iterable additionalProperties) + throws Exception { + this.getOwner().getService().getAttachment(this, bodyType, + additionalProperties); + } + + /** + * Validates this instance. + * + * @param attachmentIndex Index of this attachment. + * @throws ExchangeValidationException the service validation exception + * @throws Exception the exception + */ + abstract void validate(int attachmentIndex) throws ExchangeValidationException; + + /** + * Loads the attachment. Calling this method results in a call to EWS. + * + * @throws Exception the exception + */ + public void load() throws Exception { + this.internalLoad(null, null); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/AttachmentCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/AttachmentCollection.java new file mode 100644 index 000000000..c7c653872 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/AttachmentCollection.java @@ -0,0 +1,481 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.service.ServiceResult; +import com.eischet.ews.api.core.exception.misc.InvalidOperationException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.remote.CreateAttachmentException; +import com.eischet.ews.api.core.exception.service.remote.DeleteAttachmentException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.response.CreateAttachmentResponse; +import com.eischet.ews.api.core.response.DeleteAttachmentResponse; +import com.eischet.ews.api.core.response.ServiceResponseCollection; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Item; + +import java.io.File; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; + +/** + * Represents an item's attachment collection. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class AttachmentCollection extends ComplexPropertyCollection + implements IOwnedProperty { + + // The item owner that owns this attachment collection + /** + * The owner. + */ + private Item owner; + + /** + * Initializes a new instance of AttachmentCollection. + */ + public AttachmentCollection() { + super(); + } + + /** + * The owner of this attachment collection. + * + * @return the owner + */ + public ServiceObject getOwner() { + return this.owner; + } + + /** + * The owner of this attachment collection. + * + * @param value accepts ServiceObject + */ + public void setOwner(ServiceObject value) { + Item item = (Item) value; + EwsUtilities.ewsAssert(item != null, "AttachmentCollection.IOwnedProperty.set_Owner", + "value is not a descendant of ItemBase"); + + this.owner = item; + } + + /** + * Adds a file attachment to the collection. + * + * @param fileName the file name + * @return A FileAttachment instance. + */ + public FileAttachment addFileAttachment(String fileName) { + return this.addFileAttachment(new File(fileName).getName(), fileName); + } + + /** + * Adds a file attachment to the collection. + * + * @param name accepts String display name of the new attachment. + * @param fileName accepts String name of the file representing the content of + * the attachment. + * @return A FileAttachment instance. + */ + public FileAttachment addFileAttachment(String name, String fileName) { + FileAttachment fileAttachment = new FileAttachment(this.owner); + fileAttachment.setName(name); + fileAttachment.setFileName(fileName); + + this.internalAdd(fileAttachment); + + return fileAttachment; + } + + /** + * Adds a file attachment to the collection. + * + * @param name accepts String display name of the new attachment. + * @param contentStream accepts InputStream stream from which to read the content of + * the attachment. + * @return A FileAttachment instance. + */ + public FileAttachment addFileAttachment(String name, + InputStream contentStream) { + FileAttachment fileAttachment = new FileAttachment(this.owner); + fileAttachment.setName(name); + fileAttachment.setContentStream(contentStream); + + this.internalAdd(fileAttachment); + + return fileAttachment; + } + + /** + * Adds a file attachment to the collection. + * + * @param name the name + * @param content accepts byte byte arrays representing the content of the + * attachment. + * @return FileAttachment + */ + public FileAttachment addFileAttachment(String name, byte[] content) { + FileAttachment fileAttachment = new FileAttachment(this.owner); + fileAttachment.setName(name); + fileAttachment.setContent(content); + + this.internalAdd(fileAttachment); + + return fileAttachment; + } + + /** + * Adds an item attachment to the collection. + * + * @param the generic type + * @param cls the cls + * @return An ItemAttachment instance. + * @throws Exception the exception + */ + public GenericItemAttachment addItemAttachment( + Class cls) throws Exception { + if (cls.getDeclaredFields().length == 0) { + throw new InvalidOperationException(String.format( + "Items of type %s are not supported as attachments.", cls + .getName())); + } + + GenericItemAttachment itemAttachment = + new GenericItemAttachment( + this.owner); + itemAttachment.setTItem((TItem) EwsUtilities.createItemFromItemClass( + itemAttachment, cls, true)); + + this.internalAdd(itemAttachment); + + return itemAttachment; + } + + /** + * Removes all attachments from this collection. + */ + public void clear() { + this.internalClear(); + } + + /** + * Removes the attachment at the specified index. + * + * @param index Index of the attachment to remove. + */ + public void removeAt(int index) { + if (index < 0 || index >= this.getCount()) { + throw new IllegalArgumentException("parameter 'index' : " + "index is out of range."); + } + + this.internalRemoveAt(index); + } + + /** + * Removes the specified attachment. + * + * @param attachment The attachment to remove. + * @return True if the attachment was successfully removed from the + * collection, false otherwise. + * @throws Exception the exception + */ + public boolean remove(Attachment attachment) throws Exception { + EwsUtilities.validateParam(attachment, "attachment"); + + return this.internalRemove(attachment); + } + + /** + * Instantiate the appropriate attachment type depending on the current XML + * element name. + * + * @param xmlElementName The XML element name from which to determine the type of + * attachment to create. + * @return An Attachment instance. + */ + @Override + protected Attachment createComplexProperty(String xmlElementName) { + if (xmlElementName.equals(XmlElementNames.FileAttachment)) { + return new FileAttachment(this.owner); + } else if (xmlElementName.equals(XmlElementNames.ItemAttachment)) { + return new ItemAttachment(this.owner); + } else { + return null; + } + } + + /** + * Determines the name of the XML element associated with the + * complexProperty parameter. + * + * @param complexProperty The attachment object for which to determine the XML element + * name with. + * @return The XML element name associated with the complexProperty + * parameter. + */ + @Override + protected String getCollectionItemXmlElementName(Attachment + complexProperty) { + if (complexProperty instanceof FileAttachment) { + return XmlElementNames.FileAttachment; + } else { + return XmlElementNames.ItemAttachment; + } + } + + /** + * Saves this collection by creating new attachment and deleting removed + * ones. + * + * @throws Exception the exception + */ + public void save() throws Exception { + ArrayList attachments = + new ArrayList(); + + for (Attachment attachment : this.getRemovedItems()) { + if (!attachment.isNew()) { + attachments.add(attachment); + } + } + + // If any, delete them by calling the DeleteAttachment web method. + if (attachments.size() > 0) { + this.internalDeleteAttachments(attachments); + } + + attachments.clear(); + + // Retrieve a list of attachments that have to be created. + for (Attachment attachment : this) { + if (attachment.isNew()) { + attachments.add(attachment); + } + } + + // If there are any, create them by calling the CreateAttachment web + // method. + if (attachments.size() > 0) { + if (this.owner.isAttachment()) { + this.internalCreateAttachments(this.owner.getParentAttachment() + .getId(), attachments); + } else { + this.internalCreateAttachments( + this.owner.getId().getUniqueId(), attachments); + } + } + + + // Process all of the item attachments in this collection. + for (Attachment attachment : this) { + ItemAttachment itemAttachment = (ItemAttachment) + ((attachment instanceof + ItemAttachment) ? attachment : + null); + if (itemAttachment != null) { + // Bug E14:80864: Make sure item was created/loaded before + // trying to create/delete sub-attachments + if (itemAttachment.getItem() != null) { + // Create/delete any sub-attachments + itemAttachment.getItem().getAttachments().save(); + + // Clear the item's change log + itemAttachment.getItem().clearChangeLog(); + } + } + } + + super.clearChangeLog(); + } + + /** + * Determines whether there are any unsaved attachment collection changes. + * + * @return True if attachment adds or deletes haven't been processed yet. + * @throws ServiceLocalException + */ + public boolean hasUnprocessedChanges() throws ExchangeXmlException { + // Any new attachments? + for (Attachment attachment : this) { + if (attachment.isNew()) { + return true; + } + } + + // Any pending deletions? + for (Attachment attachment : this.getRemovedItems()) { + if (!attachment.isNew()) { + return true; + } + } + + + Collection itemAttachments = + new ArrayList(); + for (Object event : this.getItems()) { + if (event instanceof ItemAttachment) { + itemAttachments.add((ItemAttachment) event); + } + } + + // Recurse: process item attachments to check + // for new or deleted sub-attachments. + for (ItemAttachment itemAttachment : itemAttachments) { + if (itemAttachment.getItem() != null) { + if (itemAttachment.getItem().getAttachments().hasUnprocessedChanges()) { + return true; + } + } + } + + return false; + } + + /** + * Disables the change log clearing mechanism. Attachment collections are + * saved separately from the item they belong to. + */ + @Override + public void clearChangeLog() { + // Do nothing + } + + /** + * Validates this instance. + * + */ + public void validate() throws ExchangeValidationException { + // Validate all added attachments + try { + if (this.owner.isNew() + && this.owner.getService().getRequestedServerVersion() + .ordinal() >= ExchangeVersion.Exchange2010_SP2 + .ordinal()) { + boolean contactPhotoFound = false; + for (int attachmentIndex = 0; attachmentIndex < this.getAddedItems() + .size(); attachmentIndex++) { + final Attachment attachment = this.getAddedItems().get(attachmentIndex); + if (attachment != null) { + if (attachment.isNew() && attachment instanceof FileAttachment) { + // At the server side, only the last attachment with + // IsContactPhoto is kept, all other IsContactPhoto + // attachments are removed. CreateAttachment will generate + // AttachmentId for each of such attachments (although + // only the last one is valid). + // + // With E14 SP2 CreateItemWithAttachment, such request will only + // return 1 AttachmentId; but the client + // expects to see all, so let us prevent such "invalid" request + // in the first place. + // + // The IsNew check is to still let CreateAttachmentRequest allow + // multiple IsContactPhoto attachments. + // + if (((FileAttachment) attachment).isContactPhoto()) { + if (contactPhotoFound) { + throw new ExchangeValidationException("Multiple contact photos in attachment."); + } + contactPhotoFound = true; + } + } + attachment.validate(attachmentIndex); + } + } + } + } catch (ExchangeXmlException e) { + throw new ExchangeValidationException("error validating attachment collection " + this, e); + } + } + + + /** + * Calls the DeleteAttachment web method to delete a list of attachments. + * + * @param attachments the attachments + * @throws Exception the exception + */ + private void internalDeleteAttachments(Iterable attachments) + throws Exception { + ServiceResponseCollection responses = + this.owner + .getService().deleteAttachments(attachments); + Enumeration enumerator = responses + .getEnumerator(); + while (enumerator.hasMoreElements()) { + DeleteAttachmentResponse response = enumerator.nextElement(); + // We remove all attachments that were successfully deleted from the + // change log. We should never + // receive a warning from EWS, so we ignore them. + if (response.getResult() != ServiceResult.Error) { + this.removeFromChangeLog(response.getAttachment()); + } + } + + // TODO : Should we throw for warnings as well? + if (responses.getOverallResult() == ServiceResult.Error) { + throw new DeleteAttachmentException(responses, "At least one attachment couldn't be deleted."); + } + } + + /** + * Calls the CreateAttachment web method to create a list of attachments. + * + * @param parentItemId the parent item id + * @param attachments the attachments + * @throws Exception the exception + */ + private void internalCreateAttachments(String parentItemId, + Iterable attachments) throws Exception { + ServiceResponseCollection responses = + this.owner + .getService().createAttachments(parentItemId, attachments); + + Enumeration enumerator = responses + .getEnumerator(); + while (enumerator.hasMoreElements()) { + CreateAttachmentResponse response = enumerator.nextElement(); + // We remove all attachments that were successfully created from the + // change log. We should never + // receive a warning from EWS, so we ignore them. + if (response.getResult() != ServiceResult.Error) { + this.removeFromChangeLog(response.getAttachment()); + } + } + + // TODO : Should we throw for warnings as well? + if (responses.getOverallResult() == ServiceResult.Error) { + throw new CreateAttachmentException(responses, "At least one attachment couldn't be created."); + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/Attendee.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/Attendee.java new file mode 100644 index 000000000..f598024bb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/Attendee.java @@ -0,0 +1,154 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.property.MeetingResponseType; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.time.LocalDateTime; + +/** + * Represents an attendee to a meeting. + */ + +public final class Attendee extends EmailAddress { + + /** + * The response type. + */ + private MeetingResponseType responseType; + + /** + * The last response time. + */ + private LocalDateTime lastResponseTime; + + /** + * Initializes a new instance of the Attendee class. + */ + public Attendee() { + super(); + } + + /** + * Initializes a new instance of the Attendee class. + * + * @param smtpAddress the smtp address + * @throws Exception the exception + */ + public Attendee(String smtpAddress) throws ExchangeValidationException { + super(smtpAddress); + EwsUtilities.validateParam(smtpAddress, "smtpAddress"); + } + + /** + * Initializes a new instance of the Attendee class. + * + * @param name the name + * @param smtpAddress the smtp address + */ + public Attendee(String name, String smtpAddress) { + super(name, smtpAddress); + } + + /** + * Initializes a new instance of the Attendee class. + * + * @param name the name + * @param smtpAddress the smtp address + * @param routingType the routing type + */ + public Attendee(String name, String smtpAddress, String routingType) { + super(name, smtpAddress, routingType); + } + + /** + * Initializes a new instance of the Attendee class. + * + * @param mailbox the mailbox + * @throws Exception the exception + */ + public Attendee(EmailAddress mailbox) throws Exception { + super(mailbox); + } + + /** + * Gets the type of response the attendee gave to the meeting invitation + * it received. + * + * @return the response type + */ + public MeetingResponseType getResponseType() { + return responseType; + } + + /** + * Gets the last response time. + * + * @return the last response time + */ + public LocalDateTime getLastResponseTime() { + return lastResponseTime; + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Mailbox)) { + this.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.ResponseType)) { + this.responseType = reader + .readElementValue(MeetingResponseType.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.LastResponseTime)) { + this.lastResponseTime = reader.readElementValueAsDateTime(); + return true; + } else { + return super.tryReadElementFromXml(reader); + } + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeStartElement(this.getNamespace(), XmlElementNames.Mailbox); + super.writeElementsToXml(writer); + writer.writeEndElement(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/AttendeeCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/AttendeeCollection.java new file mode 100644 index 000000000..743aeff24 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/AttendeeCollection.java @@ -0,0 +1,146 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; + +/** + * Represents a collection of attendees. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class AttendeeCollection extends ComplexPropertyCollection { + + /** + * Initializes a new instance of the AttendeeCollection class. + */ + public AttendeeCollection() { + super(); + } + + /** + * Adds an attendee to the collection. + * + * @param attendee the attendee + */ + public void add(Attendee attendee) { + this.internalAdd(attendee); + } + + /** + * Adds an attendee to the collection. + * + * @param smtpAddress the smtp address + * @return An Attendee instance initialized with the provided SMTP address. + * @throws Exception the exception + */ + public Attendee add(String smtpAddress) throws ExchangeValidationException { + Attendee result = new Attendee(smtpAddress); + + this.internalAdd(result); + + return result; + } + + /** + * Adds an attendee to the collection. + * + * @param name the name + * @param smtpAddress the smtp address + * @return An Attendee instance initialized with the provided name and SMTP + * address. + */ + public Attendee add(String name, String smtpAddress) { + Attendee result = new Attendee(name, smtpAddress); + + this.internalAdd(result); + + return result; + } + + /** + * Clears the collection. + */ + public void clear() { + this.internalClear(); + } + + /** + * Removes an attendee from the collection. + * + * @param index the index + */ + public void removeAt(int index) { + if (index < 0 || index >= this.getCount()) { + throw new IllegalArgumentException("parameter 'index' : " + "index is out of range."); + } + + this.internalRemoveAt(index); + } + + /** + * Removes an attendee from the collection. + * + * @param attendee the attendee + * @return True if the attendee was successfully removed from the + * collection, false otherwise. + * @throws Exception the exception + */ + public boolean remove(Attendee attendee) throws Exception { + EwsUtilities.validateParam(attendee, "attendee"); + + return this.internalRemove(attendee); + } + + /** + * Creates an Attendee object from an XML element name. + * + * @param xmlElementName the xml element name + * @return An Attendee object. + */ + @Override + protected Attendee createComplexProperty(String xmlElementName) { + if (xmlElementName.equalsIgnoreCase(XmlElementNames.Attendee)) { + return new Attendee(); + } else { + return null; + } + } + + /** + * Retrieves the XML element name corresponding to the provided Attendee + * object. + * + * @param attendee the attendee + * @return The XML element name corresponding to the provided Attendee + * object. + */ + @Override + protected String getCollectionItemXmlElementName(Attendee attendee) { + return XmlElementNames.Attendee; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ByteArrayArray.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ByteArrayArray.java new file mode 100644 index 000000000..ff90e7f87 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ByteArrayArray.java @@ -0,0 +1,81 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents an array of byte arrays + */ +public class ByteArrayArray extends ComplexProperty { + final static String ItemXmlElementName = "Base64Binary"; + private final List content = new ArrayList<>(); + + public ByteArrayArray() { + } + + /** + * Gets the content of the array of byte arrays + * + * TODO: IntelliJ says this will not work at all (inspections) + */ + public byte[][] getContent() { + return (byte[][]) this.content.toArray(); + } + + /** + * Tries to read element from XML. + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + + if (reader.getLocalName().equalsIgnoreCase( + ByteArrayArray.ItemXmlElementName)) { + this.content.add(reader.writeBase64ElementValue()); + return true; + } else { + return false; + } + + } + + /** + * The Writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + for (byte[] item : this.content) { + writer.writeStartElement(XmlNamespace.Types, + ByteArrayArray.ItemXmlElementName); + writer.writeBase64ElementValue(item); + writer.writeEndElement(); + } + + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/CompleteName.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/CompleteName.java new file mode 100644 index 000000000..d794193b8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/CompleteName.java @@ -0,0 +1,258 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents the complete name of a contact. + */ +public final class CompleteName extends ComplexProperty { + + /** + * The title. + */ + private String title; + + /** + * The given name. + */ + private String givenName; + + /** + * The middle name. + */ + private String middleName; + + /** + * The surname. + */ + private String surname; + + /** + * The suffix. + */ + private String suffix; + + /** + * The initials. + */ + private String initials; + + /** + * The full name. + */ + private String fullName; + + /** + * The nickname. + */ + private String nickname; + + /** + * The yomi given name. + */ + private String yomiGivenName; + + /** + * The yomi surname. + */ + private String yomiSurname; + + /** + * Gets the contact's title. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Gets the given name (first name) of the contact. + * + * @return the givenName + */ + public String getGivenName() { + return givenName; + } + + /** + * Gets the middle name of the contact. + * + * @return the middleName + */ + public String getMiddleName() { + return middleName; + } + + /** + * Gets the surname (last name) of the contact. + * + * @return the surname + */ + public String getSurname() { + return surname; + } + + /** + * Gets the suffix of the contact. + * + * @return the suffix + */ + public String getSuffix() { + return suffix; + } + + /** + * Gets the initials of the contact. + * + * @return the initials + */ + public String getInitials() { + return initials; + } + + /** + * Gets the full name of the contact. + * + * @return the fullName + */ + public String getFullName() { + return fullName; + } + + /** + * Gets the nickname of the contact. + * + * @return the nickname + */ + public String getNickname() { + return nickname; + } + + /** + * Gets the Yomi given name (first name) of the contact. + * + * @return the yomiGivenName + */ + public String getYomiGivenName() { + return yomiGivenName; + } + + /** + * Gets the Yomi surname (last name) of the contact. + * + * @return the yomiSurname + */ + public String getYomiSurname() { + return yomiSurname; + } + + /** + * Tries to read element from XML. + * + * @param reader The reader. + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Title)) { + this.title = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.FirstName)) { + this.givenName = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.MiddleName)) { + this.middleName = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.LastName)) { + this.surname = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.Suffix)) { + this.suffix = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.Initials)) { + this.initials = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.FullName)) { + this.fullName = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.NickName)) { + this.nickname = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.YomiFirstName)) { + this.yomiGivenName = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.YomiLastName)) { + this.yomiSurname = reader.readElementValue(); + return true; + } else { + return false; + } + } + + /** + * Writes the elements to XML. + * + * @param writer accepts EwsServiceXmlWriter + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Title, + this.title); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.FirstName, + this.givenName); + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.MiddleName, this.middleName); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.LastName, + this.surname); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Suffix, + this.suffix); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Initials, + this.initials); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.FullName, + this.fullName); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.NickName, + this.nickname); + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.YomiFirstName, this.yomiGivenName); + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.YomiLastName, this.yomiSurname); + } +} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ComplexFunctionDelegate.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ComplexFunctionDelegate.java similarity index 87% rename from src/main/java/microsoft/exchange/webservices/data/property/complex/ComplexFunctionDelegate.java rename to ews-api/src/main/java/com/eischet/ews/api/property/complex/ComplexFunctionDelegate.java index 56271316d..9653d7cac 100644 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ComplexFunctionDelegate.java +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ComplexFunctionDelegate.java @@ -21,11 +21,11 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlReader; public interface ComplexFunctionDelegate { - Boolean func(T1 arg1) throws Exception; + Boolean func(T1 arg1) throws Exception; } diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ComplexProperty.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ComplexProperty.java new file mode 100644 index 000000000..efc7e6e2b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ComplexProperty.java @@ -0,0 +1,349 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.ISelfValidate; +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a property that can be sent to or retrieved from EWS. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class ComplexProperty implements ISelfValidate, ComplexFunctionDelegate { + + /** + * The xml namespace. + */ + private XmlNamespace xmlNamespace = XmlNamespace.Types; + + /** + * Initializes a new instance. + */ + protected ComplexProperty() { + + } + + /** + * Gets the namespace. + * + * @return the namespace. + */ + public XmlNamespace getNamespace() { + return xmlNamespace; + } + + /** + * Sets the namespace. + * + * @param xmlNamespace the namespace. + */ + public void setNamespace(XmlNamespace xmlNamespace) { + this.xmlNamespace = xmlNamespace; + } + + /** + * Instance was changed. + */ + public void changed() { + if (!onChangeList.isEmpty()) { + for (IComplexPropertyChangedDelegate change : onChangeList) { + change.complexPropertyChanged(this); + } + } + } + + /** + * Sets value of field. + * + * @param Field type. + * @param field The field. + * @param value The value. + * @return true, if successful + */ + public boolean canSetFieldValue(T field, T value) { + boolean applyChange; + if (field == null) { + applyChange = value != null; + } else { + if (field instanceof Comparable) { + Comparable c = (Comparable) field; + applyChange = value != null && c.compareTo(value) != 0; + } else { + applyChange = true; + } + } + return applyChange; + } + + /** + * Clears the change log. + */ + public void clearChangeLog() { + } + + /** + * Reads the attribute from XML. + * + * @param reader The reader. + */ + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + } + + /** + * Reads the text value from XML. + * + * @param reader The reader. + */ + public void readTextValueFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + } + + /** + * Tries to read element from XML. + * + * @param reader The reader. + * @return True if element was read. + * @throws Exception the exception + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + return false; + } + + /** + * Tries to read element from XML to patch this property. + */ + public boolean tryReadElementFromXmlToPatch(EwsServiceXmlReader reader) throws ExchangeXmlException { + return false; + } + + /** + * Writes the attribute to XML. + * + * @param writer The writer. + */ + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + } + + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + } + + public void loadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName) throws ExchangeXmlException { + + /*reader.ensureCurrentNodeIsStartElement(xmlNamespace, xmlElementName); + this.readAttributesFromXml(reader); + + if (!reader.isEmptyElement()) { + do { + reader.read(); + + switch (reader.getNodeType().nodeType) { + case XmlNodeType.START_ELEMENT: + if (!this.tryReadElementFromXml(reader)) { + reader.skipCurrentElement(); + } + break; + case XmlNodeType.CHARACTERS: + this.readTextValueFromXml(reader); + break; + } + } while (!reader.isEndElement(xmlNamespace, xmlElementName)); + } else { + // Adding this code to skip the END_ELEMENT of an Empty Element. + reader.read(); + reader.isEndElement(xmlNamespace, xmlElementName); + } */ + + this.internalLoadFromXml(reader, xmlNamespace, xmlElementName); + } + + public void updateFromXml(EwsServiceXmlReader reader, String xmlElementName) throws ExchangeXmlException { + this.updateFromXml(reader, this.getNamespace(), xmlElementName); + } + + /** + * Loads from XML to update itself. + * + * @param reader The reader. + * @param xmlNamespace The XML namespace. + * @param xmlElementName Name of the XML element. + */ + public void updateFromXml( + EwsServiceXmlReader reader, + XmlNamespace xmlNamespace, + String xmlElementName) throws ExchangeXmlException { + this.internalupdateLoadFromXml(reader, xmlNamespace, xmlElementName); + } + + /** + * Loads from XML + * + * @param reader The Reader. + * @param xmlNamespace The Xml NameSpace. + * @param xmlElementName The Xml ElementName + */ + private void internalLoadFromXml( + EwsServiceXmlReader reader, + XmlNamespace xmlNamespace, + String xmlElementName) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(xmlNamespace, xmlElementName); + + this.readAttributesFromXml(reader); + + if (!reader.isEmptyElement()) { + do { + reader.read(); + + switch (reader.getNodeType().nodeType) { + case XmlNodeType.START_ELEMENT: + if (!this.tryReadElementFromXml(reader)) { + reader.skipCurrentElement(); + } + break; + case XmlNodeType.CHARACTERS: + this.readTextValueFromXml(reader); + break; + } + } while (!reader.isEndElement(xmlNamespace, xmlElementName)); + } else { + // Adding this code to skip the END_ELEMENT of an Empty Element. + reader.read(); + reader.isEndElement(xmlNamespace, xmlElementName); + } + } + + private void internalupdateLoadFromXml( + EwsServiceXmlReader reader, + XmlNamespace xmlNamespace, + String xmlElementName) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(xmlNamespace, xmlElementName); + + this.readAttributesFromXml(reader); + + if (!reader.isEmptyElement()) { + do { + reader.read(); + + switch (reader.getNodeType().nodeType) { + case XmlNodeType.START_ELEMENT: + if (!this.tryReadElementFromXmlToPatch(reader)) { + reader.skipCurrentElement(); + } + break; + case XmlNodeType.CHARACTERS: + this.readTextValueFromXml(reader); + break; + } + } while (!reader.isEndElement(xmlNamespace, xmlElementName)); + } + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @param xmlElementName Name of the XML element. + */ + public void loadFromXml(EwsServiceXmlReader reader, String xmlElementName) throws ExchangeXmlException { + this.loadFromXml(reader, this.getNamespace(), xmlElementName); + } + + /** + * Writes to XML. + * + * @param writer The writer. + * @param xmlNamespace The XML namespace. + * @param xmlElementName Name of the XML element. + */ + public void writeToXml(EwsServiceXmlWriter writer, XmlNamespace xmlNamespace, String xmlElementName) throws ExchangeXmlException { + writer.writeStartElement(xmlNamespace, xmlElementName); + this.writeAttributesToXml(writer); + this.writeElementsToXml(writer); + writer.writeEndElement(); + } + + /** + * Writes to XML. + * + * @param writer The writer. + * @param xmlElementName Name of the XML element. + */ + public void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) throws ExchangeXmlException { + this.writeToXml(writer, this.getNamespace(), xmlElementName); + } + + /** + * Change events occur when property changed. + */ + private final List onChangeList = + new ArrayList(); + + /** + * Set event to happen when property changed. + * + * @param change change event + */ + public void addOnChangeEvent(IComplexPropertyChangedDelegate change) { + onChangeList.add(change); + } + + /** + * Remove the event from happening when property changed. + * + * @param change change event + */ + public void removeChangeEvent(IComplexPropertyChangedDelegate change) { + onChangeList.remove(change); + } + + /** + * Clears change events list. + */ + protected void clearChangeEvents() { + onChangeList.clear(); + } + + /** + * Implements ISelfValidate.validate. Validates this instance. + * + */ + public void validate() throws ExchangeValidationException { + this.internalValidate(); + } + + protected void internalValidate() throws ExchangeValidationException { + } + + public Boolean func(EwsServiceXmlReader reader) throws Exception { + return !this.tryReadElementFromXml(reader); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ComplexPropertyCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ComplexPropertyCollection.java new file mode 100644 index 000000000..2401735ca --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ComplexPropertyCollection.java @@ -0,0 +1,477 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ICustomXmlUpdateSerializer; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Represents a collection of property that can be sent to and retrieved from + * EWS. + * + * @param ComplexProperty type. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class ComplexPropertyCollection + + extends ComplexProperty implements ICustomXmlUpdateSerializer, + Iterable, IComplexPropertyChangedDelegate { + + /** + * The item. + */ + private final List items = new ArrayList<>(); + + /** + * The added item. + */ + private final List addedItems = + new ArrayList<>(); + + /** + * The modified item. + */ + private final List modifiedItems = new ArrayList<>(); + + /** + * The removed item. + */ + private final List removedItems = + new ArrayList<>(); + + /** + * Creates the complex property. + * + * @param xmlElementName Name of the XML element. + * @return Complex property instance. + */ + protected abstract TComplexProperty createComplexProperty( + String xmlElementName); + + /** + * Gets the name of the collection item XML element. + * + * @param complexProperty The complex property. + * @return XML element name. + */ + protected abstract String getCollectionItemXmlElementName( + TComplexProperty complexProperty); + + /** + * Initializes a new instance of. ComplexPropertyCollection + */ + protected ComplexPropertyCollection() { + super(); + } + + /** + * Item changed. + * + * @param property The complex property. + */ + protected void itemChanged(final TComplexProperty property) { + EwsUtilities.ewsAssert( + property != null, "ComplexPropertyCollection.ItemChanged", + "The complexProperty argument must be not null" + ); + + if (!this.addedItems.contains(property)) { + if (!this.modifiedItems.contains(property)) { + this.modifiedItems.add(property); + this.changed(); + } + } + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @param localElementName Name of the local element. + */ + @Override + public void loadFromXml(EwsServiceXmlReader reader, String localElementName) throws ExchangeXmlException { + this.loadFromXml( + reader, + XmlNamespace.Types, + localElementName); + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @param xmlNamespace The XML namespace. + * @param localElementName Name of the local element. + */ + @Override + public void loadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String localElementName) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(xmlNamespace, localElementName); + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.isStartElement()) { + TComplexProperty complexProperty = this + .createComplexProperty(reader.getLocalName()); + + if (complexProperty != null) { + complexProperty.loadFromXml(reader, reader + .getLocalName()); + this.internalAdd(complexProperty, true); + } else { + reader.skipCurrentElement(); + } + } + } while (!reader.isEndElement(xmlNamespace, localElementName)); + } else { + reader.read(); + } + } + + /** + * Loads from XML to update itself. + * + * @param reader The reader. + * @param xmlNamespace The XML namespace. + * @param xmlElementName Name of the XML element. + */ + public void updateFromXml( + EwsServiceXmlReader reader, + XmlNamespace xmlNamespace, + String xmlElementName) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(xmlNamespace, xmlElementName); + + if (!reader.isEmptyElement()) { + int index = 0; + do { + reader.read(); + + if (reader.isStartElement()) { + TComplexProperty complexProperty = this.createComplexProperty(reader.getLocalName()); + TComplexProperty actualComplexProperty = this.getPropertyAtIndex(index++); + + if (complexProperty == null || !complexProperty.equals(actualComplexProperty)) { + throw new ExchangeXmlException("Property type incompatible when updating collection."); + } + + actualComplexProperty.updateFromXml(reader, xmlNamespace, reader.getLocalName()); + } + } + while (!reader.isEndElement(xmlNamespace, xmlElementName)); + } + } + + /** + * Writes to XML. + * + * @param writer The writer. + * @param xmlNamespace The XML namespace. + * @param xmlElementName Name of the XML element. + */ + @Override + public void writeToXml(EwsServiceXmlWriter writer, XmlNamespace xmlNamespace, + String xmlElementName) throws ExchangeXmlException { + if (this.shouldWriteToXml()) { + super.writeToXml(writer, xmlNamespace, xmlElementName); + } + } + + /** + * Determine whether we should write collection to XML or not. + * + * @return True if collection contains at least one element. + */ + public boolean shouldWriteToXml() { + //Only write collection if it has at least one element. + return this.getCount() > 0; + } + + /** + * Writes elements to XML. + * + * @param writer The writer. + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + for (TComplexProperty complexProperty : this) { + complexProperty.writeToXml(writer, this.getCollectionItemXmlElementName(complexProperty)); + } + } + + /** + * Clears the change log. + */ + @Override + public void clearChangeLog() { + this.removedItems.clear(); + this.addedItems.clear(); + this.modifiedItems.clear(); + } + + /** + * Removes from change log. + * + * @param complexProperty The complex property. + */ + protected void removeFromChangeLog(TComplexProperty complexProperty) { + this.removedItems.remove(complexProperty); + this.modifiedItems.remove(complexProperty); + this.addedItems.remove(complexProperty); + } + + /** + * Gets the item. + * + * @return The item. + */ + public List getItems() { + return this.items; + } + + /** + * Gets the added item. + * + * @return The added item. + */ + protected List getAddedItems() { + return this.addedItems; + } + + /** + * Gets the modified item. + * + * @return The modified item. + */ + protected List getModifiedItems() { + return this.modifiedItems; + } + + /** + * Gets the removed item. + * + * @return The removed item. + */ + protected List getRemovedItems() { + return this.removedItems; + } + + /** + * Add complex property. + * + * @param complexProperty The complex property. + */ + protected void internalAdd(TComplexProperty complexProperty) { + this.internalAdd(complexProperty, false); + } + + /** + * Add complex property. + * + * @param complexProperty The complex property. + * @param loading If true, collection is being loaded. + */ + private void internalAdd(TComplexProperty complexProperty, boolean loading) { + EwsUtilities.ewsAssert(complexProperty != null, "ComplexPropertyCollection.InternalAdd", "complexProperty is null"); + + if (!this.items.contains(complexProperty)) { + this.items.add(complexProperty); + if (!loading) { + this.removedItems.remove(complexProperty); + this.addedItems.add(complexProperty); + } + complexProperty.addOnChangeEvent(this); + this.changed(); + } + } + + /** + * Complex property changed. + * + * @param complexProperty accepts ComplexProperty + */ + @Override + public void complexPropertyChanged(final TComplexProperty complexProperty) { + this.itemChanged(complexProperty); + } + + /** + * Clear collection. + */ + protected void internalClear() { + while (this.getCount() > 0) { + this.internalRemoveAt(0); + } + } + + /** + * Remote entry at index. + * + * @param index The index. + */ + protected void internalRemoveAt(int index) { + EwsUtilities.ewsAssert(index >= 0 && index < this.getCount(), + "ComplexPropertyCollection.InternalRemoveAt", "index is out of range."); + + this.internalRemove(this.items.get(index)); + } + + /** + * Remove specified complex property. + * + * @param complexProperty The complex property. + * @return True if the complex property was successfully removed from the + * collection, false otherwise. + */ + protected boolean internalRemove(TComplexProperty complexProperty) { + EwsUtilities.ewsAssert(complexProperty != null, "ComplexPropertyCollection.InternalRemove", + "complexProperty is null"); + + if (this.items.remove(complexProperty)) { + complexProperty.removeChangeEvent(this); + if (!this.addedItems.contains(complexProperty)) { + this.removedItems.add(complexProperty); + } else { + this.addedItems.remove(complexProperty); + } + this.modifiedItems.remove(complexProperty); + this.changed(); + return true; + } else { + return false; + } + } + + /** + * Determines whether a specific property is in the collection. + * + * @param complexProperty The property to locate in the collection. + * @return True if the property was found in the collection, false + * otherwise. + */ + public boolean contains(TComplexProperty complexProperty) { + return this.items.contains(complexProperty); + } + + /** + * Searches for a specific property and return its zero-based index within + * the collection. + * + * @param complexProperty The property to locate in the collection. + * @return The zero-based index of the property within the collection. + */ + public int indexOf(TComplexProperty complexProperty) { + return this.items.indexOf(complexProperty); + } + + /** + * Gets the total number of property in the collection. + * + * @return the count + */ + public int getCount() { + return this.items.size(); + } + + /** + * Gets the property at the specified index. + * + * @param index the index + * @return index The property at the specified index. + * @throws IllegalArgumentException thrown if if index is out of range. + */ + public TComplexProperty getPropertyAtIndex(int index) + throws IllegalArgumentException { + if (index < 0 || index >= this.getCount()) { + throw new IllegalArgumentException( + String.format("index %d is out of range [0..%d[.", index, this.getCount()) + ); + } + return this.items.get(index); + } + + /** + * Gets an enumerator that iterates through the elements of the collection. + * + * @return An Iterator for the collection. + */ + @Override + public Iterator iterator() { + return this.items.iterator(); + } + + /** + * Write set update to xml. + * + * @param writer accepts EwsServiceXmlWriter + * @param ewsObject accepts ServiceObject + * @param propertyDefinition accepts PropertyDefinition + * @return true + * @throws Exception the exception + */ + @Override + public boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, + ServiceObject ewsObject, PropertyDefinition propertyDefinition) + throws Exception { + // If the collection is empty, delete the property. + if (this.getCount() == 0) { + writer.writeStartElement(XmlNamespace.Types, ewsObject + .getDeleteFieldXmlElementName()); + propertyDefinition.writeToXml(writer); + writer.writeEndElement(); + return true; + } + // Otherwise, use the default XML serializer. + else { + return false; + } + } + + /** + * Writes the deletion update to XML. + * + * @param writer The writer. + * @param ewsObject The ews object. + * @return True if property generated serialization. + * @throws Exception the exception + */ + @Override + public boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, + ServiceObject ewsObject) throws Exception { + // Use the default XML serializer. + return false; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ConversationId.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ConversationId.java new file mode 100644 index 000000000..338314e48 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ConversationId.java @@ -0,0 +1,105 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.misc.ArgumentNullException; + +/** + * Represents the Id of a Conversation. + */ +public class ConversationId extends ServiceId { + + /** + * Initializes a new instance of the ConversationId class. + */ + public ConversationId() { + super(); + } + + /** + * Defines an implicit conversion between string and ConversationId. + * + * @param uniqueId the unique id + * @return A ConversationId initialized with the specified unique Id. + * @throws Exception the exception + */ + public static ConversationId getConversationIdFromUniqueId(String uniqueId) + throws Exception { + return new ConversationId(uniqueId); + } + + /** + * Defines an implicit conversion between ConversationId and String. + * + * @param conversationId the conversation id + * @return A ConversationId initialized with the specified unique Id. + * @throws ArgumentNullException the argument null exception + */ + public static String getStringFromConversationId( + ConversationId conversationId) throws ArgumentNullException { + if (conversationId == null) { + throw new ArgumentNullException("conversationId"); + } + + if (null == conversationId.getUniqueId() + || conversationId.getUniqueId().isEmpty()) { + return ""; + } else { + // Ignoring the change key info + return conversationId.getUniqueId(); + } + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.ConversationId; + } + + /** + * Initializes a new instance of ConversationId. + * + * @param uniqueId the unique id + * @throws Exception the exception + */ + public ConversationId(String uniqueId) throws Exception { + super(uniqueId); + } + + /** + * Gets a string representation of the Conversation Id. + * + * @return The string representation of the conversation id. + */ + @Override + public String toString() { + // We have ignored the change key portion + return this.getUniqueId(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/CreateRuleOperation.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/CreateRuleOperation.java new file mode 100644 index 000000000..007d472d3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/CreateRuleOperation.java @@ -0,0 +1,107 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents an operation to create a new rule. + */ +public final class CreateRuleOperation extends RuleOperation { + + + /** + * Inbox rule to be created. + */ + private Rule rule; + + /** + * Initializes a new instance of the + * class. + */ + public CreateRuleOperation() { + super(); + } + + /** + * Initializes a new instance of the + * class. + * + * @param rule The inbox rule to create. + */ + public CreateRuleOperation(Rule rule) { + super(); + this.rule = rule; + } + + /** + * Gets or sets the rule to be created. + */ + public Rule getRule() { + + return this.rule; + } + + public void setRule(Rule value) { + + if (this.canSetFieldValue(this.rule, value)) { + this.rule = value; + this.changed(); + + } + } + + /** + * Writes elements to XML. + * + * @param writer The writer. + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.getRule().writeToXml(writer, XmlElementNames.Rule); + } + + /** + * Validates this instance. + * + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + EwsUtilities.validateParam(this.rule, "Rule"); + } + + /** + * Gets the Xml element name of the CreateRuleOperation object. + */ + @Override + public String getXmlElementName() { + + return XmlElementNames.CreateRuleOperation; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/DelegatePermissions.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DelegatePermissions.java new file mode 100644 index 000000000..dacdfe24f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DelegatePermissions.java @@ -0,0 +1,376 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.permission.folder.DelegateFolderPermissionLevel; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import javax.xml.stream.XMLStreamException; +import java.util.HashMap; +import java.util.Map; + +/** + * Represents the permissions of a delegate user. + */ +public final class DelegatePermissions extends ComplexProperty { + + private final Map delegateFolderPermissions; + + /** + * Initializes a new instance of the class. + */ + + protected DelegatePermissions() { + super(); + this.delegateFolderPermissions = new HashMap(); + + delegateFolderPermissions.put( + XmlElementNames.CalendarFolderPermissionLevel, + new DelegateFolderPermission()); + delegateFolderPermissions.put( + XmlElementNames.TasksFolderPermissionLevel, + new DelegateFolderPermission()); + delegateFolderPermissions.put( + XmlElementNames.InboxFolderPermissionLevel, + new DelegateFolderPermission()); + delegateFolderPermissions.put( + XmlElementNames.ContactsFolderPermissionLevel, + new DelegateFolderPermission()); + delegateFolderPermissions.put( + XmlElementNames.NotesFolderPermissionLevel, + new DelegateFolderPermission()); + delegateFolderPermissions.put( + XmlElementNames.JournalFolderPermissionLevel, + new DelegateFolderPermission()); + } + + /** + * Gets the delegate user's permission on the principal's calendar. + * + * @return the calendar folder permission level + */ + public DelegateFolderPermissionLevel getCalendarFolderPermissionLevel() { + return this.delegateFolderPermissions.get(XmlElementNames. + CalendarFolderPermissionLevel).getPermissionLevel(); + + } + + /** + * sets the delegate user's permission on the principal's calendar. + * + * @param value the new calendar folder permission level + */ + public void setCalendarFolderPermissionLevel( + DelegateFolderPermissionLevel value) { + this.delegateFolderPermissions.get(XmlElementNames. + CalendarFolderPermissionLevel).setPermissionLevel(value); + } + + /** + * Gets the delegate user's permission on the principal's tasks + * folder. + * + * @return the tasks folder permission level + */ + public DelegateFolderPermissionLevel getTasksFolderPermissionLevel() { + return this.delegateFolderPermissions.get(XmlElementNames. + TasksFolderPermissionLevel).getPermissionLevel(); + + } + + /** + * Sets the tasks folder permission level. + * + * @param value the new tasks folder permission level + */ + public void setTasksFolderPermissionLevel( + DelegateFolderPermissionLevel value) { + + this.delegateFolderPermissions.get(XmlElementNames. + TasksFolderPermissionLevel).setPermissionLevel(value); + } + + /** + * Gets the delegate user's permission on the principal's inbox. + * + * @return the inbox folder permission level + */ + public DelegateFolderPermissionLevel getInboxFolderPermissionLevel() { + return this.delegateFolderPermissions.get(XmlElementNames. + InboxFolderPermissionLevel). + getPermissionLevel(); + } + + /** + * Sets the inbox folder permission level. + * + * @param value the new inbox folder permission level + */ + public void setInboxFolderPermissionLevel( + DelegateFolderPermissionLevel value) { + this.delegateFolderPermissions.get(XmlElementNames. + InboxFolderPermissionLevel). + setPermissionLevel(value); + } + + /** + * Gets the delegate user's permission on the principal's contacts + * folder. + * + * @return the contacts folder permission level + */ + public DelegateFolderPermissionLevel getContactsFolderPermissionLevel() { + return this.delegateFolderPermissions.get( + XmlElementNames.ContactsFolderPermissionLevel). + getPermissionLevel(); + } + + /** + * Sets the contacts folder permission level. + * + * @param value the new contacts folder permission level + */ + public void setContactsFolderPermissionLevel( + DelegateFolderPermissionLevel value) { + this.delegateFolderPermissions.get( + XmlElementNames.ContactsFolderPermissionLevel). + setPermissionLevel(value); + } + + /** + * Gets the delegate user's permission on the principal's notes + * folder. + * + * @return the notes folder permission level + */ + public DelegateFolderPermissionLevel getNotesFolderPermissionLevel() { + return this.delegateFolderPermissions.get(XmlElementNames. + NotesFolderPermissionLevel). + getPermissionLevel(); + } + + /** + * Sets the notes folder permission level. + * + * @param value the new notes folder permission level + */ + public void setNotesFolderPermissionLevel( + DelegateFolderPermissionLevel value) { + this.delegateFolderPermissions.get(XmlElementNames. + NotesFolderPermissionLevel). + setPermissionLevel(value); + } + + /** + * Gets the delegate user's permission on the principal's journal + * folder. + * + * @return the journal folder permission level + */ + public DelegateFolderPermissionLevel getJournalFolderPermissionLevel() { + return this.delegateFolderPermissions.get(XmlElementNames. + JournalFolderPermissionLevel). + getPermissionLevel(); + } + + /** + * Sets the journal folder permission level. + * + * @param value the new journal folder permission level + */ + public void setJournalFolderPermissionLevel( + DelegateFolderPermissionLevel value) { + this.delegateFolderPermissions.get(XmlElementNames. + JournalFolderPermissionLevel). + setPermissionLevel(value); + } + + /** + * Reset. + */ + protected void reset() { + for (DelegateFolderPermission delegateFolderPermission : this.delegateFolderPermissions.values()) { + delegateFolderPermission.reset(); + } + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return Returns true if element was read. + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + DelegateFolderPermission delegateFolderPermission = null; + + if (this.delegateFolderPermissions.containsKey(reader.getLocalName())) { + delegateFolderPermission = this.delegateFolderPermissions. + get(reader.getLocalName()); + delegateFolderPermission.initialize(reader. + readElementValue(DelegateFolderPermissionLevel.class)); + } + + + return delegateFolderPermission != null; + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.writePermissionToXml(writer, + XmlElementNames.CalendarFolderPermissionLevel); + + this.writePermissionToXml(writer, + XmlElementNames.TasksFolderPermissionLevel); + + this.writePermissionToXml(writer, + XmlElementNames.InboxFolderPermissionLevel); + + this.writePermissionToXml(writer, + XmlElementNames.ContactsFolderPermissionLevel); + + this.writePermissionToXml(writer, + XmlElementNames.NotesFolderPermissionLevel); + + this.writePermissionToXml(writer, + XmlElementNames.JournalFolderPermissionLevel); + } + + /** + * Write permission to Xml. + * + * @param writer the writer + * @param xmlElementName the element name + */ + private void writePermissionToXml(EwsServiceXmlWriter writer, String xmlElementName) throws ExchangeXmlException { + DelegateFolderPermissionLevel delegateFolderPermissionLevel = + this.delegateFolderPermissions. + get(xmlElementName).getPermissionLevel(); + // E14 Bug 298307: UpdateDelegate fails if + //Custom permission level is round tripped + // + if (delegateFolderPermissionLevel != DelegateFolderPermissionLevel.Custom) { + writer.writeElementValue( + XmlNamespace.Types, + xmlElementName, + delegateFolderPermissionLevel); + } + } + + /** + * Validates this instance for AddDelegate. + */ + protected void validateAddDelegate() throws ExchangeValidationException { + for (DelegateFolderPermission delegateFolderPermission : this.delegateFolderPermissions.values()) { + if (delegateFolderPermission.getPermissionLevel() == DelegateFolderPermissionLevel.Custom) { + throw new ExchangeValidationException("This operation can't be performed because one or more folder " + + "permission levels were set to Custom."); + } + } + } + + /** + * Validates this instance for UpdateDelegate. + */ + protected void validateUpdateDelegate() throws ExchangeValidationException { + for (DelegateFolderPermission delegateFolderPermission : this.delegateFolderPermissions.values()) { + if (delegateFolderPermission.getPermissionLevel() == DelegateFolderPermissionLevel.Custom && + !delegateFolderPermission.isExistingPermissionLevelCustom) { + throw new ExchangeValidationException("This operation can't be performed because one or more folder " + + "permission levels were set to Custom."); + } + } + } + + /** + * Represents a folder's DelegateFolderPermissionLevel + */ + private static class DelegateFolderPermission { + + /** + * Initializes this DelegateFolderPermission. + * + * @param permissionLevel The DelegateFolderPermissionLevel + */ + protected void initialize( + DelegateFolderPermissionLevel permissionLevel) { + this.setPermissionLevel(permissionLevel); + this.setIsExistingPermissionLevelCustom(permissionLevel == + DelegateFolderPermissionLevel.Custom); + } + + /** + * Resets this DelegateFolderPermission. + */ + protected void reset() { + this.initialize(DelegateFolderPermissionLevel.None); + } + + + private DelegateFolderPermissionLevel permissionLevel = DelegateFolderPermissionLevel.None; + + /** + * Gets the delegate user's permission on a principal's folder. + */ + protected DelegateFolderPermissionLevel getPermissionLevel() { + return this.permissionLevel; + } + + /** + * Sets the delegate user's permission on a principal's folder. + */ + protected void setPermissionLevel( + DelegateFolderPermissionLevel value) { + this.permissionLevel = value; + } + + + private boolean isExistingPermissionLevelCustom; + + /** + * Gets IsExistingPermissionLevelCustom. + */ + protected boolean getIsExistingPermissionLevelCustom() { + return this.isExistingPermissionLevelCustom; + } + + /** + * Sets IsExistingPermissionLevelCustom. + */ + private void setIsExistingPermissionLevelCustom(Boolean value) { + this.isExistingPermissionLevelCustom = value; + } + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/DelegateUser.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DelegateUser.java new file mode 100644 index 000000000..44e39e52e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DelegateUser.java @@ -0,0 +1,214 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.StandardUser; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents a delegate user. + */ +public final class DelegateUser extends ComplexProperty { + + /** + * The permissions. + */ + private final DelegatePermissions permissions = new DelegatePermissions(); + /** + * The user id. + */ + private UserId userId = new UserId(); + /** + * The receive copies of meeting messages. + */ + private boolean receiveCopiesOfMeetingMessages; + + /** + * The view private item. + */ + private boolean viewPrivateItems; + + /** + * Initializes a new instance of the class. + */ + public DelegateUser() { + super(); + this.receiveCopiesOfMeetingMessages = false; + this.viewPrivateItems = false; + } + + /** + * Initializes a new instance of the class. + * + * @param primarySmtpAddress the primary smtp address + */ + public DelegateUser(String primarySmtpAddress) { + this(); + this.userId.setPrimarySmtpAddress(primarySmtpAddress); + } + + /** + * Initializes a new instance of the class. + * + * @param standardUser the standard user + */ + public DelegateUser(StandardUser standardUser) { + this(); + + this.userId.setStandardUser(standardUser); + } + + /** + * Gets the user Id of the delegate user. + * + * @return the user id + */ + public UserId getUserId() { + return this.userId; + } + + /** + * Gets the list of delegate user's permissions. + * + * @return the permissions + */ + public DelegatePermissions getPermissions() { + return this.permissions; + } + + /** + * Gets a value indicating if the delegate user should receive + * copies of meeting request. + * + * @return the receive copies of meeting messages + */ + public boolean getReceiveCopiesOfMeetingMessages() { + return this.receiveCopiesOfMeetingMessages; + + } + + /** + * Sets the receive copies of meeting messages. + * + * @param value the new receive copies of meeting messages + */ + public void setReceiveCopiesOfMeetingMessages(boolean value) { + this.receiveCopiesOfMeetingMessages = value; + } + + /** + * Gets a value indicating if the delegate user should be + * able to view the principal's private item. + * + * @return the view private item + */ + public boolean getViewPrivateItems() { + return this.viewPrivateItems; + + } + + /** + * Gets a value indicating if the delegate user should be able to + * view the principal's private item. + * + * @param value the new view private item + */ + public void setViewPrivateItems(boolean value) { + + this.viewPrivateItems = value; + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return true, if successful + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.UserId)) { + + this.userId = new UserId(); + this.userId.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.UserId)) { + + this.permissions.reset(); + this.permissions.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.ReceiveCopiesOfMeetingMessages)) { + + this.receiveCopiesOfMeetingMessages = reader + .readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.ViewPrivateItems)) { + + this.viewPrivateItems = reader.readElementValue(Boolean.class); + return true; + } else { + + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.getUserId().writeToXml(writer, XmlElementNames.UserId); + this.getPermissions().writeToXml(writer, XmlElementNames.DelegatePermissions); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.ReceiveCopiesOfMeetingMessages, this.receiveCopiesOfMeetingMessages); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.ViewPrivateItems, this.viewPrivateItems); + } + + /** + * Validates this instance. + * + * @throws ExchangeValidationException the service validation exception + */ + protected void internalValidate() throws ExchangeValidationException { + if (this.getUserId() == null) { + throw new ExchangeValidationException("The UserId in the DelegateUser hasn't been specified."); + } else if (!this.getUserId().isValid()) { + throw new ExchangeValidationException( + "The UserId in the DelegateUser is invalid. The StandardUser, PrimarySmtpAddress or SID property must be set."); + } + } + + protected void validateAddDelegate() throws ExchangeValidationException { + this.permissions.validateAddDelegate(); + } + + public void validateUpdateDelegate() throws Exception { + this.permissions.validateUpdateDelegate(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/DeleteRuleOperation.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DeleteRuleOperation.java new file mode 100644 index 000000000..b688dfd61 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DeleteRuleOperation.java @@ -0,0 +1,103 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents an operation to delete an existing rule. + */ +public final class DeleteRuleOperation extends RuleOperation { + /** + * Id of the inbox rule to delete. + */ + private String ruleId; + + /** + * Initializes a new instance of the + * class. + */ + public DeleteRuleOperation() { + super(); + } + + /** + * Initializes a new instance of the + * class. + * + * @param ruleId The Id of the inbox rule to delete. + */ + public DeleteRuleOperation(String ruleId) { + super(); + this.ruleId = ruleId; + } + + /** + * Gets or sets the Id of the rule to delete. + */ + public String getRuleId() { + return this.ruleId; + } + + public void setRuleId(String value) { + if (this.canSetFieldValue(this.ruleId, value)) { + this.ruleId = value; + this.changed(); + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) + throws ExchangeXmlException { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.RuleId, this.getRuleId()); + } + + /** + * Validates this instance. + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + EwsUtilities.validateParam(this.ruleId, "RuleId"); + } + + /** + * Gets the Xml element name of the DeleteRuleOperation object. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.DeleteRuleOperation; + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/DeletedOccurrenceInfo.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DeletedOccurrenceInfo.java new file mode 100644 index 000000000..aad849dbb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DeletedOccurrenceInfo.java @@ -0,0 +1,76 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.time.LocalDateTime; + +/** + * Encapsulates information on the deleted occurrence of a recurring + * appointment. + */ +public class DeletedOccurrenceInfo extends ComplexProperty { + + /** + * The original start date and time of the deleted occurrence. The EWS + * schema contains a Start property for deleted occurrences but it's really + * the original start date and time of the occurrence. + */ + private LocalDateTime originalStart; + + /** + * Initializes a new instance of the "DeletedOccurrenceInfo" class. + */ + protected DeletedOccurrenceInfo() { + } + + /** + * Tries to read element from XML. + * + * @param reader The reader. + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Start)) { + this.originalStart = reader.readElementValueAsDateTime(); + return true; + } else { + return false; + } + } + + /** + * Gets the original start date and time of the deleted occurrence. + * + * @return the original start + */ + public LocalDateTime getOriginalStart() { + return this.originalStart; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/DeletedOccurrenceInfoCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DeletedOccurrenceInfoCollection.java new file mode 100644 index 000000000..01b637e09 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DeletedOccurrenceInfoCollection.java @@ -0,0 +1,69 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; + +/** + * Represents a collection of deleted occurrence objects. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class DeletedOccurrenceInfoCollection extends ComplexPropertyCollection { + + /** + * Initializes a new instance of the OccurrenceInfoCollection class. + */ + public DeletedOccurrenceInfoCollection() { + } + + /** + * Creates the complex property. + * + * @param xmlElementName the xml element name + * @return OccurenceInfo instance. + */ + @Override + protected DeletedOccurrenceInfo createComplexProperty( + String xmlElementName) { + if (xmlElementName.equalsIgnoreCase(XmlElementNames.DeletedOccurrence)) { + return new DeletedOccurrenceInfo(); + } else { + return null; + } + } + + /** + * Gets the name of the collection item XML element. + * + * @param complexProperty the complex property + * @return XML element name. + */ + @Override + protected String getCollectionItemXmlElementName( + DeletedOccurrenceInfo complexProperty) { + return XmlElementNames.Occurrence; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/DictionaryEntryProperty.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DictionaryEntryProperty.java new file mode 100644 index 000000000..49a82f46a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DictionaryEntryProperty.java @@ -0,0 +1,144 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; + +import javax.xml.stream.XMLStreamException; + +/** + * Represents an entry of a DictionaryProperty object. + * + * All descendants of DictionaryEntryProperty must implement a parameterless + * constructor. That constructor does not have to be public. That constructor + * does not have to be public. + * + * @param the generic type + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class DictionaryEntryProperty extends ComplexProperty { + + /** + * The key. + */ + private TKey key; + private final Class instance; + + /** + * Initializes a new instance of the "DictionaryEntryProperty<TKey>" + * class. + */ + protected DictionaryEntryProperty(Class cls) { + this.instance = cls; + } + + /** + * Initializes a new instance of the "DictionaryEntryProperty<TKey>" + * class. + * + * @param key The key. + */ + protected DictionaryEntryProperty(Class cls, TKey key) { + super(); + this.key = key; + this.instance = cls; + } + + /** + * Gets the key. + * + * @return the key + */ + protected TKey getKey() { + return key; + } + + /** + * Sets the key. + * + * @param value the value to set + */ + protected void setKey(TKey value) { + this.key = value; + } + + /** + * Reads the attribute from XML. + * + * @param reader accepts EwsServiceXmlReader + */ + @Override + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.key = reader.readAttributeValue(instance, + XmlAttributeNames.Key); + } + + /** + * Writes the attribute to XML. + * + * @param writer accepts EwsServiceXmlWriter + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.Key, this.getKey()); + } + + /** + * Writes the set update to XML. + * + * @param writer the writer + * @param ewsObject the ews object + * @param ownerDictionaryXmlElementName name of the owner dictionary XML element + * @return true if update XML was written + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + protected boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, + ServiceObject ewsObject, String ownerDictionaryXmlElementName) + throws XMLStreamException, ServiceXmlSerializationException, ExchangeXmlException { + return false; + } + + /** + * Writes the delete update to XML. + * + * @param writer the writer + * @param ewsObject the ews object + * @return true if update XML was written + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + protected boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, + ServiceObject ewsObject) throws XMLStreamException, ServiceXmlSerializationException, ExchangeXmlException { + return false; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/DictionaryProperty.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DictionaryProperty.java new file mode 100644 index 000000000..6f078b011 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/DictionaryProperty.java @@ -0,0 +1,382 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +/** + * Represents a generic dictionary that can be sent to or retrieved from EWS. + * TKey The type of key. TEntry The type of entry. + * + * @param the generic type + * @param the generic type + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class DictionaryProperty + > + extends ComplexProperty implements ICustomXmlUpdateSerializer, IComplexPropertyChangedDelegate { + + /** + * The entries. + */ + private final Map entries = new HashMap<>(); + + /** + * The removed entries. + */ + private final Map removedEntries = new HashMap<>(); + + /** + * The added entries. + */ + private final List addedEntries = new ArrayList<>(); + + /** + * The modified entries. + */ + private final List modifiedEntries = new ArrayList<>(); + + /** + * Entry was changed. + * + * @param complexProperty the complex property + */ + private void entryChanged(final TEntry complexProperty) { + TKey key = complexProperty.getKey(); + + if (!this.addedEntries.contains(key) && !this.modifiedEntries.contains(key)) { + this.modifiedEntries.add(key); + this.changed(); + } + } + + /** + * Writes the URI to XML. + * + * @param writer the writer + * @param key the key + * @throws Exception the exception + */ + private void writeUriToXml(EwsServiceXmlWriter writer, TKey key) + throws Exception { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.IndexedFieldURI); + writer.writeAttributeValue(XmlAttributeNames.FieldURI, this + .getFieldURI()); + writer.writeAttributeValue(XmlAttributeNames.FieldIndex, this + .getFieldIndex(key)); + writer.writeEndElement(); + } + + /** + * Gets the index of the field. + * + * @param key the key + * @return Key index. + */ + protected String getFieldIndex(TKey key) { + return key.toString(); + } + + /** + * Gets the field URI. + * + * @return Field URI. + */ + protected String getFieldURI() { + return null; + } + + /** + * Creates the entry. + * + * @param reader the reader + * @return Dictionary entry. + */ + protected TEntry createEntry(EwsServiceXmlReader reader) { + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Entry)) { + return this.createEntryInstance(); + } else { + return null; + } + } + + /** + * Creates instance of dictionary entry. + * + * @return New instance. + */ + protected abstract TEntry createEntryInstance(); + + /** + * Gets the name of the entry XML element. + * + * @param entry the entry + * @return XML element name. + */ + protected String getEntryXmlElementName(TEntry entry) { + return XmlElementNames.Entry; + } + + /** + * Clears the change log. + */ + public void clearChangeLog() { + this.addedEntries.clear(); + this.removedEntries.clear(); + this.modifiedEntries.clear(); + + for (TEntry entry : this.entries.values()) { + entry.clearChangeLog(); + } + } + + /** + * Add entry. + * + * @param entry the entry + */ + protected void internalAdd(TEntry entry) { + entry.addOnChangeEvent(this); + + this.entries.put(entry.getKey(), entry); + this.addedEntries.add(entry.getKey()); + this.removedEntries.remove(entry.getKey()); + + this.changed(); + } + + /** + * Complex property changed. + * + * @param complexProperty accepts ComplexProperty + */ + @Override + public void complexPropertyChanged(final TEntry complexProperty) { + entryChanged(complexProperty); + } + + /** + * Add or replace entry. + * + * @param entry the entry + */ + protected void internalAddOrReplace(TEntry entry) { + TEntry oldEntry; + if (this.entries.containsKey(entry.getKey())) { + oldEntry = this.entries.get(entry.getKey()); + oldEntry.removeChangeEvent(this); + + entry.addOnChangeEvent(this); + + if (!this.addedEntries.contains(entry.getKey())) { + if (!this.modifiedEntries.contains(entry.getKey())) { + this.modifiedEntries.add(entry.getKey()); + } + } + + this.changed(); + } else { + this.internalAdd(entry); + } + } + + /** + * Remove entry based on key. + * + * @param key the key + */ + protected void internalRemove(TKey key) { + TEntry entry; + if (this.entries.containsKey(key)) { + entry = this.entries.get(key); + entry.removeChangeEvent(this); + + this.entries.remove(key); + this.removedEntries.put(key, entry); + + this.changed(); + } + + this.addedEntries.remove(key); + } + + /** + * Loads from XML. + * + * @param reader the reader + * @param localElementName the local element name + */ + public void loadFromXml(EwsServiceXmlReader reader, String localElementName) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, + localElementName); + + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.isStartElement()) { + TEntry entry = this.createEntry(reader); + + if (entry != null) { + entry.loadFromXml(reader, reader.getLocalName()); + this.internalAdd(entry); + } else { + reader.skipCurrentElement(); + } + } + } while (!reader.isEndElement(XmlNamespace.Types, + localElementName)); + } else { + reader.read(); + } + } + + /** + * Writes to XML. + * + * @param writer The writer + * @param xmlNamespace The XML namespace. + * @param xmlElementName Name of the XML element. + */ + @Override + public void writeToXml(EwsServiceXmlWriter writer, XmlNamespace xmlNamespace, + String xmlElementName) throws ExchangeXmlException { + // Only write collection if it has at least one element. + if (this.entries.size() > 0) { + super.writeToXml( + writer, + xmlNamespace, + xmlElementName); + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + for (Entry keyValuePair : this.entries.entrySet()) { + keyValuePair.getValue().writeToXml(writer, + this.getEntryXmlElementName(keyValuePair.getValue())); + } + } + + /** + * Gets the entries. + * + * @return The entries. + */ + protected Map getEntries() { + return entries; + } + + /** + * Determines whether this instance contains the specified key. + * + * @param key the key + * @return true if this instance contains the specified key; otherwise, + * false. + */ + public boolean contains(TKey key) { + return this.entries.containsKey(key); + } + + /** + * Writes updates to XML. + * + * @param writer the writer + * @param ewsObject the ews object + * @param propertyDefinition the property definition + * @return True if property generated serialization. + * @throws Exception the exception + */ + public boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, + ServiceObject ewsObject, PropertyDefinition propertyDefinition) + throws Exception { + List tempEntries = new ArrayList<>(); + + for (TKey key : this.addedEntries) { + tempEntries.add(this.entries.get(key)); + } + for (TKey key : this.modifiedEntries) { + tempEntries.add(this.entries.get(key)); + } + for (TEntry entry : tempEntries) { + + if (!entry.writeSetUpdateToXml(writer, ewsObject, + propertyDefinition.getXmlElement())) { + writer.writeStartElement(XmlNamespace.Types, ewsObject + .getSetFieldXmlElementName()); + this.writeUriToXml(writer, entry.getKey()); + + writer.writeStartElement(XmlNamespace.Types, ewsObject + .getXmlElementName()); + //writer.writeStartElement(XmlNamespace.Types, propertyDefinition.getXmlElementName()); + writer.writeStartElement(XmlNamespace.Types, propertyDefinition.getXmlElement()); + entry.writeToXml(writer, this.getEntryXmlElementName(entry)); + writer.writeEndElement(); + writer.writeEndElement(); + + writer.writeEndElement(); + } + } + + for (TEntry entry : this.removedEntries.values()) { + if (!entry.writeDeleteUpdateToXml(writer, ewsObject)) { + writer.writeStartElement(XmlNamespace.Types, ewsObject + .getDeleteFieldXmlElementName()); + this.writeUriToXml(writer, entry.getKey()); + writer.writeEndElement(); + } + } + + return true; + } + + /** + * Writes deletion update to XML. + * + * @param writer the writer + * @param ewsObject the ews object + * @return True if property generated serialization. + */ + public boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, + ServiceObject ewsObject) { + return false; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/EmailAddress.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/EmailAddress.java new file mode 100644 index 000000000..54166eeb0 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/EmailAddress.java @@ -0,0 +1,388 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.MailboxType; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents an e-mail address. + */ +public class EmailAddress extends ComplexProperty implements ISearchStringProvider { + + private static final Logger LOG = Logger.getLogger(EmailAddress.class.getCanonicalName()); + + // SMTP routing type. + /** + * The Constant SmtpRoutingType. + */ + protected final static String SmtpRoutingType = "SMTP"; + + // / Display name. + /** + * The name. + */ + private String name; + + // / Email address. + /** + * The address. + */ + private String address; + + // / Routing type. + /** + * The routing type. + */ + private String routingType; + + // / Mailbox type. + /** + * The mailbox type. + */ + private MailboxType mailboxType; + + // / ItemId - Contact or PDL. + /** + * The id. + */ + private ItemId id; + + /** + * Initializes a new instance. + */ + public EmailAddress() { + super(); + } + + /** + * Initializes a new instance. + * + * @param smtpAddress The SMTP address used to initialize the EmailAddress. + */ + public EmailAddress(String smtpAddress) { + this(); + this.address = smtpAddress; + } + + /** + * Initializes a new instance. + * + * @param name The name used to initialize the EmailAddress. + * @param smtpAddress The SMTP address used to initialize the EmailAddress. + */ + public EmailAddress(String name, String smtpAddress) { + this(smtpAddress); + this.name = name; + } + + /** + * Initializes a new instance. + * + * @param name The name used to initialize the EmailAddress. + * @param address The address used to initialize the EmailAddress. + * @param routingType The routing type used to initialize the EmailAddress. + */ + public EmailAddress(String name, String address, String routingType) { + this(name, address); + this.routingType = routingType; + } + + /** + * Initializes a new instance. + * + * @param name The name used to initialize the EmailAddress. + * @param address The address used to initialize the EmailAddress. + * @param routingType The routing type used to initialize the EmailAddress. + * @param mailboxType Mailbox type of the participant. + */ + protected EmailAddress(String name, String address, String routingType, + MailboxType mailboxType) { + this(name, address, routingType); + this.mailboxType = mailboxType; + } + + /** + * Initializes a new instance. + * + * @param name The name used to initialize the EmailAddress. + * @param address The address used to initialize the EmailAddress. + * @param routingType The routing type used to initialize the EmailAddress. + * @param mailboxType Mailbox type of the participant. + * @param id ItemId of a Contact or PDL. + */ + protected EmailAddress(String name, String address, String routingType, + MailboxType mailboxType, ItemId id) { + this(name, address, routingType); + this.mailboxType = mailboxType; + this.id = id; + } + + /** + * Initializes a new instance from another EmailAddress instance. + * + * @param mailbox EMailAddress instance to copy. + * @throws Exception the exception + */ + protected EmailAddress(EmailAddress mailbox) throws Exception { + this(); + EwsUtilities.validateParam(mailbox, "mailbox"); + this.name = mailbox.getName(); + this.address = mailbox.getAddress(); + this.routingType = mailbox.getRoutingType(); + this.mailboxType = mailbox.getMailboxType(); + this.setId(mailbox.getId()); + + } + + /** + * Gets the name associated with the e-mail address. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets the name associated with the e-mail address. + * + * @param name the new name + */ + public void setName(String name) { + if (this.canSetFieldValue(this.name, name)) { + this.name = name; + this.changed(); + } + } + + /** + * Gets the actual address associated with the e-mail address. + * + * @return address associated with the e-mail address. + */ + public String getAddress() { + return address; + } + + /** + * Sets the actual address associated with the e-mail address. The type of + * the Address property must match the specified routing type. If + * RoutingType is not set, Address is assumed to be an SMTP address. + * + * @param address address associated with the e-mail address. + */ + public void setAddress(String address) { + + if (this.canSetFieldValue(this.address, address)) { + this.address = address; + this.changed(); + } + + } + + /** + * Gets the routing type associated with the e-mail address. + * + * @return the routing type + */ + public String getRoutingType() { + return routingType; + } + + /** + * Sets the routing type associated with the e-mail address. If RoutingType + * is not set, Address is assumed to be an SMTP address. + * + * @param routingType routing type associated with the e-mail address. + */ + public void setRoutingType(String routingType) { + if (this.canSetFieldValue(this.routingType, routingType)) { + this.routingType = routingType; + this.changed(); + } + } + + /** + * Gets the type of the e-mail address. + * + * @return type of the e-mail address. + */ + public MailboxType getMailboxType() { + return mailboxType; + } + + /** + * Sets the type of the e-mail address. + * + * @param mailboxType the new mailbox type + */ + public void setMailboxType(MailboxType mailboxType) { + if (this.canSetFieldValue(this.mailboxType, mailboxType)) { + this.mailboxType = mailboxType; + this.changed(); + } + } + + /** + * Gets the Id of the contact the e-mail address represents. + * + * @return the id + */ + public ItemId getId() { + return id; + } + + /** + * Sets the Id of the contact the e-mail address represents. When Id is + * specified, Address should be set to null. + * + * @param id the new id + */ + public void setId(ItemId id) { + + if (this.canSetFieldValue(this.id, id)) { + this.id = id; + this.changed(); + } + } + + /** + * Defines an implicit conversion between a string representing an SMTP + * address and EmailAddress. + * + * @param smtpAddress The SMTP address to convert to EmailAddress. + * @return An EmailAddress initialized with the specified SMTP address. + */ + public static EmailAddress getEmailAddressFromString(String smtpAddress) { + return new EmailAddress(smtpAddress); + } + + /** + * Try read element from xml. + * + * @param reader accepts EwsServiceXmlReader + * @return true + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + try { + if (reader.getLocalName().equals(XmlElementNames.Name)) { + this.name = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.EmailAddress)) { + this.address = reader.readElementValue(); + return true; + } else if (reader.getLocalName() + .equals(XmlElementNames.RoutingType)) { + this.routingType = reader.readElementValue(); + return true; + } else if (reader.getLocalName() + .equals(XmlElementNames.MailboxType)) { + this.mailboxType = reader.readElementValue(MailboxType.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.ItemId)) { + this.id = new ItemId(); + this.id.loadFromXml(reader, reader.getLocalName()); + return true; + } else { + return false; + } + } catch (Exception e) { + LOG.log(Level.SEVERE, "error reading XML", e); + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer The writer. + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Name, this.getName()); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.EmailAddress, this.getAddress()); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.RoutingType, this.getRoutingType()); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.MailboxType, this.getMailboxType()); + if (this.getId() != null) { + this.getId().writeToXml(writer, XmlElementNames.ItemId); + } + + } + + /** + * Get a string representation for using this instance in a search filter. + * + * @return String representation of instance. + */ + @Override + public String getSearchString() { + return this.getAddress(); + } + + /** + * Returns string that represents the current instance. + * + * @return String representation of instance. + */ + @Override + public String toString() { + String addressPart; + + if (null == this.getAddress() || this.getAddress().isEmpty()) { + return ""; + } + + if (null != this.getRoutingType() && this.getRoutingType().isEmpty()) { + addressPart = this.getRoutingType() + ":" + this.getAddress(); + } else { + addressPart = this.getAddress(); + } + + if (null != this.getName() && !this.getName().isEmpty()) { + return this.getName() + " <" + addressPart + ">"; + } else { + return addressPart; + } + } + + /** + * Gets the routing type. + * + * @return SMTP Routing type + */ + protected String getSmtpRoutingType() { + return SmtpRoutingType; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/EmailAddressCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/EmailAddressCollection.java new file mode 100644 index 000000000..0e0baaae9 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/EmailAddressCollection.java @@ -0,0 +1,192 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; + +import java.util.Iterator; + +/** + * Represents a collection of e-mail addresses. + */ +public final class EmailAddressCollection extends ComplexPropertyCollection { + + //XML element name + private final String collectionItemXmlElementName; + + /** + * Initializes a new instance. + */ + public EmailAddressCollection() { + this(XmlElementNames.Mailbox); + } + + /** + * Initializes a new instance of the EmailAddressCollection class. + * + * @param collectionItemXmlElementName Name of the collection item XML element. + */ + protected EmailAddressCollection(String collectionItemXmlElementName) { + super(); + this.collectionItemXmlElementName = collectionItemXmlElementName; + } + + /** + * Adds an e-mail address to the collection. + * + * @param emailAddress The e-mail address to add. + */ + public void add(EmailAddress emailAddress) { + this.internalAdd(emailAddress); + } + + /** + * Adds multiple e-mail addresses to the collection. + * + * @param emailAddresses The e-mail addresses to add. + */ + public void addEmailRange(Iterator emailAddresses) { + if (null != emailAddresses) { + while (emailAddresses.hasNext()) { + this.add(emailAddresses.next()); + } + } + } + + /** + * Adds an e-mail address to the collection. + * + * @param smtpAddress The SMTP address used to initialize the e-mail address. + * @return An EmailAddress object initialized with the provided SMTP + * address. + */ + public EmailAddress add(String smtpAddress) { + EmailAddress emailAddress = new EmailAddress(smtpAddress); + this.add(emailAddress); + return emailAddress; + } + + /** + * Adds multiple e-mail addresses to the collection. + * + * @param smtpAddresses The SMTP addresses used to initialize the e-mail addresses. + */ + public void addSmtpAddressRange(Iterator smtpAddresses) { + if (null != smtpAddresses) { + while (smtpAddresses.hasNext()) { + this.add(smtpAddresses.next()); + } + } + } + + /** + * Adds an e-mail address to the collection. + * + * @param name The name used to initialize the e-mail address. + * @param smtpAddress The SMTP address used to initialize the e-mail address. + * @return An EmailAddress object initialized with the provided SMTP + * address. + */ + public EmailAddress add(String name, String smtpAddress) { + EmailAddress emailAddress = new EmailAddress(name, smtpAddress); + this.add(emailAddress); + return emailAddress; + } + + /** + * Clears the collection. + */ + public void clear() { + this.internalClear(); + } + + /** + * Removes an e-mail address from the collection. + * + * @param index The index of the e-mail address to remove. + */ + public void removeAt(int index) { + if (index < 0 || index >= this.getCount()) { + throw new IllegalArgumentException( + String.format("index %d is out of range [0..%d[.", index, this.getCount()) + ); + } + + this.internalRemoveAt(index); + } + + /** + * Removes an e-mail address from the collection. + * + * @param emailAddress The e-mail address to remove. + * @return True if the email address was successfully removed from the + * collection, false otherwise. + * @throws Exception the exception + */ + public boolean remove(EmailAddress emailAddress) throws Exception { + EwsUtilities.validateParam(emailAddress, "emailAddress"); + return this.internalRemove(emailAddress); + } + + /** + * Creates an EmailAddress object from an XML element name. + * + * @param xmlElementName The XML element name from which to create the e-mail address. + * @return An EmailAddress object. + */ + @Override + protected EmailAddress createComplexProperty(String xmlElementName) { + if (xmlElementName.equals(this.collectionItemXmlElementName)) { + return new EmailAddress(); + } else { + return null; + } + } + + /** + * Retrieves the XML element name corresponding to the provided EmailAddress + * object. + * + * @param complexProperty The EmailAddress object from which to determine the XML + * element name. + * @return The XML element name corresponding to the provided EmailAddress + * object. + */ + @Override + protected String getCollectionItemXmlElementName( + EmailAddress complexProperty) { + return this.collectionItemXmlElementName; + } + + /** + * Determine whether we should write collection to XML or not. + * + * @return Always true, even if the collection is empty. + */ + @Override + public boolean shouldWriteToXml() { + return true; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/EmailAddressDictionary.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/EmailAddressDictionary.java new file mode 100644 index 000000000..cffdf52f7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/EmailAddressDictionary.java @@ -0,0 +1,113 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.property.EmailAddressKey; +import com.eischet.ews.api.misc.OutParam; + +/** + * Represents a dictionary of e-mail addresses. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class EmailAddressDictionary extends DictionaryProperty { + + /** + * Gets the field URI. + * + * @return Field URI. + */ + @Override + protected String getFieldURI() { + return "contacts:EmailAddress"; + } + + /** + * Creates instance of dictionary entry. + * + * @return New instance. + */ + @Override + protected EmailAddressEntry createEntryInstance() { + return new EmailAddressEntry(); + } + + /** + * Gets the e-mail address at the specified key. + * + * @param key the key + * @return The e-mail address at the specified key. + */ + public EmailAddress getEmailAddress(EmailAddressKey key) { + return this.getEntries().get(key).getEmailAddress(); + } + + /** + * Sets the email address. + * + * @param key the key + * @param value the value + */ + public void setEmailAddress(EmailAddressKey key, EmailAddress value) { + if (value == null) { + this.internalRemove(key); + } else { + EmailAddressEntry entry; + + if (this.getEntries().containsKey(key)) { + entry = this.getEntries().get(key); + entry.setEmailAddress(value); + complexPropertyChanged(entry); + this.changed(); + } else { + entry = new EmailAddressEntry(key, value); + this.internalAdd(entry); + } + } + } + + /** + * Tries to get the e-mail address associated with the specified key. + * + * @param key the key + * @param outparam the outparam + * @return true if the Dictionary contains an e-mail address associated with + * the specified key; otherwise, false. + */ + public boolean tryGetValue(EmailAddressKey key, + OutParam outparam) { + EmailAddressEntry entry = null; + + if (this.getEntries().containsKey(key)) { + entry = this.getEntries().get(key); + outparam.setParam(entry.getEmailAddress()); + + return true; + } else { + outparam = null; + return false; + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/EmailAddressEntry.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/EmailAddressEntry.java new file mode 100644 index 000000000..b835ce745 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/EmailAddressEntry.java @@ -0,0 +1,166 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.EmailAddressKey; +import com.eischet.ews.api.core.enumeration.property.MailboxType; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents an entry of an EmailAddressDictionary. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class EmailAddressEntry extends DictionaryEntryProperty implements IComplexPropertyChangedDelegate { + // / The email address. + /** + * The email address. + */ + private EmailAddress emailAddress; + + /** + * Initializes a new instance of the class. + */ + protected EmailAddressEntry() { + super(EmailAddressKey.class); + this.emailAddress = new EmailAddress(); + this.emailAddress.addOnChangeEvent(this); + } + + /** + * Initializes a new instance of the "EmailAddressEntry" class. + * + * @param key The key. + * @param emailAddress The email address. + */ + protected EmailAddressEntry(EmailAddressKey key, EmailAddress emailAddress) { + super(EmailAddressKey.class, key); + this.emailAddress = emailAddress; + } + + /** + * Reads the attribute from XML. + * + * @param reader accepts EwsServiceXmlReader + */ + @Override + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + super.readAttributesFromXml(reader); + this.getEmailAddress().setName(reader.readAttributeValue(XmlAttributeNames.Name)); + this.getEmailAddress().setRoutingType(reader.readAttributeValue(XmlAttributeNames.RoutingType)); + String mailboxTypeString = reader.readAttributeValue(XmlAttributeNames.MailboxType); + if ((mailboxTypeString != null) && (!mailboxTypeString.isEmpty())) { + this.getEmailAddress().setMailboxType(EwsUtilities.parse(MailboxType.class, mailboxTypeString)); + } else { + this.getEmailAddress().setMailboxType(null); + } + } + + /** + * Reads the text value from XML. + * + * @param reader accepts EwsServiceXmlReader + */ + @Override + public void readTextValueFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.getEmailAddress().setAddress(reader.readValue()); + } + + /** + * Writes the attribute to XML. + * + * @param writer accepts EwsServiceXmlWriter + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + if (writer.getService().getRequestedServerVersion().ordinal() > ExchangeVersion.Exchange2007_SP1.ordinal()) { + writer.writeAttributeValue(XmlAttributeNames.Name, this.getEmailAddress().getName()); + writer.writeAttributeValue(XmlAttributeNames.RoutingType, this.getEmailAddress().getRoutingType()); + if (this.getEmailAddress().getMailboxType() != MailboxType.Unknown) { + writer.writeAttributeValue(XmlAttributeNames.MailboxType, this.getEmailAddress().getMailboxType()); + } + } + } + + /** + * Writes elements to XML. + * + * @param writer accepts EwsServiceXmlWriter + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeValue(this.getEmailAddress().getAddress(), XmlElementNames.EmailAddress); + } + + /** + * Gets the e-mail address of the entry. + * + * @return the email address + */ + public EmailAddress getEmailAddress() { + return this.emailAddress; + // set { this.SetFieldValue(ref this.emailAddress, value); + // } + } + + /** + * Sets the e-mail address of the entry. + * + * @param value the new email address + */ + public void setEmailAddress(Object value) { + //this.canSetFieldValue((EmailAddress) this.emailAddress, value); + if (this.canSetFieldValue(this.emailAddress, value)) { + this.emailAddress = (EmailAddress) value; + } + } + + /** + * E-mail address was changed. + * + * @param complexProperty the complex property + */ + private void emailAddressChanged(ComplexProperty complexProperty) { + this.changed(); + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.ComplexPropertyChangedDelegateInterface + * #complexPropertyChanged(microsoft.exchange.webservices.ComplexProperty) + */ + @Override + public void complexPropertyChanged(ComplexProperty complexProperty) { + this.emailAddressChanged(complexProperty); + + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ExtendedProperty.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ExtendedProperty.java new file mode 100644 index 000000000..ba650adee --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ExtendedProperty.java @@ -0,0 +1,233 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.MapiTypeConverter; +import com.eischet.ews.api.property.definition.ExtendedPropertyDefinition; + +import javax.xml.stream.XMLStreamException; +import java.util.ArrayList; +import java.util.Objects; + +/** + * Represents an extended property. + */ +public final class ExtendedProperty extends ComplexProperty { + + /** + * The property definition. + */ + private ExtendedPropertyDefinition propertyDefinition; + + /** + * The value. + */ + private Object value; + + /** + * Initializes a new instance. + */ + protected ExtendedProperty() { + } + + /** + * Initializes a new instance. + * + * @param propertyDefinition The definition of the extended property. + * @throws Exception the exception + */ + protected ExtendedProperty(ExtendedPropertyDefinition propertyDefinition) + throws Exception { + this(); + EwsUtilities.validateParam(propertyDefinition, "propertyDefinition"); + this.propertyDefinition = propertyDefinition; + } + + /** + * Tries to read element from XML. + * + * @param reader The reader. + * @return true, if successful + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + + if (reader.getLocalName().equals(XmlElementNames.ExtendedFieldURI)) { + this.propertyDefinition = new ExtendedPropertyDefinition(); + this.propertyDefinition.loadFromXml(reader); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Value)) { + EwsUtilities.ewsAssert(this.getPropertyDefinition() != null, "ExtendedProperty.TryReadElementFromXml", + "PropertyDefintion is missing"); + String stringValue = reader.readElementValue(); + this.value = MapiTypeConverter.convertToValue(this.getPropertyDefinition().getMapiType(), stringValue); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Values)) { + EwsUtilities.ewsAssert(this.getPropertyDefinition() != null, "ExtendedProperty.TryReadElementFromXml", + "PropertyDefintion is missing"); + + StringList stringList = new StringList(XmlElementNames.Value); + stringList.loadFromXml(reader, reader.getLocalName()); + this.value = MapiTypeConverter.convertToValue(this + .getPropertyDefinition().getMapiType(), stringList + .iterator()); + return true; + } else { + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.getPropertyDefinition().writeToXml(writer); + + if (MapiTypeConverter.isArrayType(this.getPropertyDefinition() + .getMapiType())) { + ArrayList array = (ArrayList) this.getValue(); + writer + .writeStartElement(XmlNamespace.Types, + XmlElementNames.Values); + for (int index = 0; index < array.size(); index++) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.Value, MapiTypeConverter + .convertToString(this.getPropertyDefinition() + .getMapiType(), array.get(index))); + } + writer.writeEndElement(); + } else { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Value, + MapiTypeConverter.convertToString(this + .getPropertyDefinition().getMapiType(), this + .getValue())); + } + } + + /** + * Gets the definition of the extended property. + * + * @return The definition of the extended property. + */ + public ExtendedPropertyDefinition getPropertyDefinition() { + return this.propertyDefinition; + } + + /** + * Gets the value of the extended property. + * + * @return the value + */ + public Object getValue() { + return this.value; + } + + /** + * Sets the value of the extended property. + * + * @param val value of the extended property + * @throws Exception the exception + */ + public void setValue(Object val) throws Exception { + EwsUtilities.validateParam(val, "value"); + if (this.canSetFieldValue(this.value, MapiTypeConverter.changeType(this + .getPropertyDefinition().getMapiType(), val))) { + this.value = MapiTypeConverter.changeType(this + .getPropertyDefinition().getMapiType(), val); + this.changed(); + } + } + + /** + * Gets the string value. + * + * @return String + */ + private String getStringValue() { + if (MapiTypeConverter.isArrayType(this.getPropertyDefinition() + .getMapiType())) { + ArrayList array = (ArrayList) this.getValue(); + if (array == null) { + return null; + } else { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int index = 0; index < array.size(); index++) { + sb.append(MapiTypeConverter.convertToString(this + .getPropertyDefinition().getMapiType(), array + .get(index))); + sb.append(","); + } + sb.append("]"); + + return sb.toString(); + } + } else { + return MapiTypeConverter.convertToString(this + .getPropertyDefinition().getMapiType(), this.getValue()); + } + } + + /** + * Determines whether the specified is equal + * to the current true if the specified is equal to the current + * + * @param obj the obj + * @return boolean + */ + @Override + public boolean equals(final Object obj) { + if (obj instanceof ExtendedProperty) { + final ExtendedProperty other = (ExtendedProperty) obj; + return other.getPropertyDefinition().equals(this.getPropertyDefinition()) + && Objects.equals(this.getStringValue(), other.getStringValue()); + } + return false; + } + + /** + * Serves as a hash function for a particular type. + * + * @return int + */ + @Override + public int hashCode() { + String printableName = this.getPropertyDefinition() != null ? this + .getPropertyDefinition().getPrintableName() : ""; + String stringVal = this.getStringValue(); + return (printableName + stringVal).hashCode(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ExtendedPropertyCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ExtendedPropertyCollection.java new file mode 100644 index 000000000..2cc6111b2 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ExtendedPropertyCollection.java @@ -0,0 +1,266 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.definition.ExtendedPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a collection of extended property. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class ExtendedPropertyCollection extends ComplexPropertyCollection implements + ICustomXmlUpdateSerializer { + + /** + * Creates the complex property. + * + * @param xmlElementName Name of the XML element. + * @return Complex property instance. + */ + @Override + protected ExtendedProperty createComplexProperty(String xmlElementName) { + // This method is unused in this class, so just return null. + return null; + } + + /** + * Gets the name of the collection item XML element. + * + * @param complexProperty The complex property. + * @return XML element name. + */ + @Override + protected String getCollectionItemXmlElementName( + ExtendedProperty complexProperty) { + // This method is unused in this class, so just return null. + return null; + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @param localElementName Name of the local element. + */ + @Override + public void loadFromXml(EwsServiceXmlReader reader, String localElementName) throws ExchangeXmlException { + ExtendedProperty extendedProperty = new ExtendedProperty(); + extendedProperty.loadFromXml(reader, reader.getLocalName()); + this.internalAdd(extendedProperty); + } + + /** + * Writes to XML. + * + * @param writer The writer. + * @param xmlElementName Name of the XML element. + */ + @Override + public void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) throws ExchangeXmlException { + for (ExtendedProperty extendedProperty : this) { + extendedProperty.writeToXml(writer, XmlElementNames.ExtendedProperty); + } + } + + /** + * Gets existing or adds new extended property. + * + * @param propertyDefinition The property definition. + * @return ExtendedProperty. + * @throws Exception the exception + */ + private ExtendedProperty getOrAddExtendedProperty( + ExtendedPropertyDefinition propertyDefinition) throws Exception { + ExtendedProperty extendedProperty; + OutParam extendedPropertyOut = new OutParam<>(); + if (!this.tryGetProperty(propertyDefinition, extendedPropertyOut)) { + extendedProperty = new ExtendedProperty(propertyDefinition); + this.internalAdd(extendedProperty); + } else { + extendedProperty = extendedPropertyOut.getParam(); + } + return extendedProperty; + } + + /** + * Sets an extended property. + * + * @param propertyDefinition The property definition. + * @param value The value. + * @throws Exception the exception + */ + public void setExtendedProperty(ExtendedPropertyDefinition propertyDefinition, Object value) + throws Exception { + ExtendedProperty extendedProperty = this + .getOrAddExtendedProperty(propertyDefinition); + extendedProperty.setValue(value); + } + + /** + * Removes a specific extended property definition from the collection. + * + * @param propertyDefinition The definition of the extended property to remove. + * @return True if the property matching the extended property definition + * was successfully removed from the collection, false otherwise. + * @throws Exception the exception + */ + public boolean removeExtendedProperty(ExtendedPropertyDefinition propertyDefinition) throws Exception { + EwsUtilities.validateParam(propertyDefinition, "propertyDefinition"); + + ExtendedProperty extendedProperty; + OutParam extendedPropertyOut = + new OutParam<>(); + if (this.tryGetProperty(propertyDefinition, extendedPropertyOut)) { + extendedProperty = extendedPropertyOut.getParam(); + return this.internalRemove(extendedProperty); + } else { + return false; + } + } + + /** + * Tries to get property. + * + * @param propertyDefinition The property definition. + * @param extendedPropertyOut The extended property. + * @return True of property exists in collection. + */ + private boolean tryGetProperty( + ExtendedPropertyDefinition propertyDefinition, + OutParam extendedPropertyOut) { + boolean found = false; + extendedPropertyOut.setParam(null); + for (ExtendedProperty prop : this.getItems()) { + if (prop.getPropertyDefinition().equals(propertyDefinition)) { + found = true; + extendedPropertyOut.setParam(prop); + break; + } + } + return found; + } + + /** + * Tries to get property value. + * + * @param propertyDefinition The property definition. + * @param propertyValueOut The property value. + * @return True if property exists in collection. + */ + public boolean tryGetValue(Class cls, ExtendedPropertyDefinition propertyDefinition, + OutParam propertyValueOut) throws ArgumentException { + ExtendedProperty extendedProperty; + OutParam extendedPropertyOut = new OutParam(); + if (this.tryGetProperty(propertyDefinition, extendedPropertyOut)) { + extendedProperty = extendedPropertyOut.getParam(); + if (!cls.isAssignableFrom(propertyDefinition.getType())) { + String errorMessage = String.format( + "Property definition type '%s' and type parameter '%s' aren't compatible.", + propertyDefinition.getType().getSimpleName(), + cls.getSimpleName()); + throw new ArgumentException(errorMessage, "propertyDefinition"); + } + propertyValueOut.setParam((T) extendedProperty.getValue()); + return true; + } else { + propertyValueOut.setParam(null); + return false; + } + } + + + /** + * Writes the update to XML. + * + * @param writer The writer. + * @param ewsObject The ews object. + * @param propertyDefinition Property definition. + * @return True if property generated serialization. + * @throws Exception the exception + */ + @Override + public boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, + ServiceObject ewsObject, PropertyDefinition propertyDefinition) + throws Exception { + List propertiesToSet = + new ArrayList(); + + propertiesToSet.addAll(this.getAddedItems()); + propertiesToSet.addAll(this.getModifiedItems()); + + for (ExtendedProperty extendedProperty : propertiesToSet) { + writer.writeStartElement(XmlNamespace.Types, ewsObject + .getSetFieldXmlElementName()); + extendedProperty.getPropertyDefinition().writeToXml(writer); + + writer.writeStartElement(XmlNamespace.Types, ewsObject + .getXmlElementName()); + extendedProperty.writeToXml(writer, + XmlElementNames.ExtendedProperty); + writer.writeEndElement(); + + writer.writeEndElement(); + } + + for (ExtendedProperty extendedProperty : this.getRemovedItems()) { + writer.writeStartElement(XmlNamespace.Types, ewsObject + .getDeleteFieldXmlElementName()); + extendedProperty.getPropertyDefinition().writeToXml(writer); + writer.writeEndElement(); + } + + return true; + } + + /** + * Writes the deletion update to XML. + * + * @param writer the writer + * @param ewsObject the ews object + * @return true if property generated serialization + */ + @Override + public boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, + ServiceObject ewsObject) throws ExchangeXmlException { + for (ExtendedProperty extendedProperty : this.getItems()) { + writer.writeStartElement(XmlNamespace.Types, ewsObject.getDeleteFieldXmlElementName()); + extendedProperty.getPropertyDefinition().writeToXml(writer); + writer.writeEndElement(); + } + + return true; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/FileAttachment.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/FileAttachment.java new file mode 100644 index 000000000..26f92e7a2 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/FileAttachment.java @@ -0,0 +1,338 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.util.IOUtils; + +import java.io.*; + +/** + * Represents a file attachment. + */ +public final class FileAttachment extends Attachment { + + /** + * The file name. + */ + private String fileName; + + /** + * The content stream. + */ + private InputStream contentStream; + + /** + * The content. + */ + private byte[] content; + + /** + * The load to stream. + */ + private OutputStream loadToStream; + + /** + * The is contact photo. + */ + private boolean isContactPhoto; + + /** + * Initializes a new instance. + * + * @param owner the owner + */ + protected FileAttachment(Item owner) { + super(owner); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + public String getXmlElementName() { + return XmlElementNames.FileAttachment; + } + + /** + * {@inheritDoc} + */ + @Override + protected void validate(int attachmentIndex) throws ExchangeValidationException { + if ((this.fileName == null || this.fileName.isEmpty()) + && this.content == null && this.contentStream == null) { + throw new ExchangeValidationException(String.format( + "The content of the file attachment at index %d must be set.", + attachmentIndex)); + } + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + boolean result = super.tryReadElementFromXml(reader); + + if (!result) { + if (reader.getLocalName().equals(XmlElementNames.IsContactPhoto)) { + this.isContactPhoto = reader.readElementValue(Boolean.class); + } else if (reader.getLocalName().equals(XmlElementNames.Content)) { + if (this.loadToStream != null) { + reader.writeBase64ElementValue(this.loadToStream); + } else { + // If there's a file attachment content handler, use it. + // Otherwise + // load the content into a byte array. + // TODO: Should we mark the attachment to indicate that + // content is stored elsewhere? + if (reader.getService().getFileAttachmentContentHandler() != null) { + OutputStream outputStream = reader.getService() + .getFileAttachmentContentHandler() + .getOutputStream(getId()); + if (outputStream != null) { + reader.writeBase64ElementValue(outputStream); + } else { + this.content = reader.writeBase64ElementValue(); + } + } else { + this.content = reader.writeBase64ElementValue(); + } + } + + result = true; + } + } + + return result; + } + + + /** + * For FileAttachment, the only thing need to patch is the AttachmentId. + * + * @param reader The reader. + * @return true if element was read + */ + @Override + public boolean tryReadElementFromXmlToPatch(EwsServiceXmlReader reader) throws ExchangeXmlException { + return super.tryReadElementFromXml(reader); + } + + + /** + * Writes elements and content to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeElementsToXml(writer); + // ExchangeVersion ev=writer.getService().getRequestedServerVersion(); + if (writer.getService().getRequestedServerVersion().ordinal() > + ExchangeVersion.Exchange2007_SP1 + .ordinal()) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.IsContactPhoto, this.isContactPhoto); + } + + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Content); + + if (!(this.fileName == null || this.fileName.isEmpty())) { + try { + File fileStream = new File(this.fileName); + FileInputStream fis = null; + try { + fis = new FileInputStream(fileStream); + writer.writeBase64ElementValue(fis); + } finally { + if (fis != null) { + fis.close(); + } + } + } catch (IOException e) { + throw new ExchangeXmlException("error reading file " + this.fileName + " as a file attachment", e); + } + + } else if (this.contentStream != null) { + writer.writeBase64ElementValue(this.contentStream); + } else if (this.content != null) { + writer.writeBase64ElementValue(this.content); + } else { + EwsUtilities + .ewsAssert(false, "FileAttachment.WriteElementsToXml", "The attachment's content is not set."); + } + + writer.writeEndElement(); + } + + /** + * Loads the content of the file attachment into the specified stream. + * Calling this method results in a call to EWS. + * + * @param stream the stream + * @throws Exception the exception + */ + public void load(OutputStream stream) throws Exception { + this.loadToStream = stream; + + try { + this.load(); + } finally { + this.loadToStream = null; + } + } + + /** + * Loads the content of the file attachment into the specified file. + * Calling this method results in a call to EWS. + * + * @param fileName the file name + * @throws Exception the exception + */ + public void load(String fileName) throws Exception { + File fileStream = new File(fileName); + + try { + this.loadToStream = new FileOutputStream(fileStream); + this.load(); + this.loadToStream.flush(); + } finally { + IOUtils.closeQuietly(this.loadToStream); + this.loadToStream = null; + } + + this.fileName = fileName; + this.content = null; + this.contentStream = null; + } + + /** + * Gets the name of the file the attachment is linked to. + * + * @return the file name + */ + public String getFileName() { + return this.fileName; + } + + /** + * Sets the file name. + * + * @param fileName the new file name + */ + protected void setFileName(String fileName) { + this.throwIfThisIsNotNew(); + + this.fileName = fileName; + this.content = null; + this.contentStream = null; + } + + /** + * Gets the content stream.Gets the name of the file the attachment + * is linked to. + * + * @return The content stream + */ + protected InputStream getContentStream() { + return this.contentStream; + } + + /** + * Sets the content stream. + * + * @param contentStream the new content stream + */ + protected void setContentStream(InputStream contentStream) { + this.throwIfThisIsNotNew(); + + this.contentStream = contentStream; + this.content = null; + this.fileName = null; + } + + /** + * Gets the content of the attachment into memory. Content is set only + * when Load() is called. + * + * @return the content + */ + public byte[] getContent() { + return this.content; + } + + /** + * Sets the content. + * + * @param content the new content + */ + protected void setContent(byte[] content) { + this.throwIfThisIsNotNew(); + + this.content = content; + this.fileName = null; + this.contentStream = null; + } + + /** + * Gets a value indicating whether this attachment is a contact + * photo. + * + * @return true, if is contact photo + * @throws ServiceVersionException the service version exception + */ + public boolean isContactPhoto() throws ExchangeXmlException { + EwsUtilities.validatePropertyVersion(this.getOwner().getService(), ExchangeVersion.Exchange2010, "IsContactPhoto"); + return this.isContactPhoto; + } + + /** + * Sets the checks if is contact photo. + * + * @param isContactPhoto the new checks if is contact photo + * @throws ServiceVersionException the service version exception + */ + public void setIsContactPhoto(boolean isContactPhoto) + throws ExchangeXmlException { + EwsUtilities.validatePropertyVersion(this.getOwner().getService(), + ExchangeVersion.Exchange2010, "IsContactPhoto"); + this.throwIfThisIsNotNew(); + this.isContactPhoto = isContactPhoto; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/FolderId.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/FolderId.java new file mode 100644 index 000000000..715fb48b7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/FolderId.java @@ -0,0 +1,266 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents the Id of a folder. + */ +public final class FolderId extends ServiceId { + + /** + * The folder name. + */ + private WellKnownFolderName folderName; + + /** + * The mailbox. + */ + private Mailbox mailbox; + + /** + * Initializes a new instance. + */ + public FolderId() { + super(); + } + + /** + * Initializes a new instance.Use this constructor to link this FolderId to + * an existing folder that you have the unique Id of. + * + * @param uniqueId the unique id + * @throws Exception the exception + */ + public FolderId(String uniqueId) throws Exception { + super(uniqueId); + } + + /** + * Initializes a new instance.Use this constructor to link this FolderId to + * a well known folder (e.g. Inbox, Calendar or Contacts) + * + * @param folderName the folder name + */ + public FolderId(WellKnownFolderName folderName) { + super(); + this.folderName = folderName; + } + + /** + * Initializes a new instance.Use this constructor to link this FolderId to + * a well known folder (e.g. Inbox, Calendar or Contacts) in a specific + * mailbox. + * + * @param folderName the folder name + * @param mailbox the mailbox + */ + public FolderId(WellKnownFolderName folderName, Mailbox mailbox) { + this(folderName); + this.mailbox = mailbox; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + public String getXmlElementName() { + if (this.getFolderName() != null) { + return XmlElementNames.DistinguishedFolderId; + } else { + return XmlElementNames.FolderId; + } + } + + /** + * Writes attribute to XML. + * + * @param writer the writer + */ + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (this.getFolderName() != null) { + writer.writeAttributeValue(XmlAttributeNames.Id, this.getFolderName().toString().toLowerCase()); + if (this.mailbox != null) { + this.mailbox.writeToXml(writer, XmlElementNames.Mailbox); + } + } else { + super.writeAttributesToXml(writer); + } + } + + /** + * Validates FolderId against a specified request version. + * + * @param version the version + * @throws ServiceVersionException the service version exception + */ + public void validate(ExchangeVersion version) + throws ServiceVersionException { + // The FolderName property is a WellKnownFolderName, an enumeration + // type. If the property + // is set, make sure that the value is valid for the request version. + if (this.getFolderName() != null) { + EwsUtilities + .validateEnumVersionValue(this.getFolderName(), version); + } + } + + /** + * Gets the name of the folder associated with the folder Id. Name and Id + * are mutually exclusive; if one is set, the other is null. + * + * @return the folder name + */ + public WellKnownFolderName getFolderName() { + return this.folderName; + } + + /** + * Gets the mailbox of the folder. Mailbox is only set when FolderName is + * set. + * + * @return the mailbox + */ + public Mailbox getMailbox() { + return this.mailbox; + } + + /** + * Defines an implicit conversion between string and FolderId. + * + * @param uniqueId the unique id + * @return A FolderId initialized with the specified unique Id + * @throws Exception the exception + */ + public static FolderId getFolderIdFromString(String uniqueId) + throws Exception { + return new FolderId(uniqueId); + } + + /** + * Defines an implicit conversion between WellKnownFolderName and FolderId. + * + * @param folderName the folder name + * @return A FolderId initialized with the specified folder name + */ + public static FolderId getFolderIdFromWellKnownFolderName( + WellKnownFolderName folderName) { + return new FolderId(folderName); + } + + /** + * True if this instance is valid, false otherwise. + * + * @return the checks if is valid + */ + protected boolean getIsValid() { + if (this.folderName != null) { + return (this.mailbox == null) || this.mailbox.isValid(); + } else { + return super.isValid(); + } + } + + /** + * Determines whether the specified is equal to the current. + * + * @param obj the obj + * @return true if the specified is equal to the current + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (obj instanceof FolderId) { + FolderId other = (FolderId) obj; + + if (this.folderName != null) { + if (other.folderName != null + && this.folderName.equals(other.folderName)) { + if (this.mailbox != null) { + return this.mailbox.equals(other.mailbox); + } else return other.mailbox == null; + } + } else return super.equals(other); + + return false; + } else { + return false; + } + } + + /** + * Serves as a hash function for a particular type. + * + * @return A hash code for the current + */ + @Override + public int hashCode() { + int hashCode; + + if (this.folderName != null) { + hashCode = this.folderName.hashCode(); + + if ((this.mailbox != null) && this.mailbox.isValid()) { + hashCode = hashCode ^ this.mailbox.hashCode(); + } + } else { + hashCode = super.hashCode(); + } + + return hashCode; + } + + /** + * Returns a String that represents the current Object. + * + * @return the string + */ + public String toString() { + if (this.isValid()) { + if (this.folderName != null) { + if ((this.mailbox != null) && mailbox.isValid()) { + return String.format("%s,(%s)", this.folderName, + this.mailbox.toString()); + } else { + return this.folderName.toString(); + } + } else { + return super.toString(); + } + } else { + return ""; + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/FolderIdCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/FolderIdCollection.java new file mode 100644 index 000000000..ab437f4aa --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/FolderIdCollection.java @@ -0,0 +1,145 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.property.WellKnownFolderName; + +/** + * Represents a collection of folder Ids. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class FolderIdCollection extends ComplexPropertyCollection { + + /** + * Initializes a new instance of the class. + */ + protected FolderIdCollection() { + super(); + } + + /** + * Creates the complex property. + * + * @param xmlElementName Name of the XML element. + * @return Complex property instance. + */ + @Override + /** + * Creates the complex property. + * @param xmlElementName Name of the XML element. + * @return FolderId. + */ + protected FolderId createComplexProperty(String xmlElementName) { + return new FolderId(); + } + + /** + * Adds a folder Id to the collection. + * + * @param folderId The folder Id to add. + * @throws Exception the exception + */ + public void add(FolderId folderId) throws Exception { + EwsUtilities.validateParam(folderId, "folderId"); + if (this.contains(folderId)) { + throw new IllegalArgumentException("The ID is already in the list."); + } + this.internalAdd(folderId); + } + + /** + * Gets the name of the collection item XML element. + * + * @param complexProperty accepts FolderId + * @return XML element name. + */ + @Override + protected String getCollectionItemXmlElementName(FolderId complexProperty) { + return complexProperty.getXmlElementName(); + } + + /** + * Adds a well-known folder to the collection. + * + * @param folderName the folder name + * @return A FolderId encapsulating the specified Id. + */ + public FolderId add(WellKnownFolderName folderName) { + FolderId folderId = new FolderId(folderName); + if (this.contains(folderId)) { + throw new IllegalArgumentException("The ID is already in the list."); + } + this.internalAdd(folderId); + return folderId; + } + + /** + * Clears the collection. + */ + public void clear() { + this.internalClear(); + } + + /** + * Removes the folder Id at the specified index. + * + * @param index The zero-based index of the folder Id to remove. + */ + public void removeAt(int index) { + if (index < 0 || index >= this.getCount()) { + throw new IndexOutOfBoundsException("index is out of range."); + } + this.internalRemoveAt(index); + } + + /** + * Removes the specified folder Id from the collection. + * + * @param folderId The folder Id to remove from the collection. + * @return True if the folder id was successfully removed from the + * collection, false otherwise. + * @throws Exception the exception + */ + public boolean remove(FolderId folderId) throws Exception { + EwsUtilities.validateParam(folderId, "folderId"); + return this.internalRemove(folderId); + } + + /** + * Removes the specified well-known folder from the collection. + * + * @param folderName The well-knwon folder to remove from the collection. + * @return True if the well-known folder was successfully removed from the + * collection, false otherwise. + */ + public boolean remove(WellKnownFolderName folderName) { + FolderId folderId = FolderId + .getFolderIdFromWellKnownFolderName(folderName); + return this.internalRemove(folderId); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/FolderPermission.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/FolderPermission.java new file mode 100644 index 000000000..1214eb2e4 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/FolderPermission.java @@ -0,0 +1,872 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.permission.PermissionScope; +import com.eischet.ews.api.core.enumeration.permission.folder.FolderPermissionLevel; +import com.eischet.ews.api.core.enumeration.permission.folder.FolderPermissionReadAccess; +import com.eischet.ews.api.core.enumeration.property.StandardUser; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents a permission on a folder. + */ +public final class FolderPermission extends ComplexProperty implements IComplexPropertyChangedDelegate { + + private static final Logger LOG = Logger.getLogger(FolderPermission.class.getCanonicalName()); + + private static final LazyMember> + defaultPermissions = + new LazyMember>( + new ILazyMember>() { + @Override + public Map + createInstance() { + Map result = + new HashMap(); + + /** The default permissions. */ + FolderPermission permission = new FolderPermission(); + permission.canCreateItems = false; + permission.canCreateSubFolders = false; + permission.deleteItems = PermissionScope.None; + permission.editItems = PermissionScope.None; + permission.isFolderContact = false; + permission.isFolderOwner = false; + permission.isFolderVisible = false; + permission.readItems = FolderPermissionReadAccess.None; + + result.put(FolderPermissionLevel.None, permission); + + permission = new FolderPermission(); + permission.canCreateItems = true; + permission.canCreateSubFolders = false; + permission.deleteItems = PermissionScope.None; + permission.editItems = PermissionScope.None; + permission.isFolderContact = false; + permission.isFolderOwner = false; + permission.isFolderVisible = true; + permission.readItems = FolderPermissionReadAccess.None; + + result.put(FolderPermissionLevel.Contributor, permission); + + permission = new FolderPermission(); + permission.canCreateItems = false; + permission.canCreateSubFolders = false; + permission.deleteItems = PermissionScope.None; + permission.editItems = PermissionScope.None; + permission.isFolderContact = false; + permission.isFolderOwner = false; + permission.isFolderVisible = true; + permission.readItems = FolderPermissionReadAccess. + FullDetails; + + result.put(FolderPermissionLevel.Reviewer, permission); + + permission = new FolderPermission(); + permission.canCreateItems = true; + permission.canCreateSubFolders = false; + permission.deleteItems = PermissionScope.Owned; + permission.editItems = PermissionScope.None; + permission.isFolderContact = false; + permission.isFolderOwner = false; + permission.isFolderVisible = true; + permission.readItems = FolderPermissionReadAccess. + FullDetails; + + result.put(FolderPermissionLevel.NoneditingAuthor, + permission); + + permission = new FolderPermission(); + permission.canCreateItems = true; + permission.canCreateSubFolders = false; + permission.deleteItems = PermissionScope.Owned; + permission.editItems = PermissionScope.Owned; + permission.isFolderContact = false; + permission.isFolderOwner = false; + permission.isFolderVisible = true; + permission.readItems = FolderPermissionReadAccess. + FullDetails; + + result.put(FolderPermissionLevel.Author, permission); + + permission = new FolderPermission(); + permission.canCreateItems = true; + permission.canCreateSubFolders = true; + permission.deleteItems = PermissionScope.Owned; + permission.editItems = PermissionScope.Owned; + permission.isFolderContact = false; + permission.isFolderOwner = false; + permission.isFolderVisible = true; + permission.readItems = FolderPermissionReadAccess. + FullDetails; + + result.put(FolderPermissionLevel.PublishingAuthor, + permission); + + permission = new FolderPermission(); + permission.canCreateItems = true; + permission.canCreateSubFolders = false; + permission.deleteItems = PermissionScope.All; + permission.editItems = PermissionScope.All; + permission.isFolderContact = false; + permission.isFolderOwner = false; + permission.isFolderVisible = true; + permission.readItems = FolderPermissionReadAccess. + FullDetails; + + result.put(FolderPermissionLevel.Editor, permission); + + permission = new FolderPermission(); + permission.canCreateItems = true; + permission.canCreateSubFolders = true; + permission.deleteItems = PermissionScope.All; + permission.editItems = PermissionScope.All; + permission.isFolderContact = false; + permission.isFolderOwner = false; + permission.isFolderVisible = true; + permission.readItems = FolderPermissionReadAccess. + FullDetails; + + result.put(FolderPermissionLevel.PublishingEditor, + permission); + + permission = new FolderPermission(); + permission.canCreateItems = true; + permission.canCreateSubFolders = true; + permission.deleteItems = PermissionScope.All; + permission.editItems = PermissionScope.All; + permission.isFolderContact = true; + permission.isFolderOwner = true; + permission.isFolderVisible = true; + permission.readItems = FolderPermissionReadAccess. + FullDetails; + + result.put(FolderPermissionLevel.Owner, permission); + + permission = new FolderPermission(); + permission.canCreateItems = false; + permission.canCreateSubFolders = false; + permission.deleteItems = PermissionScope.None; + permission.editItems = PermissionScope.None; + permission.isFolderContact = false; + permission.isFolderOwner = false; + permission.isFolderVisible = false; + permission.readItems = FolderPermissionReadAccess.TimeOnly; + + result.put(FolderPermissionLevel.FreeBusyTimeOnly, + permission); + + permission = new FolderPermission(); + permission.canCreateItems = false; + permission.canCreateSubFolders = false; + permission.deleteItems = PermissionScope.None; + permission.editItems = PermissionScope.None; + permission.isFolderContact = false; + permission.isFolderOwner = false; + permission.isFolderVisible = false; + permission.readItems = FolderPermissionReadAccess. + TimeAndSubjectAndLocation; + + result + .put(FolderPermissionLevel. + FreeBusyTimeAndSubjectAndLocation, + permission); + return result; + } + }); + //End Region + + /** + * Variants of pre-defined permission levels that Outlook also displays with + * the same levels. + */ + private static final LazyMember> levelVariants = + new LazyMember>( + new ILazyMember>() { + @Override + public List createInstance() { + List results = + new ArrayList(); + + FolderPermission permissionNone = FolderPermission. + defaultPermissions + .getMember().get(FolderPermissionLevel.None); + FolderPermission permissionOwner = FolderPermission. + defaultPermissions + .getMember().get(FolderPermissionLevel.Owner); + + // PermissionLevelNoneOption1 + FolderPermission permission; + try { + permission = (FolderPermission) permissionNone.clone(); + permission.isFolderVisible = true; + results.add(permission); + + // PermissionLevelNoneOption2 + permission = (FolderPermission) permissionNone.clone(); + permission.isFolderContact = true; + results.add(permission); + + // PermissionLevelNoneOption3 + permission = (FolderPermission) permissionNone.clone(); + permission.isFolderContact = true; + permission.isFolderVisible = true; + results.add(permission); + + // PermissionLevelOwnerOption1 + permission = (FolderPermission) permissionOwner.clone(); + permission.isFolderContact = false; + results.add(permission); + + } catch (CloneNotSupportedException e) { + LOG.log(Level.SEVERE, "error cloning record", e); + } + return results; + } + }); + + /** + * The user id. + */ + private UserId userId; + + /** + * The can create item. + */ + private boolean canCreateItems; + + /** + * The can create sub folder. + */ + private boolean canCreateSubFolders; + + /** + * The is folder owner. + */ + private boolean isFolderOwner; + + /** + * The is folder visible. + */ + private boolean isFolderVisible; + + /** + * The is folder contact. + */ + private boolean isFolderContact; + + /** + * The edit item. + */ + private PermissionScope editItems = PermissionScope.None; + + /** + * The delete item. + */ + private PermissionScope deleteItems = PermissionScope.None; + + /** + * The read item. + */ + private FolderPermissionReadAccess readItems = FolderPermissionReadAccess.None; + + /** + * The permission level. + */ + private FolderPermissionLevel permissionLevel = FolderPermissionLevel.None; + + /** + * Determines whether the specified folder permission is the same as this + * one. The comparison does not take UserId and PermissionLevel into + * consideration. + * + * @param permission the permission + * @return True is the specified folder permission is equal to this one, + * false otherwise. + */ + private boolean isEqualTo(FolderPermission permission) { + + return this.canCreateItems == permission.canCreateItems && + this.canCreateSubFolders == permission.canCreateSubFolders && + this.isFolderContact == permission.isFolderContact && + this.isFolderVisible == permission.isFolderVisible && + this.isFolderOwner == permission.isFolderOwner && + this.editItems == permission.editItems && + this.deleteItems == permission.deleteItems && + this.readItems == permission.readItems; + } + + /** + * Create a copy of this FolderPermission instance. + * + * @return Clone of this instance. + */ + /* + * private FolderPermission Clone() throws CloneNotSupportedException { + * return (FolderPermission)this.clone(); } + */ + + /** + * Determines the permission level of this folder permission based on its + * individual settings, and sets the PermissionLevel property accordingly. + */ + private void AdjustPermissionLevel() { + for (Entry keyValuePair : defaultPermissions + .getMember().entrySet()) { + if (this.isEqualTo(keyValuePair.getValue())) { + this.permissionLevel = keyValuePair.getKey(); + return; + } + } + this.permissionLevel = FolderPermissionLevel.Custom; + } + + /** + * Copies the values of the individual permissions of the specified folder + * permission to this folder permissions. + * + * @param permission the permission + */ + private void AssignIndividualPermissions(FolderPermission permission) { + this.canCreateItems = permission.canCreateItems; + this.canCreateSubFolders = permission.canCreateSubFolders; + this.isFolderContact = permission.isFolderContact; + this.isFolderOwner = permission.isFolderOwner; + this.isFolderVisible = permission.isFolderVisible; + this.editItems = permission.editItems; + this.deleteItems = permission.deleteItems; + this.readItems = permission.readItems; + } + + /** + * Initializes a new instance of the FolderPermission class. + */ + public FolderPermission() { + super(); + this.userId = new UserId(); + } + + /** + * Initializes a new instance of the FolderPermission class. + * + * @param userId the user id + * @param permissionLevel the permission level + * @throws Exception the exception + */ + public FolderPermission(UserId userId, FolderPermissionLevel permissionLevel) throws Exception { + EwsUtilities.validateParam(userId, "userId"); + this.userId = userId; + this.permissionLevel = permissionLevel; + } + + /** + * Initializes a new instance of the FolderPermission class. + * + * @param primarySmtpAddress the primary smtp address + * @param permissionLevel the permission level + */ + public FolderPermission(String primarySmtpAddress, + FolderPermissionLevel permissionLevel) { + this.userId = new UserId(primarySmtpAddress); + this.permissionLevel = permissionLevel; + } + + /** + * Initializes a new instance of the FolderPermission class. + * + * @param standardUser the standard user + * @param permissionLevel the permission level + */ + public FolderPermission(StandardUser standardUser, + FolderPermissionLevel permissionLevel) { + this.userId = new UserId(standardUser); + this.permissionLevel = permissionLevel; + } + + /** + * Validates this instance. + * + * @param isCalendarFolder the is calendar folder + * @param permissionIndex the permission index + * @throws ExchangeValidationException the service validation exception + * @throws ServiceLocalException the service local exception + */ + void validate(boolean isCalendarFolder, int permissionIndex) + throws ExchangeValidationException, ServiceLocalException { + // Check UserId + if (!this.userId.isValid()) { + throw new ExchangeValidationException(String.format( + "The UserId in the folder permission at index %d is invalid. " + + "The StandardUser, PrimarySmtpAddress, or SID property must be set.", permissionIndex)); + } + + // If this permission is to be used for a non-calendar folder make sure + // that read access and permission level aren't set to Calendar-only + // values + if (!isCalendarFolder) { + if ((this.readItems == FolderPermissionReadAccess.TimeAndSubjectAndLocation) + || (this.readItems == FolderPermissionReadAccess. + TimeOnly)) { + throw new ServiceLocalException(String.format( + "Permission read access value %s cannot be used with non-calendar folder.", + this.readItems)); + } + + if ((this.permissionLevel == FolderPermissionLevel.FreeBusyTimeAndSubjectAndLocation) + || (this.permissionLevel == FolderPermissionLevel. + FreeBusyTimeOnly)) { + throw new ServiceLocalException(String.format( + "Permission level value %s cannot be used with non-calendar folder.", + this.permissionLevel)); + } + } + } + + /** + * Gets the Id of the user the permission applies to. + * + * @return the user id + */ + + public UserId getUserId() { + return this.userId; + } + + /** + * Sets the user id. + * + * @param value the new user id + */ + public void setUserId(UserId value) { + if (this.userId != null) { + this.userId.removeChangeEvent(this); + } + + if (this.canSetFieldValue(this.userId, value)) { + userId = value; + this.changed(); + } + if (this.userId != null) { + this.userId.addOnChangeEvent(this); + } + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.ComplexPropertyChangedDelegateInterface + * #complexPropertyChanged(microsoft.exchange.webservices.ComplexProperty) + */ + @Override + public void complexPropertyChanged(ComplexProperty complexProperty) { + this.propertyChanged(complexProperty); + } + + /** + * Property was changed. + * + * @param complexProperty the complex property + */ + private void propertyChanged(ComplexProperty complexProperty) { + this.changed(); + } + + /** + * Gets a value indicating whether the user can create new item. + * + * @return the can create item + */ + public boolean getCanCreateItems() { + return this.canCreateItems; + } + + /** + * Sets the can create item. + * + * @param value the new can create item + */ + public void setCanCreateItems(boolean value) { + if (this.canSetFieldValue(this.canCreateItems, value)) { + this.canCreateItems = value; + this.changed(); + } + this.AdjustPermissionLevel(); + } + + /** + * Gets a value indicating whether the user can create + * sub-folder. + * + * @return the can create sub folder + */ + public boolean getCanCreateSubFolders() { + return this.canCreateSubFolders; + } + + /** + * Sets the can create sub folder. + * + * @param value the new can create sub folder + */ + public void setCanCreateSubFolders(boolean value) { + if (this.canSetFieldValue(this.canCreateSubFolders, value)) { + this.canCreateSubFolders = value; + this.changed(); + } + this.AdjustPermissionLevel(); + } + + /** + * Gets a value indicating whether the user owns the folder. + * + * @return the checks if is folder owner + */ + public boolean getIsFolderOwner() { + return this.isFolderOwner; + } + + /** + * Sets the checks if is folder owner. + * + * @param value the new checks if is folder owner + */ + public void setIsFolderOwner(boolean value) { + if (this.canSetFieldValue(this.isFolderOwner, value)) { + this.isFolderOwner = value; + this.changed(); + } + this.AdjustPermissionLevel(); + } + + /** + * Gets a value indicating whether the folder is visible to the + * user. + * + * @return the checks if is folder visible + */ + public boolean getIsFolderVisible() { + return this.isFolderVisible; + } + + /** + * Sets the checks if is folder visible. + * + * @param value the new checks if is folder visible + */ + public void setIsFolderVisible(boolean value) { + if (this.canSetFieldValue(this.isFolderVisible, value)) { + this.isFolderVisible = value; + this.changed(); + } + this.AdjustPermissionLevel(); + } + + /** + * Gets a value indicating whether the user is a contact for the + * folder. + * + * @return the checks if is folder contact + */ + public boolean getIsFolderContact() { + return this.isFolderContact; + } + + /** + * Sets the checks if is folder contact. + * + * @param value the new checks if is folder contact + */ + public void setIsFolderContact(boolean value) { + if (this.canSetFieldValue(this.isFolderContact, value)) { + this.isFolderContact = value; + this.changed(); + } + this.AdjustPermissionLevel(); + } + + /** + * Gets a value indicating if/how the user can edit existing + * item. + * + * @return the edits the item + */ + public PermissionScope getEditItems() { + return this.editItems; + } + + /** + * Sets the edits the item. + * + * @param value the new edits the item + */ + public void setEditItems(PermissionScope value) { + if (this.canSetFieldValue(this.editItems, value)) { + this.editItems = value; + this.changed(); + } + this.AdjustPermissionLevel(); + } + + /** + * Gets a value indicating if/how the user can delete existing + * item. + * + * @return the delete item + */ + public PermissionScope getDeleteItems() { + return this.deleteItems; + } + + /** + * Sets the delete item. + * + * @param value the new delete item + */ + public void setDeleteItems(PermissionScope value) { + if (this.canSetFieldValue(this.deleteItems, value)) { + this.deleteItems = value; + this.changed(); + } + this.AdjustPermissionLevel(); + } + + /** + * Gets the read item access permission. + * + * @return the read item + */ + public FolderPermissionReadAccess getReadItems() { + return this.readItems; + } + + /** + * Sets the read item. + * + * @param value the new read item + */ + public void setReadItems(FolderPermissionReadAccess value) { + if (this.canSetFieldValue(this.readItems, value)) { + this.readItems = value; + this.changed(); + } + this.AdjustPermissionLevel(); + } + + /** + * Gets the permission level. + * + * @return the permission level + */ + public FolderPermissionLevel getPermissionLevel() { + return this.permissionLevel; + } + + /** + * Sets the permission level. + * + * @param value the new permission level + * @throws ServiceLocalException the service local exception + */ + public void setPermissionLevel(FolderPermissionLevel value) + throws ServiceLocalException { + if (this.permissionLevel != value) { + if (value == FolderPermissionLevel.Custom) { + throw new ServiceLocalException( + "The PermissionLevel property can't be set to FolderPermissionLevel.Custom. " + + "To define a custom permission, set its individual property to the values you want."); + } + + this.AssignIndividualPermissions(defaultPermissions.getMember() + .get(value)); + if (this.canSetFieldValue(this.permissionLevel, value)) { + this.permissionLevel = value; + this.changed(); + } + } + } + + /** + * Gets the permission level that Outlook would display for this folder + * permission. + * + * @return the display permission level + */ + public FolderPermissionLevel getDisplayPermissionLevel() { + // If permission level is set to Custom, see if there's a variant + // that Outlook would map to the same permission level. + if (this.permissionLevel == FolderPermissionLevel.Custom) { + for (FolderPermission variant : FolderPermission.levelVariants + .getMember()) { + if (this.isEqualTo(variant)) { + return variant.getPermissionLevel(); + } + } + } + + return this.permissionLevel; + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.UserId)) { + this.userId = new UserId(); + this.userId.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.CanCreateItems)) { + this.canCreateItems = reader.readValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.CanCreateSubFolders)) { + this.canCreateSubFolders = reader.readValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.IsFolderOwner)) { + this.isFolderOwner = reader.readValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.IsFolderVisible)) { + this.isFolderVisible = reader.readValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.IsFolderContact)) { + this.isFolderContact = reader.readValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.EditItems)) { + this.editItems = reader.readValue(PermissionScope.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.DeleteItems)) { + this.deleteItems = reader.readValue(PermissionScope.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.ReadItems)) { + this.readItems = reader.readValue(FolderPermissionReadAccess.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.PermissionLevel) + || reader.getLocalName().equalsIgnoreCase( + XmlElementNames.CalendarPermissionLevel)) { + this.permissionLevel = reader + .readValue(FolderPermissionLevel.class); + return true; + } else { + return false; + } + } + + /** + * Loads from XML. + * + * @param reader the reader + * @param xmlNamespace the xml namespace + * @param xmlElementName the xml element name + */ + public void loadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName) throws ExchangeXmlException { + super.loadFromXml(reader, xmlNamespace, xmlElementName); + + this.AdjustPermissionLevel(); + } + + /** + * Writes elements to XML. + * + * @param writer the writer + * @param isCalendarFolder the is calendar folder + */ + private void writeElementsToXml(EwsServiceXmlWriter writer, boolean isCalendarFolder) throws ExchangeXmlException { + if (this.userId != null) { + this.userId.writeToXml(writer, XmlElementNames.UserId); + } + + if (this.permissionLevel == FolderPermissionLevel.Custom) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.CanCreateItems, this.canCreateItems); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.CanCreateSubFolders, + this.canCreateSubFolders); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.IsFolderOwner, this.isFolderOwner); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.IsFolderVisible, this.isFolderVisible); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.IsFolderContact, this.isFolderContact); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.EditItems, this.editItems); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.DeleteItems, this.deleteItems); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.ReadItems, this.readItems); + } + + writer + .writeElementValue( + XmlNamespace.Types, + isCalendarFolder ? XmlElementNames. + CalendarPermissionLevel + : XmlElementNames.PermissionLevel, + this.permissionLevel); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param xmlElementName the xml element name + * @param isCalendarFolder the is calendar folder + * @throws Exception the exception + */ + void writeToXml(EwsServiceXmlWriter writer, String xmlElementName, boolean isCalendarFolder) throws ExchangeXmlException { + writer.writeStartElement(this.getNamespace(), xmlElementName); + this.writeAttributesToXml(writer); + this.writeElementsToXml(writer, isCalendarFolder); + writer.writeEndElement(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/FolderPermissionCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/FolderPermissionCollection.java new file mode 100644 index 000000000..e71c50a7a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/FolderPermissionCollection.java @@ -0,0 +1,238 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.folder.CalendarFolder; +import com.eischet.ews.api.core.service.folder.Folder; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents a collection of folder permissions. + */ +public final class FolderPermissionCollection extends ComplexPropertyCollection { + + private static final Logger LOG = Logger.getLogger(FolderPermissionCollection.class.getCanonicalName()); + + /** + * The is calendar folder. + */ + private final boolean isCalendarFolder; + + /** + * The unknown entries. + */ + private final Collection unknownEntries = new ArrayList(); + + /** + * Initializes a new instance of the FolderPermissionCollection class. + * + * @param owner the owner + */ + public FolderPermissionCollection(Folder owner) { + super(); + this.isCalendarFolder = owner instanceof CalendarFolder; + } + + /** + * Gets the name of the inner collection XML element. + * + * @return the inner collection xml element name + */ + private String getInnerCollectionXmlElementName() { + return this.isCalendarFolder ? XmlElementNames.CalendarPermissions : + XmlElementNames.Permissions; + } + + /** + * Gets the name of the collection item XML element. + * + * @return the collection item xml element name + */ + private String getCollectionItemXmlElementName() { + return this.isCalendarFolder ? XmlElementNames.CalendarPermission : + XmlElementNames.Permission; + } + + /** + * Gets the name of the collection item XML element. + * + * @param complexProperty the complex property + * @return the collection item xml element name + */ + @Override + protected String getCollectionItemXmlElementName( + FolderPermission complexProperty) { + return this.getCollectionItemXmlElementName(); + } + + /** + * Loads from XML. + * + * @param reader the reader + * @param localElementName the local element name + */ + @Override + public void loadFromXml(EwsServiceXmlReader reader, String localElementName) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, + localElementName); + + reader.readStartElement(XmlNamespace.Types, this + .getInnerCollectionXmlElementName()); + super.loadFromXml(reader, this.getInnerCollectionXmlElementName()); + reader.readEndElementIfNecessary(XmlNamespace.Types, this + .getInnerCollectionXmlElementName()); + + reader.read(); + + if (reader.isStartElement(XmlNamespace.Types, + XmlElementNames.UnknownEntries)) { + do { + reader.read(); + + if (reader.isStartElement(XmlNamespace.Types, + XmlElementNames.UnknownEntry)) { + this.unknownEntries.add(reader.readElementValue()); + } + } while (!reader.isEndElement(XmlNamespace.Types, + XmlElementNames.UnknownEntries)); + } + } + + /** + * Validates this instance. + */ + public void validate() throws ExchangeValidationException { + for (int permissionIndex = 0; permissionIndex < this.getItems().size(); permissionIndex++) { + FolderPermission permission = this.getItems().get(permissionIndex); + try { + permission.validate(this.isCalendarFolder, permissionIndex); + } catch (ServiceLocalException e) { + LOG.log(Level.SEVERE, "validation error", e); + } + } + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, this + .getInnerCollectionXmlElementName()); + for (FolderPermission folderPermission : this) { + folderPermission.writeToXml(writer, this + .getCollectionItemXmlElementName(folderPermission), + this.isCalendarFolder); + } + writer.writeEndElement(); // this.InnerCollectionXmlElementName + } + + /** + * Creates the complex property. + * + * @param xmlElementName the xml element name + * @return FolderPermission instance. + */ + @Override + protected FolderPermission createComplexProperty(String xmlElementName) { + return new FolderPermission(); + } + + /** + * Adds a permission to the collection. + * + * @param permission the permission + */ + public void add(FolderPermission permission) { + this.internalAdd(permission); + } + + /** + * Adds the specified permissions to the collection. + * + * @param permissions the permissions + * @throws Exception the exception + */ + public void addFolderRange(Iterator permissions) + throws Exception { + EwsUtilities.validateParam(permissions, "permissions"); + + if (null != permissions) { + while (permissions.hasNext()) { + this.add(permissions.next()); + } + } + } + + /** + * Clears this collection. + */ + public void clear() { + this.internalClear(); + } + + /** + * Removes a permission from the collection. + * + * @param permission the permission + * @return True if the folder permission was successfully removed from the + * collection, false otherwise. + */ + public boolean remove(FolderPermission permission) { + return this.internalRemove(permission); + } + + /** + * Removes a permission from the collection. + * + * @param index the index + */ + public void removeAt(int index) { + this.internalRemoveAt(index); + } + + /** + * Gets a list of unknown user Ids in the collection. + * + * @return the unknown entries + */ + public Collection getUnknownEntries() { + return this.unknownEntries; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/GenericItemAttachment.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/GenericItemAttachment.java new file mode 100644 index 000000000..6f8fdbbae --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/GenericItemAttachment.java @@ -0,0 +1,61 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.service.item.Item; + +/** + * Represents a strongly typed item attachment. + * + * @param Item type. + */ +public final class GenericItemAttachment extends ItemAttachment { + + /** + * Initializes a new instance of the GenericItemAttachment class. + * + * @param owner the owner + */ + protected GenericItemAttachment(Item owner) { + super(owner); + } + + /** + * Gets the item associated with the attachment. + * + * @return the t item + */ + public TItem getTItem() { + return (TItem) super.getItem(); + } + + /** + * Sets the t item. + * + * @param value the new t item + */ + protected void setTItem(TItem value) { + super.setItem(value); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/GroupMember.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/GroupMember.java new file mode 100644 index 000000000..852a1ca65 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/GroupMember.java @@ -0,0 +1,348 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.RequiredServerVersion; +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.EmailAddressKey; +import com.eischet.ews.api.core.enumeration.property.MailboxType; +import com.eischet.ews.api.core.enumeration.property.MemberStatus; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.item.Contact; + +/** + * Represents a group member. + */ +@RequiredServerVersion(version = ExchangeVersion.Exchange2010) +public class GroupMember extends ComplexProperty implements IComplexPropertyChangedDelegate { + + // AddressInformation field. + /** + * The address information. + */ + private EmailAddress addressInformation; + + // Status field. + + /** + * The status. + */ + private MemberStatus status; + + // / Member key field. + + /** + * The key. + */ + private String key; + + /** + * Initializes a new instance of the GroupMember class. + */ + + public GroupMember() { + super(); + + // Key is assigned by server + this.key = null; + + // Member status is calculated by server + this.status = MemberStatus.Unrecognized; + } + + /** + * Initializes a new instance of the GroupMember class. + * + * @param smtpAddress The SMTP address of the member + */ + public GroupMember(String smtpAddress) { + this(); + this.setAddressInformation(new EmailAddress(smtpAddress)); + } + + /** + * Initializes a new instance of the GroupMember class. + * + * @param address the address + * @param routingType The routing type of the address. + * @param mailboxType The mailbox type of the member. + * @throws ServiceLocalException the service local exception + */ + public GroupMember(String address, String routingType, + MailboxType mailboxType) throws ServiceLocalException { + this(); + + switch (mailboxType) { + case PublicGroup: + case PublicFolder: + case Mailbox: + case Contact: + case OneOff: + this.setAddressInformation(new EmailAddress(null, address, + routingType, mailboxType)); + break; + + default: + throw new ServiceLocalException("The mailbox type isn't valid."); + } + } + + /** + * Initializes a new instance of the GroupMember class. + * + * @param smtpAddress The SMTP address of the member + * @param mailboxType The mailbox type of the member. + * @throws ServiceLocalException the service local exception + */ + public GroupMember(String smtpAddress, MailboxType mailboxType) + throws ServiceLocalException { + + this(smtpAddress, EmailAddress.SmtpRoutingType, mailboxType); + + } + + /** + * Initializes a new instance of the GroupMember class. + * + * @param name The name of the one-off member. + * @param address the address + * @param routingType The routing type of the address. + */ + public GroupMember(String name, String address, String routingType) { + this(); + + this.setAddressInformation(new EmailAddress(name, address, routingType, + MailboxType.OneOff)); + } + + /** + * Initializes a new instance of the GroupMember class. + * + * @param name The name of the one-off member. + * @param smtpAddress The SMTP address of the member + */ + public GroupMember(String name, String smtpAddress) { + this(name, smtpAddress, EmailAddress.SmtpRoutingType); + + } + + /** + * Initializes a new instance of the GroupMember class. + * + * @param contactGroupId The Id of the contact group to link the member to. + */ + public GroupMember(ItemId contactGroupId) { + this(); + + this.setAddressInformation(new EmailAddress(null, null, null, + MailboxType.ContactGroup, contactGroupId)); + } + + /** + * Initializes a new instance of the GroupMember class. + * + * @param contactId The Id of the contact member + * @param addressToLink The Id of the contact to link the member to. + */ + public GroupMember(ItemId contactId, String addressToLink) { + this(); + + this.setAddressInformation(new EmailAddress(null, addressToLink, null, + MailboxType.Contact, contactId)); + } + + /** + * Initializes a new instance of the GroupMember class. + * + * @param addressInformation The e-mail address of the member. + * @throws Exception the exception + */ + public GroupMember(EmailAddress addressInformation) throws Exception { + this(); + + this.setAddressInformation(new EmailAddress(addressInformation)); + } + + /** + * Initializes a new instance of the GroupMember class. + * + * @param member GroupMember class instance to copy. + * @throws Exception the exception + */ + protected GroupMember(GroupMember member) throws Exception { + this(); + + EwsUtilities.validateParam(member, "member"); + this.setAddressInformation(new EmailAddress(member + .getAddressInformation())); + } + + /** + * Initializes a new instance of the GroupMember class. + * + * @param contact The contact to link to. + * @param emailAddressKey The contact's e-mail address to link to. + * @throws Exception the exception + */ + public GroupMember(Contact contact, EmailAddressKey emailAddressKey) + throws Exception { + this(); + + EwsUtilities.validateParam(contact, "contact"); + EmailAddress emailAddress = contact.getEmailAddresses() + .getEmailAddress(emailAddressKey); + this.setAddressInformation(new EmailAddress(emailAddress)); + this.getAddressInformation().setId(contact.getId()); + } + + /** + * Gets the key of the member. + * + * @return the key + */ + public String getKey() { + + return this.key; + + } + + /** + * Gets the address information of the member. + * + * @return the address information + */ + public EmailAddress getAddressInformation() { + + return this.addressInformation; + } + + /** + * Sets the address information. + * + * @param value the new address information + */ + protected void setAddressInformation(EmailAddress value) { + + if (this.addressInformation != null) { + + this.addressInformation.removeChangeEvent(this); + } + + this.addressInformation = value; + + if (this.addressInformation != null) { + + this.addressInformation.addOnChangeEvent(this); + } + } + + /** + * Gets the status of the member. + * + * @return the status + */ + + public MemberStatus getStatus() { + + return this.status; + + } + + /** + * Reads the member Key attribute from XML. + * + * @param reader the reader + */ + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.key = reader.readAttributeValue(String.class, XmlAttributeNames.Key); + } + + /** + * Tries to read Status or Mailbox elements from XML. + * + * @param reader the reader + * @return True if element was read. + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.Status)) { + + this.status = EwsUtilities.parse(MemberStatus.class, reader.readElementValue()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Mailbox)) { + + this.setAddressInformation(new EmailAddress()); + this.getAddressInformation().loadFromXml(reader, + reader.getLocalName()); + return true; + } else { + + return false; + } + } + + /** + * Writes the member key attribute to XML. + * + * @param writer the writer + */ + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + // if this.key is null or empty, writer skips the attribute + writer.writeAttributeValue(XmlAttributeNames.Key, this.key); + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + // No need to write member Status back to server + // Write only AddressInformation container element + this.getAddressInformation().writeToXml(writer, XmlNamespace.Types, + XmlElementNames.Mailbox); + } + + /** + * AddressInformation instance is changed. + * + * @param complexProperty Changed property. + */ + private void addressInformationChanged(ComplexProperty complexProperty) { + this.changed(); + } + + /** + * Complex property changed. + * + * @param complexProperty accepts ComplexProperty + */ + @Override + public void complexPropertyChanged(ComplexProperty complexProperty) { + + this.addressInformationChanged(complexProperty); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/GroupMemberCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/GroupMemberCollection.java new file mode 100644 index 000000000..666838dde --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/GroupMemberCollection.java @@ -0,0 +1,470 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.ICustomXmlUpdateSerializer; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.EmailAddressKey; +import com.eischet.ews.api.core.enumeration.property.MailboxType; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Contact; +import com.eischet.ews.api.core.service.schema.ContactGroupSchema; +import com.eischet.ews.api.property.definition.GroupMemberPropertyDefinition; +import com.eischet.ews.api.property.definition.PropertyDefinition; + +import javax.xml.stream.XMLStreamException; +import java.util.Iterator; +import java.util.List; + +/** + * Represents a collection of members of GroupMember type. + */ +public final class GroupMemberCollection extends ComplexPropertyCollection implements + ICustomXmlUpdateSerializer { + /** + * If the collection is cleared, then store PDL members collection is + * updated with "SetItemField". If the collection is not cleared, then store + * PDL members collection is updated with "AppendToItemField". + */ + private boolean collectionIsCleared = false; + + /** + * Initializes a new instance. + */ + public GroupMemberCollection() { + super(); + } + + /** + * Retrieves the XML element name corresponding to the provided + * GroupMember object. + * + * @param member the member + * @return The XML element name corresponding to the provided GroupMember + * object + */ + @Override + protected String getCollectionItemXmlElementName(GroupMember member) { + return XmlElementNames.Member; + } + + /** + * * Finds the member with the specified key in the collection.Members that + * have not yet been saved do not have a key. + * + * @param key the key + * @return The member with the specified key + * @throws Exception the exception + */ + public GroupMember find(String key) throws Exception { + EwsUtilities.validateParam(key, "key"); + + for (GroupMember item : this.getItems()) { + if (item.getKey().equals(key)) { + return item; + } + } + + return null; + } + + /** + * Clears the collection. + */ + public void clear() { + // mark the whole collection for deletion + this.internalClear(); + this.collectionIsCleared = true; + } + + /** + * Adds a member to the collection. + * + * @param member the member + * @throws Exception the exception + */ + public void add(GroupMember member) throws Exception { + EwsUtilities.validateParam(member, "member"); + EwsUtilities.ewsAssert(member.getKey() == null, "GroupMemberCollection.Add", "member.Key is not null."); + EwsUtilities.ewsAssert(!this.contains(member), "GroupMemberCollection.Add", + "The member is already in the collection"); + + this.internalAdd(member); + } + + /** + * Adds multiple members to the collection. + * + * @param members the members + * @throws Exception the exception + */ + public void addRange(Iterator members) throws Exception { + EwsUtilities.validateParam(members, "members"); + while (members.hasNext()) { + this.add(members.next()); + + } + } + + /** + * Adds a member linked to a Contact Group. + * + * @param contactGroupId the contact group id + * @throws Exception the exception + */ + public void addContactGroup(ItemId contactGroupId) throws Exception { + this.add(new GroupMember(contactGroupId)); + } + + /** + * Adds a member linked to a specific contact?s e-mail address. + * + * @param contactId the contact id + * @param addressToLink the address to link + * @throws Exception the exception + */ + public void addPersonalContact(ItemId contactId, String addressToLink) + throws Exception { + this.add(new GroupMember(contactId, addressToLink)); + } + + /** + * Adds a member linked to a contact?s first available e-mail address. + * + * @param contactId the contact id + * @throws Exception the exception + */ + public void addPersonalContact(ItemId contactId) throws Exception { + this.addPersonalContact(contactId, null); + } + + /** + * Adds a member linked to an Active Directory user. + * + * @param smtpAddress the smtp address + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + public void addDirectoryUser(String smtpAddress) + throws ServiceLocalException, Exception { + this.addDirectoryUser(smtpAddress, new EmailAddress() + .getSmtpRoutingType()); + } + + /** + * Adds a member linked to an Active Directory user. + * + * @param address the address + * @param routingType the routing type + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + public void addDirectoryUser(String address, String routingType) + throws ServiceLocalException, Exception { + this.add(new GroupMember(address, routingType, MailboxType.Mailbox)); + } + + /** + * Adds a member linked to an Active Directory contact. + * + * @param smtpAddress the smtp address + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + public void addDirectoryContact(String smtpAddress) + throws ServiceLocalException, Exception { + this.addDirectoryContact(smtpAddress, new EmailAddress() + .getSmtpRoutingType()); + } + + /** + * Adds a member linked to an Active Directory contact. + * + * @param address the address + * @param routingType the routing type + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + public void addDirectoryContact(String address, String routingType) + throws ServiceLocalException, Exception { + this.add(new GroupMember(address, routingType, MailboxType.Contact)); + } + + /** + * Adds a member linked to a Public Group. + * + * @param smtpAddress the smtp address + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + public void addPublicGroup(String smtpAddress) + throws ServiceLocalException, Exception { + this.add(new GroupMember(smtpAddress, new EmailAddress() + .getSmtpRoutingType(), MailboxType.PublicGroup)); + } + + /** + * Adds a member linked to a mail-enabled Public Folder. + * + * @param smtpAddress the smtp address + * @throws ServiceLocalException the service local exception + * @throws Exception the exception + */ + public void addDirectoryPublicFolder(String smtpAddress) + throws ServiceLocalException, Exception { + this.add(new GroupMember(smtpAddress, new EmailAddress() + .getSmtpRoutingType(), MailboxType.PublicFolder)); + } + + /** + * Adds a one-off member. + * + * @param displayName the display name + * @param address the address + * @param routingType the routing type + * @throws Exception the exception + */ + public void addOneOff(String displayName, + String address, String routingType) + throws Exception { + this.add(new GroupMember(displayName, address, routingType)); + } + + /** + * Adds a one-off member. + * + * @param displayName the display name + * @param smtpAddress the smtp address + * @throws Exception the exception + */ + public void addOneOff(String displayName, String smtpAddress) + throws Exception { + this.addOneOff(displayName, smtpAddress, new EmailAddress() + .getSmtpRoutingType()); + } + + /** + * Adds a member that is linked to a specific e-mail address of a contact. + * + * @param contact the contact + * @param emailAddressKey the email address key + * @throws Exception the exception + */ + public void addContactEmailAddress(Contact contact, + EmailAddressKey emailAddressKey) throws Exception { + this.add(new GroupMember(contact, emailAddressKey)); + } + + /** + * Removes a member at the specified index. + * + * @param index the index + */ + public void removeAt(int index) { + if (index < 0 || index >= this.getCount()) { + throw new IllegalArgumentException("index", new Throwable("index is out of range.")); + + } + + this.internalRemoveAt(index); + } + + /** + * Removes a member from the collection. + * + * @param member the member + * @return True if the group member was successfully removed from the + * collection, false otherwise. + */ + public boolean remove(GroupMember member) { + return this.internalRemove(member); + } + + /** + * Writes the update to XML. + * + * @param writer the writer + * @param ownerObject the owner object + * @param propertyDefinition the property definition + * @return True if property generated serialization. + * @throws Exception the exception + */ + public boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, + ServiceObject ownerObject, PropertyDefinition propertyDefinition) + throws Exception { + if (this.collectionIsCleared) { + + if (!this.getAddedItems().isEmpty()) { // not visible + + // Delete the whole members collection + this.writeDeleteMembersCollectionToXml(writer); + } else { + // The collection is cleared, so Set + this.writeSetOrAppendMembersToXml(writer, this.getAddedItems(), + true); + } + } else { + // The collection is not cleared, i.e. dl.Members.Clear() is not + // called. + // Append AddedItems. + this.writeSetOrAppendMembersToXml(writer, this.getAddedItems(), + false); + + // Since member replacement is not supported by server + // Delete old ModifiedItems, then recreate new instead. + this.writeDeleteMembersToXml(writer, this.getModifiedItems()); + this.writeSetOrAppendMembersToXml(writer, this.getModifiedItems(), + false); + + // Delete RemovedItems. + this.writeDeleteMembersToXml(writer, this.getRemovedItems()); + } + + return true; + } + + /** + * Writes the deletion update to XML. + * + * @param writer the writer + * @param ewsObject the ews object + * @return True if property generated serialization. + */ + public boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, + ServiceObject ewsObject) { + return false; + } + + /** + * Creates a GroupMember object from an XML element name. + * + * @param xmlElementName the xml element name + * @return An GroupMember object + */ + protected GroupMember createComplexProperty(String xmlElementName) { + return new GroupMember(); + } + + /** + * Clears the change log. + */ + public void clearChangeLog() { + super.clearChangeLog(); + this.collectionIsCleared = false; + } + + /** + * Delete the whole members collection. + * + * @param writer the writer + */ + private void writeDeleteMembersCollectionToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.DeleteItemField); + ContactGroupSchema.Members.writeToXml(writer); + writer.writeEndElement(); + } + + /** + * Generate XML to delete individual members. + * + * @param writer the writer + * @param members the members + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + private void writeDeleteMembersToXml(EwsServiceXmlWriter writer, + List members) throws XMLStreamException, + ServiceXmlSerializationException, ExchangeXmlException { + if (!members.isEmpty()) { + GroupMemberPropertyDefinition memberPropDef = + new GroupMemberPropertyDefinition(); + + for (GroupMember member : members) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.DeleteItemField); + + memberPropDef.setKey(member.getKey()); + memberPropDef.writeToXml(writer); + + writer.writeEndElement(); // DeleteItemField + } + } + } + + /** + * Write set or append members to xml. + * + * @param writer the writer + * @param members the members + * @param setMode the set mode + * @throws Exception the exception + */ + private void writeSetOrAppendMembersToXml(EwsServiceXmlWriter writer, + List members, boolean setMode) throws Exception { + if (!members.isEmpty()) { + writer.writeStartElement(XmlNamespace.Types, + setMode ? XmlElementNames.SetItemField + : XmlElementNames.AppendToItemField); + + ContactGroupSchema.Members.writeToXml(writer); + + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.DistributionList); + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.Members); + + for (GroupMember member : members) { + member.writeToXml(writer, XmlElementNames.Member); + } + + writer.writeEndElement(); // Members + writer.writeEndElement(); // Group + writer.writeEndElement(); // setMode ? SetItemField : + // AppendItemField + } + } + + /** + * Validates this instance. + * + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + + for (GroupMember groupMember : this.getModifiedItems()) { + if (!(groupMember.getKey() == null || groupMember.getKey().isEmpty())) { + throw new ExchangeValidationException("The contact group's Members property must be reloaded before " + + "newly-added members can be updated."); + } + } + } +} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/IComplexPropertyChanged.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/IComplexPropertyChanged.java similarity index 84% rename from src/main/java/microsoft/exchange/webservices/data/property/complex/IComplexPropertyChanged.java rename to ews-api/src/main/java/com/eischet/ews/api/property/complex/IComplexPropertyChanged.java index 8d736f099..aba5a0075 100644 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/IComplexPropertyChanged.java +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/IComplexPropertyChanged.java @@ -21,17 +21,17 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; /** * Indicates that a complex property changed. */ public interface IComplexPropertyChanged { - /** - * Indicates that a complex property changed. - * - * @param complexProperty Complex property. - */ - void complexPropertyChanged(ComplexProperty complexProperty); + /** + * Indicates that a complex property changed. + * + * @param complexProperty Complex property. + */ + void complexPropertyChanged(ComplexProperty complexProperty); } diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/IComplexPropertyChangedDelegate.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/IComplexPropertyChangedDelegate.java similarity index 85% rename from src/main/java/microsoft/exchange/webservices/data/property/complex/IComplexPropertyChangedDelegate.java rename to ews-api/src/main/java/com/eischet/ews/api/property/complex/IComplexPropertyChangedDelegate.java index bebfa9e49..125a0c54c 100644 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/IComplexPropertyChangedDelegate.java +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/IComplexPropertyChangedDelegate.java @@ -21,18 +21,18 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; /** * The Interface ComplexPropertyChangedDelegateInterface. */ public interface IComplexPropertyChangedDelegate { - /** - * Complex property changed. - * - * @param complexProperty the complex property - */ - void complexPropertyChanged(TComplexProperty complexProperty); + /** + * Complex property changed. + * + * @param complexProperty the complex property + */ + void complexPropertyChanged(TComplexProperty complexProperty); } diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ICreateComplexPropertyDelegate.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ICreateComplexPropertyDelegate.java similarity index 83% rename from src/main/java/microsoft/exchange/webservices/data/property/complex/ICreateComplexPropertyDelegate.java rename to ews-api/src/main/java/com/eischet/ews/api/property/complex/ICreateComplexPropertyDelegate.java index 7b9b12fe2..367f48fcc 100644 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ICreateComplexPropertyDelegate.java +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ICreateComplexPropertyDelegate.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; /** * Used to create instances of ComplexProperty. @@ -29,12 +29,12 @@ * @param Type that extends ComplexProperty */ public interface ICreateComplexPropertyDelegate - { + { - /** - * used to create instances of ComplexProperty. - * - * @return Complex property instance - */ - TComplexProperty createComplexProperty(); + /** + * used to create instances of ComplexProperty. + * + * @return Complex property instance + */ + TComplexProperty createComplexProperty(); } diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/IOwnedProperty.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/IOwnedProperty.java similarity index 80% rename from src/main/java/microsoft/exchange/webservices/data/property/complex/IOwnedProperty.java rename to ews-api/src/main/java/com/eischet/ews/api/property/complex/IOwnedProperty.java index e5e826739..e6b828a1e 100644 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/IOwnedProperty.java +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/IOwnedProperty.java @@ -21,9 +21,9 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; -import microsoft.exchange.webservices.data.core.service.ServiceObject; +import com.eischet.ews.api.core.service.ServiceObject; /** * Complex property that implement that interface are owned by an instance of @@ -31,17 +31,17 @@ */ public interface IOwnedProperty { - /** - * Gets the owner. - * - * @return The owner. - */ - ServiceObject getOwner(); + /** + * Gets the owner. + * + * @return The owner. + */ + ServiceObject getOwner(); - /** - * Sets the owner. - * - * @param obj The owner. - */ - void setOwner(ServiceObject obj); + /** + * Sets the owner. + * + * @param obj The owner. + */ + void setOwner(ServiceObject obj); } diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/IPropertyBagChangedDelegate.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/IPropertyBagChangedDelegate.java similarity index 81% rename from src/main/java/microsoft/exchange/webservices/data/property/complex/IPropertyBagChangedDelegate.java rename to ews-api/src/main/java/com/eischet/ews/api/property/complex/IPropertyBagChangedDelegate.java index c3da32fdc..17e1b83be 100644 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/IPropertyBagChangedDelegate.java +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/IPropertyBagChangedDelegate.java @@ -21,9 +21,9 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; -import microsoft.exchange.webservices.data.core.SimplePropertyBag; +import com.eischet.ews.api.core.SimplePropertyBag; /** * The Interface PropertyBagChangedDelegateInterface. @@ -32,10 +32,10 @@ */ public interface IPropertyBagChangedDelegate { - /** - * Property bag changed. - * - * @param simplePropertyBag the simple property bag - */ - void propertyBagChanged(SimplePropertyBag simplePropertyBag); + /** + * Property bag changed. + * + * @param simplePropertyBag the simple property bag + */ + void propertyBagChanged(SimplePropertyBag simplePropertyBag); } diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ISearchStringProvider.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ISearchStringProvider.java similarity index 84% rename from src/main/java/microsoft/exchange/webservices/data/property/complex/ISearchStringProvider.java rename to ews-api/src/main/java/com/eischet/ews/api/property/complex/ISearchStringProvider.java index 5a9f8d841..878c5ead4 100644 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ISearchStringProvider.java +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ISearchStringProvider.java @@ -21,17 +21,17 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; /** * Interface defined for types that can produce a string representation for use * in search filter. */ public interface ISearchStringProvider { - /** - * Get a string representation for using this instance in a search filter. - * - * @return String representation of instance. - */ - String getSearchString(); + /** + * Get a string representation for using this instance in a search filter. + * + * @return String representation of instance. + */ + String getSearchString(); } diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/IServiceObjectChangedDelegate.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/IServiceObjectChangedDelegate.java similarity index 81% rename from src/main/java/microsoft/exchange/webservices/data/property/complex/IServiceObjectChangedDelegate.java rename to ews-api/src/main/java/com/eischet/ews/api/property/complex/IServiceObjectChangedDelegate.java index dfd8d953d..dc5096dd9 100644 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/IServiceObjectChangedDelegate.java +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/IServiceObjectChangedDelegate.java @@ -21,20 +21,20 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; -import microsoft.exchange.webservices.data.core.service.ServiceObject; +import com.eischet.ews.api.core.service.ServiceObject; /** * The Interface ServiceObjectChangedDelegateInterface. */ public interface IServiceObjectChangedDelegate { - /** - * Service object changed. - * - * @param serviceObject the service object - */ - void serviceObjectChanged(ServiceObject serviceObject); + /** + * Service object changed. + * + * @param serviceObject the service object + */ + void serviceObjectChanged(ServiceObject serviceObject); } diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ImAddressDictionary.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ImAddressDictionary.java new file mode 100644 index 000000000..7766fe776 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ImAddressDictionary.java @@ -0,0 +1,111 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.property.ImAddressKey; +import com.eischet.ews.api.misc.OutParam; + +/** + * Represents a dictionary of Instant Messaging addresses. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class ImAddressDictionary extends DictionaryProperty { + + /** + * Gets the field URI. + * + * @return Field URI. + */ + @Override + protected String getFieldURI() { + return "contacts:ImAddress"; + } + + /** + * Creates instance of dictionary entry. + * + * @return New instance. + */ + @Override + protected ImAddressEntry createEntryInstance() { + return new ImAddressEntry(); + } + + /** + * Gets the Instant Messaging address at the specified key. + * + * @param key the key + * @return The Instant Messaging address at the specified key. + */ + public String getImAddressKey(ImAddressKey key) { + return this.getEntries().get(key).getImAddress(); + } + + /** + * Sets the im address key. + * + * @param key the key + * @param value the value + */ + public void setImAddressKey(ImAddressKey key, String value) { + if (value == null) { + this.internalRemove(key); + } else { + ImAddressEntry entry; + + if (this.getEntries().containsKey(key)) { + entry = this.getEntries().get(key); + entry.setImAddress(value); + this.changed(); + } else { + entry = new ImAddressEntry(key, value); + this.internalAdd(entry); + } + } + } + + /** + * Tries to get the IM address associated with the specified key. + * + * @param key the key + * @param outParam the out param + * @return true if the Dictionary contains an IM address associated with the + * specified key; otherwise, false. + */ + public boolean tryGetValue(ImAddressKey key, OutParam outParam) { + ImAddressEntry entry = null; + + if (this.getEntries().containsKey(key)) { + entry = this.getEntries().get(key); + outParam.setParam(entry.getImAddress()); + + return true; + } else { + outParam = null; + return false; + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ImAddressEntry.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ImAddressEntry.java new file mode 100644 index 000000000..e26d47ed9 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ImAddressEntry.java @@ -0,0 +1,104 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.property.ImAddressKey; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import javax.xml.stream.XMLStreamException; + +/** + * Represents an entry of an ImAddressDictionary. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class ImAddressEntry extends DictionaryEntryProperty { + + /** + * The im address. + */ + private String imAddress; + + /** + * Initializes a new instance of the "ImAddressEntry" class. + */ + protected ImAddressEntry() { + super(ImAddressKey.class); + } + + /** + * Initializes a new instance of the ="ImAddressEntry" class. + * + * @param key The key. + * @param imAddress The im address. + */ + protected ImAddressEntry(ImAddressKey key, String imAddress) { + super(ImAddressKey.class, key); + this.imAddress = imAddress; + } + + /** + * Gets the Instant Messaging address of the entry. + * + * @return imAddress + */ + public String getImAddress() { + return this.imAddress; + } + + /** + * Sets the Instant Messaging address of the entry. + * + * @param value the new im address + */ + public void setImAddress(Object value) { + + this.canSetFieldValue(this.imAddress, value); + } + + /** + * Reads the text value from XML. + * + * @param reader accepts EwsServiceXmlReader + */ + @Override + public void readTextValueFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.imAddress = reader.readValue(); + } + + /** + * Writes elements to XML. + * + * @param writer The writer. + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeValue(this.imAddress, XmlElementNames.ImAddress); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/InternetMessageHeader.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/InternetMessageHeader.java new file mode 100644 index 000000000..996e269be --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/InternetMessageHeader.java @@ -0,0 +1,133 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Defines the EwsXmlReader class. + */ +public final class InternetMessageHeader extends ComplexProperty { + + /** + * The name. + */ + private String name; + + /** + * The value. + */ + private String value; + + /** + * Initializes a new instance of the EwsXmlReader class. + */ + protected InternetMessageHeader() { + } + + /** + * Reads the attribute from XML. + * + * @param reader the reader + */ + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.name = reader.readAttributeValue(XmlAttributeNames.HeaderName); + } + + /** + * Reads the text value from XML. + * + * @param reader the reader + */ + public void readTextValueFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.value = reader.readValue(); + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + */ + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.HeaderName, this.name); + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeValue(this.value, this.name); + } + + /** + * Obtains a string representation of the header. + * + * @return The string representation of the header. + */ + public String toString() { + return String.format("%s=%s", this.name, this.value); + } + + /** + * The name of the header. + * + * @param name the new name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Gets the name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * The value of the header. + * + * @return the value + */ + public String getValue() { + return value; + } + + /** + * Sets the value. + * + * @param value the value to set + */ + public void setValue(String value) { + this.value = value; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/InternetMessageHeaderCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/InternetMessageHeaderCollection.java new file mode 100644 index 000000000..8cf1dab02 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/InternetMessageHeaderCollection.java @@ -0,0 +1,85 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; + +/** + * Represents a collection of Internet message headers. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class InternetMessageHeaderCollection extends ComplexPropertyCollection { + /** + * Initializes a new instance of the "InternetMessageHeaderCollection" + * class. + */ + public InternetMessageHeaderCollection() { + super(); + } + + /** + * Creates the complex property. + * + * @param xmlElementName Name of the XML element. + * @return InternetMessageHeader instance + */ + @Override + protected InternetMessageHeader createComplexProperty( + String xmlElementName) { + return new InternetMessageHeader(); + } + + /** + * Gets the name of the collection item XML element. + * + * @param complexProperty The complex property. + * @return XML element name. + */ + @Override + protected String getCollectionItemXmlElementName( + InternetMessageHeader complexProperty) { + return XmlElementNames.InternetMessageHeader; + } + + /** + * Find a specific header in the collection. + * + * @param name The name of the header to locate. + * @return An InternetMessageHeader representing the header with the + * specified name; null if no header with the specified name was + * found. + */ + public InternetMessageHeader find(String name) { + for (InternetMessageHeader internetMessageHeader : this) { + if (name.compareTo(internetMessageHeader.getName()) == 0 && + name.equalsIgnoreCase(internetMessageHeader.getName())) { + return internetMessageHeader; + } + } + return null; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ItemAttachment.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ItemAttachment.java new file mode 100644 index 000000000..8e148d095 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ItemAttachment.java @@ -0,0 +1,249 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.property.BodyType; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.property.definition.PropertyDefinitionBase; + +import java.util.Arrays; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents an item attachment. + */ +public class ItemAttachment extends Attachment implements IServiceObjectChangedDelegate { + + private static final Logger LOG = Logger.getLogger(ItemAttachment.class.getCanonicalName()); + + /** + * The item. + */ + private Item item; + + /** + * Initializes a new instance of the class. + * + * @param owner The owner of the attachment + */ + protected ItemAttachment(Item owner) { + super(owner); + } + + /** + * Gets the item associated with the attachment. + * + * @return the item + */ + public Item getItem() { + return this.item; + } + + /** + * Sets the item associated with the attachment. + * + * @param item the new item + */ + protected void setItem(Item item) { + this.throwIfThisIsNotNew(); + + if (this.item != null) { + + this.item.removeServiceObjectChangedEvent(this); + } + this.item = item; + if (this.item != null) { + this.item.addServiceObjectChangedEvent(this); + } + } + + /** + * Implements the OnChange event handler for the item associated with the + * attachment. + * + * @param serviceObject ,The service object that triggered the OnChange event. + */ + private void itemChanged(ServiceObject serviceObject) { + this.item.getPropertyBag().changed(); + } + + /** + * Obtains EWS XML element name for this object. + * + * @return The XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.ItemAttachment; + } + + /** + * Tries to read the element at the current position of the reader. + * + * @param reader the reader + * @return True if the element was read, false otherwise. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + boolean result = super.tryReadElementFromXml(reader); + + if (!result) { + this.item = EwsUtilities.createItemFromXmlElementName(this, reader.getLocalName()); + + if (this.item != null) { + try { + this.item.loadFromXml(reader, true /* clearPropertyBag */); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error reading XML", e); + } + } + } + + return result; + } + + /** + * For ItemAttachment, AttachmentId and Item should be patched. + * + * @param reader The reader. + *

+ * True if element was read. + */ + public boolean tryReadElementFromXmlToPatch(EwsServiceXmlReader reader) throws ExchangeXmlException { + // update the attachment id. + super.tryReadElementFromXml(reader); + + reader.read(); + + String localName = reader.getLocalName(); + Class itemClass = EwsUtilities.getItemTypeFromXmlElementName(localName); + + if (itemClass != null) { + if (item == null || item.getClass() != itemClass) { + throw new ExchangeXmlException("Attachment item type mismatch."); + } + + this.item.loadFromXml(reader, false /* clearPropertyBag */); + return true; + } + + return false; + } + + + /** + * Writes the property of this object as XML elements. + * + * @param writer ,The writer to write the elements to. + * @throws Exception the exception + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeElementsToXml(writer); + try { + this.item.writeToXml(writer); + } catch (Exception e) { + LOG.log(Level.SEVERE, "error writing XML", e); + + } + } + + /** + * {@inheritDoc} + */ + @Override + protected void validate(int attachmentIndex) throws ExchangeValidationException { + if (this.getName() == null || this.getName().isEmpty()) { + throw new ExchangeValidationException(String.format("The name of the item attachment at index %d must be set.", attachmentIndex)); + } + // Recurse through any item attached to item attachment. + this.validate(); + } + + /** + * Loads this attachment. + * + * @param additionalProperties the additional property + * @throws Exception the exception + */ + public void load(PropertyDefinitionBase... additionalProperties) + throws Exception { + internalLoad(null /* bodyType */, Arrays.asList(additionalProperties)); + } + + /** + * Loads this attachment. + * + * @param additionalProperties the additional property + * @throws Exception the exception + */ + public void load(Iterable additionalProperties) + throws Exception { + this.internalLoad(null, additionalProperties); + } + + /** + * Loads this attachment. + * + * @param bodyType the body type + * @param additionalProperties the additional property + * @throws Exception the exception + */ + public void load(BodyType bodyType, + PropertyDefinitionBase... additionalProperties) throws Exception { + internalLoad(bodyType, Arrays.asList(additionalProperties)); + } + + /** + * Loads this attachment. + * + * @param bodyType the body type + * @param additionalProperties the additional property + * @throws Exception the exception + */ + public void load(BodyType bodyType, + Iterable additionalProperties) + throws Exception { + this.internalLoad(bodyType, additionalProperties); + } + + /** + * Service object changed. + * + * @param serviceObject accepts ServiceObject + */ + @Override + public void serviceObjectChanged(ServiceObject serviceObject) { + this.itemChanged(serviceObject); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ItemCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ItemCollection.java new file mode 100644 index 000000000..66d9c2a1c --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ItemCollection.java @@ -0,0 +1,145 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents a collection of item. + * + * @param the generic type. The type of item the collection contains. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class ItemCollection extends ComplexProperty + implements Iterable { + + private static final Logger LOG = Logger.getLogger(ItemCollection.class.getCanonicalName()); + + /** + * The item. + */ + private final List items = new ArrayList(); + + /** + * Initializes a new instance of the "ItemCollection<TItem>" class. + */ + public ItemCollection() { + super(); + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @param localElementName Name of the local element. + */ + @Override + public void loadFromXml(EwsServiceXmlReader reader, String localElementName) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, + localElementName); + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { + TItem item = EwsUtilities + .createEwsObjectFromXmlElementName(Item.class, reader.getService(), reader.getLocalName()); + + if (item == null) { + reader.skipCurrentElement(); + } else { + try { + item.loadFromXml(reader, + true /* clearPropertyBag */); + } catch (ServiceVersionException e) { + LOG.log(Level.SEVERE, "error loading XML", e); + } + + this.items.add(item); + } + } + } while (!reader.isEndElement(XmlNamespace.Types, + localElementName)); + } else { + reader.read(); + } + } + + /** + * Gets the total number of item in the collection. + * + * @return the count + */ + public int getCount() { + return this.items.size(); + } + + /** + * Gets the item at the specified index. + * + * @param index The zero-based index of the item to get. + * @return The item at the specified index. + */ + public TItem getItem(int index) { + + if (index < 0 || index >= this.getCount()) { + throw new ArrayIndexOutOfBoundsException("index is out of range."); + } + return this.items.get(index); + } + + /** + * Gets an iterator that iterates through the elements of the collection. + * + * @return An Iterator for the collection. + */ + public Iterator getIterator() { + return this.items.iterator(); + } + + /** + * Returns an iterator over a set of elements of type T. + * + * @return an Iterator. + */ + @Override + public Iterator iterator() { + return this.items.iterator(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ItemId.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ItemId.java new file mode 100644 index 000000000..069321ea7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ItemId.java @@ -0,0 +1,70 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.XmlElementNames; + +/** + * Represents the Id of an Exchange item. + */ +public class ItemId extends ServiceId { + + /** + * Initializes a new instance. + */ + public ItemId() { + super(); + } + + /** + * Defines an implicit conversion between string and ItemId. + * + * @param uniqueId The unique Id to convert to ItemId. + * @return An ItemId initialized with the specified unique Id. + * @throws Exception the exception + */ + public static ItemId getItemIdFromString(String uniqueId) throws Exception { + return new ItemId(uniqueId); + } + + /** + * Initializes a new instance of ItemId. + * + * @param uniqueId The unique Id used to initialize the ItemId. + * @throws Exception the exception + */ + public ItemId(String uniqueId) throws Exception { + super(uniqueId); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.ItemId; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ItemIdCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ItemIdCollection.java new file mode 100644 index 000000000..f8660e831 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ItemIdCollection.java @@ -0,0 +1,58 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +/** + * Represents a collection of item Ids. + */ +public final class ItemIdCollection extends ComplexPropertyCollection { + /** + * Initializes a new instance of the class. + */ + public ItemIdCollection() { + super(); + } + + /** + * Creates the complex property. + * + * @param xmlElementName Name of the XML element. + * @return ItemId. + */ + @Override + protected ItemId createComplexProperty(String xmlElementName) { + return new ItemId(); + } + + /** + * Gets the name of the collection item XML element. + * + * @param complexProperty The complex property. + * @return XML element name. + */ + @Override + protected String getCollectionItemXmlElementName(ItemId complexProperty) { + return complexProperty.getXmlElementName(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/Mailbox.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/Mailbox.java new file mode 100644 index 000000000..bfcbd7d9e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/Mailbox.java @@ -0,0 +1,253 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents a mailbox reference. + */ +public class Mailbox extends ComplexProperty implements ISearchStringProvider { + + // Routing type + /** + * The routing type. + */ + private String routingType; + + // Email address + /** + * The address. + */ + private String address; + + /** + * Initializes a new instance of the Mailbox class. + */ + public Mailbox() { + super(); + } + + /** + * Initializes a new instance of the Mailbox class. + * + * @param smtpAddress the smtp address + */ + public Mailbox(String smtpAddress) { + this(); + this.setAddress(smtpAddress); + } + + /** + * Initializes a new instance of the Mailbox class. + * + * @param address the address + * @param routingType the routing type + */ + public Mailbox(String address, String routingType) { + this(address); + this.setRoutingType(routingType); + } + + /** + * Gets the address. + * + * @return the address + */ + public String getAddress() { + return address; + } + + /** + * Sets the address. + * + * @param address the new address + */ + public void setAddress(String address) { + this.address = address; + } + + /** + * True if this instance is valid, false otherthise. + * + * @return true if this instance is valid; otherwise false + */ + public boolean isValid() { + return !(this.getAddress() == null || this.getAddress().isEmpty()); + } + + /** + * Gets the routing type of the address used to refer to the user + * mailbox. + * + * @return the routing type + */ + public String getRoutingType() { + return routingType; + } + + /** + * Sets the routing type. + * + * @param routingType the new routing type + */ + public void setRoutingType(String routingType) { + this.routingType = routingType; + } + + /** + * Defines an implicit conversion between a string representing an SMTP + * address and Mailbox. + * + * @param smtpAddress the smtp address + * @return A Mailbox initialized with the specified SMTP address. + */ + public static Mailbox getMailboxFromString(String smtpAddress) { + return new Mailbox(smtpAddress); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + * @throws Exception the exception + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName() + .equalsIgnoreCase(XmlElementNames.EmailAddress)) { + this.setAddress(reader.readElementValue()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.RoutingType)) { + this.setRoutingType(reader.readElementValue()); + return true; + } else { + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.EmailAddress, this.address); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.RoutingType, this.routingType); + } + + /** + * Get a string representation for using this instance in a search filter. + * + * @return String representation of instance. + */ + public String getSearchString() { + return this.address; + } + + /** + * Validates this instance. + * + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + EwsUtilities.validateNonBlankStringParamAllowNull(this.getAddress(), "address"); + EwsUtilities.validateNonBlankStringParamAllowNull(this.getRoutingType(), "routingType"); + } + + + /** + * Determines whether the specified Object is equal to the current Object. + * + * @param obj the obj + * @return true if the specified Object is equal to the current Object + * otherwise, false. + */ + @Override + public boolean equals(Object obj) { + if (super.equals(obj)) { + return true; + } else { + if (!(obj instanceof Mailbox)) { + return false; + } else { + Mailbox other = (Mailbox) obj; + if (((this.address == null) && (other.address == null)) + || ((this.address != null) && this.address + .equalsIgnoreCase(other.address))) { + return ((this.routingType == null) && + (other.routingType == null)) + || ((this.routingType != null) && this.routingType + .equalsIgnoreCase(other.routingType)); + } else { + return false; + } + } + } + } + + /** + * Serves as a hash function for a particular type. + * + * @return A hash code for the current object + */ + @Override + public int hashCode() { + if (!(null == this.getAddress() || this.getAddress().isEmpty())) { + int hashCode = this.address.hashCode(); + + if (!(null == this.getRoutingType() || this.getRoutingType() + .isEmpty())) { + hashCode ^= this.routingType.hashCode(); + } + return hashCode; + } else { + return super.hashCode(); + } + } + + /** + * Returns a String that represents the current Object. + * + * @return A String that represents the current Object. + */ + @Override + public String toString() { + if (!this.isValid()) { + return ""; + } else if (!(this.routingType == null || this.routingType.isEmpty())) { + return this.routingType + ":" + this.address; + } else { + return this.address; + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ManagedFolderInformation.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ManagedFolderInformation.java new file mode 100644 index 000000000..a6da93fa2 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ManagedFolderInformation.java @@ -0,0 +1,243 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.OutParam; + +/** + * Represents information for a managed folder. + */ +public final class ManagedFolderInformation extends ComplexProperty { + + /** + * The can delete. + */ + private Boolean canDelete; + + /** + * The can rename or move. + */ + private Boolean canRenameOrMove; + + /** + * The must display comment. + */ + private Boolean mustDisplayComment; + + /** + * The has quota. + */ + private Boolean hasQuota; + + /** + * The is managed folder root. + */ + private Boolean isManagedFoldersRoot; + + /** + * The managed folder id. + */ + private String managedFolderId; + + /** + * The comment. + */ + private String comment; + + /** + * The storage quota. + */ + private Integer storageQuota; + + /** + * The folder size. + */ + private Integer folderSize; + + /** + * The home page. + */ + private String homePage; + + /** + * Initializes a new instance of the ManagedFolderInformation class. + */ + public ManagedFolderInformation() { + super(); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.CanDelete)) { + this.canDelete = reader.readValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.CanRenameOrMove)) { + this.canRenameOrMove = reader.readValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.MustDisplayComment)) { + this.mustDisplayComment = reader.readValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.HasQuota)) { + this.hasQuota = reader.readValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.IsManagedFoldersRoot)) { + this.isManagedFoldersRoot = reader.readValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.ManagedFolderId)) { + this.managedFolderId = reader.readValue(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.Comment)) { + OutParam value = new OutParam<>(); + reader.tryReadValue(value); + this.comment = value.getParam(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.StorageQuota)) { + this.storageQuota = reader.readValue(Integer.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.FolderSize)) { + this.folderSize = reader.readValue(Integer.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.HomePage)) { + OutParam value = new OutParam<>(); + reader.tryReadValue(value); + this.homePage = value.getParam(); + return true; + } else { + return false; + } + + } + + /** + * Gets a value indicating whether the user can delete objects in the + * folder. + * + * @return the can delete + */ + public Boolean getCanDelete() { + return this.canDelete; + } + + /** + * Gets a value indicating whether the user can rename or move objects in + * the folder. + * + * @return the can rename or move + */ + public Boolean getCanRenameOrMove() { + return canRenameOrMove; + } + + /** + * Gets a value indicating whether the client application must display the + * Comment property to the user. + * + * @return the must display comment + */ + public Boolean getMustDisplayComment() { + return mustDisplayComment; + } + + /** + * Gets a value indicating whether the folder has a quota. + * + * @return the checks for quota + */ + public Boolean getHasQuota() { + return hasQuota; + } + + /** + * Gets a value indicating whether the folder is the root of the managed + * folder hierarchy. + * + * @return the checks if is managed folder root + */ + public Boolean getIsManagedFoldersRoot() { + return isManagedFoldersRoot; + } + + /** + * Gets the Managed Folder Id of the folder. + * + * @return the managed folder id + */ + public String getManagedFolderId() { + return managedFolderId; + } + + /** + * Gets the comment associated with the folder. + * + * @return the comment + */ + public String getComment() { + return comment; + } + + /** + * Gets the storage quota of the folder. + * + * @return the storage quota + */ + public Integer getStorageQuota() { + return storageQuota; + } + + /** + * Gets the size of the folder. + * + * @return the folder size + */ + public Integer getFolderSize() { + return folderSize; + } + + /** + * Gets the home page associated with the folder. + * + * @return the home page + */ + public String getHomePage() { + return homePage; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/MeetingTimeZone.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/MeetingTimeZone.java new file mode 100644 index 000000000..914845d98 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/MeetingTimeZone.java @@ -0,0 +1,272 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.TimeSpan; +import com.eischet.ews.api.property.complex.time.TimeZoneDefinition; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents a time zone in which a meeting is defined. + */ +public final class MeetingTimeZone extends ComplexProperty { + + private static final Logger LOG = Logger.getLogger(MeetingTimeZone.class.getCanonicalName()); + + /** + * The name. + */ + private String name; + + /** + * The base offset. + */ + private TimeSpan baseOffset; + + /** + * The standard. + */ + private TimeChange standard; + + /** + * The daylight. + */ + private TimeChange daylight; + + /** + * Initializes a new instance of the MeetingTimeZone class. + * + * @param timeZone The time zone used to initialize this instance. + */ + public MeetingTimeZone(TimeZoneDefinition timeZone) { + // Unfortunately, MeetingTimeZone does not support all the time + // transition types + // supported by TimeZoneInfo. That leaves us unable to accurately + // convert TimeZoneInfo + // into MeetingTimeZone. So we don't... Instead, we emit the time zone's + // Id and + // hope the server will find a match (which it should). + this.name = timeZone.getId(); + } + + /** + * Initializes a new instance of the MeetingTimeZone class. + */ + public MeetingTimeZone() { + super(); + } + + /** + * Initializes a new instance of the MeetingTimeZone class. + * + * @param name The name of the time zone. + */ + public MeetingTimeZone(String name) { + this(); + this.name = name; + } + + /** + * Gets the minimum required server version. + * + * @param reader the reader + * @return Earliest Exchange version in which this service object type is + * supported. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.BaseOffset)) { + this.baseOffset = EwsUtilities.getXSDurationToTimeSpan(reader.readElementValue()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Standard)) { + this.standard = new TimeChange(); + this.standard.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Daylight)) { + this.daylight = new TimeChange(); + this.daylight.loadFromXml(reader, reader.getLocalName()); + return true; + } else { + return false; + } + } + + /** + * Reads the attribute from XML. + * + * @param reader the reader + */ + @Override + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.name = reader.readAttributeValue(XmlAttributeNames.TimeZoneName); + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.TimeZoneName, this.getName()); + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (this.baseOffset != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.BaseOffset, EwsUtilities + .getTimeSpanToXSDuration(this.getBaseOffset())); + } + + if (this.getStandard() != null) { + this.getStandard().writeToXml(writer, XmlElementNames.Standard); + } + + if (this.getDaylight() != null) { + this.getDaylight().writeToXml(writer, XmlElementNames.Daylight); + } + } + + /** + * Converts this meeting time zone into a TimeZoneInfo structure. + * + * @return the time zone + */ + public TimeZoneDefinition toTimeZoneInfo() { + TimeZoneDefinition result = null; + + try { + result = new TimeZoneDefinition(); + //TimeZone.getTimeZone(this.getName()); + result.setId(this.getName()); + } catch (Exception e) { + // Could not find a time zone with that Id on the local system. + LOG.log(Level.SEVERE, "Could not find a time zone with that Id on the local system: " + this.getName(), e); + } + + // Again, we cannot accurately convert MeetingTimeZone into TimeZoneInfo + // because TimeZoneInfo doesn't support absolute date transitions. So if + // there is no system time zone that has a matching Id, we return null. + return result; + } + + /** + * Gets the name of the time zone. + * + * @return the name + */ + public String getName() { + return this.name; + } + + /** + * Sets the name. + * + * @param value the new name + */ + public void setName(String value) { + if (this.canSetFieldValue(this.name, value)) { + this.name = value; + this.changed(); + } + } + + /** + * Gets the base offset of the time zone from the UTC time zone. + * + * @return the base offset + */ + public TimeSpan getBaseOffset() { + return this.baseOffset; + } + + /** + * Sets the base offset. + * + * @param value the new base offset + */ + public void setBaseOffset(TimeSpan value) { + if (this.canSetFieldValue(this.name, value)) { + this.baseOffset = value; + this.changed(); + } + } + + /** + * Gets a TimeChange defining when the time changes to Standard + * Time. + * + * @return the standard + */ + public TimeChange getStandard() { + return this.standard; + } + + /** + * Sets the standard. + * + * @param value the new standard + */ + public void setStandard(TimeChange value) { + if (this.canSetFieldValue(this.standard, value)) { + this.standard = value; + this.changed(); + } + } + + /** + * Gets a TimeChange defining when the time changes to Daylight + * Saving Time. + * + * @return the daylight + */ + public TimeChange getDaylight() { + return this.daylight; + } + + /** + * Sets the daylight. + * + * @param value the new daylight + */ + public void setDaylight(TimeChange value) { + if (this.canSetFieldValue(this.daylight, value)) { + this.daylight = value; + this.changed(); + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/MessageBody.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/MessageBody.java new file mode 100644 index 000000000..c5abab37f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/MessageBody.java @@ -0,0 +1,201 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.property.BodyType; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import javax.xml.stream.XMLStreamException; +import java.util.logging.Logger; + +/** + * Represents the body of a message. + */ +public final class MessageBody extends ComplexProperty { + + private static final Logger log = Logger.getLogger(MessageBody.class.getCanonicalName()); + + /** + * The body type. + */ + private BodyType bodyType; + + /** + * The text. + */ + private String text; + + /** + * Initializes a new instance. + */ + public MessageBody() { + + } + + /** + * Initializes a new instance. + * + * @param bodyType The type of the message body's text. + * @param text The text of the message body. + */ + public MessageBody(BodyType bodyType, String text) { + this(); + this.bodyType = bodyType; + this.text = text; + } + + /** + * Initializes a new instance. + * + * @param text The text of the message body, assumed to be HTML. + */ + public MessageBody(String text) { + this(BodyType.HTML, text); + } + + /** + * Defines an implicit conversation between a string and MessageBody. + * + * @param textBody The string to convert to MessageBody, assumed to be HTML. + * @return A MessageBody initialized with the specified string. + */ + public static MessageBody getMessageBodyFromText(String textBody) { + return new MessageBody(BodyType.HTML, textBody); + } + + /** + * Defines an implicit conversion of MessageBody into a string. + * + * @param messageBody The MessageBody to convert to a string. + * @return A string containing the text of the MessageBody. + * @throws Exception the exception + */ + public static String getStringFromMessageBody(MessageBody messageBody) throws Exception { + EwsUtilities.validateParam(messageBody, "messageBody"); + return messageBody.text; + } + + /** + * Reads attribute from XML. + * + * @param reader The reader. + */ + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.bodyType = reader.readAttributeValue(BodyType.class, + XmlAttributeNames.BodyType); + } + + /** + * Reads text value from XML. + * + * @param reader the reader + */ + @Override + public void readTextValueFromXml(EwsServiceXmlReader reader) + throws ExchangeXmlException { + log.fine(() -> "Reading text value from XML. BodyType = " + this.getBodyType() + + ", keepWhiteSpace = " + + ((this.getBodyType() == BodyType.Text) ? "true." : "false.")); + this.text = reader.readValue(this.getBodyType() == BodyType.Text); + log.fine(() -> "Text value read:\n---\n" + this.text + "\n---"); + } + + /** + * Writes attribute to XML. + * + * @param writer The writer. + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.BodyType, this + .getBodyType()); + } + + /** + * Writes elements to XML. + * + * @param writer The writer. + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (null != this.text && !this.text.isEmpty()) { + writer.writeValue(this.getText(), XmlElementNames.Body); + } + } + + /** + * Gets the type of the message body's text. + * + * @return BodyType enum + */ + public BodyType getBodyType() { + return this.bodyType; + } + + /** + * Sets the type of the message body's text. + * + * @param bodyType BodyType enum + */ + public void setBodyType(BodyType bodyType) { + if (this.canSetFieldValue(this.bodyType, bodyType)) { + this.bodyType = bodyType; + this.changed(); + } + } + + /** + * Gets the text of the message body. + * + * @return message body text + */ + private String getText() { + return this.text; + } + + /** + * Sets the text of the message body. + * + * @param text message body text + */ + public void setText(String text) { + if (this.canSetFieldValue(this.text, text)) { + this.text = text; + this.changed(); + } + } + + /** + * Returns a String that represents the current Object. + * + * @return the string + */ + @Override + public String toString() { + return (this.text == null) ? "" : this.text; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/MimeContent.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/MimeContent.java new file mode 100644 index 000000000..faca18271 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/MimeContent.java @@ -0,0 +1,175 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import javax.xml.stream.XMLStreamException; +import java.util.Base64; + +/** + * Represents the MIME content of an item. + */ +public final class MimeContent extends ComplexProperty { + + /** + * The character set. + */ + private String characterSet; + + /** + * The content. + */ + private byte[] content; + + /** + * Initializes a new instance of the class. + */ + public MimeContent() { + } + + /** + * Initializes a new instance of the class. + * + * @param characterSet the character set + * @param content the content + */ + public MimeContent(String characterSet, byte[] content) { + this(); + this.characterSet = characterSet; + this.content = content; + } + + /** + * Reads attribute from XML. + * + * @param reader the reader + */ + @Override + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.characterSet = reader.readAttributeValue(String.class, XmlAttributeNames.CharacterSet); + } + + /** + * Reads text value from XML. + * + * @param reader the reader + */ + @Override + public void readTextValueFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.content = Base64.getMimeDecoder().decode(reader.readValue()); + } + + /** + * Writes attribute to XML. + * + * @param writer the writer + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.CharacterSet, + this.characterSet); + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (this.content != null && this.content.length > 0) { + writer.writeBase64ElementValue(this.content); + } + } + + /** + * Gets the character set of the content. + * + * @return the character set + */ + public String getCharacterSet() { + return this.characterSet; + } + + /** + * Sets the character set. + * + * @param characterSet the new character set + */ + public void setCharacterSet(String characterSet) { + this.canSetFieldValue(this.characterSet, characterSet); + } + + /** + * Gets the character set of the content. + * + * @return the content + */ + public byte[] getContent() { + return this.content; + } + + /** + * Sets the content. + * + * @param content the new content + */ + public void setContent(byte[] content) { + this.canSetFieldValue(this.content, content); + } + + /** + * Writes attribute to XML. + * + * @return the string + */ + @Override + public String toString() { + if (this.getContent() == null) { + return ""; + } else { + try { + + // Try to convert to original MIME content using specified + // charset. If this fails, + // return the Base64 representation of the content. + // Note: Encoding.GetString can throw DecoderFallbackException + // which is a subclass + // of ArgumentException. + String charSet = (this.getCharacterSet() == null || + this.getCharacterSet().isEmpty()) ? + "UTF-8" : this.getCharacterSet(); + return new String(this.getContent(), charSet); + } catch (Exception e) { + return Base64.getMimeEncoder().encodeToString(this.getContent()); + } + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/OccurrenceInfo.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/OccurrenceInfo.java new file mode 100644 index 000000000..ab2631092 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/OccurrenceInfo.java @@ -0,0 +1,129 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.time.LocalDateTime; + +/** + * Encapsulates information on the occurrence of a recurring appointment. + */ +public final class OccurrenceInfo extends ComplexProperty { + + /** + * The item id. + */ + private ItemId itemId; + + /** + * The start. + */ + private LocalDateTime start; + + /** + * The end. + */ + private LocalDateTime end; + + /** + * The original start. + */ + private LocalDateTime originalStart; + + /** + * Initializes a new instance of the OccurrenceInfo class. + */ + public OccurrenceInfo() { + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return true, if successful + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.ItemId)) { + + this.itemId = new ItemId(); + this.itemId.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Start)) { + + this.start = reader.readElementValueAsDateTime(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.End)) { + + this.end = reader.readElementValueAsDateTime(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.OriginalStart)) { + + this.originalStart = reader.readElementValueAsDateTime(); + return true; + } else { + + return false; + } + } + + /** + * Gets the Id of the occurrence. + * + * @return the item id + */ + public ItemId getItemId() { + return itemId; + } + + /** + * Gets the start date and time of the occurrence. + * + * @return the start + */ + public LocalDateTime getStart() { + return start; + } + + /** + * Gets the end date and time of the occurrence. + * + * @return the end + */ + public LocalDateTime getEnd() { + return end; + } + + /** + * Gets the original start date and time of the occurrence. + * + * @return the original start + */ + public LocalDateTime getOriginalStart() { + return originalStart; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/OccurrenceInfoCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/OccurrenceInfoCollection.java new file mode 100644 index 000000000..e62512bb3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/OccurrenceInfoCollection.java @@ -0,0 +1,70 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; + +/** + * Represents a collection of OccurrenceInfo objects. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class OccurrenceInfoCollection extends ComplexPropertyCollection { + + /** + * Initializes a new instance of the + * class. + */ + public OccurrenceInfoCollection() { + } + + /** + * Creates the complex property. + * + * @param xmlElementName Name of the XML element + * @return OccuranceInfo instance + */ + @Override + protected OccurrenceInfo createComplexProperty(String xmlElementName) { + if (xmlElementName.equals(XmlElementNames.Occurrence)) { + return new OccurrenceInfo(); + } else { + return null; + } + } + + /** + * Gets the name of the collection item XML element. + * + * @param complexProperty The complex property. + * @return XML element name. + */ + @Override + protected String getCollectionItemXmlElementName( + OccurrenceInfo complexProperty) { + return XmlElementNames.Occurrence; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/PhoneNumberDictionary.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/PhoneNumberDictionary.java new file mode 100644 index 000000000..58258e203 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/PhoneNumberDictionary.java @@ -0,0 +1,113 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.property.PhoneNumberKey; +import com.eischet.ews.api.misc.OutParam; + +/** + * Represents a dictionary of phone numbers. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class PhoneNumberDictionary extends DictionaryProperty { + + /** + * Gets the field URI. + * + * @return Field URI. + */ + @Override + protected String getFieldURI() { + return "contacts:PhoneNumber"; + } + + /** + * Creates instance of dictionary entry. + * + * @return New instance. + */ + @Override + protected PhoneNumberEntry createEntryInstance() { + return new PhoneNumberEntry(); + } + + /** + * Gets the phone number at the specified key. + * + * @param key The phone number key. + * @return The phone number at the specified key if found; otherwise null. + */ + public String getPhoneNumber(PhoneNumberKey key) { + PhoneNumberEntry phoneNumberEntry = this.getEntries().get(key); + if (phoneNumberEntry == null) { + return null; + } + + return phoneNumberEntry.getPhoneNumber(); + } + + /** + * Sets the phone number. + * + * @param key the key + * @param value the value + */ + public void setPhoneNumber(PhoneNumberKey key, String value) { + if (value == null) { + this.internalRemove(key); + } else { + PhoneNumberEntry entry; + + if (this.getEntries().containsKey(key)) { + entry = this.getEntries().get(key); + entry.setPhoneNumber(value); + complexPropertyChanged(entry); + this.changed(); + } else { + entry = new PhoneNumberEntry(key, value); + this.internalAdd(entry); + } + } + } + + /** + * Tries to get the phone number associated with the specified key. + * + * @param key the key + * @param outparam the outparam + * @return true if the Dictionary contains a phone number associated with + * the specified key; otherwise, false. + */ + public boolean tryGetValue(PhoneNumberKey key, OutParam outparam) { + String phoneNumber = this.getPhoneNumber(key); + if (phoneNumber == null) { + return false; + } + + outparam.setParam(phoneNumber); + return true; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/PhoneNumberEntry.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/PhoneNumberEntry.java new file mode 100644 index 000000000..c7c37de63 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/PhoneNumberEntry.java @@ -0,0 +1,102 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.property.PhoneNumberKey; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents an entry of a PhoneNumberDictionary. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class PhoneNumberEntry extends DictionaryEntryProperty { + + /** + * The phone number. + */ + private String phoneNumber; + + /** + * Initializes a new instance of the "PhoneNumberEntry" class. + */ + protected PhoneNumberEntry() { + super(PhoneNumberKey.class); + } + + /** + * Initializes a new instance of the class. + * + * @param key The key. + * @param phoneNumber The phone number. + */ + protected PhoneNumberEntry(PhoneNumberKey key, String phoneNumber) { + super(PhoneNumberKey.class, key); + this.phoneNumber = phoneNumber; + } + + /** + * Reads the text value from XML. + * + * @param reader accepts EwsServiceXmlReader + */ + @Override + public void readTextValueFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.phoneNumber = reader.readValue(); + } + + /** + * Writes elements to XML. + * + * @param writer The writer. + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeValue(this.phoneNumber, XmlElementNames.PhoneNumber); + } + + /** + * Gets the phone number of the entry. + * + * @return the phone number + */ + public String getPhoneNumber() { + return this.phoneNumber; + } + + /** + * Sets the phone number of the entry. + * + * @param value the new phone number + */ + public void setPhoneNumber(Object value) { + //this.canSetFieldValue((String) this.phoneNumber, value); + if (this.canSetFieldValue(this.phoneNumber, value)) { + this.phoneNumber = (String) value; + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/PhysicalAddressDictionary.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/PhysicalAddressDictionary.java new file mode 100644 index 000000000..1036fe10e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/PhysicalAddressDictionary.java @@ -0,0 +1,90 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.property.PhysicalAddressKey; +import com.eischet.ews.api.misc.OutParam; + +/** + * Represents a dictionary of physical addresses. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class PhysicalAddressDictionary extends + DictionaryProperty { + + /** + * Creates instance of dictionary entry. + * + * @return New instance. + */ + @Override + protected PhysicalAddressEntry createEntryInstance() { + return new PhysicalAddressEntry(); + } + + /** + * Gets the physical address at the specified key. + * + * @param key the key + * @return The physical address at the specified key. + */ + public PhysicalAddressEntry getPhysicalAddress(PhysicalAddressKey key) { + return this.getEntries().get(key); + } + + /** + * Sets the physical address. + * + * @param key the key + * @param value the value + */ + public void setPhysicalAddress(PhysicalAddressKey key, + PhysicalAddressEntry value) { + if (value == null) { + this.internalRemove(key); + } else { + value.setKey(key); + this.internalAddOrReplace(value); + } + } + + /** + * Tries to get the physical address associated with the specified key. + * + * @param key the key + * @param outparam the outparam + * @return true if the Dictionary contains a physical address associated + * with the specified key; otherwise, false. + */ + public boolean tryGetValue(PhysicalAddressKey key, + OutParam outparam) { + if (this.getEntries().containsKey(key)) { + outparam.setParam(this.getEntries().get(key)); + } + return this.getEntries().containsKey(key); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/PhysicalAddressEntry.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/PhysicalAddressEntry.java new file mode 100644 index 000000000..409127a74 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/PhysicalAddressEntry.java @@ -0,0 +1,365 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.PhysicalAddressKey; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; + +import javax.xml.stream.XMLStreamException; +import java.util.ArrayList; +import java.util.List; + +/** + * Represents an entry of an PhysicalAddressDictionary. + */ +public final class PhysicalAddressEntry extends DictionaryEntryProperty implements + IPropertyBagChangedDelegate { + + /** + * The property bag. + */ + private final SimplePropertyBag propertyBag; + + /** + * Initializes a new instance of PhysicalAddressEntry. + */ + public PhysicalAddressEntry() { + super(PhysicalAddressKey.class); + this.propertyBag = new SimplePropertyBag(); + this.propertyBag.addOnChangeEvent(this); + } + + /** + * Property was changed. + * + * @param simplePropertyBag the simple property bag + */ + public void propertyBagChanged(SimplePropertyBag simplePropertyBag) { + this.changed(); + } + + /** + * Gets the street. + * + * @return the street + * @throws Exception the exception + */ + public String getStreet() throws Exception { + return (String) this.propertyBag + .getSimplePropertyBag(PhysicalAddressSchema.Street); + } + + /** + * Sets the street. + * + * @param value the new street + * @throws Exception the exception + */ + public void setStreet(String value) throws Exception { + this.propertyBag.setSimplePropertyBag(PhysicalAddressSchema.Street, + value); + + } + + /** + * Gets the city. + * + * @return the city + * @throws Exception the exception + */ + public String getCity() throws Exception { + return (String) this.propertyBag + .getSimplePropertyBag(PhysicalAddressSchema.City); + } + + /** + * Sets the city. + * + * @param value the new city + */ + public void setCity(String value) { + this.propertyBag + .setSimplePropertyBag(PhysicalAddressSchema.City, value); + } + + /** + * Gets the state. + * + * @return the state + * @throws Exception the exception + */ + public String getState() throws Exception { + return (String) this.propertyBag + .getSimplePropertyBag(PhysicalAddressSchema.State); + } + + /** + * Sets the state. + * + * @param value the new state + */ + public void setState(String value) { + this.propertyBag.setSimplePropertyBag(PhysicalAddressSchema.State, + value); + } + + /** + * Gets the country or region. + * + * @return the country or region + * @throws Exception the exception + */ + public String getCountryOrRegion() throws Exception { + return (String) this.propertyBag + .getSimplePropertyBag(PhysicalAddressSchema.CountryOrRegion); + } + + /** + * Sets the country or region. + * + * @param value the new country or region + */ + public void setCountryOrRegion(String value) { + this.propertyBag.setSimplePropertyBag( + PhysicalAddressSchema.CountryOrRegion, value); + } + + /** + * Gets the postal code. + * + * @return the postal code + */ + public String getPostalCode() { + return (String) this.propertyBag + .getSimplePropertyBag(PhysicalAddressSchema.PostalCode); + } + + /** + * Sets the postal code. + * + * @param value the new postal code + */ + public void setPostalCode(String value) { + this.propertyBag.setSimplePropertyBag(PhysicalAddressSchema.PostalCode, + value); + } + + /** + * Clears the change log. + */ + @Override + public void clearChangeLog() { + this.propertyBag.clearChangeLog(); + } + + /** + * Writes elements to XML. + * + * @param reader the reader + * @return true, if successful + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (PhysicalAddressSchema.getXmlElementNames().contains( + reader.getLocalName())) { + this.propertyBag.setSimplePropertyBag(reader.getLocalName(), reader + .readElementValue()); + return true; + } else { + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + for (String xmlElementName : PhysicalAddressSchema.getXmlElementNames()) { + writer.writeElementValue(XmlNamespace.Types, xmlElementName, + this.propertyBag.getSimplePropertyBag(xmlElementName)); + + } + } + + /** + * Writes the update to XML. + * + * @param writer the writer + * @param ewsObject the ews object + * @param ownerDictionaryXmlElementName the owner dictionary xml element name + * @return true if update XML was written + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + protected boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, ServiceObject ewsObject, String ownerDictionaryXmlElementName) throws ExchangeXmlException { + List fieldsToSet = new ArrayList(); + + for (String xmlElementName : this.propertyBag.getAddedItems()) { + fieldsToSet.add(xmlElementName); + } + + for (String xmlElementName : this.propertyBag.getModifiedItems()) { + fieldsToSet.add(xmlElementName); + } + + for (String xmlElementName : fieldsToSet) { + writer.writeStartElement(XmlNamespace.Types, ewsObject + .getSetFieldXmlElementName()); + + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.IndexedFieldURI); + writer.writeAttributeValue(XmlAttributeNames.FieldURI, + getFieldUri(xmlElementName)); + writer.writeAttributeValue(XmlAttributeNames.FieldIndex, this + .getKey().toString()); + writer.writeEndElement(); // IndexedFieldURI + + writer.writeStartElement(XmlNamespace.Types, ewsObject + .getXmlElementName()); + writer.writeStartElement(XmlNamespace.Types, + ownerDictionaryXmlElementName); + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Entry); + this.writeAttributesToXml(writer); + writer.writeElementValue(XmlNamespace.Types, xmlElementName, + this.propertyBag.getSimplePropertyBag(xmlElementName)); + writer.writeEndElement(); // Entry + writer.writeEndElement(); // ownerDictionaryXmlElementName + writer.writeEndElement(); // ewsObject.GetXmlElementName() + + writer.writeEndElement(); // ewsObject.GetSetFieldXmlElementName() + } + + for (String xmlElementName : this.propertyBag.getRemovedItems()) { + this.internalWriteDeleteFieldToXml(writer, ewsObject, + xmlElementName); + } + + return true; + } + + /** + * Writes the delete update to XML. + * + * @param writer the writer + * @param ewsObject the ews object + * @return true if update XML was written + */ + @Override + protected boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, ServiceObject ewsObject) throws ExchangeXmlException { + for (String xmlElementName : PhysicalAddressSchema.getXmlElementNames()) { + this.internalWriteDeleteFieldToXml(writer, ewsObject, xmlElementName); + } + return true; + } + + /** + * Gets the field URI. + * + * @param xmlElementName the xml element name + * @return Field URI. + */ + private static String getFieldUri(String xmlElementName) { + return "contacts:PhysicalAddress:" + xmlElementName; + } + + /** + * Write field deletion to XML. + * + * @param writer the writer + * @param ewsObject the ews object + * @param fieldXmlElementName the field xml element name + */ + private void internalWriteDeleteFieldToXml(EwsServiceXmlWriter writer, ServiceObject ewsObject, String fieldXmlElementName) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, ewsObject.getDeleteFieldXmlElementName()); + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.IndexedFieldURI); + writer.writeAttributeValue(XmlAttributeNames.FieldURI, getFieldUri(fieldXmlElementName)); + writer.writeAttributeValue(XmlAttributeNames.FieldIndex, this.getKey().toString()); + writer.writeEndElement(); // IndexedFieldURI + writer.writeEndElement(); // ewsObject.GetDeleteFieldXmlElementName() + } + + /** + * Schema definition for PhysicalAddress. + */ + private static class PhysicalAddressSchema { + + /** + * The Constant Street. + */ + public static final String Street = "Street"; + + /** + * The Constant City. + */ + public static final String City = "City"; + + /** + * The Constant State. + */ + public static final String State = "State"; + + /** + * The Constant CountryOrRegion. + */ + public static final String CountryOrRegion = "CountryOrRegion"; + + /** + * The Constant PostalCode. + */ + public static final String PostalCode = "PostalCode"; + + /** + * List of XML element names. + */ + private static final LazyMember> xmlElementNames = + new LazyMember<>( + () -> { + List result = new ArrayList<>(5); + result.add(Street); + result.add(City); + result.add(State); + result.add(CountryOrRegion); + result.add(PostalCode); + return result; + }); + + /** + * Gets the XML element names. + * + * @return The XML element names. + */ + public static List getXmlElementNames() { + return xmlElementNames.getMember(); + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/RecurringAppointmentMasterId.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RecurringAppointmentMasterId.java new file mode 100644 index 000000000..218153e85 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RecurringAppointmentMasterId.java @@ -0,0 +1,67 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents the Id of an occurrence of a recurring appointment. + */ +public final class RecurringAppointmentMasterId extends ItemId { + + /** + * Represents the Id of an occurrence of a recurring appointment. + * + * @param occurrenceId the occurrence id + * @throws Exception the exception + */ + public RecurringAppointmentMasterId(String occurrenceId) throws Exception { + super(occurrenceId); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.RecurringMasterItemId; + } + + /** + * Writes attribute to XML. + * + * @param writer the writer + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.OccurrenceId, this.getUniqueId()); + writer.writeAttributeValue(XmlAttributeNames.ChangeKey, this.getChangeKey()); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/Rule.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/Rule.java new file mode 100644 index 000000000..5239caef3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/Rule.java @@ -0,0 +1,310 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents a rule that automatically handles incoming messages. + * A rule consists of a set of conditions + * and exception that determine whether or + * not a set of actions should be executed on incoming messages. + */ +public final class Rule extends ComplexProperty { + + /** + * The rule ID. + */ + private String ruleId; + + /** + * The rule display name. + */ + private String displayName; + + /** + * The rule priority. + */ + private int priority; + + /** + * The rule status of enabled or not. + */ + private boolean isEnabled; + + /** + * The rule status of is supported or not. + */ + private boolean isNotSupported; + + /** + * The rule status of in error or not. + */ + private boolean isInError; + + /** + * The rule conditions. + */ + private final RulePredicates conditions; + + /** + * The rule actions. + */ + private final RuleActions actions; + + /** + * The rule exception. + */ + private final RulePredicates exceptions; + + /** + * Initializes a new instance of the Rule class. + */ + public Rule() { + super(); + + /** + * New rule has priority as 0 by default + */ + this.priority = 1; + + /** + * New rule is enabled by default + */ + this.isEnabled = true; + this.conditions = new RulePredicates(); + this.actions = new RuleActions(); + this.exceptions = new RulePredicates(); + } + + + /** + * Gets or sets the Id of this rule. + */ + public String getId() { + + return this.ruleId; + } + + public void setId(String value) { + if (this.canSetFieldValue(this.ruleId, value)) { + this.ruleId = value; + this.changed(); + } + } + + /** + * Gets or sets the name of this rule as it should be displayed to the user. + */ + public String getDisplayName() { + return this.displayName; + } + + public void setDisplayName(String value) { + if (this.canSetFieldValue(this.displayName, value)) { + this.displayName = value; + this.changed(); + } + } + + + /** + * Gets or sets the priority of this rule, + * which determines its execution order. + */ + public int getPriority() { + return this.priority; + } + + public void setPriority(int value) { + if (this.canSetFieldValue(this.priority, value)) { + this.priority = value; + this.changed(); + } + } + + + /** + * Gets or sets a value indicating whether this rule is enabled. + */ + public boolean getIsEnabled() { + return this.isEnabled; + } + + public void setIsEnabled(boolean value) { + if (this.canSetFieldValue(this.isEnabled, value)) { + this.isEnabled = value; + this.changed(); + } + } + + /** + * Gets a value indicating whether this rule can be modified via EWS. + * If IsNotSupported is true, the rule cannot be modified via EWS. + */ + public boolean getIsNotSupported() { + return this.isNotSupported; + + } + + /** + * Gets or sets a value indicating whether + * this rule has errors. A rule that is in error + * cannot be processed unless it is updated and the error is corrected. + */ + public boolean getIsInError() { + return this.isInError; + } + + public void setIsInError(boolean value) { + if (this.canSetFieldValue(this.isInError, value)) { + this.isInError = value; + this.changed(); + } + } + + /** + * Gets the conditions that determine whether or not this rule should be + * executed against incoming messages. + */ + public RulePredicates getConditions() { + return this.conditions; + } + + /** + * Gets the actions that should be executed against incoming messages if the + * conditions evaluate as true. + */ + public RuleActions getActions() { + return this.actions; + + } + + /** + * Gets the exception that determine + * if this rule should be skipped even if + * its conditions evaluate to true. + */ + public RulePredicates getExceptions() { + return this.exceptions; + } + + /** + * Tries to read element from XML. + * + * @param reader The reader. + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader + reader) throws ExchangeXmlException { + + if (reader.getLocalName().equals(XmlElementNames.DisplayName)) { + this.displayName = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.RuleId)) { + this.ruleId = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Priority)) { + this.priority = reader.readElementValue(Integer.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.IsEnabled)) { + this.isEnabled = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.IsNotSupported)) { + this.isNotSupported = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.IsInError)) { + this.isInError = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Conditions)) { + this.conditions.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Actions)) { + this.actions.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Exceptions)) { + this.exceptions.loadFromXml(reader, reader.getLocalName()); + return true; + } else { + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer The writer. + * @throws Exception + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (!(getId() == null || getId().isEmpty())) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.RuleId, + this.getId()); + } + + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.DisplayName, + this.getDisplayName()); + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.Priority, + this.getPriority()); + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsEnabled, + this.getIsEnabled()); + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsInError, + this.getIsInError()); + this.getConditions().writeToXml(writer, XmlElementNames.Conditions); + this.getExceptions().writeToXml(writer, XmlElementNames.Exceptions); + this.getActions().writeToXml(writer, XmlElementNames.Actions); + } + + + /** + * Validates this instance. + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + EwsUtilities.validateParam(this.displayName, "DisplayName"); + EwsUtilities.validateParam(this.conditions, "Conditions"); + EwsUtilities.validateParam(this.exceptions, "Exceptions"); + EwsUtilities.validateParam(this.actions, "Actions"); + } +} + diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleActions.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleActions.java new file mode 100644 index 000000000..f80e05cf1 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleActions.java @@ -0,0 +1,533 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.Importance; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.MobilePhone; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * Represents the set of actions available for a rule. + */ +public final class RuleActions extends ComplexProperty { + + /** + * SMS recipient address type. + */ + private static final String MobileType = "MOBILE"; + + /** + * The AssignCategories action. + */ + private final StringList assignCategories; + + /** + * The CopyToFolder action. + */ + private FolderId copyToFolder; + + /** + * The Delete action. + */ + private boolean delete; + + /** + * The ForwardAsAttachmentToRecipients action. + */ + private final EmailAddressCollection forwardAsAttachmentToRecipients; + + /** + * The ForwardToRecipients action. + */ + private final EmailAddressCollection forwardToRecipients; + + /** + * The MarkImportance action. + */ + private Importance markImportance; + + /** + * The MarkAsRead action. + */ + private boolean markAsRead; + + /** + * The MoveToFolder action. + */ + private FolderId moveToFolder; + + /** + * The PermanentDelete action. + */ + private boolean permanentDelete; + + /** + * The RedirectToRecipients action. + */ + private final EmailAddressCollection redirectToRecipients; + + /** + * The SendSMSAlertToRecipients action. + */ + private Collection sendSMSAlertToRecipients; + + /** + * The ServerReplyWithMessage action. + */ + private ItemId serverReplyWithMessage; + + /** + * The StopProcessingRules action. + */ + private boolean stopProcessingRules; + + /** + * Initializes a new instance of the RulePredicates class. + */ + protected RuleActions() { + super(); + this.assignCategories = new StringList(); + this.forwardAsAttachmentToRecipients = + new EmailAddressCollection(XmlElementNames.Address); + this.forwardToRecipients = + new EmailAddressCollection(XmlElementNames.Address); + this.redirectToRecipients = + new EmailAddressCollection(XmlElementNames.Address); + this.sendSMSAlertToRecipients = new ArrayList(); + } + + /** + * Gets the categories that should be stamped on incoming messages. + * To disable stamping incoming messages with categories, set + * AssignCategories to null. + */ + public StringList getAssignCategories() { + + return this.assignCategories; + + } + + /** + * Gets or sets the Id of the folder incoming messages should be copied to. + * To disable copying incoming messages + * to a folder, set CopyToFolder to null. + */ + public FolderId getCopyToFolder() { + return this.copyToFolder; + } + + public void setCopyToFolder(FolderId value) { + if (this.canSetFieldValue(this.copyToFolder, value)) { + this.copyToFolder = value; + this.changed(); + } + } + + /** + * Gets or sets a value indicating whether incoming messages should be + * automatically moved to the Deleted Items folder. + */ + public boolean getDelete() { + return this.delete; + } + + public void setDelete(boolean value) { + if (this.canSetFieldValue(this.delete, value)) { + this.delete = value; + this.changed(); + } + + } + + /** + * Gets the e-mail addresses to which incoming messages should be + * forwarded as attachments. To disable forwarding incoming messages + * as attachments, empty the ForwardAsAttachmentToRecipients list. + */ + public EmailAddressCollection getForwardAsAttachmentToRecipients() { + return this.forwardAsAttachmentToRecipients; + } + + /** + * Gets the e-mail addresses to which + * incoming messages should be forwarded. + * To disable forwarding incoming messages, + * empty the ForwardToRecipients list. + */ + public EmailAddressCollection getForwardToRecipients() { + return this.forwardToRecipients; + + } + + /** + * Gets or sets the importance that should be stamped on incoming + * messages. To disable the stamping of incoming messages with an + * importance, set MarkImportance to null. + */ + public Importance getMarkImportance() { + return this.markImportance; + } + + public void setMarkImportance(Importance value) { + if (this.canSetFieldValue(this.markImportance, value)) { + this.markImportance = value; + this.changed(); + } + } + + /** + * Gets or sets a value indicating whether + * incoming messages should be marked as read. + */ + public boolean getMarkAsRead() { + return this.markAsRead; + } + + public void setMarkAsRead(boolean value) { + if (this.canSetFieldValue(this.markAsRead, value)) { + this.markAsRead = value; + this.changed(); + } + } + + /** + * Gets or sets the Id of the folder to which incoming messages should be + * moved. To disable the moving of incoming messages to a folder, set + * CopyToFolder to null. + */ + public FolderId getMoveToFolder() { + return this.moveToFolder; + } + + public void setMoveToFolder(FolderId value) { + if (this.canSetFieldValue(this.moveToFolder, value)) { + this.moveToFolder = value; + this.changed(); + } + + } + + /** + * Gets or sets a value indicating whether incoming messages should be + * permanently deleted. When a message is permanently deleted, it is never + * saved into the recipient's mailbox. To delete a message after it has + * saved into the recipient's mailbox. To delete a message after it has + */ + public boolean getPermanentDelete() { + return this.permanentDelete; + } + + public void setPermanentDelete(boolean value) { + if (this.canSetFieldValue(this.permanentDelete, value)) { + this.permanentDelete = value; + this.changed(); + } + } + + /** + * Gets the e-mail addresses to which incoming messages should be + * redirecteded. To disable redirection of incoming messages, empty + * the RedirectToRecipients list. Unlike forwarded mail, redirected mail + * maintains the original sender and recipients. + */ + public EmailAddressCollection getRedirectToRecipients() { + return this.redirectToRecipients; + + } + + /** + * Gets the phone numbers to which an SMS alert should be sent. To disable + * sending SMS alerts for incoming messages, empty the + * SendSMSAlertToRecipients list. + */ + public Collection getSendSMSAlertToRecipients() { + return this.sendSMSAlertToRecipients; + + } + + /** + * Gets or sets the Id of the template message that should be sent + * as a reply to incoming messages. To disable automatic replies, set + * ServerReplyWithMessage to null. + */ + public ItemId getServerReplyWithMessage() { + return this.serverReplyWithMessage; + } + + public void setServerReplyWithMessage(ItemId value) { + if (this.canSetFieldValue(this.serverReplyWithMessage, value)) { + this.serverReplyWithMessage = value; + this.changed(); + } + } + + /** + * Gets or sets a value indicating whether + * subsequent rules should be evaluated. + */ + public boolean getStopProcessingRules() { + return this.stopProcessingRules; + } + + public void setStopProcessingRules(boolean value) { + if (this.canSetFieldValue(this.stopProcessingRules, value)) { + this.stopProcessingRules = value; + this.changed(); + } + + } + + /** + * Tries to read element from XML. + * + * @param reader The reader. + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader + reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.CopyToFolder)) { + reader.readStartElement(XmlNamespace.NotSpecified, + XmlElementNames.FolderId); + this.copyToFolder = new FolderId(); + this.copyToFolder.loadFromXml(reader, XmlElementNames.FolderId); + reader.readEndElement(XmlNamespace.NotSpecified, + XmlElementNames.CopyToFolder); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.AssignCategories)) { + this.assignCategories.loadFromXml(reader, + reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Delete)) { + this.delete = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.ForwardAsAttachmentToRecipients)) { + this.forwardAsAttachmentToRecipients.loadFromXml(reader, + reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.ForwardToRecipients)) { + this.forwardToRecipients.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.MarkImportance)) { + this.markImportance = reader.readElementValue(Importance.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.MarkAsRead)) { + this.markAsRead = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.MoveToFolder)) { + reader.readStartElement(XmlNamespace.NotSpecified, + XmlElementNames.FolderId); + this.moveToFolder = new FolderId(); + this.moveToFolder.loadFromXml(reader, XmlElementNames.FolderId); + reader.readEndElement(XmlNamespace.NotSpecified, + XmlElementNames.MoveToFolder); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.PermanentDelete)) { + this.permanentDelete = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.RedirectToRecipients)) { + this.redirectToRecipients.loadFromXml(reader, + reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.SendSMSAlertToRecipients)) { + EmailAddressCollection smsRecipientCollection = + new EmailAddressCollection(XmlElementNames.Address); + smsRecipientCollection.loadFromXml(reader, reader.getLocalName()); + this.sendSMSAlertToRecipients = convertSMSRecipientsFromEmailAddressCollectionToMobilePhoneCollection( + smsRecipientCollection); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.ServerReplyWithMessage)) { + this.serverReplyWithMessage = new ItemId(); + this.serverReplyWithMessage.loadFromXml(reader, + reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.StopProcessingRules)) { + this.stopProcessingRules = reader.readElementValue(Boolean.class); + return true; + } else { + return false; + } + + } + + /** + * Writes elements to XML. + * + * @param writer The writer. + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (this.getAssignCategories().getSize() > 0) { + this.getAssignCategories().writeToXml(writer, + XmlElementNames.AssignCategories); + } + + if (this.getCopyToFolder() != null) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.CopyToFolder); + this.getCopyToFolder().writeToXml(writer); + writer.writeEndElement(); + } + + if (this.getDelete()) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.Delete, + this.getDelete()); + } + + if (this.getForwardAsAttachmentToRecipients().getCount() > 0) { + this.getForwardAsAttachmentToRecipients().writeToXml(writer, + XmlElementNames.ForwardAsAttachmentToRecipients); + } + + if (this.getForwardToRecipients().getCount() > 0) { + this.getForwardToRecipients().writeToXml(writer, + XmlElementNames.ForwardToRecipients); + } + + if (this.getMarkImportance() != null) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.MarkImportance, + this.getMarkImportance()); + } + + if (this.getMarkAsRead() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.MarkAsRead, + this.getMarkAsRead()); + } + + if (this.getMoveToFolder() != null) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.MoveToFolder); + this.getMoveToFolder().writeToXml(writer); + writer.writeEndElement(); + } + + if (this.getPermanentDelete() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.PermanentDelete, + this.getPermanentDelete()); + } + + if (this.getRedirectToRecipients().getCount() > 0) { + this.getRedirectToRecipients().writeToXml(writer, + XmlElementNames.RedirectToRecipients); + } + + if (this.getSendSMSAlertToRecipients().size() > 0) { + EmailAddressCollection emailCollection = + convertSMSRecipientsFromMobilePhoneCollectionToEmailAddressCollection( + this.getSendSMSAlertToRecipients()); + emailCollection.writeToXml(writer, + XmlElementNames.SendSMSAlertToRecipients); + } + + if (this.getServerReplyWithMessage() != null) { + this.getServerReplyWithMessage().writeToXml(writer, + XmlElementNames.ServerReplyWithMessage); + } + + if (this.getStopProcessingRules() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.StopProcessingRules, + this.getStopProcessingRules()); + } + } + + /** + * Validates this instance. + * + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + EwsUtilities.validateParam(this.forwardAsAttachmentToRecipients, "ForwardAsAttachmentToRecipients"); + EwsUtilities.validateParam(this.forwardToRecipients, + "ForwardToRecipients"); + EwsUtilities.validateParam(this.redirectToRecipients, + "RedirectToRecipients"); + for (MobilePhone sendSMSAlertToRecipient : this.sendSMSAlertToRecipients) { + EwsUtilities.validateParam(sendSMSAlertToRecipient, + "SendSMSAlertToRecipient"); + } + } + + /** + * Convert the SMS recipient list from + * EmailAddressCollection type to MobilePhone collection type. + * + * @return A MobilePhone collection object + * containing all SMS recipient in MobilePhone type. + */ + private static Collection convertSMSRecipientsFromEmailAddressCollectionToMobilePhoneCollection( + EmailAddressCollection emailCollection) { + Collection mobilePhoneCollection = + new ArrayList(); + for (EmailAddress emailAddress : emailCollection) { + mobilePhoneCollection.add(new MobilePhone(emailAddress.getName(), + emailAddress.getAddress())); + } + + return mobilePhoneCollection; + } + + /** + * Convert the SMS recipient list from MobilePhone + * collection type to EmailAddressCollection type. + * + * @return An EmailAddressCollection object + * containing recipients with "MOBILE" address type. + */ + private static EmailAddressCollection convertSMSRecipientsFromMobilePhoneCollectionToEmailAddressCollection( + Collection recipientCollection) { + EmailAddressCollection emailCollection = + new EmailAddressCollection(XmlElementNames.Address); + for (MobilePhone recipient : recipientCollection) { + EmailAddress emailAddress = new EmailAddress( + recipient.getName(), + recipient.getPhoneNumber(), + RuleActions.MobileType); + emailCollection.add(emailAddress); + } + + return emailCollection; + } + +} + diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleCollection.java new file mode 100644 index 000000000..34060d23e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleCollection.java @@ -0,0 +1,122 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.misc.ArgumentOutOfRangeException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.util.ArrayList; +import java.util.Iterator; + +/** + * Represents a collection of rules. + */ +public final class RuleCollection extends ComplexProperty implements Iterable { + + /** + * The OutlookRuleBlobExists flag. + */ + private boolean outlookRuleBlobExists; + + /** + * The rules in the rule collection. + */ + private final ArrayList rules; + + /** + * Initializes a new instance of the RuleCollection class. + */ + public RuleCollection() { + super(); + this.rules = new ArrayList(); + } + + /** + * Gets a value indicating whether an Outlook rule blob exists in the user's + * mailbox. To update rules with EWS when the Outlook rule blob exists, call + * SetInboxRules passing true as the + * value of the removeOutlookBlob parameter. + */ + public boolean getOutlookRuleBlobExists() { + return this.outlookRuleBlobExists; + } + + public void setOutlookRuleBlobExists(boolean value) { + this.outlookRuleBlobExists = value; + } + + /** + * Gets the number of rules in this collection. + */ + public int getCount() { + return this.rules.size(); + } + + /** + * Gets the rule at the specified index in the collection. + * + * @param index The index of the rule to get. + * @return The rule at the specified index. + * @throws ArgumentOutOfRangeException + */ + public Rule getRule(int index) throws ArgumentOutOfRangeException { + if (index < 0 || index >= this.rules.size()) { + throw new ArgumentOutOfRangeException("Index"); + } + + return this.rules.get(index); + + } + + + /** + * Tries to read element from XML. + * + * @param reader The reader. + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.Rule)) { + Rule rule = new Rule(); + rule.loadFromXml(reader, XmlElementNames.Rule); + this.rules.add(rule); + return true; + } else { + return false; + } + } + + /** + * Get an enumerator for the collection + */ + @Override + public Iterator iterator() { + return this.rules.iterator(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleError.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleError.java new file mode 100644 index 000000000..244a4d6f0 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleError.java @@ -0,0 +1,122 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.property.RuleProperty; +import com.eischet.ews.api.core.enumeration.property.error.RuleErrorCode; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Defines the RuleError class. + */ +public final class RuleError extends ComplexProperty { + + /** + * The Rule property. + */ + private RuleProperty ruleProperty; + + /** + * The Rule validation error code. + */ + private RuleErrorCode errorCode; + + /** + * The Error message. + */ + private String errorMessage; + + /** + * The Field value. + */ + private String value; + + /** + * The Initializes a new instance of the RuleError class. + */ + protected RuleError() { + super(); + } + + /** + * Gets the property which failed validation. + * + * @return ruleProperty + */ + public RuleProperty getRuleProperty() { + return this.ruleProperty; + } + + /** + * Gets the validation error code. + * + * @return ruleProperty + */ + public RuleErrorCode getErrorCode() { + return this.errorCode; + } + + /** + * Gets the error message. + * + * @return ruleProperty + */ + public String getErrorMessage() { + return this.errorMessage; + } + + /** + * Gets the value that failed validation. + */ + public String getValue() { + return this.value; + } + + /** + * Tries to read element from XML. + * + * @param reader The reader + * @return True if element was read + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.FieldURI)) { + this.ruleProperty = reader.readElementValue(RuleProperty.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.ErrorCode)) { + this.errorCode = reader.readElementValue(RuleErrorCode.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.ErrorMessage)) { + this.errorMessage = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.FieldValue)) { + this.value = reader.readElementValue(); + return true; + } else { + return false; + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleErrorCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleErrorCollection.java new file mode 100644 index 000000000..d73039d8b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleErrorCollection.java @@ -0,0 +1,70 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.XmlElementNames; + +/** + * Represents a collection of rule validation errors. + */ +public final class RuleErrorCollection extends ComplexPropertyCollection { + + /** + * Initializes a new instance of the RuleErrorCollection class. + */ + protected RuleErrorCollection() { + super(); + } + + /** + * Creates an RuleError object from an XML element name. + * + * @param xmlElementName The XML element name from + * which to create the RuleError object. + * @return A RuleError object. + */ + @Override + protected RuleError createComplexProperty(String xmlElementName) { + if (xmlElementName.equals(XmlElementNames.Error)) { + return new RuleError(); + } else { + return null; + } + } + + /** + * Retrieves the XML element name corresponding + * to the provided RuleError object. + * + * @param ruleValidationError The RuleError object from which + * to determine the XML element name. + * @return The XML element name corresponding + * to the provided RuleError object. + */ + @Override + protected String getCollectionItemXmlElementName(RuleError + ruleValidationError) { + return XmlElementNames.Error; + } +} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleOperation.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleOperation.java similarity index 76% rename from src/main/java/microsoft/exchange/webservices/data/property/complex/RuleOperation.java rename to ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleOperation.java index c8ee0167a..1054d5ac0 100644 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleOperation.java +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleOperation.java @@ -21,25 +21,25 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; /** * Represents an operation to be performed on a rule. */ public abstract class RuleOperation extends ComplexProperty { - protected String xmlElementName; + protected String xmlElementName; - /** - * Initializes a new instance of the class. - */ - protected RuleOperation() { - super(); - } + /** + * Initializes a new instance of the class. + */ + protected RuleOperation() { + super(); + } - /** - * Gets the XML element name of the rule operation. - */ - public String getXmlElementName() { - return this.xmlElementName; - } + /** + * Gets the XML element name of the rule operation. + */ + public String getXmlElementName() { + return this.xmlElementName; + } } diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleOperationError.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleOperationError.java new file mode 100644 index 000000000..a2d953d65 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleOperationError.java @@ -0,0 +1,131 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.misc.ArgumentOutOfRangeException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.util.Iterator; + +/** + * Defines the RuleOperationError class. + */ +public final class RuleOperationError extends ComplexProperty implements Iterable { + /** + * Index of the operation mapping to the error. + */ + private int operationIndex; + + /** + * RuleOperation object mapping to the error. + */ + private RuleOperation operation; + + /** + * RuleError Collection. + */ + private RuleErrorCollection ruleErrors; + + /** + * Initializes a new instance of the RuleOperationError class. + */ + protected RuleOperationError() { + super(); + } + + /** + * Gets the operation that resulted in an error. + * + * @return operation + */ + public RuleOperation getOperation() { + return this.operation; + } + + /** + * Gets the number of rule errors in the list. + * + * @return count + */ + public int getCount() { + return this.ruleErrors.getCount(); + } + + /** + * Gets the rule error at the specified index. + * + * @return Index + * @throws ArgumentOutOfRangeException + */ + public RuleError getRuleError(int index) + throws ArgumentOutOfRangeException { + if (index < 0 || index >= this.getCount()) { + throw new ArgumentOutOfRangeException("index"); + } + + return this.ruleErrors.getPropertyAtIndex(index); + + } + + + /** + * Tries to read element from XML. + * + * @return true + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.OperationIndex)) { + this.operationIndex = reader.readElementValue(Integer.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.ValidationErrors)) { + this.ruleErrors = new RuleErrorCollection(); + this.ruleErrors.loadFromXml(reader, reader.getLocalName()); + return true; + } else { + return false; + } + } + + /** + * Set operation property by the index of a given opeation enumerator. + */ + public void setOperationByIndex(Iterator operations) { + for (int i = 0; i <= this.operationIndex; i++) { + operations.next(); + } + this.operation = operations.next(); + } + + /** + * Gets an iterator that iterates through the elements of the collection. + * + * @return An Iterator for the collection. + */ + public Iterator iterator() { + return this.ruleErrors.iterator(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleOperationErrorCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleOperationErrorCollection.java new file mode 100644 index 000000000..100480d00 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RuleOperationErrorCollection.java @@ -0,0 +1,71 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.XmlElementNames; + +/** + * Represents a collection of rule operation errors. + */ +public final class RuleOperationErrorCollection extends ComplexPropertyCollection { + + /** + * Initializes a new instance of the + * class. + */ + public RuleOperationErrorCollection() { + super(); + } + + /** + * Creates an RuleOperationError object from an XML element name. + * + * @param xmlElementName The XML element name from which + * to create the RuleOperationError object. + * @return A RuleOperationError object. + */ + @Override + protected RuleOperationError createComplexProperty(String xmlElementName) { + if (xmlElementName.equals(XmlElementNames.RuleOperationError)) { + return new RuleOperationError(); + } else { + return null; + } + } + + /** + * Retrieves the XML element name corresponding + * to the provided RuleOperationError object. + * + * @param operationError The RuleOperationError object + * from which to determine the XML element name. + * @return The XML element name corresponding + * to the provided RuleOperationError object. + */ + @Override + protected String getCollectionItemXmlElementName(RuleOperationError + operationError) { + return XmlElementNames.RuleOperationError; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/RulePredicateDateRange.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RulePredicateDateRange.java new file mode 100644 index 000000000..9fb869404 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RulePredicateDateRange.java @@ -0,0 +1,133 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.time.LocalDateTime; + +/** + * Represents the date and time range within which messages have been received. + */ +public final class RulePredicateDateRange extends ComplexProperty { + + /** + * The end DateTime. + */ + private LocalDateTime start; + + /** + * The end DateTime. + */ + private LocalDateTime end; + + /** + * Initializes a new instance of the RulePredicateDateRange class. + */ + protected RulePredicateDateRange() { + super(); + } + + /** + * Gets or sets the range start date and time. + * If Start is set to null, no start date applies. + */ + public LocalDateTime getStart() { + return this.start; + } + + public void setStart(LocalDateTime value) { + if (this.canSetFieldValue(this.start, value)) { + this.start = value; + this.changed(); + } + } + + /** + * Gets or sets the range end date and time. + * If End is set to null, no end date applies. + */ + public LocalDateTime getEnd() { + return this.end; + } + + public void setEnd(LocalDateTime value) { + if (this.canSetFieldValue(this.end, value)) { + this.end = value; + this.changed(); + } + } + + /** + * Tries to read element from XML. + * + * @param reader The reader. + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.StartDateTime)) { + this.start = reader.readElementValueAsDateTime(); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.EndDateTime)) { + this.end = reader.readElementValueAsDateTime(); + return true; + } else { + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (this.getStart() != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.StartDateTime, this.getStart()); + } + if (this.getEnd() != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.EndDateTime, this.getEnd()); + } + } + + /** + * Validates this instance. + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + if (this.start != null && this.end != null && this.start.isAfter(this.end)) { + throw new ExchangeValidationException("Start date time cannot be bigger than end date time."); + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/RulePredicateSizeRange.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RulePredicateSizeRange.java new file mode 100644 index 000000000..c207b341d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RulePredicateSizeRange.java @@ -0,0 +1,141 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents the minimum and maximum size of a message. + */ +public final class RulePredicateSizeRange extends ComplexProperty { + /** + * Minimum Size. + */ + private Integer minimumSize; + + /** + * Mamixmum Size. + */ + private Integer maximumSize; + + /** + * Initializes a new instance of the RulePredicateSizeRange class. + */ + protected RulePredicateSizeRange() { + super(); + } + + /** + * Gets or sets the minimum size, in kilobytes. + * If MinimumSize is set to null, no minimum size applies. + */ + public Integer getMinimumSize() { + + return this.minimumSize; + } + + public void setMinimumSize(Integer value) { + if (this.canSetFieldValue(this.minimumSize, value)) { + this.minimumSize = value; + this.changed(); + } + } + + /** + * Gets or sets the maximum size, in kilobytes. + * If MaximumSize is set to null, no maximum size applies. + */ + public Integer getMaximumSize() { + return this.maximumSize; + } + + public void setMaximumSize(Integer value) { + if (this.canSetFieldValue(this.maximumSize, value)) { + this.maximumSize = value; + this.changed(); + } + + } + + + /** + * Tries to read element from XML. + * + * @param reader The reader. + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.MinimumSize)) { + this.minimumSize = reader.readElementValue(Integer.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.MaximumSize)) { + this.maximumSize = reader.readElementValue(Integer.class); + return true; + } else { + return false; + } + + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (this.getMinimumSize() != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.MinimumSize, this.getMinimumSize()); + } + if (this.getMaximumSize() != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.MaximumSize, this.getMaximumSize()); + } + } + + /** + * Validates this instance. + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + if (this.minimumSize != null && + this.maximumSize != null && + this.minimumSize > this.maximumSize) { + throw new ExchangeValidationException( + "MinimumSize cannot be larger than MaximumSize."); + } + } +} + + + diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/RulePredicates.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RulePredicates.java new file mode 100644 index 000000000..1b571c1c2 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/RulePredicates.java @@ -0,0 +1,1052 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.FlaggedForAction; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.Importance; +import com.eischet.ews.api.core.enumeration.property.Sensitivity; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents the set of conditions and exception available for a rule. + */ +public final class RulePredicates extends ComplexProperty { + + /** + * The HasCategories predicate. + */ + private final StringList categories; + + /** + * The ContainsBodyStrings predicate. + */ + private final StringList containsBodyStrings; + /** + * The ContainsHeaderStrings predicate. + */ + private final StringList containsHeaderStrings; + + /** + * The ContainsRecipientStrings predicate. + */ + private final StringList containsRecipientStrings; + + /** + * The ContainsSenderStrings predicate. + */ + private final StringList containsSenderStrings; + + /** + * The ContainsSubjectOrBodyStrings predicate. + */ + private final StringList containsSubjectOrBodyStrings; + + /** + * The ContainsSubjectStrings predicate. + */ + private final StringList containsSubjectStrings; + + /** + * The FlaggedForAction predicate. + */ + private FlaggedForAction flaggedForAction; + + /** + * The FromAddresses predicate. + */ + private final EmailAddressCollection fromAddresses; + + /** + * The FromConnectedAccounts predicate. + */ + private final StringList fromConnectedAccounts; + + /** + * The HasAttachments predicate. + */ + private boolean hasAttachments; + + /** + * The Importance predicate. + */ + private Importance importance; + + /** + * The IsApprovalRequest predicate. + */ + private boolean isApprovalRequest; + + /** + * The IsAutomaticForward predicate. + */ + private boolean isAutomaticForward; + + /** + * The IsAutomaticReply predicate. + */ + private boolean isAutomaticReply; + + /** + * The IsEncrypted predicate. + */ + private boolean isEncrypted; + + /** + * The IsMeetingRequest predicate. + */ + private boolean isMeetingRequest; + + /** + * The IsMeetingResponse predicate. + */ + private boolean isMeetingResponse; + + /** + * The IsNDR predicate. + */ + private boolean isNonDeliveryReport; + + /** + * The IsPermissionControlled predicate. + */ + private boolean isPermissionControlled; + + /** + * The IsSigned predicate. + */ + private boolean isSigned; + + /** + * The IsVoicemail predicate. + */ + private boolean isVoicemail; + + /** + * The IsReadReceipt predicate. + */ + private boolean isReadReceipt; + + /** + * ItemClasses predicate. + */ + private final StringList itemClasses; + + /** + * The MessageClassifications predicate. + */ + private final StringList messageClassifications; + + /** + * The NotSentToMe predicate. + */ + private boolean notSentToMe; + + /** + * SentCcMe predicate. + */ + private boolean sentCcMe; + + /** + * The SentOnlyToMe predicate. + */ + private boolean sentOnlyToMe; + + /** + * The SentToAddresses predicate. + */ + private final EmailAddressCollection sentToAddresses; + + /** + * The SentToMe predicate. + */ + private boolean sentToMe; + + /** + * The SentToOrCcMe predicate. + */ + private boolean sentToOrCcMe; + + /** + * The Sensitivity predicate. + */ + private Sensitivity sensitivity; + + /** + * The Sensitivity predicate. + */ + private final RulePredicateDateRange withinDateRange; + + /** + * The Sensitivity predicate. + */ + private final RulePredicateSizeRange withinSizeRange; + + /** + * Initializes a new instance of the RulePredicates class. + */ + protected RulePredicates() { + super(); + this.categories = new StringList(); + this.containsBodyStrings = new StringList(); + this.containsHeaderStrings = new StringList(); + this.containsRecipientStrings = new StringList(); + this.containsSenderStrings = new StringList(); + this.containsSubjectOrBodyStrings = new StringList(); + this.containsSubjectStrings = new StringList(); + this.fromAddresses = + new EmailAddressCollection(XmlElementNames.Address); + this.fromConnectedAccounts = new StringList(); + this.itemClasses = new StringList(); + this.messageClassifications = new StringList(); + this.sentToAddresses = + new EmailAddressCollection(XmlElementNames.Address); + this.withinDateRange = new RulePredicateDateRange(); + this.withinSizeRange = new RulePredicateSizeRange(); + } + + /** + * Gets the categories that an incoming message + * should be stamped with for the condition or exception to apply. + * To disable this predicate, empty the list. + */ + public StringList getCategories() { + return this.categories; + } + + /** + * Gets the strings that should appear in the body of + * incoming messages for the condition or exception to apply. + * To disable this predicate, empty the list. + */ + public StringList getContainsBodyStrings() { + return this.containsBodyStrings; + } + + /** + * Gets the strings that should appear in the + * headers of incoming messages for the condition or + * exception to apply. To disable this predicate, empty the list. + */ + public StringList getContainsHeaderStrings() { + return this.containsHeaderStrings; + } + + /** + * Gets the strings that should appear in either the + * To or Cc fields of incoming messages for the condition + * or exception to apply. To disable this predicate, empty the list. + */ + public StringList getContainsRecipientStrings() { + return this.containsRecipientStrings; + } + + /** + * Gets the strings that should appear + * in the From field of incoming messages + * for the condition or exception to apply. + * To disable this predicate, empty the list. + */ + public StringList getContainsSenderStrings() { + return this.containsSenderStrings; + } + + /** + * Gets the strings that should appear in either + * the body or the subject of incoming messages for the + * condition or exception to apply. + * To disable this predicate, empty the list. + */ + public StringList getContainsSubjectOrBodyStrings() { + return this.containsSubjectOrBodyStrings; + } + + /** + * Gets the strings that should appear in the subject + * of incoming messages for the condition or exception + * to apply. To disable this predicate, empty the list. + */ + public StringList getContainsSubjectStrings() { + return this.containsSubjectStrings; + } + + /** + * Gets or sets the flag for action value that should + * appear on incoming messages for the condition or execption to apply. + * To disable this predicate, set it to null. + */ + public FlaggedForAction getFlaggedForAction() { + + return this.flaggedForAction; + } + + public void setFlaggedForAction(FlaggedForAction value) { + if (this.canSetFieldValue(this.flaggedForAction, value)) { + this.flaggedForAction = value; + this.changed(); + } + } + + /** + * Gets the e-mail addresses of the senders of incoming + * messages for the condition or exception to apply. + * To disable this predicate, empty the list. + */ + public EmailAddressCollection getFromAddresses() { + return this.fromAddresses; + } + + /** + * Gets or sets a value indicating whether incoming messages must have + * attachments for the condition or exception to apply. + */ + public boolean getHasAttachments() { + return this.hasAttachments; + } + + public void setHasAttachments(boolean value) { + if (this.canSetFieldValue(this.hasAttachments, value)) { + this.hasAttachments = value; + this.changed(); + } + } + + /** + * Gets or sets the importance that should be stamped on incoming messages + * for the condition or exception to apply. + * To disable this predicate, set it to null. + */ + public Importance getImportance() { + return this.importance; + } + + public void setImportance(Importance value) { + if (this.canSetFieldValue(this.importance, value)) { + this.importance = value; + this.changed(); + } + } + + /** + * Gets or sets a value indicating whether incoming messages must be + * approval request for the condition or exception to apply. + */ + public boolean getIsApprovalRequest() { + return this.isApprovalRequest; + } + + public void setIsApprovalRequest(boolean value) { + if (this.canSetFieldValue(this.isApprovalRequest, value)) { + + this.isApprovalRequest = value; + this.changed(); + } + } + + /** + * Gets or sets a value indicating whether incoming messages must be + * automatic forwards for the condition or exception to apply. + */ + public boolean getIsAutomaticForward() { + return this.isAutomaticForward; + } + + public void setIsAutomaticForward(boolean value) { + if (this.canSetFieldValue(this.isAutomaticForward, value)) { + this.isAutomaticForward = value; + this.changed(); + } + } + + /** + * Gets or sets a value indicating whether incoming messages must be + * automatic replies for the condition or exception to apply. + */ + public boolean getIsAutomaticReply() { + return this.isAutomaticReply; + } + + public void setIsAutomaticReply(boolean value) { + if (this.canSetFieldValue(this.isAutomaticReply, value)) { + this.isAutomaticReply = value; + this.changed(); + } + } + + + /** + * Gets or sets a value indicating whether incoming messages must be + * S/MIME encrypted for the condition or exception to apply. + */ + public boolean getIsEncrypted() { + return this.isEncrypted; + } + + public void setIsEncrypted(boolean value) { + if (this.canSetFieldValue(this.isEncrypted, value)) { + this.isEncrypted = value; + this.changed(); + } + } + + /** + * Gets or sets a value indicating whether incoming messages must be + * meeting request for the condition or exception to apply. + */ + public boolean getIsMeetingRequest() { + return this.isMeetingRequest; + } + + public void setIsMeetingRequest(boolean value) { + // original pull request for ews-java-api: https://github.com/OfficeDev/ews-java-api/pull/586/commits/1b299312dcdd9adbd9d8af306ea187634476bcb2 + if (this.canSetFieldValue(this.isMeetingRequest, value)) { + + this.isMeetingRequest = value; + this.changed(); + } + + } + + + /** + * Gets or sets a value indicating whether incoming messages must be + * meeting response for the condition or exception to apply. + */ + public boolean getIsMeetingResponse() { + + return this.isMeetingResponse; + } + + public void setIsMeetingResponse(boolean value) { + if (this.canSetFieldValue(this.isMeetingResponse, value)) { + this.isMeetingResponse = value; + this.changed(); + } + } + + /** + * Gets or sets a value indicating whether incoming messages must be + * non-delivery reports (NDR) for the condition or exception to apply. + */ + public boolean getIsNonDeliveryReport() { + return this.isNonDeliveryReport; + } + + public void setIsNonDeliveryReport(boolean value) { + if (this.canSetFieldValue(this.isNonDeliveryReport, value)) { + this.isNonDeliveryReport = value; + this.changed(); + } + } + + /** + * Gets or sets a value indicating whether incoming messages must be + * permission controlled (RMS protected) for the condition or exception + * to apply. + */ + public boolean getIsPermissionControlled() { + return this.isPermissionControlled; + } + + public void setIsPermissionControlled(boolean value) { + if (this.canSetFieldValue(this.isPermissionControlled, value)) { + this.isPermissionControlled = value; + this.changed(); + } + } + + + /** + * Gets or sets a value indicating whether incoming messages must be + * S/MIME signed for the condition or exception to apply. + */ + public boolean getIsSigned() { + return this.isSigned; + } + + public void setIsSigned(boolean value) { + if (this.canSetFieldValue(this.isSigned, value)) { + this.isSigned = value; + this.changed(); + } + } + + + /** + * Gets or sets a value indicating whether incoming messages must be + * voice mails for the condition or exception to apply. + */ + public boolean getIsVoicemail() { + return this.isVoicemail; + } + + public void setIsVoicemail(boolean value) { + if (this.canSetFieldValue(this.isVoicemail, value)) { + this.isVoicemail = value; + this.changed(); + } + } + + + /** + * Gets or sets a value indicating whether incoming messages must be + * read receipts for the condition or exception to apply. + */ + public boolean getIsReadReceipt() { + return this.isReadReceipt; + } + + public void setIsReadReceipt(boolean value) { + if (this.canSetFieldValue(this.isReadReceipt, value)) { + this.isReadReceipt = value; + this.changed(); + } + } + + /** + * Gets the e-mail account names from which incoming messages must have + * been aggregated for the condition or exception to apply. To disable + * this predicate, empty the list. + */ + public StringList getFromConnectedAccounts() { + return this.fromConnectedAccounts; + } + + /** + * Gets the item classes that must be stamped on incoming messages for + * the condition or exception to apply. To disable this predicate, + * empty the list. + */ + public StringList getItemClasses() { + return this.itemClasses; + } + + /** + * Gets the message classifications that + * must be stamped on incoming messages + * for the condition or exception to apply. To disable this predicate, + * empty the list. + */ + public StringList getMessageClassifications() { + + return this.messageClassifications; + + } + + /** + * Gets or sets a value indicating whether the owner of the mailbox must + * NOT be a To recipient of the incoming messages for the condition or + * exception to apply. + */ + + public boolean getNotSentToMe() { + return this.notSentToMe; + } + + public void setNotSentToMe(boolean value) { + if (this.canSetFieldValue(this.notSentToMe, value)) { + this.notSentToMe = value; + this.changed(); + } + } + + + /** + * Gets or sets a value indicating whether the owner of the mailbox must be + * a Cc recipient of incoming messages + * for the condition or exception to apply. + */ + public boolean getSentCcMe() { + return this.sentCcMe; + } + + public void setSentCcMe(boolean value) { + if (this.canSetFieldValue(this.sentCcMe, value)) { + this.sentCcMe = value; + this.changed(); + } + } + + + /** + * Gets or sets a value indicating whether the owner of the mailbox must be + * the only To recipient of incoming + * messages for the condition or exception + * to apply. + */ + public boolean getSentOnlyToMe() { + return this.sentOnlyToMe; + } + + public void setSentOnlyToMe(boolean value) { + if (this.canSetFieldValue(this.sentOnlyToMe, value)) { + this.sentOnlyToMe = value; + this.changed(); + } + } + + + /** + * Gets the e-mail addresses incoming messages must have been sent to for + * the condition or exception to apply. To disable this predicate, empty + * the list. + */ + public EmailAddressCollection getSentToAddresses() { + return this.sentToAddresses; + + } + + /** + * Gets or sets a value indicating whether the owner of the mailbox must be + * a To recipient of incoming messages + * for the condition or exception to apply. + */ + public boolean getSentToMe() { + return this.sentToMe; + } + + public void setSentToMe(boolean value) { + if (this.canSetFieldValue(this.sentToMe, value)) { + this.sentToMe = value; + this.changed(); + } + } + + + /** + * Gets or sets a value indicating whether the owner of the mailbox must be + * either a To or Cc recipient of incoming messages for the condition or + * exception to apply. + */ + public boolean getSentToOrCcMe() { + return this.sentToOrCcMe; + } + + public void setSentToOrCcMe(boolean value) { + if (this.canSetFieldValue(this.sentToOrCcMe, value)) { + this.sentToOrCcMe = value; + this.changed(); + } + } + + + /** + * Gets or sets the sensitivity that must be stamped on incoming messages + * for the condition or exception to apply. + * To disable this predicate, set it + * to null. + */ + public Sensitivity getSensitivity() { + return this.sensitivity; + } + + public void setSensitivity(Sensitivity value) { + if (this.canSetFieldValue(this.sensitivity, value)) { + this.sensitivity = value; + this.changed(); + } + } + + /** + * Gets the date range within which + * incoming messages must have been received + * for the condition or exception to apply. + * To disable this predicate, set both + * its Start and End property to null. + */ + public RulePredicateDateRange getWithinDateRange() { + return this.withinDateRange; + + } + + /** + * Gets the minimum and maximum sizes incoming messages must have for the + * condition or exception to apply. To disable this predicate, set both its + * MinimumSize and MaximumSize property to null. + */ + public RulePredicateSizeRange getWithinSizeRange() { + return this.withinSizeRange; + + } + + /** + * Tries to read element from XML. + * + * @param reader The reader + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Categories)) { + this.categories.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsBodyStrings)) { + this.containsBodyStrings.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsHeaderStrings)) { + this.containsHeaderStrings.loadFromXml(reader, + reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsRecipientStrings)) { + this.containsRecipientStrings.loadFromXml(reader, + reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsSenderStrings)) { + this.containsSenderStrings.loadFromXml(reader, + reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsSubjectOrBodyStrings)) { + this.containsSubjectOrBodyStrings.loadFromXml(reader, + reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsSubjectStrings)) { + this.containsSubjectStrings.loadFromXml(reader, + reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.FlaggedForAction)) { + this.flaggedForAction = reader. + readElementValue(FlaggedForAction.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.FromAddresses)) { + this.fromAddresses.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.FromConnectedAccounts)) { + this.fromConnectedAccounts.loadFromXml(reader, + reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.HasAttachments)) { + this.hasAttachments = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Importance)) { + this.importance = reader.readElementValue(Importance.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsApprovalRequest)) { + this.isApprovalRequest = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsAutomaticForward)) { + this.isAutomaticForward = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsAutomaticReply)) { + this.isAutomaticReply = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsEncrypted)) { + this.isEncrypted = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsMeetingRequest)) { + this.isMeetingRequest = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsMeetingResponse)) { + this.isMeetingResponse = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsNDR)) { + this.isNonDeliveryReport = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsPermissionControlled)) { + this.isPermissionControlled = reader. + readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsSigned)) { + this.isSigned = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsVoicemail)) { + this.isVoicemail = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsReadReceipt)) { + this.isReadReceipt = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ItemClasses)) { + this.itemClasses.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.MessageClassifications)) { + this.messageClassifications.loadFromXml(reader, + reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.NotSentToMe)) { + this.notSentToMe = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentCcMe)) { + this.sentCcMe = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentOnlyToMe)) { + this.sentOnlyToMe = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentToAddresses)) { + this.sentToAddresses.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentToMe)) { + this.sentToMe = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentToOrCcMe)) { + this.sentToOrCcMe = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Sensitivity)) { + this.sensitivity = reader.readElementValue(Sensitivity.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.WithinDateRange)) { + this.withinDateRange.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.WithinSizeRange)) { + this.withinSizeRange.loadFromXml(reader, reader.getLocalName()); + return true; + } else { + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer The writer. + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (this.getCategories().getSize() > 0) { + this.getCategories().writeToXml(writer, XmlElementNames.Categories); + } + + if (this.getContainsBodyStrings().getSize() > 0) { + this.getContainsBodyStrings().writeToXml(writer, + XmlElementNames.ContainsBodyStrings); + } + + if (this.getContainsHeaderStrings().getSize() > 0) { + this.getContainsHeaderStrings().writeToXml(writer, + XmlElementNames.ContainsHeaderStrings); + } + + if (this.getContainsRecipientStrings().getSize() > 0) { + this.getContainsRecipientStrings().writeToXml(writer, + XmlElementNames.ContainsRecipientStrings); + } + + if (this.getContainsSenderStrings().getSize() > 0) { + this.getContainsSenderStrings().writeToXml(writer, + XmlElementNames.ContainsSenderStrings); + } + + if (this.getContainsSubjectOrBodyStrings().getSize() > 0) { + this.getContainsSubjectOrBodyStrings().writeToXml(writer, + XmlElementNames.ContainsSubjectOrBodyStrings); + } + + if (this.getContainsSubjectStrings().getSize() > 0) { + this.getContainsSubjectStrings().writeToXml(writer, + XmlElementNames.ContainsSubjectStrings); + } + + if (this.getFlaggedForAction() != null) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.FlaggedForAction, + FlaggedForAction.values()); + } + + if (this.getFromAddresses().getCount() > 0) { + this.getFromAddresses().writeToXml(writer, + XmlElementNames.FromAddresses); + } + + if (this.getFromConnectedAccounts().getSize() > 0) { + this.getFromConnectedAccounts().writeToXml(writer, + XmlElementNames.FromConnectedAccounts); + } + + if (this.getHasAttachments() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.HasAttachments, + this.getHasAttachments()); + } + + if (this.getImportance() != null) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.Importance, + this.getImportance()); + } + + if (this.getIsApprovalRequest() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsApprovalRequest, + this.getIsApprovalRequest()); + } + + if (this.getIsAutomaticForward() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsAutomaticForward, + this.getIsAutomaticForward()); + } + + if (this.getIsAutomaticReply() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsAutomaticReply, + this.getIsAutomaticReply()); + } + + if (this.getIsEncrypted() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsEncrypted, + this.getIsEncrypted()); + } + + if (this.getIsMeetingRequest() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsMeetingRequest, + this.getIsMeetingRequest()); + } + + if (this.getIsMeetingResponse() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsMeetingResponse, + this.getIsMeetingResponse()); + } + + if (this.getIsNonDeliveryReport() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsNDR, + this.getIsNonDeliveryReport()); + } + + if (this.getIsPermissionControlled() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsPermissionControlled, + this.getIsPermissionControlled()); + } + + if (this.getIsReadReceipt() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsReadReceipt, + this.getIsReadReceipt()); + } + + if (this.getIsSigned() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsSigned, + this.getIsSigned()); + } + + if (this.getIsVoicemail() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.IsVoicemail, + this.getIsVoicemail()); + } + + if (this.getItemClasses().getSize() > 0) { + this.getItemClasses().writeToXml(writer, + XmlElementNames.ItemClasses); + } + + if (this.getMessageClassifications().getSize() > 0) { + this.getMessageClassifications().writeToXml(writer, + XmlElementNames.MessageClassifications); + } + + if (this.getNotSentToMe() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.NotSentToMe, + this.getNotSentToMe()); + } + + if (this.getSentCcMe() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.SentCcMe, + this.getSentCcMe()); + } + + if (this.getSentOnlyToMe() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.SentOnlyToMe, + this.getSentOnlyToMe()); + } + + if (this.getSentToAddresses().getCount() > 0) { + this.getSentToAddresses().writeToXml(writer, + XmlElementNames.SentToAddresses); + } + + if (this.getSentToMe() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.SentToMe, + this.getSentToMe()); + } + + if (this.getSentToOrCcMe() != false) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.SentToOrCcMe, + this.getSentToOrCcMe()); + } + + if (this.getSensitivity() != null) { + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.Sensitivity, + Sensitivity.values()); + } + + if (this.getWithinDateRange().getStart() != null || this.getWithinDateRange().getEnd() != null) { + this.getWithinDateRange().writeToXml(writer, + XmlElementNames.WithinDateRange); + } + + if (this.getWithinSizeRange().getMaximumSize() != null + || this.getWithinSizeRange().getMinimumSize() != null) { + this.getWithinSizeRange().writeToXml(writer, + XmlElementNames.WithinSizeRange); + } + } + + /** + * Validates this instance. + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + EwsUtilities.validateParam(this.fromAddresses, "FromAddresses"); + EwsUtilities.validateParam(this.sentToAddresses, "SentToAddresses"); + EwsUtilities.validateParam(this.withinDateRange, "WithinDateRange"); + EwsUtilities.validateParam(this.withinSizeRange, "WithinSizeRange"); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/SearchFolderParameters.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/SearchFolderParameters.java new file mode 100644 index 000000000..5bcfcdfbc --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/SearchFolderParameters.java @@ -0,0 +1,220 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.search.SearchFolderTraversal; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.search.filter.SearchFilter; + +/** + * Represents the parameters associated with a search folder. + */ +public final class SearchFolderParameters extends ComplexProperty implements IComplexPropertyChangedDelegate { + + /** + * The traversal. + */ + private SearchFolderTraversal traversal; + + /** + * The root folder ids. + */ + private final FolderIdCollection rootFolderIds = new FolderIdCollection(); + + /** + * The search filter. + */ + private SearchFilter searchFilter; + + /** + * Initializes a new instance of the SearchFolderParameters class. + */ + public SearchFolderParameters() { + super(); + this.rootFolderIds.addOnChangeEvent(this); + } + + /** + * Complex property changed. + * + * @param complexProperty the complex property + */ + @Override + public void complexPropertyChanged(ComplexProperty complexProperty) { + this.propertyChanged(complexProperty); + } + + /** + * Property changed. + * + * @param complexProperty the complex property + */ + private void propertyChanged(ComplexProperty complexProperty) { + this.changed(); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.BaseFolderIds)) { + this.rootFolderIds.internalClear(); + this.rootFolderIds.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.Restriction)) { + reader.read(); + this.searchFilter = SearchFilter.loadFromXml(reader); + return true; + } else { + return false; + } + } + + /** + * Reads the attribute from XML. + * + * @param reader the reader + */ + @Override + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.traversal = reader.readAttributeValue(SearchFolderTraversal.class, XmlAttributeNames.Traversal); + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.Traversal, this.traversal); + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (this.searchFilter != null) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.Restriction); + this.searchFilter.writeToXml(writer); + writer.writeEndElement(); // Restriction + } + + this.rootFolderIds.writeToXml(writer, XmlElementNames.BaseFolderIds); + } + + /** + * Validates this instance. + * + */ + public void validate() throws ExchangeValidationException { + // Search folder must have at least one root folder id. + if (this.rootFolderIds.getCount() == 0) { + throw new ExchangeValidationException("SearchParameters must contain at least one folder id."); + } + + // Validate the search filter + if (this.searchFilter != null) { + this.searchFilter.internalValidate(); + } + } + + /** + * Gets the traversal mode for the search folder. + * + * @return the traversal + */ + public SearchFolderTraversal getTraversal() { + return traversal; + } + + /** + * Sets the traversal. + * + * @param traversal the new traversal + */ + public void setTraversal(SearchFolderTraversal traversal) { + if (this.canSetFieldValue(this.traversal, traversal)) { + this.traversal = traversal; + this.changed(); + } + } + + /** + * Gets the list of root folder the search folder searches in. + * + * @return the root folder ids + */ + public FolderIdCollection getRootFolderIds() { + return rootFolderIds; + } + + /** + * Gets the search filter associated with the search folder. + * Available search filter classes include SearchFilter.IsEqualTo, + * SearchFilter.ContainsSubstring and SearchFilter.SearchFilterCollection. + * + * @return the search filter + */ + public SearchFilter getSearchFilter() { + return searchFilter; + } + + /** + * Sets the search filter. + * + * @param searchFilter the new search filter + */ + public void setSearchFilter(SearchFilter searchFilter) { + + if (this.searchFilter != null) { + this.searchFilter.removeChangeEvent(this); + } + + if (this.canSetFieldValue(this.searchFilter, searchFilter)) { + this.searchFilter = searchFilter; + this.changed(); + } + if (this.searchFilter != null) { + this.searchFilter.addOnChangeEvent(this); + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/ServiceId.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ServiceId.java new file mode 100644 index 000000000..bf9a16360 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/ServiceId.java @@ -0,0 +1,208 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.util.Objects; + +/** + * Represents the Id of an Exchange object. + */ +public abstract class ServiceId extends ComplexProperty { + + /** + * The change key. + */ + private String changeKey; + + /** + * The unique id. + */ + private String uniqueId; + + /** + * Initializes a new instance. + */ + public ServiceId() { + super(); + } + + /** + * Initializes a new instance. + * + * @param uniqueId The unique id. + */ + public ServiceId(String uniqueId) throws ExchangeXmlException { + this(); + EwsUtilities.validateParam(uniqueId, "uniqueId"); + this.uniqueId = uniqueId; + } + + /** + * Read attribute from XML. + * + * @param reader The reader. + */ + @Override + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.uniqueId = reader.readAttributeValue(XmlAttributeNames.Id); + this.changeKey = reader.readAttributeValue(XmlAttributeNames.ChangeKey); + + } + + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.Id, this.getUniqueId()); + writer.writeAttributeValue(XmlAttributeNames.ChangeKey, this.getChangeKey()); + } + + public abstract String getXmlElementName(); + + public void writeToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.writeToXml(writer, this.getXmlElementName()); + } + + /** + * Assigns from existing id. + * + * @param source The source. + */ + public void assign(ServiceId source) { + this.uniqueId = source.getUniqueId(); + this.changeKey = source.getChangeKey(); + } + + /** + * True if this instance is valid, false otherthise. + * + * @return true if this instance is valid; otherwise,false + */ + public boolean isValid() { + return (null != this.uniqueId && !this.uniqueId.isEmpty()); + } + + /** + * Gets the unique Id of the Exchange object. + * + * @return unique Id of the Exchange object. + */ + public String getUniqueId() { + return uniqueId; + } + + /** + * Sets the unique Id of the Exchange object. + * + * @param uniqueId unique Id of the Exchange object. + */ + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } + + /** + * Gets the change key associated with the Exchange object. The change key + * represents the version of the associated item or folder. + * + * @return change key associated with the Exchange object. + */ + public String getChangeKey() { + return changeKey; + } + + /** + * Sets the change key associated with the Exchange object. The change key + * represents the version of the associated item or folder. + * + * @param changeKey change key associated with the Exchange object. + */ + public void setChangeKey(String changeKey) { + this.changeKey = changeKey; + } + + /** + * Determines whether two ServiceId instances are equal (including + * ChangeKeys). + * + * @param other The ServiceId to compare with the current ServiceId. + * @return true if equal otherwise false. + */ + public boolean sameIdAndChangeKey(final ServiceId other) { + return this.equals(other) && Objects.equals(this.getChangeKey(), other.getChangeKey()); + } + + /** + * Determines whether the specified instance is equal to the current + * instance. We do not consider the ChangeKey for ServiceId.Equals. + * + * @param obj The object to compare with the current instance + * @return true if the specified object is equal to the current instance, + * otherwise, false. + */ + @Override + public boolean equals(Object obj) { + if (super.equals(obj)) { + return true; + } else { + if (!(obj instanceof ServiceId)) { + return false; + } else { + ServiceId other = (ServiceId) obj; + if (!(this.isValid() && other.isValid())) { + return false; + } else { + return this.getUniqueId().equals(other.getUniqueId()); + } + } + } + } + + /** + * Serves as a hash function for a particular type. We do not consider the + * change key in the hash code computation. + * + * @return A hash code for the current + */ + @Override + public int hashCode() { + return this.isValid() ? this.getUniqueId().hashCode() : super + .hashCode(); + } + + /** + * Returns a string that represents the current instance. + * + * @return A string that represents the current instance. + */ + @Override + public String toString() { + return (this.uniqueId == null) ? "" : this.uniqueId; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/SetRuleOperation.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/SetRuleOperation.java new file mode 100644 index 000000000..dc831ea98 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/SetRuleOperation.java @@ -0,0 +1,120 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents an operation to update an existing rule. + */ +public class SetRuleOperation extends RuleOperation { + /** + * Inbox rule to be updated. + */ + private Rule rule; + + /** + * Initializes a new instance of the SetRuleOperation class. + */ + public SetRuleOperation() { + super(); + } + + /** + * Initializes a new instance of the SetRuleOperation class. + * + * @param rule The rule + * The inbox rule to update. + */ + public SetRuleOperation(Rule rule) { + super(); + this.rule = rule; + } + + /** + * Gets the rule to be updated. + */ + public Rule getRule() { + return this.rule; + } + + /** + * Sets the rule to be updated. + */ + public void setRule(Rule value) { + if (this.canSetFieldValue(this.rule, value)) { + this.rule = value; + this.changed(); + } + } + + /** + * Tries to read element from XML. + * + * @param reader The reader + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.Rule)) { + this.rule = new Rule(); + this.rule.loadFromXml(reader, reader.getLocalName()); + return true; + } else { + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer The writer. + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.rule.writeToXml(writer, XmlElementNames.Rule); + } + + /** + * Validates this instance. + * + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + EwsUtilities.validateParam(this.rule, "Rule"); + } + + /** + * Gets the Xml element name of the SetRuleOperation object. + */ + @Override + public String getXmlElementName() { + return XmlElementNames.SetRuleOperation; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/StringList.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/StringList.java new file mode 100644 index 000000000..e4ad7608f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/StringList.java @@ -0,0 +1,340 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import javax.xml.stream.XMLStreamException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Represents a list of strings. + */ +public class StringList extends ComplexProperty implements Iterable { + + /** + * The item. + */ + private final List items = new ArrayList<>(); + + /** + * The item xml element name. + */ + private String itemXmlElementName = XmlElementNames.String; + + /** + * Initializes a new instance of the "StringList" class. + */ + public StringList() { + } + + /** + * Initializes a new instance of the class. + * + * @param strings The strings. + */ + public StringList(Iterable strings) { + this.addRange(strings); + } + + /** + * Initializes a new instance of the "StringList" class. + * + * @param itemXmlElementName Name of the item XML element. + */ + public StringList(String itemXmlElementName) { + this.itemXmlElementName = itemXmlElementName; + } + + /** + * Tries to read element from XML. + * + * @param reader accepts EwsServiceXmlReader + * @return True if element was read + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + boolean returnValue = false; + if (reader.getLocalName().equals(this.itemXmlElementName)) { + if (!reader.isEmptyElement()) { + this.add(reader.readValue()); + returnValue = true; + } else { + reader.read(); + + returnValue = true; + } + + } + return returnValue; + } + + /** + * Writes elements to XML. + * + * @param writer accepts EwsServiceXmlWriter + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + for (String item : this.items) { + writer.writeStartElement(XmlNamespace.Types, this.itemXmlElementName); + writer.writeValue(item, this.itemXmlElementName); + writer.writeEndElement(); + } + } + + /** + * Adds a string to the list. + * + * @param s The string to add. + */ + public void add(String s) { + this.items.add(s); + this.changed(); + } + + /** + * Adds multiple strings to the list. + * + * @param strings The strings to add. + */ + public void addRange(Iterable strings) { + boolean changed = false; + + for (String s : strings) { + if (!this.contains(s)) { + this.items.add(s); + changed = true; + } + } + if (changed) { + this.changed(); + } + } + + /** + * Determines whether the list contains a specific string. + * + * @param s The string to check the presence of. + * @return True if s is present in the list, false otherwise. + */ + public boolean contains(String s) { + return this.items.contains(s); + } + + /** + * Removes a string from the list. + * + * @param s The string to remove. + * @return True is s was removed, false otherwise. + */ + public boolean remove(String s) { + boolean result = this.items.remove(s); + if (result) { + this.changed(); + } + return result; + } + + /** + * Removes the string at the specified position from the list. + * + * @param index The index of the string to remove. + */ + public void removeAt(int index) { + if (index < 0 || index >= this.getSize()) { + throw new ArrayIndexOutOfBoundsException("index is out of range."); + } + this.items.remove(index); + this.changed(); + } + + /** + * Clears the list. + */ + public void clearList() { + this.items.clear(); + this.changed(); + } + + /** + * Returns a string representation of the object. In general, the + * toString method returns a string that "textually represents" + * this object. The result should be a concise but informative + * representation that is easy for a person to read. It is recommended that + * all subclasses override this method. + *

+ * The toString method for class Object returns a + * string consisting of the name of the class of which the object is an + * instance, the at-sign character `@', and the unsigned + * hexadecimal representation of the hash code of the object. In other + * words, this method returns a string equal to the value of:

+ *

+ *

+     * getClass().getName() + '@' + Integer.toHexString(hashCode())
+     * 
+ *

+ *

+ * + * @return a string representation of the object. + */ + @Override + public String toString() { + StringBuffer temp = new StringBuffer(); + for (String str : this.items) { + temp.append(str.concat(",")); + } + String tempString = temp.toString(); + return tempString; + } + + /** + * Gets the number of strings in the list. + * + * @return the size + */ + public int getSize() { + return this.items.size(); + } + + /** + * Gets the string at the specified index. + * + * @param index The index of the string to get or set. + * @return The string at the specified index. + */ + public String getString(int index) { + if (index < 0 || index >= this.getSize()) { + throw new ArrayIndexOutOfBoundsException("index is out of range."); + } + return this.items.get(index); + } + + /** + * Sets the string at the specified index. + * + * @param index The index + * @param object The object. + */ + public void setString(int index, Object object) { + if (index < 0 || index >= this.getSize()) { + throw new ArrayIndexOutOfBoundsException("index is out of range."); + } + + if (this.items.get(index) != object) { + this.items.set(index, (String) object); + this.changed(); + } + } + + /** + * Gets an iterator that iterates through the elements of the collection. + * + * @return An Iterator for the collection. + */ + public Iterator getIterator() { + return this.items.iterator(); + } + + /** + * Indicates whether some other object is "equal to" this one. + *

+ * The equals method implements an equivalence relation on + * non-null object references: + *

    + *
  • It is reflexive: for any non-null reference value + * x, x.equals(x) should return true. + *
  • It is symmetric: for any non-null reference values + * x and y, x.equals(y) should return + * true if and only if y.equals(x) returns + * true. + *
  • It is transitive: for any non-null reference values + * x, y, and z, if + * x.equals(y) returns true and + * y.equals(z) returns true, then + * x.equals(z) should return true. + *
  • It is consistent: for any non-null reference values + * x and y, multiple invocations of + * x.equals(y) consistently return true or + * consistently return false, provided no information used in + * equals comparisons on the objects is modified. + *
  • For any non-null reference value x, + * x.equals(null) should return false. + *
+ *

+ * The equals method for class Object implements the + * most discriminating possible equivalence relation on objects; that is, + * for any non-null reference values x and y, this + * method returns true if and only if x and + * y refer to the same object (x == y has the + * value true). + *

+ * Note that it is generally necessary to override the hashCode + * method whenever this method is overridden, so as to maintain the general + * contract for the hashCode method, which states that equal + * objects must have equal hash codes. + * + * @param obj the reference object with which to compare. + * @return if this object is the same as the obj argument; otherwise. + * @see #hashCode() + * @see java.util.Hashtable + */ + @Override + public boolean equals(Object obj) { + if (obj instanceof StringList) { + StringList other = (StringList) obj; + return this.toString().equals(other.toString()); + } else { + return false; + } + } + + /** + * Serves as a hash function for a particular type. + * + * @return A hash code for the current "T:System.Object". + */ + @Override + public int hashCode() { + return this.toString().hashCode(); + } + + /** + * Returns an iterator over a set of elements of type T. + * + * @return an Iterator. + */ + @Override + public Iterator iterator() { + return items.iterator(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/TimeChange.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/TimeChange.java new file mode 100644 index 000000000..43eec33b8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/TimeChange.java @@ -0,0 +1,270 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.Time; +import com.eischet.ews.api.misc.TimeSpan; +import com.eischet.ews.api.util.DateTimeUtils; + +import java.time.LocalDateTime; +import java.util.logging.Logger; + +/** + * Represents a change of time for a time zone. + */ +public final class TimeChange extends ComplexProperty { + + /** + * The time zone name. + */ + private String timeZoneName; + + /** + * The offset. + */ + private TimeSpan offset; + + /** + * The time. + */ + private Time time; + + /** + * The absolute date. + */ + private LocalDateTime absoluteDate; + + /** + * The recurrence. + */ + private TimeChangeRecurrence recurrence; + + /** + * Initializes a new instance of the "TimeChange" class. + */ + public TimeChange() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param offset The offset since the beginning of the year when the change + * occurs. + */ + public TimeChange(TimeSpan offset) { + this(); + this.offset = offset; + } + + /** + * Initializes a new instance of the "TimeChange" class. + * + * @param offset The offset since the beginning of the year when the change + * occurs. + * @param time The time at which the change occurs. + */ + public TimeChange(TimeSpan offset, Time time) { + this(offset); + this.time = time; + } + + /** + * Gets the name of the associated time zone. + * + * @return the timeZoneName + */ + public String getTimeZoneName() { + return timeZoneName; + } + + /** + * Sets the name of the associated time zone. + * + * @param timeZoneName the timeZoneName to set + */ + public void setTimeZoneName(String timeZoneName) { + this.timeZoneName = timeZoneName; + } + + /** + * Gets the offset since the beginning of the year when the change occurs. + * + * @return the offset + */ + public TimeSpan getOffset() { + return offset; + } + + /** + * Sets the offset since the beginning of the year when the change occurs. + * + * @param offset the offset to set + */ + public void setOffset(TimeSpan offset) { + this.offset = offset; + } + + /** + * Gets the time. + * + * @return the time + */ + public Time getTime() { + return time; + } + + /** + * Sets the time. + * + * @param time the time to set + */ + public void setTime(Time time) { + this.time = time; + } + + /** + * Gets the absolute date. + * + * @return the absoluteDate + */ + public LocalDateTime getAbsoluteDate() { + return absoluteDate; + } + + /** + * Sets the absolute date. + * + * @param absoluteDate the absoluteDate to set + */ + public void setAbsoluteDate(LocalDateTime absoluteDate) { + this.absoluteDate = absoluteDate; + if (absoluteDate != null) { + this.recurrence = null; + } + } + + /** + * Gets the recurrence. + * + * @return the recurrence + */ + public TimeChangeRecurrence getRecurrence() { + return recurrence; + } + + /** + * Sets the recurrence. + * + * @param recurrence the recurrence to set + */ + public void setRecurrence(TimeChangeRecurrence recurrence) { + this.recurrence = recurrence; + if (this.recurrence != null) { + this.absoluteDate = null; + } + } + + /** + * Tries to read element from XML. + * + * @param reader accepts EwsServiceXmlReader + * @return True if element was read + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Offset)) { + this.offset = EwsUtilities.getXSDurationToTimeSpan(reader.readElementValue()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.RelativeYearlyRecurrence)) { + this.recurrence = new TimeChangeRecurrence(); + this.recurrence.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.AbsoluteDate)) { + this.absoluteDate = DateTimeUtils.parseDateTime(reader.readElementValue()); + return true; + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Time)) { + this.time = new Time(DateTimeUtils.parseTime(reader.readElementValue())); + // Calendar cal = DatatypeConverter.parseTime(reader.readElementValue()); + // this.time = new Time(cal.getTime()); + return true; + } else { + return false; + } + } + + /** + * Reads the attribute from XML. + * + * @param reader accepts EwsServiceXmlReader + */ + @Override + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.timeZoneName = reader.readAttributeValue(XmlAttributeNames.TimeZoneName); + } + + /** + * Writes the attribute to XML. + * + * @param writer accepts EwsServiceXmlWriter + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.TimeZoneName, this.timeZoneName); + } + + /** + * Writes elements to XML. + * + * @param writer accepts EwsServiceXmlWriter + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (this.offset != null) { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Offset, EwsUtilities.getTimeSpanToXSDuration(this.getOffset())); + } + + if (this.recurrence != null) { + this.recurrence.writeToXml(writer, + XmlElementNames.RelativeYearlyRecurrence); + } + + if (this.absoluteDate != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.AbsoluteDate, EwsUtilities + .dateTimeToXSDate(this.getAbsoluteDate())); + } + + if (this.time != null) { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Time, + this.getTime().toXSTime()); + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/TimeChangeRecurrence.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/TimeChangeRecurrence.java new file mode 100644 index 000000000..077cc1ccd --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/TimeChangeRecurrence.java @@ -0,0 +1,187 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.time.DayOfTheWeek; +import com.eischet.ews.api.core.enumeration.property.time.DayOfTheWeekIndex; +import com.eischet.ews.api.core.enumeration.property.time.Month; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents a recurrence pattern for a time change in a time zone. + */ +final class TimeChangeRecurrence extends ComplexProperty { + + /** + * The day of the week. + */ + private DayOfTheWeek dayOfTheWeek; + + /** + * The day of the week index. + */ + private DayOfTheWeekIndex dayOfTheWeekIndex; + + /** + * The month. + */ + private Month month; + + /** + * Initializes a new instance of the TimeChangeRecurrence class. + */ + public TimeChangeRecurrence() { + super(); + } + + /** + * Initializes a new instance of the TimeChangeRecurrence class. + * + * @param dayOfTheWeekIndex the day of the week index + * @param dayOfTheWeek the day of the week + * @param month the month + */ + public TimeChangeRecurrence(DayOfTheWeekIndex dayOfTheWeekIndex, + DayOfTheWeek dayOfTheWeek, Month month) { + this(); + this.dayOfTheWeekIndex = dayOfTheWeekIndex; + this.dayOfTheWeek = dayOfTheWeek; + this.month = month; + } + + /** + * Gets the day of the week the time change occurs. + * + * @return the day of the week + */ + public DayOfTheWeek getDayOfTheWeek() { + return dayOfTheWeek; + } + + /** + * Sets the day of the week. + * + * @param dayOfTheWeek the new day of the week + */ + public void setDayOfTheWeek(DayOfTheWeek dayOfTheWeek) { + if (this.canSetFieldValue(this.dayOfTheWeek, dayOfTheWeek)) { + this.dayOfTheWeek = dayOfTheWeek; + this.changed(); + } + } + + /** + * Gets the index of the day in the month at which the time change + * occurs. + * + * @return the day of the week index + */ + public DayOfTheWeekIndex getDayOfTheWeekIndex() { + return dayOfTheWeekIndex; + } + + /** + * Sets the day of the week index. + * + * @param dayOfTheWeekIndex the new day of the week index + */ + public void setDayOfTheWeekIndex(DayOfTheWeekIndex dayOfTheWeekIndex) { + if (this.canSetFieldValue(this.dayOfTheWeekIndex, dayOfTheWeekIndex)) { + this.dayOfTheWeekIndex = dayOfTheWeekIndex; + this.changed(); + } + } + + /** + * Gets the month the time change occurs. + * + * @return the month + */ + public Month getMonth() { + return month; + } + + /** + * Sets the month. + * + * @param month the new month + */ + public void setMonth(Month month) { + if (this.canSetFieldValue(this.month, month)) { + this.month = month; + this.changed(); + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (this.dayOfTheWeek != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.DaysOfWeek, this.dayOfTheWeek); + } + + if (this.dayOfTheWeekIndex != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.DayOfWeekIndex, this.dayOfTheWeekIndex); + } + + if (this.month != null) { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Month, + this.month); + } + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.DaysOfWeek)) { + + this.dayOfTheWeek = reader.readElementValue(DayOfTheWeek.class); + return true; + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.DayOfWeekIndex)) { + this.dayOfTheWeekIndex = reader + .readElementValue(DayOfTheWeekIndex.class); + return true; + } else if (reader.getLocalName() + .equalsIgnoreCase(XmlElementNames.Month)) { + this.month = reader.readElementValue(Month.class); + return true; + } else { + return false; + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/UniqueBody.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/UniqueBody.java new file mode 100644 index 000000000..db8f8e83e --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/UniqueBody.java @@ -0,0 +1,130 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.property.BodyType; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents the body part of an item that is unique to the conversation the + * item is part of. + */ +public final class UniqueBody extends ComplexProperty { + + /** + * The body type. + */ + private BodyType bodyType; + + /** + * The text. + */ + private String text; + + /** + * Initializes a new instance. + */ + public UniqueBody() { + } + + /** + * Defines an implicit conversion of UniqueBody into a string. + * + * @param messageBody the message body + * @return string containing the text of the UniqueBody + * @throws Exception the exception + */ + public static String getStringFromUniqueBody(UniqueBody messageBody) throws Exception { + EwsUtilities.validateParam(messageBody, "messageBody"); + return messageBody.text; + } + + /** + * Reads attribute from XML. + * + * @param reader the reader + */ + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.bodyType = reader.readAttributeValue(BodyType.class, XmlAttributeNames.BodyType); + } + + /** + * Reads attribute from XML. + * + * @param reader the reader + */ + public void readTextValueFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.text = reader.readValue(); + } + + /** + * Writes attributes from XML. + * + * @param writer the writer + */ + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.BodyType, this.bodyType); + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (!(this.text == null || this.text.isEmpty())) { + writer.writeValue(this.text, XmlElementNames.UniqueBody); + } + } + + /** + * Gets the type of the unique body's text. + * + * @return bodytype + */ + public BodyType getBodyType() { + return this.bodyType; + } + + /** + * Gets the text of the unique body. + * + * @return text + */ + public String getText() { + return this.text; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return (this.getText() == null) ? "" : this.getText(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/UserConfigurationDictionary.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/UserConfigurationDictionary.java new file mode 100644 index 000000000..758e12bae --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/UserConfigurationDictionary.java @@ -0,0 +1,665 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.UserConfigurationDictionaryObjectType; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.util.DateTimeUtils; + +import javax.xml.stream.XMLStreamException; +import java.lang.reflect.Array; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.*; +import java.util.Map.Entry; + +/** + * Represents a user configuration's Dictionary property. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public final class UserConfigurationDictionary extends ComplexProperty implements Iterable { + + // TODO: Consider implementing IsDirty mechanism in ComplexProperty. + + /** + * The dictionary. + */ + private final Map dictionary; + + /** + * The is dirty. + */ + private boolean isDirty = false; + + /** + * Initializes a new instance of "UserConfigurationDictionary" class. + */ + public UserConfigurationDictionary() { + super(); + this.dictionary = new HashMap<>(); + } + + /** + * Gets the element with the specified key. + * + * @param key The key of the element to get or set. + * @return The element with the specified key. + */ + public Object getElements(Object key) { + return this.dictionary.get(key); + } + + /** + * Sets the element with the specified key. + * + * @param key The key of the element to get or set + * @param value the value + * @throws Exception the exception + */ + public void setElements(Object key, Object value) throws Exception { + this.validateEntry(key, value); + this.dictionary.put(key, value); + this.changed(); + } + + /** + * Adds an element with the provided key and value to the user configuration + * dictionary. + * + * @param key The object to use as the key of the element to add. + * @param value The object to use as the value of the element to add. + * @throws Exception the exception + */ + public void addElement(Object key, Object value) throws Exception { + this.validateEntry(key, value); + this.dictionary.put(key, value); + this.changed(); + } + + /** + * Determines whether the user configuration dictionary contains an element + * with the specified key. + * + * @param key The key to locate in the user configuration dictionary. + * @return true if the user configuration dictionary contains an element + * with the key; otherwise false. + */ + public boolean containsKey(Object key) { + return this.dictionary.containsKey(key); + } + + /** + * Removes the element with the specified key from the user configuration + * dictionary. + * + * @param key The key of the element to remove. + * @return true if the element is successfully removed; otherwise false. + */ + public boolean remove(Object key) { + boolean isRemoved = false; + if (key != null) { + this.dictionary.remove(key); + isRemoved = true; + } + + if (isRemoved) { + this.changed(); + } + + return isRemoved; + } + + /** + * Gets the value associated with the specified key. + * + * @param key The key whose value to get. + * @param value When this method returns, the value associated with the + * specified key, if the key is found; otherwise, null. + * @return true if the user configuration dictionary contains the key; + * otherwise false. + */ + public boolean tryGetValue(Object key, OutParam value) { + if (this.dictionary.containsKey(key)) { + value.setParam(this.dictionary.get(key)); + return true; + } else { + value.setParam(null); + return false; + } + + } + + /** + * Gets the number of elements in the user configuration dictionary. + * + * @return the count + */ + public int getCount() { + return this.dictionary.size(); + } + + /** + * Removes all item from the user configuration dictionary. + */ + public void clear() { + if (this.dictionary.size() != 0) { + this.dictionary.clear(); + + this.changed(); + } + } + + /** + * Gets the enumerator. + * + * @return the enumerator + */ + + /** + * Returns an enumerator that iterates through + * the user configuration dictionary. + * + * @return An IEnumerator that can be used + * to iterate through the user configuration dictionary. + */ + public Iterator getEnumerator() { + return (this.dictionary.values().iterator()); + } + + /** + * Gets the isDirty flag. + * + * @return the checks if is dirty + */ + public boolean getIsDirty() { + return this.isDirty; + } + + /** + * Sets the isDirty flag. + * + * @param value the new checks if is dirty + */ + public void setIsDirty(boolean value) { + this.isDirty = value; + } + + /** + * Instance was changed. + */ + @Override + public void changed() { + super.changed(); + this.isDirty = true; + } + + /** + * Writes elements to XML. + * + * @param writer accepts EwsServiceXmlWriter + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + EwsUtilities.ewsAssert(writer != null, "UserConfigurationDictionary.WriteElementsToXml", "writer is null"); + Iterator> it = this.dictionary.entrySet().iterator(); + while (it.hasNext()) { + Entry dictionaryEntry = it.next(); + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.DictionaryEntry); + this.writeObjectToXml(writer, XmlElementNames.DictionaryKey, dictionaryEntry.getKey()); + this.writeObjectToXml(writer, XmlElementNames.DictionaryValue, dictionaryEntry.getValue()); + writer.writeEndElement(); + } + } + + /** + * Writes a dictionary object (key or value) to Xml. + * + * @param writer the writer + * @param xmlElementName the Xml element name + * @param dictionaryObject the object to write + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + private void writeObjectToXml(EwsServiceXmlWriter writer, String xmlElementName, Object dictionaryObject) throws ExchangeXmlException { + EwsUtilities.ewsAssert(writer != null, "UserConfigurationDictionary.WriteObjectToXml", "writer is null"); + EwsUtilities.ewsAssert(xmlElementName != null, "UserConfigurationDictionary.WriteObjectToXml", "xmlElementName is null"); + writer.writeStartElement(XmlNamespace.Types, xmlElementName); + + if (dictionaryObject == null) { + EwsUtilities.ewsAssert((!xmlElementName.equals(XmlElementNames.DictionaryKey)), "UserConfigurationDictionary.WriteObjectToXml", "Key is null"); + + writer.writeAttributeValue(EwsUtilities.EwsXmlSchemaInstanceNamespacePrefix, XmlAttributeNames.Nil, EwsUtilities.XSTrue); + } else { + this.writeObjectValueToXml(writer, dictionaryObject); + } + + writer.writeEndElement(); + } + + /** + * Writes a dictionary Object's value to Xml. + * + * @param writer The writer. + * @param dictionaryObject The dictionary object to write.
+ * Object values are either:
+ * an array of strings, an array of bytes (which will be encoded into base64)
+ * or a single value. Single values can be:
+ * - datetime, boolean, byte, int, long, string + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + private void writeObjectValueToXml(final EwsServiceXmlWriter writer, final Object dictionaryObject) throws ExchangeXmlException { + // Preconditions + if (dictionaryObject == null) { + throw new NullPointerException("DictionaryObject must not be null"); + } + if (writer == null) { + throw new NullPointerException("EwsServiceXmlWriter must not be null"); + } + + // Processing + final UserConfigurationDictionaryObjectType dictionaryObjectType; + if (dictionaryObject instanceof String[]) { + dictionaryObjectType = UserConfigurationDictionaryObjectType.StringArray; + this.writeEntryTypeToXml(writer, dictionaryObjectType); + + for (String arrayElement : (String[]) dictionaryObject) { + this.writeEntryValueToXml(writer, arrayElement); + } + } else { + final String valueAsString; + if (dictionaryObject instanceof String) { + dictionaryObjectType = UserConfigurationDictionaryObjectType.String; + valueAsString = String.valueOf(dictionaryObject); + } else if (dictionaryObject instanceof Boolean) { + dictionaryObjectType = UserConfigurationDictionaryObjectType.Boolean; + valueAsString = EwsUtilities.boolToXSBool((Boolean) dictionaryObject); + } else if (dictionaryObject instanceof Byte) { + dictionaryObjectType = UserConfigurationDictionaryObjectType.Byte; + valueAsString = String.valueOf(dictionaryObject); + } else if (dictionaryObject instanceof LocalDateTime) { + dictionaryObjectType = UserConfigurationDictionaryObjectType.DateTime; + valueAsString = writer.getService().convertDateTimeToUniversalDateTimeString((LocalDateTime) dictionaryObject); + } else if (dictionaryObject instanceof LocalDate) { + dictionaryObjectType = UserConfigurationDictionaryObjectType.DateTime; + valueAsString = writer.getService().convertDateTimeToUniversalDateTimeString((LocalDate) dictionaryObject); + } else if (dictionaryObject instanceof Integer) { + // removed unsigned integer because in Java, all types are + // signed, there are no unsigned versions + dictionaryObjectType = UserConfigurationDictionaryObjectType.Integer32; + valueAsString = String.valueOf(dictionaryObject); + } else if (dictionaryObject instanceof Long) { + // removed unsigned integer because in Java, all types are + // signed, there are no unsigned versions + dictionaryObjectType = UserConfigurationDictionaryObjectType.Integer64; + valueAsString = String.valueOf(dictionaryObject); + } else if (dictionaryObject instanceof byte[]) { + dictionaryObjectType = UserConfigurationDictionaryObjectType.ByteArray; + valueAsString = Base64.getMimeEncoder().encodeToString((byte[]) dictionaryObject); + } else if (dictionaryObject instanceof Byte[]) { + dictionaryObjectType = UserConfigurationDictionaryObjectType.ByteArray; + + // cast Byte[] to byte[] + Byte[] from = (Byte[]) dictionaryObject; + byte[] to = new byte[from.length]; + for (int currentIndex = 0; currentIndex < from.length; currentIndex++) { + to[currentIndex] = from[currentIndex]; + } + + valueAsString = Base64.getMimeEncoder().encodeToString(to); + } else { + throw new IllegalArgumentException(String.format("Unsupported type: %s", dictionaryObject.getClass().toString())); + } + this.writeEntryTypeToXml(writer, dictionaryObjectType); + this.writeEntryValueToXml(writer, valueAsString); + } + } + + + /** + * Writes a dictionary entry type to Xml. + * + * @param writer the writer + * @param dictionaryObjectType type to write + */ + private void writeEntryTypeToXml(EwsServiceXmlWriter writer, UserConfigurationDictionaryObjectType dictionaryObjectType) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Type); + writer.writeValue(dictionaryObjectType.toString(), XmlElementNames.Type); + writer.writeEndElement(); + } + + /** + * Writes a dictionary entry value to Xml. + * + * @param writer the writer + * @param value value to write + */ + private void writeEntryValueToXml(EwsServiceXmlWriter writer, String value) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Value); + + // While an entry value can't be null, if the entry is an array, an + // element of the array can be null. + if (value != null) { + writer.writeValue(value, XmlElementNames.Value); + } + + writer.writeEndElement(); + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.ComplexProperty#loadFromXml(microsoft. + * exchange.webservices.EwsServiceXmlReader, + * microsoft.exchange.webservices.XmlNamespace, java.lang.String) + */ + @Override + /** + * Loads this dictionary from the specified reader. + * @param reader The reader. + * @param xmlNamespace The dictionary's XML namespace. + * @param xmlElementName Name of the XML element + * representing the dictionary. + */ public void loadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName) throws ExchangeXmlException { + super.loadFromXml(reader, xmlNamespace, xmlElementName); + + this.isDirty = false; + } + + /** + * Tries to read element from XML. + * + * @param reader The reader. + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(this.getNamespace(), XmlElementNames.DictionaryEntry); + this.loadEntry(reader); + return true; + } + + /** + * Loads an entry, consisting of a key value pair, into this dictionary from + * the specified reader. + * + * @param reader The reader. + * @throws Exception the exception + */ + private void loadEntry(EwsServiceXmlReader reader) throws ExchangeXmlException { + EwsUtilities.ewsAssert(reader != null, "UserConfigurationDictionary.LoadEntry", "reader is null"); + + Object key; + Object value = null; + + // Position at DictionaryKey + reader.readStartElement(this.getNamespace(), XmlElementNames.DictionaryKey); + + key = this.getDictionaryObject(reader); + + // Position at DictionaryValue + reader.readStartElement(this.getNamespace(), XmlElementNames.DictionaryValue); + + String nil = reader.readAttributeValue(XmlNamespace.XmlSchemaInstance, XmlAttributeNames.Nil); + boolean hasValue = (nil == null) || (!nil.getClass().equals(Boolean.TYPE)); + if (hasValue) { + value = this.getDictionaryObject(reader); + } + this.dictionary.put(key, value); + } + + /** + * Extracts a dictionary object (key or entry value) from the specified + * reader. + * + * @param reader The reader. + * @return Dictionary object. + * @throws Exception the exception + */ + private Object getDictionaryObject(EwsServiceXmlReader reader) throws ExchangeXmlException { + EwsUtilities.ewsAssert(reader != null, "UserConfigurationDictionary.loadFromXml", "reader is null"); + UserConfigurationDictionaryObjectType type = this.getObjectType(reader); + List values = this.getObjectValue(reader, type); + return this.constructObject(type, values, reader); + } + + /** + * Extracts a dictionary object (key or entry value) as a string list from + * the specified reader. + * + * @param reader The reader. + * @param type The object type. + * @return String list representing a dictionary object. + * @throws Exception the exception + */ + private List getObjectValue(EwsServiceXmlReader reader, UserConfigurationDictionaryObjectType type) throws ExchangeXmlException { + EwsUtilities.ewsAssert(reader != null, "UserConfigurationDictionary.loadFromXml", "reader is null"); + + List values = new ArrayList<>(); + + reader.readStartElement(this.getNamespace(), XmlElementNames.Value); + + do { + String value = null; + + if (reader.isEmptyElement()) { + // Only string types can be represented with empty values. + if (type.equals(UserConfigurationDictionaryObjectType.String) || type.equals(UserConfigurationDictionaryObjectType.StringArray)) { + value = ""; + } else { + EwsUtilities.ewsAssert(false, "UserConfigurationDictionary." + "GetObjectValue", "Empty element passed for type: " + type); + + } + + } else { + value = reader.readElementValue(); + } + + values.add(value); + reader.read(); // Position at next element or + // DictionaryKey/DictionaryValue end element + } while (reader.isStartElement(this.getNamespace(), XmlElementNames.Value)); + return values; + } + + /** + * Extracts the dictionary object (key or entry value) type from the + * specified reader. + * + * @param reader The reader. + * @return Dictionary object type. + * @throws Exception the exception + */ + private UserConfigurationDictionaryObjectType getObjectType(EwsServiceXmlReader reader) throws ExchangeXmlException { + EwsUtilities.ewsAssert(reader != null, "UserConfigurationDictionary.loadFromXml", "reader is null"); + + reader.readStartElement(this.getNamespace(), XmlElementNames.Type); + + String type = reader.readElementValue(); + return UserConfigurationDictionaryObjectType.valueOf(type); + } + + /** + * Constructs a dictionary object (key or entry value) from the specified + * type and string list. + * + * @param type Object type to construct. + * @param value Value of the dictionary object as a string list + * @param reader The reader. + * @return Dictionary object. + */ + private Object constructObject(UserConfigurationDictionaryObjectType type, List value, EwsServiceXmlReader reader) { + EwsUtilities.ewsAssert(value != null, "UserConfigurationDictionary.ConstructObject", "value is null"); + EwsUtilities.ewsAssert((value.size() == 1 || type == UserConfigurationDictionaryObjectType.StringArray), + + "UserConfigurationDictionary.ConstructObject", "value is array but type is not StringArray"); + EwsUtilities.ewsAssert(reader != null, "UserConfigurationDictionary.ConstructObject", "reader is null"); + + Object dictionaryObject = null; + if (type.equals(UserConfigurationDictionaryObjectType.Boolean)) { + dictionaryObject = Boolean.parseBoolean(value.get(0)); + } else if (type.equals(UserConfigurationDictionaryObjectType.Byte)) { + dictionaryObject = Byte.parseByte(value.get(0)); + } else if (type.equals(UserConfigurationDictionaryObjectType.ByteArray)) { + dictionaryObject = Base64.getDecoder().decode(value.get(0)); + } else if (type.equals(UserConfigurationDictionaryObjectType.DateTime)) { + LocalDateTime dateTime = DateTimeUtils.parseDateTime(value.get(0)); + if (dateTime != null) { + dictionaryObject = dateTime; + } else { + EwsUtilities.ewsAssert(false, "UserConfigurationDictionary.ConstructObject", "DateTime is null"); + } + } else if (type.equals(UserConfigurationDictionaryObjectType.Integer32)) { + dictionaryObject = Integer.parseInt(value.get(0)); + } else if (type.equals(UserConfigurationDictionaryObjectType.Integer64)) { + dictionaryObject = Long.parseLong(value.get(0)); + } else if (type.equals(UserConfigurationDictionaryObjectType.String)) { + dictionaryObject = String.valueOf(value.get(0)); + } else if (type.equals(UserConfigurationDictionaryObjectType.StringArray)) { + dictionaryObject = value.toArray(); + } else if (type.equals(UserConfigurationDictionaryObjectType.UnsignedInteger32)) { + dictionaryObject = Integer.parseInt(value.get(0)); + } else if (type.equals(UserConfigurationDictionaryObjectType.UnsignedInteger64)) { + dictionaryObject = Long.parseLong(value.get(0)); + } else { + EwsUtilities.ewsAssert(false, "UserConfigurationDictionary.ConstructObject", "Type not recognized: " + type); + } + + return dictionaryObject; + } + + /** + * Validates the specified key and value. + * + * @param key The key. + * @param value The diction dictionary entry key.ary entry value. + * @throws Exception the exception + */ + private void validateEntry(Object key, Object value) throws Exception { + this.validateObject(key); + this.validateObject(value); + + } + + /** + * Validates the dictionary object (key or entry value). + * + * @param dictionaryObject Object to validate. + * @throws Exception the exception + */ + private void validateObject(Object dictionaryObject) throws Exception { + // Keys may not be null but we rely on the internal dictionary to throw + // if the key is null. + if (dictionaryObject != null) { + if (dictionaryObject.getClass().isArray()) { + int length = Array.getLength(dictionaryObject); + Class wrapperType = Array.get(dictionaryObject, 0).getClass(); + Object[] newArray = (Object[]) Array.newInstance(wrapperType, length); + for (int i = 0; i < length; i++) { + newArray[i] = Array.get(dictionaryObject, i); + } + this.validateArrayObject(newArray); + } else { + this.validateObjectType(dictionaryObject); + + } + + } else { + throw new NullPointerException(); + } + } + + /** + * Validate the array object. + * + * @param dictionaryObjectAsArray Object to validate + * @throws ServiceLocalException the service local exception + */ + private void validateArrayObject(Object[] dictionaryObjectAsArray) throws ServiceLocalException { + // This logic is based on + // Microsoft.Exchange.Data.Storage.ConfigurationDictionary. + // CheckElementSupportedType(). + // if (dictionaryObjectAsArray is string[]) + + if (dictionaryObjectAsArray instanceof String[]) { + if (dictionaryObjectAsArray.length > 0) { + for (Object arrayElement : dictionaryObjectAsArray) { + if (arrayElement == null) { + throw new ServiceLocalException("The array contains at least one null element."); + } + } + } else { + throw new ServiceLocalException("The array must contain at least one element."); + } + } else if (dictionaryObjectAsArray instanceof Byte[]) { + if (dictionaryObjectAsArray.length <= 0) { + throw new ServiceLocalException("The array must contain at least one element."); + } + } else { + throw new ServiceLocalException(String.format("Objects of type %s can't be added to the dictionary. The following types are supported: string array, byte array, boolean, byte, DateTime, integer, long, string, unsigned integer, and unsigned long.", dictionaryObjectAsArray.getClass())); + } + } + + /** + * Validates the dictionary object type. + * + * @param theObject Object to validate. + * @throws ServiceLocalException the service local exception + */ + private void validateObjectType(Object theObject) throws ServiceLocalException { + // This logic is based on + // Microsoft.Exchange.Data.Storage.ConfigurationDictionary. + // CheckElementSupportedType(). + boolean isValidType = false; + if (theObject != null) { + if (theObject instanceof String || theObject instanceof Boolean || theObject instanceof Byte || theObject instanceof Long || theObject instanceof LocalDateTime || theObject instanceof LocalDate || theObject instanceof Integer) { + isValidType = true; + } + } + + if (!isValidType) { + throw new ServiceLocalException(String.format("Objects of type %s can't be added to the dictionary. The following types are supported: String, Boolean, Byte, Long, LocalDateTime, LocalDate, Integer.", (theObject != null ? theObject.getClass().toString() : "null"))); + } + } + + /* + * (non-Javadoc) + * + * @see java.lang.Iterable#iterator() + */ + @Override + public Iterator iterator() { + return this.dictionary.values().iterator(); + + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/UserId.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/UserId.java new file mode 100644 index 000000000..0583ef941 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/UserId.java @@ -0,0 +1,236 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.StandardUser; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents the Id of a user. + */ +public class UserId extends ComplexProperty { + + /** + * The s id. + */ + private String sID; + + /** + * The primary smtp address. + */ + private String primarySmtpAddress; + + /** + * The display name. + */ + private String displayName; + + /** + * The standard user. + */ + private StandardUser standardUser; + + /** + * Initializes a new instance. + */ + public UserId() { + super(); + } + + /** + * Initializes a new instance. + * + * @param primarySmtpAddress the primary smtp address + */ + public UserId(String primarySmtpAddress) { + + this.primarySmtpAddress = primarySmtpAddress; + } + + /** + * Initializes a new instance. + * + * @param standardUser the standard user + */ + public UserId(StandardUser standardUser) { + this(); + this.standardUser = standardUser; + } + + /** + * Implements an implicit conversion between a string representing a + * primary SMTP address and UserId. + * + * @param primarySmtpAddress the primary smtp address + * @return A UserId initialized with the specified primary SMTP address + */ + public static UserId getUserId(String primarySmtpAddress) { + return new UserId(primarySmtpAddress); + } + + /** + * Implements an implicit conversion between StandardUser and UserId. + * + * @param standardUser the standard user + * @return A UserId initialized with the specified standard user value + */ + public static UserId getUserIdFromStandardUser(StandardUser standardUser) { + return new UserId(standardUser); + } + + /** + * Determines whether this instance is valid. + * + * @return true, if this instance is valid. Else, false + */ + protected boolean isValid() { + return (this.standardUser != null || !(this.primarySmtpAddress == null || this.primarySmtpAddress.isEmpty()) || !(this.sID == null || this.sID.isEmpty())); + } + + /** + * Gets the SID of the user. + * + * @return the sID + */ + public String getSID() { + return this.sID; + } + + /** + * Sets the sID. + * + * @param sID the new sID + */ + public void setSID(String sID) { + if (this.canSetFieldValue(this.sID, sID)) { + this.sID = sID; + this.changed(); + } + } + + /** + * Gets the primary SMTP address or the user. + * + * @return the primary smtp address + */ + public String getPrimarySmtpAddress() { + return this.primarySmtpAddress; + } + + /** + * Sets the primary smtp address. + * + * @param primarySmtpAddress the new primary smtp address + */ + public void setPrimarySmtpAddress(String primarySmtpAddress) { + if (this.canSetFieldValue(this.primarySmtpAddress, primarySmtpAddress)) { + this.primarySmtpAddress = primarySmtpAddress; + this.changed(); + } + + } + + /** + * Gets the display name of the user. + * + * @return the display name + */ + public String getDisplayName() { + return this.displayName; + } + + /** + * Sets the display name. + * + * @param displayName the new display name + */ + public void setDisplayName(String displayName) { + if (this.canSetFieldValue(this.displayName, displayName)) { + this.displayName = displayName; + this.changed(); + } + } + + /** + * Gets a value indicating which standard user the user + * represents. + * + * @return the standard user + */ + public StandardUser getstandardUser() { + return this.standardUser; + } + + /** + * Sets the standard user. + * + * @param standardUser the new standard user + */ + public void setStandardUser(StandardUser standardUser) { + if (this.canSetFieldValue(this.standardUser, standardUser)) { + this.standardUser = standardUser; + this.changed(); + } + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.SID)) { + this.sID = reader.readValue(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.PrimarySmtpAddress)) { + this.primarySmtpAddress = reader.readValue(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.DisplayName)) { + this.displayName = reader.readValue(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.DistinguishedUser)) { + this.standardUser = reader.readValue(StandardUser.class); + return true; + } else { + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.SID, this.sID); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.PrimarySmtpAddress, this.primarySmtpAddress); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.DisplayName, this.displayName); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.DistinguishedUser, this.standardUser); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/CalendarEvent.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/CalendarEvent.java new file mode 100644 index 000000000..e9841337d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/CalendarEvent.java @@ -0,0 +1,134 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.availability; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.property.LegacyFreeBusyStatus; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; + +import java.time.LocalDateTime; + + +/** + * Represents an event in a calendar. + */ +public final class CalendarEvent extends ComplexProperty { + + /** + * The start time. + */ + private LocalDateTime startTime; + + /** + * The end time. + */ + private LocalDateTime endTime; + + /** + * The free busy status. + */ + private LegacyFreeBusyStatus freeBusyStatus; + + /** + * The details. + */ + private CalendarEventDetails details; + + /** + * Initializes a new instance of the CalendarEvent class. + */ + public CalendarEvent() { + super(); + } + + /** + * Gets the start date and time of the event. + * + * @return the start time + */ + public LocalDateTime getStartTime() { + return startTime; + } + + /** + * Gets the end date and time of the event. + * + * @return the end time + */ + public LocalDateTime getEndTime() { + return endTime; + } + + /** + * Gets the free/busy status associated with the event. + * + * @return the free busy status + */ + public LegacyFreeBusyStatus getFreeBusyStatus() { + return freeBusyStatus; + } + + /** + * Gets the details of the calendar event. Details is null if the user + * requsting them does no have the appropriate rights. + * + * @return the details + */ + public CalendarEventDetails getDetails() { + return details; + } + + /** + * Attempts to read the element at the reader's current position. + * + * @param reader the reader + * @return True if the element was read, false otherwise. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.StartTime)) { + this.startTime = reader + .readElementValueAsUnbiasedDateTimeScopedToServiceTimeZone(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.EndTime)) { + this.endTime = reader + .readElementValueAsUnbiasedDateTimeScopedToServiceTimeZone(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.BusyType)) { + this.freeBusyStatus = reader + .readElementValue(LegacyFreeBusyStatus.class); + return true; + } + if (reader.getLocalName().equals(XmlElementNames.CalendarEventDetails)) { + this.details = new CalendarEventDetails(); + this.details.loadFromXml(reader, reader.getLocalName()); + return true; + } else { + return false; + } + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/CalendarEventDetails.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/CalendarEventDetails.java new file mode 100644 index 000000000..92a5c44a0 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/CalendarEventDetails.java @@ -0,0 +1,196 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.availability; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; + +/** + * Represents the details of a calendar event as returned by the + * GetUserAvailability operation. + */ +public final class CalendarEventDetails extends ComplexProperty { + + /** + * The store id. + */ + private String storeId; + + /** + * The subject. + */ + private String subject; + + /** + * The location. + */ + private String location; + + /** + * The is meeting. + */ + private boolean isMeeting; + + /** + * The is recurring. + */ + private boolean isRecurring; + + /** + * The is exception. + */ + private boolean isException; + + /** + * The is reminder set. + */ + private boolean isReminderSet; + + /** + * The is private. + */ + private boolean isPrivate; + + /** + * Initializes a new instance of the CalendarEventDetails class. + */ + protected CalendarEventDetails() { + super(); + } + + /** + * Attempts to read the element at the reader's current position. + * + * @param reader the reader + * @return True if the element was read, false otherwise. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.ID)) { + this.storeId = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Subject)) { + this.subject = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Location)) { + this.location = reader.readElementValue(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.IsMeeting)) { + this.isMeeting = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.IsRecurring)) { + this.isRecurring = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.IsException)) { + this.isException = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.IsReminderSet)) { + + this.isReminderSet = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.IsPrivate)) { + this.isPrivate = reader.readElementValue(Boolean.class); + return true; + } else { + return false; + } + + } + + /** + * Gets the store Id of the calendar event. + * + * @return the store id + */ + public String getStoreId() { + return this.storeId; + } + + /** + * Gets the subject of the calendar event. + * + * @return the subject + */ + public String getSubject() { + return subject; + } + + /** + * Gets the location of the calendar event. + * + * @return the location + */ + public String getLocation() { + return location; + } + + /** + * Gets a value indicating whether the calendar event is a meeting. + * + * @return true, if is meeting + */ + public boolean isMeeting() { + return isMeeting; + } + + /** + * Gets a value indicating whether the calendar event is recurring. + * + * @return true, if is recurring + */ + public boolean isRecurring() { + return isRecurring; + } + + /** + * Gets a value indicating whether the calendar event is an exception in a + * recurring series. + * + * @return true, if is exception + */ + public boolean isException() { + return isException; + } + + /** + * Gets a value indicating whether the calendar event has a reminder set. + * + * @return true, if is reminder set + */ + public boolean isReminderSet() { + return isReminderSet; + } + + /** + * Gets a value indicating whether the calendar event is private. + * + * @return true, if is private + */ + public boolean isPrivate() { + return isPrivate; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/Conflict.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/Conflict.java new file mode 100644 index 000000000..9874b3109 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/Conflict.java @@ -0,0 +1,177 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.availability; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.property.ConflictType; +import com.eischet.ews.api.core.enumeration.property.LegacyFreeBusyStatus; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; + +/** + * Represents a conflict in a meeting time suggestion. + */ +public final class Conflict extends ComplexProperty { + + /** + * The conflict type. + */ + private final ConflictType conflictType; + + /** + * The number of members. + */ + private int numberOfMembers; + + /** + * The number of members available. + */ + private int numberOfMembersAvailable; + + /** + * The number of members with conflict. + */ + private int numberOfMembersWithConflict; + + /** + * The number of members with no data. + */ + private int numberOfMembersWithNoData; + + /** + * The free busy status. + */ + private LegacyFreeBusyStatus freeBusyStatus; + + /** + * Initializes a new instance of the Conflict class. + * + * @param conflictType the conflict type + */ + protected Conflict(ConflictType conflictType) { + super(); + this.conflictType = conflictType; + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if appropriate element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.NumberOfMembers)) { + this.numberOfMembers = reader.readElementValue(Integer.class); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.NumberOfMembersAvailable)) { + this.numberOfMembersAvailable = reader + .readElementValue(Integer.class); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.NumberOfMembersWithConflict)) { + this.numberOfMembersWithConflict = reader + .readElementValue(Integer.class); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.NumberOfMembersWithNoData)) { + this.numberOfMembersWithNoData = reader + .readElementValue(Integer.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.BusyType)) { + this.freeBusyStatus = reader + .readElementValue(LegacyFreeBusyStatus.class); + return true; + } else { + return false; + } + } + + /** + * Gets the type of the conflict. + * + * @return the conflict type + */ + public ConflictType getConflictType() { + return conflictType; + } + + /** + * Gets the number of users, resources, and rooms in the conflicting group. + * The value of this property is only meaningful when ConflictType is equal + * to ConflictType.GroupConflict. + * + * @return the number of members + */ + public int getNumberOfMembers() { + return numberOfMembers; + } + + /** + * Gets the number of members who are available (whose status is Free) in + * the conflicting group. The value of this property is only meaningful when + * ConflictType is equal to ConflictType.GroupConflict. + * + * @return the number of members available + */ + public int getNumberOfMembersAvailable() { + return numberOfMembersAvailable; + } + + /** + * Gets the number of members who have a conflict (whose status is Busy, OOF + * or Tentative) in the conflicting group. The value of this property is + * only meaningful when ConflictType is equal to ConflictType.GroupConflict. + * + * @return the number of members with conflict + */ + public int getNumberOfMembersWithConflict() { + return numberOfMembersWithConflict; + } + + /** + * Gets the number of members who do not have published free/busy data in + * the conflicting group. The value of this property is only meaningful when + * ConflictType is equal to ConflictType.GroupConflict. + * + * @return the number of members with no data + */ + public int getNumberOfMembersWithNoData() { + return numberOfMembersWithNoData; + } + + /** + * Gets the free/busy status of the conflicting attendee. The value of this + * property is only meaningful when ConflictType is equal to + * ConflictType.IndividualAttendee. + * + * @return the free busy status + */ + public LegacyFreeBusyStatus getFreeBusyStatus() { + return freeBusyStatus; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/OofSettings.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/OofSettings.java new file mode 100644 index 000000000..4707607f5 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/OofSettings.java @@ -0,0 +1,289 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.availability; + +import com.eischet.ews.api.ISelfValidate; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.OofExternalAudience; +import com.eischet.ews.api.core.enumeration.property.OofState; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.availability.OofReply; +import com.eischet.ews.api.misc.availability.TimeWindow; +import com.eischet.ews.api.property.complex.ComplexProperty; + +import javax.xml.stream.XMLStreamException; + +/** + * Represents a user's Out of Office (OOF) settings. + */ +public final class OofSettings extends ComplexProperty implements ISelfValidate { + + /** + * The state. + */ + private OofState state = OofState.Disabled; + + /** + * The external audience. + */ + private OofExternalAudience externalAudience = OofExternalAudience.None; + + /** + * The allow external oof. + */ + private OofExternalAudience allowExternalOof = OofExternalAudience.None; + + /** + * The duration. + */ + private TimeWindow duration; + + /** + * The internal reply. + */ + private OofReply internalReply; + + /** + * The external reply. + */ + private OofReply externalReply; + + /** + * Serializes an OofReply. Emits an empty OofReply in case the one passed in + * is null. + * + * @param oofReply The oof reply + * @param writer The writer + * @param xmlElementName Name of the xml element + */ + private void serializeOofReply(OofReply oofReply, + EwsServiceXmlWriter writer, String xmlElementName) + throws ExchangeXmlException { + if (oofReply != null) { + oofReply.writeToXml(writer, xmlElementName); + } else { + OofReply.writeEmptyReplyToXml(writer, xmlElementName); + } + } + + /** + * Initializes a new instance of OofSettings. + */ + public OofSettings() { + super(); + } + + /** + * Tries to read element from XML. + * + * @param reader The reader + * @return True if appropriate element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.OofState)) { + this.state = reader.readValue(OofState.class); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.ExternalAudience)) { + this.externalAudience = reader.readValue(OofExternalAudience.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Duration)) { + this.duration = new TimeWindow(); + this.duration.loadFromXml(reader); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.InternalReply)) { + this.internalReply = new OofReply(); + this.internalReply.loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.ExternalReply)) { + this.externalReply = new OofReply(); + this.externalReply.loadFromXml(reader, reader.getLocalName()); + return true; + } else { + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer The writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeElementsToXml(writer); + + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.OofState, + this.getState()); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.ExternalAudience, this.getExternalAudience()); + + if (this.getDuration() != null && this.getState() == OofState.Scheduled) { + this.getDuration().writeToXml(writer, XmlElementNames.Duration); + } + + this.serializeOofReply(this.getInternalReply(), writer, + XmlElementNames.InternalReply); + this.serializeOofReply(this.getExternalReply(), writer, + XmlElementNames.ExternalReply); + } + + /** + * Gets the user's OOF state. + * + * @return The user's OOF state. + */ + public OofState getState() { + return state; + } + + /** + * Sets the user's OOF state. + * + * @param state the new state + */ + public void setState(OofState state) { + this.state = state; + } + + /** + * Gets a value indicating who should receive external OOF messages. + * + * @return the external audience + */ + public OofExternalAudience getExternalAudience() { + return externalAudience; + } + + /** + * Sets a value indicating who should receive external OOF messages. + * + * @param externalAudience the new external audience + */ + public void setExternalAudience(OofExternalAudience externalAudience) { + this.externalAudience = externalAudience; + } + + /** + * Gets the duration of the OOF status when State is set to + * OofState.Scheduled. + * + * @return the duration + */ + public TimeWindow getDuration() { + return duration; + } + + /** + * Sets the duration of the OOF status when State is set to + * OofState.Scheduled. + * + * @param duration the new duration + */ + public void setDuration(TimeWindow duration) { + this.duration = duration; + } + + /** + * Gets the OOF response sent other users in the user's domain or trusted + * domain. + * + * @return the internal reply + */ + public OofReply getInternalReply() { + return internalReply; + } + + /** + * Sets the OOF response sent other users in the user's domain or trusted + * domain. + * + * @param internalReply the new internal reply + */ + public void setInternalReply(OofReply internalReply) { + this.internalReply = internalReply; + } + + /** + * Gets the OOF response sent to addresses outside the user's domain or + * trusted domain. + * + * @return the external reply + */ + public OofReply getExternalReply() { + return externalReply; + } + + /** + * Sets the OOF response sent to addresses outside the user's domain or + * trusted domain. + * + * @param externalReply the new external reply + */ + public void setExternalReply(OofReply externalReply) { + this.externalReply = externalReply; + } + + /** + * Gets a value indicating the authorized external OOF notification. + * + * @return the allow external oof + */ + public OofExternalAudience getAllowExternalOof() { + return allowExternalOof; + } + + /** + * Sets a value indicating the authorized external OOF notification. + * + * @param allowExternalOof the new allow external oof + */ + public void setAllowExternalOof(OofExternalAudience allowExternalOof) { + this.allowExternalOof = allowExternalOof; + } + + /** + * Validates this instance. + * + */ + @Override + public void validate() throws ExchangeValidationException { + if (this.getState() == OofState.Scheduled) { + if (this.getDuration() == null) { + throw new ArgumentException("Duration must be specified when State is equal to Scheduled."); + } + EwsUtilities.validateParam(this.getDuration(), "Duration"); + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/Suggestion.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/Suggestion.java new file mode 100644 index 000000000..f59c40074 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/Suggestion.java @@ -0,0 +1,132 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.availability; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.availability.SuggestionQuality; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; +import com.eischet.ews.api.util.DateTimeUtils; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collection; + +/** + * Represents a suggestion for a specific date. + */ +public final class Suggestion extends ComplexProperty { + + /** + * The date. + */ + private LocalDateTime date; + + /** + * The quality. + */ + private SuggestionQuality quality; + + /** + * The time suggestions. + */ + private final Collection timeSuggestions = new ArrayList<>(); + + /** + * Initializes a new instance of the Suggestion class. + */ + public Suggestion() { + super(); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if appropriate element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.Date)) { + this.date = DateTimeUtils.parseDateTime(reader.readElementValue()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.DayQuality)) { + this.quality = reader.readElementValue(SuggestionQuality.class); + return true; + } else if (reader.getLocalName() + .equals(XmlElementNames.SuggestionArray)) { + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.isStartElement(XmlNamespace.Types, + XmlElementNames.Suggestion)) { + TimeSuggestion timeSuggestion = new TimeSuggestion(); + + timeSuggestion.loadFromXml(reader, reader + .getLocalName()); + + this.timeSuggestions.add(timeSuggestion); + } + } while (!reader.isEndElement(XmlNamespace.Types, + XmlElementNames.SuggestionArray)); + } + + return true; + } else { + return false; + } + + } + + /** + * Gets the date and time of the suggestion. + * + * @return the date + */ + public LocalDateTime getDate() { + return date; + } + + /** + * Gets the quality of the suggestion. + * + * @return the quality + */ + public SuggestionQuality getQuality() { + return quality; + } + + /** + * Gets a collection of suggested times within the suggested day. + * + * @return the time suggestions + */ + public Collection getTimeSuggestions() { + return timeSuggestions; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/TimeSuggestion.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/TimeSuggestion.java new file mode 100644 index 000000000..76f00cd4b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/TimeSuggestion.java @@ -0,0 +1,180 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.availability; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.availability.SuggestionQuality; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.ConflictType; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Collection; + +/** + * Represents an availability time suggestion. + */ +public final class TimeSuggestion extends ComplexProperty { + + /** + * The meeting time. + */ + private LocalDateTime meetingTime; + + /** + * The is work time. + */ + private boolean isWorkTime; + + /** + * The quality. + */ + private SuggestionQuality quality; + + /** + * The conflicts. + */ + private final Collection conflicts = new ArrayList(); + + /** + * Initializes a new instance of the TimeSuggestion class. + */ + protected TimeSuggestion() { + super(); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if appropriate element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.MeetingTime)) { + this.meetingTime = reader + .readElementValueAsUnbiasedDateTimeScopedToServiceTimeZone(); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.IsWorkTime)) { + this.isWorkTime = reader.readElementValue(Boolean.class); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.SuggestionQuality)) { + this.quality = reader.readElementValue(SuggestionQuality.class); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.AttendeeConflictDataArray)) { + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.isStartElement()) { + Conflict conflict = null; + + if (reader.getLocalName().equals( + XmlElementNames.UnknownAttendeeConflictData)) { + conflict = new Conflict( + ConflictType.UnknownAttendeeConflict); + } else if (reader + .getLocalName() + .equals( + XmlElementNames. + TooBigGroupAttendeeConflictData)) { + conflict = new Conflict( + ConflictType.GroupTooBigConflict); + } else if (reader.getLocalName().equals( + XmlElementNames. + IndividualAttendeeConflictData)) { + conflict = new Conflict( + ConflictType.IndividualAttendeeConflict); + } else if (reader.getLocalName().equals( + XmlElementNames.GroupAttendeeConflictData)) { + conflict = new Conflict(ConflictType.GroupConflict); + } else { + EwsUtilities + .ewsAssert(false, "TimeSuggestion." + "TryReadElementFromXml", + String.format("The %s element name " + + "does not map " + + "to any AttendeeConflict " + + "descendant.", reader.getLocalName())); + + // The following line to please the compiler + } + conflict.loadFromXml(reader, reader.getLocalName()); + + this.conflicts.add(conflict); + } + } while (!reader.isEndElement(XmlNamespace.Types, + XmlElementNames.AttendeeConflictDataArray)); + } + + return true; + } else { + return false; + } + + } + + /** + * Gets the suggested time. + * + * @return the meeting time + */ + public LocalDateTime getMeetingTime() { + return meetingTime; + } + + /** + * Gets a value indicating whether the suggested time is within working + * hours. + * + * @return true, if is work time + */ + public boolean isWorkTime() { + return isWorkTime; + } + + /** + * Gets the quality of the suggestion. + * + * @return the quality + */ + public SuggestionQuality getQuality() { + return quality; + } + + /** + * Gets a collection of conflicts at the suggested time. + * + * @return the conflicts + */ + public Collection getConflicts() { + return conflicts; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/WorkingHours.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/WorkingHours.java new file mode 100644 index 000000000..9ea49981b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/WorkingHours.java @@ -0,0 +1,177 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.availability; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.time.DayOfTheWeek; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.availability.LegacyAvailabilityTimeZone; +import com.eischet.ews.api.property.complex.ComplexProperty; +import com.eischet.ews.api.property.complex.time.TimeZoneDefinition; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Represents the working hours for a specific time zone. + */ +public final class WorkingHours extends ComplexProperty { + + /** + * The time zone. + */ + private TimeZoneDefinition timeZone; + + /** + * The days of the week. + */ + private final Collection daysOfTheWeek = + new ArrayList(); + + /** + * The start time. + */ + private long startTime; + + /** + * The end time. + */ + private long endTime; + + /** + * Instantiates a new working hours. + */ + public WorkingHours() { + super(); + } + + /** + * Tries to read element from XML. + * + * @param reader accepts EwsServiceXmlReader + * @return True if element was read + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.TimeZone)) { + LegacyAvailabilityTimeZone legacyTimeZone = + new LegacyAvailabilityTimeZone(); + legacyTimeZone.loadFromXml(reader, reader.getLocalName()); + + this.timeZone = legacyTimeZone.toTimeZoneInfo(); + + return true; + } + if (reader.getLocalName().equals(XmlElementNames.WorkingPeriodArray)) { + List workingPeriods = new ArrayList<>(); + + do { + reader.read(); + + if (reader.isStartElement(XmlNamespace.Types, + XmlElementNames.WorkingPeriod)) { + WorkingPeriod workingPeriod = new WorkingPeriod(); + + workingPeriod.loadFromXml(reader, reader.getLocalName()); + + workingPeriods.add(workingPeriod); + } + } while (!reader.isEndElement(XmlNamespace.Types, + XmlElementNames.WorkingPeriodArray)); + + // Availability supports a structure that can technically represent + // different working + // times for each day of the week. This is apparently how the + // information is stored in + // Exchange. However, no client (Outlook, OWA) either will let you + // specify different + // working times for each day of the week, and Outlook won't either + // honor that complex + // structure if it happens to be in Exchange (OWA goes through XSO + // which doesn't either + // honor the structure). + // So here we'll do what Outlook and OWA do: we'll use the start and + // end times of the + // first working period, but we'll use the week days of all the + // periods. + + this.startTime = workingPeriods.get(0).getStartTime(); + this.endTime = workingPeriods.get(0).getEndTime(); + + for (WorkingPeriod workingPeriod : workingPeriods) { + // TODO check: can it possibly be right to ignore the loop var here an instead use the first element? I don't think so, but the API is so obtuse in parts I'm really not sure. + for (DayOfTheWeek dayOfWeek : workingPeriods.get(0).getDaysOfWeek()) { + if (!this.daysOfTheWeek.contains(dayOfWeek)) { + this.daysOfTheWeek.add(dayOfWeek); + } + } + } + + return true; + } else { + return false; + } + + } + + /** + * Gets the time zone to which the working hours apply. + * + * @return the time zone + */ + public TimeZoneDefinition getTimeZone() { + return timeZone; + } + + /** + * Gets the working days of the attendees. + * + * @return the days of the week + */ + public Collection getDaysOfTheWeek() { + return daysOfTheWeek; + } + + /** + * Gets the time of the day the attendee starts working. + * + * @return the start time + */ + public long getStartTime() { + return startTime; + } + + /** + * Gets the time of the day the attendee stops working. + * + * @return the end time + */ + public long getEndTime() { + return endTime; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/WorkingPeriod.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/WorkingPeriod.java new file mode 100644 index 000000000..f0826f2bc --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/availability/WorkingPeriod.java @@ -0,0 +1,115 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.availability; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.property.time.DayOfTheWeek; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a working period. + */ +final class WorkingPeriod extends ComplexProperty { + + /** + * The days of week. + */ + private final List daysOfWeek = new ArrayList(); + + /** + * The start time. + */ + private long startTime; + + /** + * The end time. + */ + private long endTime; + + /** + * Initializes a new instance of the WorkingPeriod class. + */ + protected WorkingPeriod() { + super(); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return true, if successful + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.DayOfWeek)) { + EwsUtilities.parseEnumValueList(DayOfTheWeek.class, this.daysOfWeek, reader.readElementValue(), ' '); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.StartTimeInMinutes)) { + this.startTime = reader.readElementValue(Integer.class); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.EndTimeInMinutes)) { + this.endTime = reader.readElementValue(Integer.class); + return true; + } else { + return false; + } + + } + + /** + * Gets a collection of work days. + * + * @return the days of week + */ + public List getDaysOfWeek() { + return daysOfWeek; + } + + /** + * Gets the start time of the period. + * + * @return the start time + */ + public long getStartTime() { + return startTime; + } + + /** + * Gets the end time of the period. + * + * @return the end time + */ + public long getEndTime() { + return endTime; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/DayOfTheWeekCollection.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/DayOfTheWeekCollection.java new file mode 100644 index 000000000..ed1dd5609 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/DayOfTheWeekCollection.java @@ -0,0 +1,215 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.recurrence; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.time.DayOfTheWeek; +import com.eischet.ews.api.core.exception.misc.ArgumentOutOfRangeException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Represents a collection of DayOfTheWeek values. + */ +public final class DayOfTheWeekCollection extends ComplexProperty implements + Iterable { + + /** + * The item. + */ + private final List items = new ArrayList<>(); + + /** + * Initializes a new instance of the class. + */ + public DayOfTheWeekCollection() { + } + + /** + * Convert to string. + * + * @param separator the separator + * @return String representation of collection. + */ + private String toString(String separator) { + if (this.getCount() == 0) { + return ""; + } else { + // String[] daysOfTheWeekArray = new String[this.getCount()]; + StringBuilder daysOfTheWeekstr = new StringBuilder(); + + for (int i = 0; i < this.getCount(); i++) { + // daysOfTheWeekArray[i] = item.get(i).toString(); + if (daysOfTheWeekstr.length() == 0) { + daysOfTheWeekstr.append(items.get(i).toString()); + } else { + daysOfTheWeekstr.append(separator); + daysOfTheWeekstr.append(items.get(i).toString()); + } + } + + return daysOfTheWeekstr.toString(); + } + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @param xmlElementName Name of the XML element. + */ + public void loadFromXml(EwsServiceXmlReader reader, String xmlElementName) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, + xmlElementName); + EwsUtilities.parseEnumValueList(DayOfTheWeek.class, this.items, reader.readElementValue(), ' '); + } + + /** + * Gets the request version. + * + * @param writer the writer + * @param xmlElementName the xml element name + */ + @Override + public void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) + throws ExchangeXmlException { + String daysOfWeekAsString = this.toString(" "); + + if (!daysOfWeekAsString.isEmpty()) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.DaysOfWeek, daysOfWeekAsString); + } + } + + /** + * Builds string representation of the collection. + * + * @return A comma-delimited string representing the collection. + */ + @Override + public String toString() { + return this.toString(","); + } + + /** + * Adds a day to the collection if it is not already present. + * + * @param dayOfTheWeek The day to add. + */ + public void add(DayOfTheWeek dayOfTheWeek) { + if (!this.items.contains(dayOfTheWeek)) { + this.items.add(dayOfTheWeek); + this.changed(); + } + } + + /** + * Adds multiple days to the collection if they are not already present. + * + * @param daysOfTheWeek The days to add. + */ + public void addRange(Iterator daysOfTheWeek) { + while (daysOfTheWeek.hasNext()) { + this.add(daysOfTheWeek.next()); + } + } + + /** + * Clears the collection. + */ + public void clear() { + if (this.getCount() > 0) { + this.items.clear(); + this.changed(); + } + } + + /** + * Remove a specific day from the collection. + * + * @param dayOfTheWeek the day of the week + * @return True if the day was removed from the collection, false otherwise. + */ + public boolean remove(DayOfTheWeek dayOfTheWeek) { + boolean result = this.items.remove(dayOfTheWeek); + + if (result) { + this.changed(); + } + return result; + } + + /** + * Removes the day at a specific index. + * + * @param index the index + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public void removeAt(int index) throws ArgumentOutOfRangeException { + if (index < 0 || index >= this.getCount()) { + throw new ArgumentOutOfRangeException("index", "index is out of range."); + } + + this.items.remove(index); + this.changed(); + } + + /** + * Gets the DayOfTheWeek at a specific index in the collection. + * + * @param index the index + * @return DayOfTheWeek at index + */ + public DayOfTheWeek getWeekCollectionAtIndex(int index) { + return this.items.get(index); + } + + /** + * Gets the number of days in the collection. + * + * @return the count + */ + public int getCount() { + return this.items.size(); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Iterable#iterator() + */ + @Override + public Iterator iterator() { + return this.items.iterator(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/pattern/Recurrence.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/pattern/Recurrence.java new file mode 100644 index 000000000..edb8a156d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/pattern/Recurrence.java @@ -0,0 +1,1463 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.recurrence.pattern; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.time.DayOfTheWeek; +import com.eischet.ews.api.core.enumeration.property.time.DayOfTheWeekIndex; +import com.eischet.ews.api.core.enumeration.property.time.Month; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.misc.ArgumentOutOfRangeException; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; +import com.eischet.ews.api.property.complex.IComplexPropertyChangedDelegate; +import com.eischet.ews.api.property.complex.recurrence.DayOfTheWeekCollection; +import com.eischet.ews.api.property.complex.recurrence.range.EndDateRecurrenceRange; +import com.eischet.ews.api.property.complex.recurrence.range.NoEndRecurrenceRange; +import com.eischet.ews.api.property.complex.recurrence.range.NumberedRecurrenceRange; +import com.eischet.ews.api.property.complex.recurrence.range.RecurrenceRange; + +import java.time.LocalDate; +import java.util.*; + +/** + * Represents a recurrence pattern, as used by Appointment and Task item. + */ +public abstract class Recurrence extends ComplexProperty { + + /** + * The start date. + */ + private LocalDate startDate; + + /** + * The number of occurrences. + */ + private Integer numberOfOccurrences; + + /** + * The end date. + */ + private LocalDate endDate; + + /** + * Initializes a new instance. + */ + public Recurrence() { + super(); + } + + /** + * Initializes a new instance. + * + * @param startDate the start date + */ + public Recurrence(LocalDate startDate) { + this(); + this.startDate = startDate; + } + + /** + * Gets the name of the XML element. + * + * @return the xml element name + */ + public abstract String getXmlElementName(); + + /** + * Gets a value indicating whether this instance is regeneration pattern. + * + * @return true, if is regeneration pattern + */ + public boolean isRegenerationPattern() { + return false; + } + + /** + * Write property to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public final void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, this.getXmlElementName()); + this.internalWritePropertiesToXml(writer); + writer.writeEndElement(); + + RecurrenceRange range = null; + + if (!this.hasEnd()) { + range = new NoEndRecurrenceRange(this.getStartDate()); + } else if (this.getNumberOfOccurrences() != null) { + range = new NumberedRecurrenceRange(this.startDate, + this.numberOfOccurrences); + } else { + if (this.getEndDate() != null) { + range = new EndDateRecurrenceRange(this.getStartDate(), this + .getEndDate()); + } + } + if (range != null) { + range.writeToXml(writer, range.getXmlElementName()); + } + + } + + /** + * Gets a property value or throw if null. * + * + * @param the generic type + * @param cls the cls + * @param value the value + * @param name the name + * @return Property value + * @throws ExchangeValidationException the service validation exception + */ + public T getFieldValueOrThrowIfNull(Class cls, Object value, String name) throws ExchangeValidationException { + if (value != null) { + return (T) value; + } else { + throw new ExchangeValidationException(String.format("The recurrence pattern's %s property must be specified.", name)); + } + } + + /** + * Gets the date and time when the recurrence start. + * + * @return Date + * @throws ExchangeValidationException the service validation exception + */ + public LocalDate getStartDate() throws ExchangeValidationException { + return this.getFieldValueOrThrowIfNull(LocalDate.class, this.startDate, "StartDate"); + + } + + /** + * sets the date and time when the recurrence start. + * + * @param value the new start date + */ + public void setStartDate(LocalDate value) { + this.startDate = value; + } + + /** + * Gets a value indicating whether the pattern has a fixed number of + * occurrences or an end date. + * + * @return boolean + */ + public boolean hasEnd() { + + return ((this.numberOfOccurrences != null) || (this.endDate != null)); + } + + /** + * Sets up this recurrence so that it never ends. Calling NeverEnds is + * equivalent to setting both NumberOfOccurrences and EndDate to null. + */ + public void neverEnds() { + this.numberOfOccurrences = null; + this.endDate = null; + this.changed(); + } + + /** + * Validates this instance. + * + */ + @Override + public void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + if (this.startDate == null) { + throw new ExchangeValidationException("The recurrence pattern's StartDate property must be specified."); + } + } + + /** + * Gets the number of occurrences after which the recurrence ends. + * Setting NumberOfOccurrences resets EndDate. + * + * @return the number of occurrences + */ + public Integer getNumberOfOccurrences() { + return this.numberOfOccurrences; + } + + /** + * Gets the number of occurrences after which the recurrence ends. + * Setting NumberOfOccurrences resets EndDate. + * + * @param value the new number of occurrences + * @throws ArgumentException the argument exception + */ + public void setNumberOfOccurrences(Integer value) throws ArgumentException { + if (value < 1) { + throw new ArgumentException("NumberOfOccurrences must be greater than 0."); + } + + if (this.canSetFieldValue(this.numberOfOccurrences, value)) { + numberOfOccurrences = value; + this.changed(); + } + + this.endDate = null; + + } + + /** + * Gets the date after which the recurrence ends. Setting EndDate resets + * NumberOfOccurrences. + * + * @return the end date + */ + public LocalDate getEndDate() { + + return this.endDate; + } + + /** + * sets the date after which the recurrence ends. Setting EndDate resets + * NumberOfOccurrences. + * + * @param value the new end date + */ + public void setEndDate(LocalDate value) { + + if (this.canSetFieldValue(this.endDate, value)) { + this.endDate = value; + this.changed(); + } + + this.numberOfOccurrences = null; + + } + + /** + * Represents a recurrence pattern where each occurrence happens a specific + * number of days after the previous one. + */ + public final static class DailyPattern extends IntervalPattern { + + /** + * Gets the name of the XML element. + * + * @return the xml element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.DailyRecurrence; + } + + /** + * Initializes a new instance of the DailyPattern class. + */ + + public DailyPattern() { + super(); + } + + /** + * Initializes a new instance of the DailyPattern class. + * + * @param startDate The date and time when the recurrence starts. + * @param interval The number of days between each occurrence. + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public DailyPattern(LocalDate startDate, int interval) + throws ArgumentOutOfRangeException { + super(startDate, interval); + } + + } + + + /** + * Represents a regeneration pattern, as used with recurring tasks, where + * each occurrence happens a specified number of days after the previous one + * is completed. + */ + + public final static class DailyRegenerationPattern extends IntervalPattern { + + /** + * Initializes a new instance of the DailyRegenerationPattern class. + */ + public DailyRegenerationPattern() { + super(); + } + + /** + * Initializes a new instance of the DailyRegenerationPattern class. + * + * @param startDate The date and time when the recurrence starts. + * @param interval The number of days between each occurrence. + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public DailyRegenerationPattern(LocalDate startDate, int interval) + throws ArgumentOutOfRangeException { + super(startDate, interval); + + } + + /** + * Gets the name of the XML element. + * + * @return the xml element name + */ + public String getXmlElementName() { + return XmlElementNames.DailyRegeneration; + } + + /** + * Gets a value indicating whether this instance is a regeneration + * pattern. + * + * @return true, if is regeneration pattern + */ + public boolean isRegenerationPattern() { + return true; + } + + } + + + /** + * Represents a recurrence pattern where each occurrence happens at a + * specific interval after the previous one. + * [EditorBrowsable(EditorBrowsableState.Never)] + */ + @EditorBrowsable(state = EditorBrowsableState.Never) + public abstract static class IntervalPattern extends Recurrence { + + /** + * The interval. + */ + private int interval = 1; + + /** + * Initializes a new instance of the IntervalPattern class. + */ + public IntervalPattern() { + super(); + } + + /** + * Initializes a new instance of the IntervalPattern class. + * + * @param startDate The date and time when the recurrence starts. + * @param interval The number of days between each occurrence. + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public IntervalPattern(LocalDate startDate, int interval) + throws ArgumentOutOfRangeException { + + super(startDate); + if (interval < 1) { + throw new ArgumentOutOfRangeException("interval", "The interval must be greater than or equal to 1."); + } + + this.setInterval(interval); + } + + /** + * Write property to XML. + * + * @param writer the writer + */ + @Override + public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.internalWritePropertiesToXml(writer); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.Interval, this.getInterval()); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return true, if successful + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (super.tryReadElementFromXml(reader)) { + return true; + } else { + + if (reader.getLocalName().equals(XmlElementNames.Interval)) { + this.interval = reader.readElementValue(Integer.class); + return true; + } else { + return false; + } + } + } + + /** + * Gets the interval between occurrences. + * + * @return the interval + */ + public int getInterval() { + return this.interval; + } + + /** + * Sets the interval. + * + * @param value the new interval + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public void setInterval(int value) throws ArgumentOutOfRangeException { + + if (value < 1) { + throw new ArgumentOutOfRangeException("value", "The interval must be greater than or equal to 1."); + } + + if (this.canSetFieldValue(this.interval, value)) { + this.interval = value; + this.changed(); + } + + } + + } + + + /** + * Represents a recurrence pattern where each occurrence happens on a + * specific day a specific number of months after the previous one. + */ + + public final static class MonthlyPattern extends IntervalPattern { + + /** + * The day of month. + */ + private Integer dayOfMonth; + + /** + * Initializes a new instance of the MonthlyPattern class. + */ + public MonthlyPattern() { + super(); + + } + + /** + * Initializes a new instance of the MonthlyPattern class. + * + * @param startDate the start date + * @param interval the interval + * @param dayOfMonth the day of month + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public MonthlyPattern(LocalDate startDate, int interval, int dayOfMonth) + throws ArgumentOutOfRangeException { + super(startDate, interval); + + this.setDayOfMonth(dayOfMonth); + } + + // / Gets the name of the XML element. + + /* + * (non-Javadoc) + * + * @see microsoft.exchange.webservices.Recurrence#getXmlElementName() + */ + @Override + public String getXmlElementName() { + return XmlElementNames.AbsoluteMonthlyRecurrence; + } + + /** + * Write property to XML. + * + * @param writer the writer + */ + @Override + public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.internalWritePropertiesToXml(writer); + try { + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.DayOfMonth, this.getDayOfMonth()); + } catch (ExchangeValidationException e) { + throw new ExchangeXmlException("invalid day of month " + this.getDayOfMonth(), e); + } + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if appropriate element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (super.tryReadElementFromXml(reader)) { + return true; + } else { + if (reader.getLocalName().equals(XmlElementNames.DayOfMonth)) { + this.dayOfMonth = reader.readElementValue(Integer.class); + return true; + } else { + return false; + } + } + } + + /** + * Validates this instance. + * + */ + @Override + public void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + + if (this.dayOfMonth == null) { + throw new ExchangeValidationException("DayOfMonth must be between 1 and 31."); + } + } + + /** + * Gets the day of month. + * + * @return the day of month + * @throws ExchangeValidationException the service validation exception + */ + public int getDayOfMonth() throws ExchangeValidationException { + return this.getFieldValueOrThrowIfNull(Integer.class, this.dayOfMonth, + "DayOfMonth"); + + } + + /** + * Sets the day of month. + * + * @param value the new day of month + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public void setDayOfMonth(int value) + throws ArgumentOutOfRangeException { + if (value < 1 || value > 31) { + throw new ArgumentOutOfRangeException("DayOfMonth", "DayOfMonth must be between 1 and 31."); + } + + if (this.canSetFieldValue(this.dayOfMonth, value)) { + this.dayOfMonth = value; + this.changed(); + } + } + } + + + /** + * Represents a regeneration pattern, as used with recurring tasks, where + * each occurrence happens a specified number of months after the previous + * one is completed. + */ + public final static class MonthlyRegenerationPattern extends + IntervalPattern { + + /** + * Instantiates a new monthly regeneration pattern. + */ + public MonthlyRegenerationPattern() { + super(); + + } + + /** + * Instantiates a new monthly regeneration pattern. + * + * @param startDate the start date + * @param interval the interval + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public MonthlyRegenerationPattern(LocalDate startDate, int interval) throws ArgumentOutOfRangeException { + super(startDate, interval); + + } + + /** + * Gets the name of the XML element. + * + * @return the xml element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.MonthlyRegeneration; + } + + /** + * Gets a value indicating whether this instance is regeneration + * pattern. + * + * @return true, if is regeneration pattern + */ + public boolean isRegenerationPattern() { + return true; + } + } + + + /** + * Represents a recurrence pattern where each occurrence happens on a + * relative day a specific number of months after the previous one. + */ + public final static class RelativeMonthlyPattern extends IntervalPattern { + + /** + * The day of the week. + */ + private DayOfTheWeek dayOfTheWeek; + + /** + * The day of the week index. + */ + private DayOfTheWeekIndex dayOfTheWeekIndex; + + // / Initializes a new instance of the class. + + /** + * Instantiates a new relative monthly pattern. + */ + public RelativeMonthlyPattern() { + super(); + } + + /** + * Instantiates a new relative monthly pattern. + * + * @param startDate the start date + * @param interval the interval + * @param dayOfTheWeek the day of the week + * @param dayOfTheWeekIndex the day of the week index + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public RelativeMonthlyPattern(LocalDate startDate, int interval, + DayOfTheWeek dayOfTheWeek, DayOfTheWeekIndex dayOfTheWeekIndex) + throws ArgumentOutOfRangeException { + super(startDate, interval); + + this.setDayOfTheWeek(dayOfTheWeek); + this.setDayOfTheWeekIndex(dayOfTheWeekIndex); + } + + /** + * Gets the name of the XML element. + * + * @return the xml element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.RelativeMonthlyRecurrence; + } + + /** + * Write property to XML. + * + * @param writer the writer + */ + @Override + public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.internalWritePropertiesToXml(writer); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.DaysOfWeek, this.getDayOfTheWeek()); + + writer + .writeElementValue(XmlNamespace.Types, + XmlElementNames.DayOfWeekIndex, this + .getDayOfTheWeekIndex()); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if appropriate element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (super.tryReadElementFromXml(reader)) { + return true; + } else { + if (reader.getLocalName().equals(XmlElementNames.DaysOfWeek)) { + + this.dayOfTheWeek = reader + .readElementValue(DayOfTheWeek.class); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.DayOfWeekIndex)) { + + this.dayOfTheWeekIndex = reader + .readElementValue(DayOfTheWeekIndex.class); + return true; + } else { + + return false; + } + } + } + + /** + * Validates this instance. + * + */ + @Override + public void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + + if (this.dayOfTheWeek == null) { + throw new ExchangeValidationException( + "The recurrence pattern's property DayOfTheWeek must be specified."); + } + + if (this.dayOfTheWeekIndex == null) { + throw new ExchangeValidationException( + "The recurrence pattern's DayOfWeekIndex property must be specified."); + } + } + + /** + * Day of the week index. + * + * @return the day of the week index + * @throws ExchangeValidationException the service validation exception + */ + public DayOfTheWeekIndex getDayOfTheWeekIndex() + throws ExchangeValidationException { + return this.getFieldValueOrThrowIfNull(DayOfTheWeekIndex.class, + this.dayOfTheWeekIndex, "DayOfTheWeekIndex"); + } + + /** + * Day of the week index. + * + * @param value the value + */ + public void setDayOfTheWeekIndex(DayOfTheWeekIndex value) { + if (this.canSetFieldValue(this.dayOfTheWeekIndex, value)) { + this.dayOfTheWeekIndex = value; + this.changed(); + } + + } + + /** + * Gets the day of the week. + * + * @return the day of the week + * @throws ExchangeValidationException the service validation exception + */ + public DayOfTheWeek getDayOfTheWeek() throws ExchangeValidationException { + return this.getFieldValueOrThrowIfNull(DayOfTheWeek.class, this.dayOfTheWeek, "DayOfTheWeek"); + + } + + /** + * Sets the day of the week. + * + * @param value the new day of the week + */ + public void setDayOfTheWeek(DayOfTheWeek value) { + + if (this.canSetFieldValue(this.dayOfTheWeek, value)) { + this.dayOfTheWeek = value; + this.changed(); + } + } + } + + + /** + * The Class RelativeYearlyPattern. + */ + public final static class RelativeYearlyPattern extends Recurrence { + + /** + * The day of the week. + */ + private DayOfTheWeek dayOfTheWeek; + + /** + * The day of the week index. + */ + private DayOfTheWeekIndex dayOfTheWeekIndex; + + /** + * The month. + */ + private Month month; + + /** + * Gets the name of the XML element. The name of the XML + * element. + * + * @return the xml element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.RelativeYearlyRecurrence; + } + + /** + * Write property to XML. + * + * @param writer the writer + */ + @Override + public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.internalWritePropertiesToXml(writer); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.DaysOfWeek, this.dayOfTheWeek); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.DayOfWeekIndex, this.dayOfTheWeekIndex); + + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Month, + this.month); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (super.tryReadElementFromXml(reader)) { + return true; + } else { + if (reader.getLocalName().equals(XmlElementNames.DaysOfWeek)) { + + this.dayOfTheWeek = reader + .readElementValue(DayOfTheWeek.class); + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.DayOfWeekIndex)) { + + this.dayOfTheWeekIndex = reader + .readElementValue(DayOfTheWeekIndex.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Month)) { + + this.month = reader.readElementValue(Month.class); + return true; + } else { + + return false; + } + } + } + + /** + * Instantiates a new relative yearly pattern. + */ + public RelativeYearlyPattern() { + super(); + + } + + /** + * Instantiates a new relative yearly pattern. + * + * @param startDate the start date + * @param month the month + * @param dayOfTheWeek the day of the week + * @param dayOfTheWeekIndex the day of the week index + */ + public RelativeYearlyPattern(LocalDate startDate, Month month, + DayOfTheWeek dayOfTheWeek, + DayOfTheWeekIndex dayOfTheWeekIndex) { + super(startDate); + + this.month = month; + this.dayOfTheWeek = dayOfTheWeek; + this.dayOfTheWeekIndex = dayOfTheWeekIndex; + } + + /** + * Validates this instance. + * + */ + @Override + public void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + + if (this.dayOfTheWeekIndex == null) { + throw new ExchangeValidationException( + "The recurrence pattern's DayOfWeekIndex property must be specified."); + } + + if (this.dayOfTheWeek == null) { + throw new ExchangeValidationException( + "The recurrence pattern's property DayOfTheWeek must be specified."); + } + + if (this.month == null) { + throw new ExchangeValidationException("The recurrence pattern's Month property must be specified."); + } + } + + /** + * Gets the relative position of the day specified in DayOfTheWeek + * within the month. + * + * @return the day of the week index + * @throws ExchangeValidationException the service validation exception + */ + public DayOfTheWeekIndex getDayOfTheWeekIndex() + throws ExchangeValidationException { + + return this.getFieldValueOrThrowIfNull(DayOfTheWeekIndex.class, + this.dayOfTheWeekIndex, "DayOfTheWeekIndex"); + } + + /** + * Sets the relative position of the day specified in DayOfTheWeek + * within the month. + * + * @param value the new day of the week index + */ + public void setDayOfTheWeekIndex(DayOfTheWeekIndex value) { + + if (this.canSetFieldValue(this.dayOfTheWeekIndex, value)) { + this.dayOfTheWeekIndex = value; + this.changed(); + } + } + + /** + * Gets the day of the week. + * + * @return the day of the week + * @throws ExchangeValidationException the service validation exception + */ + public DayOfTheWeek getDayOfTheWeek() + throws ExchangeValidationException { + + return this.getFieldValueOrThrowIfNull(DayOfTheWeek.class, + this.dayOfTheWeek, "DayOfTheWeek"); + } + + /** + * Sets the day of the week. + * + * @param value the new day of the week + */ + public void setDayOfTheWeek(DayOfTheWeek value) { + + if (this.canSetFieldValue(this.dayOfTheWeek, value)) { + this.dayOfTheWeek = value; + this.changed(); + } + } + + /** + * Gets the month. + * + * @return the month + * @throws ExchangeValidationException the service validation exception + */ + public Month getMonth() throws ExchangeValidationException { + + return this.getFieldValueOrThrowIfNull(Month.class, this.month, + "Month"); + + } + + /** + * Sets the month. + * + * @param value the new month + */ + public void setMonth(Month value) { + + if (this.canSetFieldValue(this.month, value)) { + this.month = value; + this.changed(); + } + } + } + + + /** + * Represents a recurrence pattern where each occurrence happens on specific + * days a specific number of weeks after the previous one. + */ + public final static class WeeklyPattern extends IntervalPattern implements IComplexPropertyChangedDelegate { + + /** + * The days of the week. + */ + private final DayOfTheWeekCollection daysOfTheWeek = + new DayOfTheWeekCollection(); + + private Calendar firstDayOfWeek; + + /** + * Initializes a new instance of the WeeklyPattern class. specific days + * a specific number of weeks after the previous one. + */ + public WeeklyPattern() { + super(); + + this.daysOfTheWeek.addOnChangeEvent(this); + } + + /** + * Initializes a new instance of the WeeklyPattern class. + * + * @param startDate the start date + * @param interval the interval + * @param daysOfTheWeek the days of the week + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public WeeklyPattern(LocalDate startDate, int interval, + DayOfTheWeek... daysOfTheWeek) + throws ArgumentOutOfRangeException { + super(startDate, interval); + + ArrayList toProcess = new ArrayList( + Arrays.asList(daysOfTheWeek)); + Iterator idaysOfTheWeek = toProcess.iterator(); + this.daysOfTheWeek.addRange(idaysOfTheWeek); + } + + /** + * Change event handler. + * + * @param complexProperty the complex property + */ + private void daysOfTheWeekChanged(ComplexProperty complexProperty) { + this.changed(); + } + + /** + * Gets the name of the XML element. The name of the XML + * element. + * + * @return the xml element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.WeeklyRecurrence; + } + + /** + * Write property to XML. + * + * @param writer the writer + */ + @Override + public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.internalWritePropertiesToXml(writer); + + this.getDaysOfTheWeek().writeToXml(writer, + XmlElementNames.DaysOfWeek); + if (this.firstDayOfWeek != null) { + + EwsUtilities + .validatePropertyVersion((ExchangeService) writer.getService(), ExchangeVersion.Exchange2010_SP1, + "FirstDayOfWeek"); + + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.FirstDayOfWeek, + this.firstDayOfWeek); + } + + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if appropriate element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (super.tryReadElementFromXml(reader)) { + return true; + } else { + if (reader.getLocalName().equals(XmlElementNames.DaysOfWeek)) { + + this.getDaysOfTheWeek().loadFromXml(reader, reader.getLocalName()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.FirstDayOfWeek)) { + this.firstDayOfWeek = reader. + readElementValue(Calendar.class, + XmlNamespace.Types, + XmlElementNames.FirstDayOfWeek); + return true; + } else { + + return false; + } + } + } + + /** + * Validates this instance. + * + */ + @Override + public void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + + if (this.getDaysOfTheWeek().getCount() == 0) { + throw new ExchangeValidationException( + "The recurrence pattern's property DaysOfTheWeek must contain at least one day of the week."); + } + } + + /** + * Gets the list of the days of the week when occurrences happen. + * + * @return the days of the week + */ + public DayOfTheWeekCollection getDaysOfTheWeek() { + return this.daysOfTheWeek; + } + + public Calendar getFirstDayOfWeek() throws ExchangeValidationException { + return this.getFieldValueOrThrowIfNull(Calendar.class, + this.firstDayOfWeek, "FirstDayOfWeek"); + } + + public void setFirstDayOfWeek(Calendar value) { + if (this.canSetFieldValue(this.firstDayOfWeek, value)) { + this.firstDayOfWeek = value; + this.changed(); + } + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices. + * ComplexPropertyChangedDelegateInterface# + * complexPropertyChanged(microsoft.exchange.webservices.ComplexProperty + * ) + */ + @Override + public void complexPropertyChanged(ComplexProperty complexProperty) { + this.daysOfTheWeekChanged(complexProperty); + } + + } + + + /** + * Represents a regeneration pattern, as used with recurring tasks, where + * each occurrence happens a specified number of weeks after the previous + * one is completed. + */ + public final static class WeeklyRegenerationPattern extends IntervalPattern { + + /** + * Initializes a new instance of the WeeklyRegenerationPattern class. + */ + public WeeklyRegenerationPattern() { + + super(); + } + + /** + * Initializes a new instance of the WeeklyRegenerationPattern class. + * + * @param startDate the start date + * @param interval the interval + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public WeeklyRegenerationPattern(LocalDate startDate, int interval) + throws ArgumentOutOfRangeException { + super(startDate, interval); + + } + + /** + * Gets the name of the XML element. The name of the XML + * element. + * + * @return the xml element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.WeeklyRegeneration; + } + + /** + * Gets a value indicating whether this instance is regeneration + * pattern. true if this instance is regeneration + * pattern; otherwise, false. + * + * @return true, if is regeneration pattern + */ + public boolean isRegenerationPattern() { + return true; + } + } + + + /** + * Represents a recurrence pattern where each occurrence happens on a + * specific day every year. + */ + public final static class YearlyPattern extends Recurrence { + + /** + * The month. + */ + private Month month; + + /** + * The day of month. + */ + private Integer dayOfMonth; + + /** + * Initializes a new instance of the YearlyPattern class. + */ + public YearlyPattern() { + super(); + + } + + /** + * Initializes a new instance of the YearlyPattern class. + * + * @param startDate the start date + * @param month the month + * @param dayOfMonth the day of month + */ + public YearlyPattern(LocalDate startDate, Month month, int dayOfMonth) { + super(startDate); + + this.month = month; + this.dayOfMonth = dayOfMonth; + } + + /** + * Gets the name of the XML element. The name of the XML + * element. + * + * @return the xml element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.AbsoluteYearlyRecurrence; + } + + /** + * Write property to XML. + * + * @param writer the writer + */ + @Override + public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.internalWritePropertiesToXml(writer); + + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.DayOfMonth, this.getDayOfMonth()); + + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Month, + this.getMonth()); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (super.tryReadElementFromXml(reader)) { + return true; + } else { + if (reader.getLocalName().equals(XmlElementNames.DayOfMonth)) { + + this.dayOfMonth = reader.readElementValue(Integer.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Month)) { + + this.month = reader.readElementValue(Month.class); + return true; + } else { + + return false; + } + } + } + + /** + * Validates this instance. + * + */ + @Override + public void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + + if (this.month == null) { + throw new ExchangeValidationException("The recurrence pattern's Month property must be specified."); + } + + if (this.dayOfMonth == null) { + throw new ExchangeValidationException( + "The recurrence pattern's DayOfMonth property must be specified."); + } + } + + /** + * Gets the month of the year when each occurrence happens. + * + * @return the month + * @throws ExchangeValidationException the service validation exception + */ + public Month getMonth() throws ExchangeValidationException { + return this.getFieldValueOrThrowIfNull(Month.class, this.month, + "Month"); + } + + /** + * Sets the month. + * + * @param value the new month + */ + public void setMonth(Month value) { + + if (this.canSetFieldValue(this.month, value)) { + this.month = value; + this.changed(); + } + } + + /** + * Gets the day of the month when each occurrence happens. DayOfMonth + * must be between 1 and 31. + * + * @return the day of month + * @throws ExchangeValidationException the service validation exception + */ + public int getDayOfMonth() throws ExchangeValidationException { + + return this.getFieldValueOrThrowIfNull(Integer.class, this.dayOfMonth, + "DayOfMonth"); + + } + + /** + * Sets the day of the month when each occurrence happens. DayOfMonth + * must be between 1 and 31. + * + * @param value the new day of month + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public void setDayOfMonth(int value) + throws ArgumentOutOfRangeException { + + if (value < 1 || value > 31) { + throw new ArgumentOutOfRangeException("DayOfMonth", "DayOfMonth must be between 1 and 31."); + } + + if (this.canSetFieldValue(this.dayOfMonth, value)) { + this.dayOfMonth = value; + this.changed(); + } + } + } + + + /** + * Represents a regeneration pattern, as used with recurring tasks, where + * each occurrence happens a specified number of years after the previous + * one is completed. + */ + public final static class YearlyRegenerationPattern extends + IntervalPattern { + + /** + * Gets the name of the XML element. + * + * @return the xml element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.YearlyRegeneration; + } + + /** + * Gets a value indicating whether this instance is regeneration + * pattern. + * + * @return true, if is regeneration pattern + */ + public boolean isRegenerationPattern() { + return true; + } + + /** + * Initializes a new instance of the YearlyRegenerationPattern class. + */ + public YearlyRegenerationPattern() { + super(); + + } + + /** + * Initializes a new instance of the YearlyRegenerationPattern class. + * + * @param startDate the start date + * @param interval the interval + * @throws ArgumentOutOfRangeException the argument out of range exception + */ + public YearlyRegenerationPattern(LocalDate startDate, int interval) + throws ArgumentOutOfRangeException { + super(startDate, interval); + + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/range/EndDateRecurrenceRange.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/range/EndDateRecurrenceRange.java new file mode 100644 index 000000000..e264d2735 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/range/EndDateRecurrenceRange.java @@ -0,0 +1,144 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.recurrence.range; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.recurrence.pattern.Recurrence; + +import javax.xml.stream.XMLStreamException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.time.LocalDate; + +/** + * Represents recurrent range with an end date. + */ +public final class EndDateRecurrenceRange extends RecurrenceRange { + + /** + * The end date. + */ + private LocalDate endDate; + + /** + * Initializes a new instance. + */ + public EndDateRecurrenceRange() { + super(); + } + + /** + * Initializes a new instance. + * + * @param startDate the start date + * @param endDate the end date + */ + public EndDateRecurrenceRange(LocalDate startDate, LocalDate endDate) { + super(startDate); + this.endDate = endDate; + } + + /** + * Gets the name of the XML element. + * + * @return The name of the XML element + */ + public String getXmlElementName() { + return XmlElementNames.EndDateRecurrence; + } + + /** + * Setups the recurrence. + * + * @param recurrence the new up recurrence + */ + public void setupRecurrence(Recurrence recurrence) throws ExchangeXmlException { + super.setupRecurrence(recurrence); + recurrence.setEndDate(this.endDate); + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + LocalDate d = this.endDate; + DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + String formattedString = df.format(d); + + super.writeElementsToXml(writer); + + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.EndDate, + formattedString); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (super.tryReadElementFromXml(reader)) { + return true; + } else { + if (reader.getLocalName().equals(XmlElementNames.EndDate)) { + + LocalDate temp = reader.readElementValueAsUnspecifiedDate(); + + if (temp != null) { + this.endDate = temp; + } + return true; + } else { + return false; + } + } + } + + /** + * Gets the end date. + * + * @return endDate + */ + public LocalDate getEndDate() { + return this.endDate; + } + + /** + * sets the end date. + * + * @param value the new end date + */ + public void setEndDate(LocalDate value) { + this.canSetFieldValue(this.endDate, value); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/range/NoEndRecurrenceRange.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/range/NoEndRecurrenceRange.java new file mode 100644 index 000000000..aad0cb0b0 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/range/NoEndRecurrenceRange.java @@ -0,0 +1,73 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.recurrence.range; + +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.recurrence.pattern.Recurrence; + +import java.time.LocalDate; + +/** + * Represents recurrence range with no end date. + */ +public final class NoEndRecurrenceRange extends RecurrenceRange { + + /** + * Initializes a new instance. + */ + public NoEndRecurrenceRange() { + super(); + } + + /** + * Initializes a new instance. + * + * @param startDate the start date + */ + public NoEndRecurrenceRange(LocalDate startDate) { + super(startDate); + } + + /** + * Gets the name of the XML element. + * + * @return The name of the XML element + */ + public String getXmlElementName() { + return XmlElementNames.NoEndRecurrence; + } + + /** + * Setups the recurrence. + * + * @param recurrence the new up recurrence + */ + public void setupRecurrence(Recurrence recurrence) throws ExchangeXmlException { + super.setupRecurrence(recurrence); + + recurrence.neverEnds(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/range/NumberedRecurrenceRange.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/range/NumberedRecurrenceRange.java new file mode 100644 index 000000000..c3abccd01 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/range/NumberedRecurrenceRange.java @@ -0,0 +1,141 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.recurrence.range; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.recurrence.pattern.Recurrence; + +import javax.xml.stream.XMLStreamException; +import java.time.LocalDate; + +/** + * The Class NumberedRecurrenceRange. + */ +public final class NumberedRecurrenceRange extends RecurrenceRange { + + /** + * The number of occurrences. + */ + private Integer numberOfOccurrences; + + /** + * Initializes a new instance. + */ + public NumberedRecurrenceRange() { + super(); + } + + /** + * Initializes a new instance. + * + * @param startDate the start date + * @param numberOfOccurrences the number of occurrences + */ + public NumberedRecurrenceRange(LocalDate startDate, + Integer numberOfOccurrences) { + super(startDate); + this.numberOfOccurrences = numberOfOccurrences; + } + + /** + * Gets the name of the XML element. + * + * @return The name of the XML element + */ + public String getXmlElementName() { + return XmlElementNames.NumberedRecurrence; + } + + /** + * Setups the recurrence. + * + * @param recurrence the new up recurrence + */ + public void setupRecurrence(Recurrence recurrence) throws ExchangeXmlException { + super.setupRecurrence(recurrence); + recurrence.setNumberOfOccurrences(this.numberOfOccurrences); + } + + /** + * Writes the elements to XML.. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeElementsToXml(writer); + + if (this.numberOfOccurrences != null) { + writer.writeElementValue(XmlNamespace.Types, + XmlElementNames.NumberOfOccurrences, + this.numberOfOccurrences); + } + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (super.tryReadElementFromXml(reader)) { + return true; + } else { + if (reader.getLocalName().equals( + XmlElementNames.NumberOfOccurrences)) { + this.numberOfOccurrences = reader + .readElementValue(Integer.class); + return true; + } else { + return false; + } + } + } + + /** + * Gets the number of occurrences. + * + * @return numberOfOccurrences + */ + + public Integer getNumberOfOccurrences() { + return this.numberOfOccurrences; + } + + /** + * sets the number of occurrences. + * + * @param value the new number of occurrences + */ + public void setNumberOfOccurrences(Integer value) { + this.canSetFieldValue(this.numberOfOccurrences, value); + + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/range/RecurrenceRange.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/range/RecurrenceRange.java new file mode 100644 index 000000000..d83b1fad7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/recurrence/range/RecurrenceRange.java @@ -0,0 +1,167 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.recurrence.range; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; +import com.eischet.ews.api.property.complex.recurrence.pattern.Recurrence; + +import javax.xml.stream.XMLStreamException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.time.LocalDate; + +/** + * Represents recurrence range with start and end dates. + */ +public abstract class RecurrenceRange extends ComplexProperty { + + /** + * The start date. + */ + private LocalDate startDate; + + /** + * The recurrence. + */ + private Recurrence recurrence; + + /** + * Initializes a new instance. + */ + protected RecurrenceRange() { + super(); + } + + /** + * Initializes a new instance. + * + * @param startDate the start date + */ + protected RecurrenceRange(LocalDate startDate) { + this(); + this.startDate = startDate; + } + + /** + * Changes handler. + */ + public void changed() { + if (this.recurrence != null) { + this.recurrence.changed(); + } + } + + /** + * Setup the recurrence. + * + * @param recurrence the new up recurrence + * @throws Exception the exception + */ + public void setupRecurrence(Recurrence recurrence) throws ExchangeXmlException { + recurrence.setStartDate(this.getStartDate()); + } + + /** + * Writes elements to XML.. + * + * @param writer the writer + */ + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + LocalDate d = this.startDate; + DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + String formattedString = df.format(d); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.StartDate, formattedString); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read + */ + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.StartDate)) { + //this.startDate = reader.readElementValueAsDateTime(); + LocalDate startDate = reader.readElementValueAsUnspecifiedDate(); + if (startDate != null) { + this.startDate = startDate; + return true; + } + return false; + } else { + return false; + } + } + + /** + * Gets the name of the XML element. + * + * @return recurrence + */ + public abstract String getXmlElementName(); + + /** + * Gets or sets the recurrence. + * + * @return recurrence + */ + protected Recurrence getRecurrence() { + return this.recurrence; + } + + /** + * Sets the recurrence. + * + * @param value the new recurrence + */ + protected void setRecurrence(Recurrence value) { + this.recurrence = value; + } + + /** + * Gets the start date. + * + * @return startDate + */ + protected LocalDate getStartDate() { + return this.startDate; + + } + + /** + * Sets the start date. + * + * @param value the new start date + */ + protected void setStartDate(LocalDate value) { + this.canSetFieldValue(this.startDate, value); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/AbsoluteDateTransition.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/AbsoluteDateTransition.java new file mode 100644 index 000000000..7acc71ae2 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/AbsoluteDateTransition.java @@ -0,0 +1,126 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.time; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.util.DateTimeUtils; + +import javax.xml.stream.XMLStreamException; +import java.text.ParseException; +import java.time.LocalDateTime; + +/** + * Represents a time zone period transition that occurs on a fixed (absolute) + * date. + */ +public class AbsoluteDateTransition extends TimeZoneTransition { + + /** + * The date time. + */ + private LocalDateTime dateTime; + + /** + * Gets the XML element name associated with the transition. + * + * @return The XML element name associated with the transition. + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.AbsoluteDateTransition; + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + boolean result = super.tryReadElementFromXml(reader); + if (!result) { + if (reader.getLocalName().equals(XmlElementNames.DateTime)) { + this.dateTime = DateTimeUtils.parseDateTime(reader.readElementValue()); + result = true; + } + } + return result; + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeElementsToXml(writer); + + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.DateTime, + this.dateTime); + } + + /** + * Initializes a new instance of the AbsoluteDateTransition class. + * + * @param timeZoneDefinition , The time zone definition the transition will belong to. + */ + protected AbsoluteDateTransition(TimeZoneDefinition timeZoneDefinition) { + super(timeZoneDefinition); + } + + /** + * Initializes a new instance of the AbsoluteDateTransition class. + * + * @param timeZoneDefinition The time zone definition the transition will belong to. + * @param targetGroup the target group + */ + protected AbsoluteDateTransition(TimeZoneDefinition timeZoneDefinition, TimeZoneTransitionGroup targetGroup) { + super(timeZoneDefinition, targetGroup); + } + + /** + * Gets the absolute date and time when the transition occurs. + * + * @return the date time + */ + public LocalDateTime getDateTime() { + return dateTime; + } + + /** + * Sets the date time. + * + * @param dateTime the new date time + */ + protected void setDateTime(LocalDateTime dateTime) { + this.dateTime = dateTime; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/AbsoluteDayOfMonthTransition.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/AbsoluteDayOfMonthTransition.java new file mode 100644 index 000000000..bb1c23c70 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/AbsoluteDayOfMonthTransition.java @@ -0,0 +1,122 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.time; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import javax.xml.stream.XMLStreamException; + +/** + * Represents a time zone period transition that occurs on a specific day of a + * specific month. + */ +class AbsoluteDayOfMonthTransition extends AbsoluteMonthTransition { + + /** + * The day of month. + */ + private int dayOfMonth; + + /** + * Gets the XML element name associated with the transition. + * + * @return The XML element name associated with the transition. + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.RecurringDateTransition; + } + + /** + * Tries to read element from XML. + * + * @param reader returns True if element was read. + * @return true + * @throws Exception throws Exception + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (super.tryReadElementFromXml(reader)) { + return true; + } else { + if (reader.getLocalName().equals(XmlElementNames.Day)) { + this.dayOfMonth = reader.readElementValue(Integer.class); + + EwsUtilities.ewsAssert(this.dayOfMonth > 0 && this.dayOfMonth <= 31, + "AbsoluteDayOfMonthTransition.TryReadElementFromXml", + "dayOfMonth is not in the valid 1 - 31 range."); + + return true; + } else { + return false; + } + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeElementsToXml(writer); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Day, this.dayOfMonth); + } + + /** + * Initializes a new instance of the AbsoluteDayOfMonthTransition class. + * + * @param timeZoneDefinition the time zone definition + */ + protected AbsoluteDayOfMonthTransition(TimeZoneDefinition timeZoneDefinition) { + super(timeZoneDefinition); + } + + /** + * Initializes a new instance of the AbsoluteDayOfMonthTransition class. + * + * @param timeZoneDefinition the time zone definition + * @param targetPeriod the target period + */ + + protected AbsoluteDayOfMonthTransition(TimeZoneDefinition timeZoneDefinition, TimeZonePeriod targetPeriod) { + super(timeZoneDefinition, targetPeriod); + } + + /** + * Gets the day of then month when this transition occurs. + * + * @return the day of month + */ + protected int getDayOfMonth() { + return this.dayOfMonth; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/AbsoluteMonthTransition.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/AbsoluteMonthTransition.java new file mode 100644 index 000000000..dca97e924 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/AbsoluteMonthTransition.java @@ -0,0 +1,124 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.time; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.TimeSpan; + +/** + * Represents the base class for all recurring time zone period transitions. + */ +abstract class AbsoluteMonthTransition extends TimeZoneTransition { + + /** + * The time offset. + */ + private TimeSpan timeOffset; + + /** + * The month. + */ + private int month; + + /** + * Initializes a new instance of the AbsoluteMonthTransition class. + * + * @param timeZoneDefinition the time zone definition + */ + protected AbsoluteMonthTransition(TimeZoneDefinition timeZoneDefinition) { + super(timeZoneDefinition); + } + + /** + * Initializes a new instance of the AbsoluteMonthTransition class. + * + * @param timeZoneDefinition the time zone definition + * @param targetPeriod the target period + */ + protected AbsoluteMonthTransition(TimeZoneDefinition timeZoneDefinition, TimeZonePeriod targetPeriod) { + super(timeZoneDefinition, targetPeriod); + } + + /** + * Tries to read element from XML. + * + * @param reader accepts EwsServiceXmlReader + * @return True if element was read + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (super.tryReadElementFromXml(reader)) { + return true; + } else { + if (reader.getLocalName().equals(XmlElementNames.TimeOffset)) { + this.timeOffset = EwsUtilities.getXSDurationToTimeSpan(reader.readElementValue()); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Month)) { + this.month = reader.readElementValue(Integer.class); + + EwsUtilities.ewsAssert(this.month > 0 && this.month <= 12, "AbsoluteMonthTransition.TryReadElementFromXml", "month is not in the valid 1 - 12 range."); + + return true; + } else { + return false; + } + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeElementsToXml(writer); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.TimeOffset, EwsUtilities.getTimeSpanToXSDuration(this.timeOffset)); + writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Month, this.month); + } + + /** + * Gets the time offset from midnight when the transition occurs. + * + * @return the time offset + */ + protected TimeSpan getTimeOffset() { + return this.timeOffset; + } + + /** + * Gets the month when the transition occurs. + * + * @return the month + */ + protected int getMonth() { + return this.month; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/RelativeDayOfMonthTransition.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/RelativeDayOfMonthTransition.java new file mode 100644 index 000000000..b04faecbe --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/RelativeDayOfMonthTransition.java @@ -0,0 +1,144 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.time; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.time.DayOfTheWeek; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import javax.xml.stream.XMLStreamException; + +/** + * Represents a time zone period transition that occurs on a relative day of a + * specific month. + */ +class RelativeDayOfMonthTransition extends AbsoluteMonthTransition { + + /** + * The day of the week. + */ + private DayOfTheWeek dayOfTheWeek; + + /** + * The week index. + */ + private int weekIndex; + + /** + * Gets the XML element name associated with the transition. + * + * @return The XML element name associated with the transition. + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.RecurringDayTransition; + } + + /** + * Tries to read element from XML. + * + * @param reader accepts EwsServiceXmlReader + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (super.tryReadElementFromXml(reader)) { + return true; + } else { + if (reader.getLocalName().equals(XmlElementNames.DayOfWeek)) { + this.dayOfTheWeek = reader.readElementValue(DayOfTheWeek.class); + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Occurrence)) { + this.weekIndex = reader.readElementValue(Integer.class); + return true; + } else { + return false; + } + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeElementsToXml(writer); + + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.DayOfWeek, + this.dayOfTheWeek); + + writer.writeElementValue( + XmlNamespace.Types, + XmlElementNames.Occurrence, + this.weekIndex); + } + + /** + * Initializes a new instance of the "RelativeDayOfMonthTransition class. + * + * @param timeZoneDefinition the time zone definition + */ + protected RelativeDayOfMonthTransition( + TimeZoneDefinition timeZoneDefinition) { + super(timeZoneDefinition); + } + + /** + * Initializes a new instance of the "RelativeDayOfMonthTransition class. + * + * @param timeZoneDefinition the time zone definition + * @param targetPeriod the target period + */ + protected RelativeDayOfMonthTransition( + TimeZoneDefinition timeZoneDefinition, + TimeZonePeriod targetPeriod) { + super(timeZoneDefinition, targetPeriod); + } + + /** + * Gets the day of the week when the transition occurs. + * + * @return the day of the week + */ + protected DayOfTheWeek getDayOfTheWeek() { + return this.dayOfTheWeek; + } + + /** + * Gets the index of the week in the month when the transition occurs. + * + * @return the week index + */ + protected int getWeekIndex() { + return this.weekIndex; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/TimeZoneDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/TimeZoneDefinition.java new file mode 100644 index 000000000..489f74f57 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/TimeZoneDefinition.java @@ -0,0 +1,425 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.time; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.InvalidOrUnsupportedTimeZoneDefinitionException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; + +import java.time.LocalDateTime; +import java.util.*; + +/** + * Represents a time zone as defined by the EWS schema. + */ +public class TimeZoneDefinition extends ComplexProperty implements Comparator { + + /** + * Prefix for generated ids. + */ + private static final String NoIdPrefix = "NoId_"; + + /** + * The Standard period id. + */ + protected final String StandardPeriodId = "Std"; + + /** + * The Standard period name. + */ + protected final String StandardPeriodName = "Standard"; + + /** + * The Daylight period id. + */ + protected final String DaylightPeriodId = "Dlt"; + + /** + * The Daylight period name. + */ + protected final String DaylightPeriodName = "Daylight"; + + /** + * The name. + */ + public String name; + + /** + * The id. + */ + public String id; + + /** + * The periods. + */ + private final Map periods = + new HashMap(); + + /** + * The transition groups. + */ + private final Map transitionGroups = + new HashMap(); + + /** + * The transitions. + */ + private final List transitions = + new ArrayList(); + + /** + * Compares the transitions. + * + * @param x The first transition. + * @param y The second transition. + * @return A negative number if x is less than y, 0 if x and y are equal, a + * positive number if x is greater than y. + */ + @Override + public int compare(final TimeZoneTransition x, final TimeZoneTransition y) { + if (x == y) { + return 0; + } else if (x != null && y != null) { + if (x instanceof AbsoluteDateTransition && y instanceof AbsoluteDateTransition) { + final AbsoluteDateTransition firstTransition = (AbsoluteDateTransition) x; + final AbsoluteDateTransition secondTransition = (AbsoluteDateTransition) y; + + final LocalDateTime firstDateTime = firstTransition.getDateTime(); + final LocalDateTime secondDateTime = secondTransition.getDateTime(); + + return firstDateTime.compareTo(secondDateTime); + + } else if (y instanceof TimeZoneTransition) { + return 1; + } + } else if (y == null) { + return 1; + } + return -1; + } + + /** + * Initializes a new instance of the TimeZoneDefinition class. + */ + public TimeZoneDefinition() { + super(); + } + + + /** + * Adds a transition group with a single transition to the specified period. + * + * @param timeZonePeriod the time zone period + * @return A TimeZoneTransitionGroup. + */ + private TimeZoneTransitionGroup createTransitionGroupToPeriod( + TimeZonePeriod timeZonePeriod) { + TimeZoneTransition transitionToPeriod = new TimeZoneTransition(this, + timeZonePeriod); + + TimeZoneTransitionGroup transitionGroup = new TimeZoneTransitionGroup( + this, String.valueOf(this.transitionGroups.size())); + transitionGroup.getTransitions().add(transitionToPeriod); + this.transitionGroups.put(transitionGroup.getId(), transitionGroup); + return transitionGroup; + } + + /** + * Reads the attribute from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.name = reader.readAttributeValue(XmlAttributeNames.Name); + this.id = reader.readAttributeValue(XmlAttributeNames.Id); + + // E14:319057 -- EWS can return a TimeZone definition with no Id. Generate a new Id in this case. + if (this.id == null || this.id.isEmpty()) { + String nameValue = (this.getName() == null || this. + getName().isEmpty()) ? "" : this.getName(); + this.setId(NoIdPrefix + Math.abs(nameValue.hashCode())); + } + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + // The Name attribute is only supported in Exchange 2010 and above. + if (writer.getService().getRequestedServerVersion() != ExchangeVersion.Exchange2007_SP1) { + writer.writeAttributeValue(XmlAttributeNames.Name, this.name); + } + + writer.writeAttributeValue(XmlAttributeNames.Id, this.id); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + * @throws Exception the exception + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.Periods)) { + do { + reader.read(); + if (reader.isStartElement(XmlNamespace.Types, + XmlElementNames.Period)) { + TimeZonePeriod period = new TimeZonePeriod(); + period.loadFromXml(reader); + + this.periods.put(period.getId(), period); + } + } while (!reader.isEndElement(XmlNamespace.Types, + XmlElementNames.Periods)); + + return true; + } else if (reader.getLocalName().equals( + XmlElementNames.TransitionsGroups)) { + do { + reader.read(); + if (reader.isStartElement(XmlNamespace.Types, + XmlElementNames.TransitionsGroup)) { + TimeZoneTransitionGroup transitionGroup = + new TimeZoneTransitionGroup( + this); + + transitionGroup.loadFromXml(reader); + + this.transitionGroups.put(transitionGroup.getId(), + transitionGroup); + } + } while (!reader.isEndElement(XmlNamespace.Types, + XmlElementNames.TransitionsGroups)); + + return true; + } else if (reader.getLocalName().equals(XmlElementNames.Transitions)) { + do { + reader.read(); + if (reader.isStartElement()) { + TimeZoneTransition transition = TimeZoneTransition.create(this, reader.getLocalName()); + transition.loadFromXml(reader); + this.transitions.add(transition); + } + } while (!reader.isEndElement(XmlNamespace.Types, + XmlElementNames.Transitions)); + + return true; + } else { + return false; + } + } + + /** + * Loads from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader) throws Exception { + this.loadFromXml(reader, XmlElementNames.TimeZoneDefinition); + Collections.sort(this.transitions, new TimeZoneDefinition()); + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + // We only emit the full time zone definition against Exchange 2010 + // servers and above. + if (writer.getService().getRequestedServerVersion() != ExchangeVersion.Exchange2007_SP1) { + if (this.periods.size() > 0) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.Periods); + + Iterator it = this.periods.values().iterator(); + while (it.hasNext()) { + it.next().writeToXml(writer); + } + + writer.writeEndElement(); // Periods + } + + if (this.transitionGroups.size() > 0) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.TransitionsGroups); + for (int i = 0; i < this.transitionGroups.size(); i++) { + Object[] key = this.transitionGroups.keySet().toArray(); + this.transitionGroups.get(key[i]).writeToXml(writer); + } + writer.writeEndElement(); // TransitionGroups + } + + if (this.transitions.size() > 0) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.Transitions); + + for (TimeZoneTransition transition : this.transitions) { + transition.writeToXml(writer); + } + + writer.writeEndElement(); // Transitions + } + } + } + + /** + * Writes to XML. + * + * @param writer The writer. + * @throws Exception the exception + */ + protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { + this.writeToXml(writer, XmlElementNames.TimeZoneDefinition); + } + + /** + * Validates this time zone definition. + * + * @throws InvalidOrUnsupportedTimeZoneDefinitionException thrown when time zone definition is not valid. + */ + public void validate() throws ExchangeValidationException { + // The definition must have at least one period, one transition group + // and one transition, + // and there must be as many transitions as there are transition groups. + if (this.periods.isEmpty() || this.transitions.isEmpty() + || this.transitionGroups.isEmpty() + || this.transitionGroups.size() != this.transitions.size()) { + throw new InvalidOrUnsupportedTimeZoneDefinitionException(); + } + + // The first transition must be of type TimeZoneTransition. + if (this.transitions.get(0).getClass() != TimeZoneTransition.class) { + throw new InvalidOrUnsupportedTimeZoneDefinitionException(); + } + + // All transitions must be to transition groups and be either + // TimeZoneTransition or + // AbsoluteDateTransition instances. + for (TimeZoneTransition transition : this.transitions) { + Class transitionType = transition.getClass(); + + if (transitionType != TimeZoneTransition.class + && transitionType != AbsoluteDateTransition.class) { + throw new InvalidOrUnsupportedTimeZoneDefinitionException(); + } + + if (transition.getTargetGroup() == null) { + throw new InvalidOrUnsupportedTimeZoneDefinitionException(); + } + } + + // All transition groups must be valid. + for (TimeZoneTransitionGroup transitionGroup : this.transitionGroups + .values()) { + transitionGroup.validate(); + } + } + + /** + * Gets the name of this time zone definition. + * + * @return the name + */ + public String getName() { + return this.name; + } + + /** + * Sets the name. + * + * @param name the new name + */ + protected void setName(String name) { + this.name = name; + } + + /** + * Gets the Id of this time zone definition. + * + * @return the id + */ + public String getId() { + return this.id; + } + + /** + * Sets the id. + * + * @param id the new id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Adds a transition group with a single transition to the specified period. + * + * @return A TimeZoneTransitionGroup. + */ + public Map getPeriods() { + return this.periods; + } + + /** + * Gets the transition groups associated with this time zone definition, + * indexed by Id. + * + * @return the transition groups + */ + public Map getTransitionGroups() { + return this.transitionGroups; + } + + /** + * Writes to XML. + * + * @param writer accepts EwsServiceXmlWriter + * @param xmlElementName accepts String + * @throws Exception throws Exception + */ + public void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) throws ExchangeXmlException { + this.writeToXml(writer, this.getNamespace(), xmlElementName); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/TimeZonePeriod.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/TimeZonePeriod.java new file mode 100644 index 000000000..2285b3307 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/TimeZonePeriod.java @@ -0,0 +1,188 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.time; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.TimeSpan; +import com.eischet.ews.api.property.complex.ComplexProperty; + +/** + * Represents a time zone period as defined in the EWS schema. + */ +public class TimeZonePeriod extends ComplexProperty { + + /** + * The Constant StandardPeriodId. + */ + protected final static String StandardPeriodId = "Std"; + + /** + * The Constant StandardPeriodName. + */ + protected final static String StandardPeriodName = "Standard"; + + /** + * The Constant DaylightPeriodId. + */ + protected final static String DaylightPeriodId = "Dlt"; + + /** + * The Constant DaylightPeriodName. + */ + protected final static String DaylightPeriodName = "Daylight"; + + /** + * The bias. + */ + private TimeSpan bias; + + /** + * The name. + */ + private String name; + + /** + * The id. + */ + private String id; + + /** + * Reads the attribute from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + public void readAttributesFromXml(EwsServiceXmlReader reader) + throws ExchangeXmlException { + this.id = reader.readAttributeValue(XmlAttributeNames.Id); + this.name = reader.readAttributeValue(XmlAttributeNames.Name); + this.bias = EwsUtilities.getXSDurationToTimeSpan(reader.readAttributeValue(XmlAttributeNames.Bias)); + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.Bias, EwsUtilities.getTimeSpanToXSDuration(this.bias)); + writer.writeAttributeValue(XmlAttributeNames.Name, this.name); + writer.writeAttributeValue(XmlAttributeNames.Id, this.id); + } + + /** + * Loads from XML. + * + * @param reader the reader + */ + public void loadFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.loadFromXml(reader, XmlElementNames.Period); + } + + /** + * Writes to XML. + * + * @param writer the writer + */ + public void writeToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.writeToXml(writer, XmlElementNames.Period); + } + + /** + * Initializes a new instance of the TimeZonePeriod class. + */ + public TimeZonePeriod() { + super(); + } + + /** + * Gets a value indicating whether this period represents the Standard + * period. + * + * @return true if this instance is standard period; otherwise, false + */ + protected boolean isStandardPeriod() { + return this.name.equals(TimeZonePeriod.StandardPeriodName); + } + + /** + * Gets the bias to UTC associated with this period. + * + * @return the bias + */ + protected TimeSpan getBias() { + return bias; + } + + /** + * Sets the bias. + * + * @param bias the new bias + */ + protected void setBias(TimeSpan bias) { + this.bias = bias; + } + + /** + * Gets the name of this period. + * + * @return the name + */ + protected String getName() { + return name; + } + + /** + * Sets the name. + * + * @param name the new name + */ + protected void setName(String name) { + this.name = name; + } + + /** + * Gets the id of this period. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets the id. + * + * @param id the new id + */ + protected void setId(String id) { + this.id = id; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/TimeZoneTransition.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/TimeZoneTransition.java new file mode 100644 index 000000000..573652347 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/TimeZoneTransition.java @@ -0,0 +1,229 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.time; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; + +/** + * Represents the base class for all time zone transitions. + */ +public class TimeZoneTransition extends ComplexProperty { + + /** + * The Period target. + */ + private final String PeriodTarget = "Period"; + + /** + * The Group target. + */ + private final String GroupTarget = "Group"; + + /** + * The time zone definition. + */ + private final TimeZoneDefinition timeZoneDefinition; + + /** + * The target period. + */ + private TimeZonePeriod targetPeriod; + + /** + * The target group. + */ + private TimeZoneTransitionGroup targetGroup; + + /** + * Creates a time zone period transition of the appropriate type given an + * XML element name. + * + * @param timeZoneDefinition the time zone definition + * @param xmlElementName the xml element name + * @return A TimeZonePeriodTransition instance. + */ + public static TimeZoneTransition create(TimeZoneDefinition timeZoneDefinition, String xmlElementName) throws ExchangeXmlException { + if (xmlElementName.equals(XmlElementNames.AbsoluteDateTransition)) { + return new AbsoluteDateTransition(timeZoneDefinition); + } else if (xmlElementName.equals(XmlElementNames.AbsoluteDateTransition)) { + return new AbsoluteDateTransition(timeZoneDefinition); + } else if (xmlElementName.equals(XmlElementNames.RecurringDayTransition)) { + return new RelativeDayOfMonthTransition(timeZoneDefinition); + } else if (xmlElementName.equals(XmlElementNames.RecurringDateTransition)) { + return new AbsoluteDayOfMonthTransition(timeZoneDefinition); + } else if (xmlElementName.equals(XmlElementNames.Transition)) { + return new TimeZoneTransition(timeZoneDefinition); + } else { + throw new ExchangeXmlException(String.format("Unknown time zone transition type: %s", xmlElementName)); + } + } + + /** + * Gets the XML element name associated with the transition. + * + * @return The XML element name associated with the transition. + */ + protected String getXmlElementName() { + return XmlElementNames.Transition; + } + + /** + * Tries to read element from XML.The reader. + * + * @param reader The + * reader. + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) + throws ExchangeXmlException { + if (reader.getLocalName().equals(XmlElementNames.To)) { + String targetKind = reader + .readAttributeValue(XmlAttributeNames.Kind); + String targetId = reader.readElementValue(); + if (targetKind.equals(PeriodTarget)) { + if (!this.timeZoneDefinition.getPeriods().containsKey(targetId)) { + + throw new ExchangeXmlException(String.format( + "Invalid transition. A period with the specified Id couldn't be found: %s", targetId)); + } else { + this.targetPeriod = this.timeZoneDefinition.getPeriods() + .get(targetId); + } + } else if (targetKind.equals(GroupTarget)) { + if (!this.timeZoneDefinition.getTransitionGroups().containsKey( + targetId)) { + + throw new ExchangeXmlException(String.format("Invalid transition. A transition group with the specified ID couldn't be found: %s", targetId)); + } else { + this.targetGroup = this.timeZoneDefinition + .getTransitionGroups().get(targetId); + } + } else { + throw new ExchangeXmlException("The time zone transition target isn't supported."); + } + + return true; + } else { + return false; + } + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.To); + if (this.targetPeriod != null) { + writer.writeAttributeValue(XmlAttributeNames.Kind, PeriodTarget); + writer.writeValue(this.targetPeriod.getId(), XmlElementNames.To); + } else if (this.targetGroup != null) { + writer.writeAttributeValue(XmlAttributeNames.Kind, GroupTarget); + writer.writeValue(this.targetGroup.getId(), XmlElementNames.To); + } + + writer.writeEndElement(); // To + } + + /** + * Loads from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.loadFromXml(reader, this.getXmlElementName()); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.writeToXml(writer, this.getXmlElementName()); + } + + /** + * Initializes a new instance of the class. + * + * @param timeZoneDefinition the time zone definition + */ + protected TimeZoneTransition(TimeZoneDefinition timeZoneDefinition) { + super(); + this.timeZoneDefinition = timeZoneDefinition; + } + + /** + * Initializes a new instance of the class. + * + * @param timeZoneDefinition the time zone definition + * @param targetGroup the target group + */ + protected TimeZoneTransition(TimeZoneDefinition timeZoneDefinition, + TimeZoneTransitionGroup targetGroup) { + this(timeZoneDefinition); + this.targetGroup = targetGroup; + } + + /** + * Initializes a new instance of the class. + * + * @param timeZoneDefinition the time zone definition + * @param targetPeriod the target period + */ + public TimeZoneTransition(TimeZoneDefinition timeZoneDefinition, TimeZonePeriod targetPeriod) { + this(timeZoneDefinition); + this.targetPeriod = targetPeriod; + } + + /** + * Gets the target period of the transition. + * + * @return the target period + */ + protected TimeZonePeriod getTargetPeriod() { + return this.targetPeriod; + } + + /** + * Gets the target transition group of the transition. + * + * @return the target group + */ + public TimeZoneTransitionGroup getTargetGroup() { + return this.targetGroup; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/TimeZoneTransitionGroup.java b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/TimeZoneTransitionGroup.java new file mode 100644 index 000000000..57af6a627 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/complex/time/TimeZoneTransitionGroup.java @@ -0,0 +1,423 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.complex.time; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.InvalidOrUnsupportedTimeZoneDefinitionException; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.TimeSpan; +import com.eischet.ews.api.property.complex.ComplexProperty; + +import java.util.ArrayList; +import java.util.List; + +/** + * Represents a group of time zone period transitions. + */ +public class TimeZoneTransitionGroup extends ComplexProperty { + + /** + * The time zone definition. + */ + private final TimeZoneDefinition timeZoneDefinition; + + /** + * The id. + */ + private String id; + + /** + * The transitions. + */ + private final List transitions = + new ArrayList(); + + /** + * The transition to standard. + */ + private TimeZoneTransition transitionToStandard; + + /** + * The transition to daylight. + */ + private TimeZoneTransition transitionToDaylight; + + /** + * The Constant PeriodTarget. + */ + private final static String PeriodTarget = "Period"; + + /** + * The Constant GroupTarget. + */ + private final static String GroupTarget = "Group"; + + + /** + * Loads from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.loadFromXml(reader, XmlElementNames.TransitionsGroup); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.writeToXml(writer, XmlElementNames.TransitionsGroup); + } + + /** + * Reads the attribute from XML. + * + * @param reader the reader + * @throws Exception the exception + */ + @Override + public void readAttributesFromXml(EwsServiceXmlReader reader) + throws ExchangeXmlException { + this.id = reader.readAttributeValue(XmlAttributeNames.Id); + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) + throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.Id, this.id); + } + + /** + * Writes the attribute to XML. + * + * @param reader the reader + * @return true, if successful + * @throws Exception the exception + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) + throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(); + + TimeZoneTransition transition = TimeZoneTransition.create( + this.timeZoneDefinition, reader.getLocalName()); + + transition.loadFromXml(reader); + + EwsUtilities + .ewsAssert(transition.getTargetPeriod() != null, "TimeZoneTransitionGroup.TryReadElementFromXml", + "The transition's target period is null."); + + this.transitions.add(transition); + + return true; + } + + /** + * Writes elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + for (TimeZoneTransition transition : this.transitions) { + transition.writeToXml(writer); + } + } + + /** + * Validates this transition group. + * + * @throws InvalidOrUnsupportedTimeZoneDefinitionException thrown when time zone definition is not valid. + */ + public void validate() throws ExchangeValidationException { + // There must be exactly one or two transitions in the group. + if (this.transitions.isEmpty() || this.transitions.size() > 2) { + throw new InvalidOrUnsupportedTimeZoneDefinitionException(); + } + + // If there is only one transition, it must be of type + // TimeZoneTransition + if (this.transitions.size() == 1 + && !(this.transitions.get(0).getClass() == + TimeZoneTransition.class)) { + throw new InvalidOrUnsupportedTimeZoneDefinitionException(); + } + + // If there are two transitions, none of them should be of type + // TimeZoneTransition + if (this.transitions.size() == 2) { + for (TimeZoneTransition transition : this.transitions) { + if (transition.getClass() == TimeZoneTransition.class) { + throw new InvalidOrUnsupportedTimeZoneDefinitionException(); + } + } + } + + // All the transitions in the group must be to a period. + for (TimeZoneTransition transition : this.transitions) { + if (transition.getTargetPeriod() == null) { + throw new InvalidOrUnsupportedTimeZoneDefinitionException(); + } + } + } + + /** + * The Class CustomTimeZoneCreateParams. + */ + protected static class CustomTimeZoneCreateParams { + + /** + * The base offset to utc. + */ + private TimeSpan baseOffsetToUtc; + + /** + * The standard display name. + */ + private String standardDisplayName; + + /** + * The daylight display name. + */ + private String daylightDisplayName; + + /** + * Initializes a new instance of the class. + */ + protected CustomTimeZoneCreateParams() { + } + + /** + * Gets the base offset to UTC. + * + * @return the base offset to utc + */ + protected TimeSpan getBaseOffsetToUtc() { + return this.baseOffsetToUtc; + } + + /** + * Sets the base offset to utc. + * + * @param baseOffsetToUtc the new base offset to utc + */ + protected void setBaseOffsetToUtc(TimeSpan baseOffsetToUtc) { + this.baseOffsetToUtc = baseOffsetToUtc; + } + + /** + * Gets the display name of the standard period. + * + * @return the standard display name + */ + protected String getStandardDisplayName() { + return this.standardDisplayName; + } + + /** + * Sets the standard display name. + * + * @param standardDisplayName the new standard display name + */ + protected void setStandardDisplayName(String standardDisplayName) { + this.standardDisplayName = standardDisplayName; + } + + /** + * Gets the display name of the daylight period. + * + * @return the daylight display name + */ + protected String getDaylightDisplayName() { + return this.daylightDisplayName; + } + + /** + * Sets the daylight display name. + * + * @param daylightDisplayName the new daylight display name + */ + protected void setDaylightDisplayName(String daylightDisplayName) { + this.daylightDisplayName = daylightDisplayName; + } + + /** + * Gets a value indicating whether the custom time zone should have a + * daylight period. true if the custom time zone should + * have a daylight period; otherwise, false. + * + * @return the checks for daylight period + */ + protected boolean getHasDaylightPeriod() { + return (!(this.daylightDisplayName == null || + this.daylightDisplayName.isEmpty())); + } + } + + /** + * Gets a value indicating whether this group contains a transition to the + * Daylight period. true if this group contains a transition + * to daylight; otherwise, false. + * + * @return the supports daylight + */ + protected boolean getSupportsDaylight() { + return this.transitions.size() == 2; + } + + /** + * Initializes the private members holding references to the transitions to + * the Daylight and Standard periods. + * + * @throws InvalidOrUnsupportedTimeZoneDefinitionException thrown when time zone definition is not valid. + */ + private void initializeTransitions() throws InvalidOrUnsupportedTimeZoneDefinitionException { + if (this.transitionToStandard == null) { + for (TimeZoneTransition transition : this.transitions) { + if (transition.getTargetPeriod().isStandardPeriod() || + (this.transitions.size() == 1)) { + this.transitionToStandard = transition; + } else { + this.transitionToDaylight = transition; + } + } + } + + // If we didn't find a Standard period, this is an invalid time zone + // group. + if (this.transitionToStandard == null) { + throw new InvalidOrUnsupportedTimeZoneDefinitionException(); + } + } + + /** + * Gets the transition to the Daylight period. + * + * @return the transition to daylight + */ + private TimeZoneTransition getTransitionToDaylight() throws InvalidOrUnsupportedTimeZoneDefinitionException { + this.initializeTransitions(); + return this.transitionToDaylight; + } + + /** + * Gets the transition to the Standard period. + * + * @return the transition to standard + */ + private TimeZoneTransition getTransitionToStandard() + throws InvalidOrUnsupportedTimeZoneDefinitionException { + this.initializeTransitions(); + return this.transitionToStandard; + } + + /** + * Gets the offset to UTC based on this group's transitions. + * + * @return the custom time zone creation params + */ + protected CustomTimeZoneCreateParams getCustomTimeZoneCreationParams() { + CustomTimeZoneCreateParams result = new CustomTimeZoneCreateParams(); + + if (this.transitionToDaylight != null) { + result.setDaylightDisplayName(this.transitionToDaylight + .getTargetPeriod().getName()); + } + + result.setStandardDisplayName(this.transitionToStandard + .getTargetPeriod().getName()); + + // Assume that the standard period's offset is the base offset to UTC. + // EWS returns a positive offset for time zones that are behind UTC, and + // a negative one for time zones ahead of UTC. TimeZoneInfo does it the + // other + // way around. + // result.BaseOffsetToUtc = + // -this.TransitionToStandard.TargetPeriod.Bias; + + return result; + } + + /** + * Initializes a new instance of the class. + * + * @param timeZoneDefinition the time zone definition + */ + public TimeZoneTransitionGroup(TimeZoneDefinition timeZoneDefinition) { + super(); + this.timeZoneDefinition = timeZoneDefinition; + } + + /** + * Initializes a new instance of the class. + * + * @param timeZoneDefinition the time zone definition + * @param id the id + */ + public TimeZoneTransitionGroup(TimeZoneDefinition timeZoneDefinition, String id) { + this(timeZoneDefinition); + this.id = id; + } + + /** + * Gets the id of this group. + * + * @return the id + */ + public String getId() { + return this.id; + } + + /** + * Sets the id. + * + * @param id the new id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Gets the transitions in this group. + * + * @return the transitions + */ + public List getTransitions() { + return this.transitions; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/AttachmentsPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/AttachmentsPropertyDefinition.java new file mode 100644 index 000000000..69c20fded --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/AttachmentsPropertyDefinition.java @@ -0,0 +1,76 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.property.complex.AttachmentCollection; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; + +import java.util.EnumSet; + +/** + * Represents base Attachments property type. + */ +public final class AttachmentsPropertyDefinition extends ComplexPropertyDefinition { + + private static final EnumSet Exchange2010SP2PropertyDefinitionFlags = EnumSet + .of(PropertyDefinitionFlags.AutoInstantiateOnRead, + PropertyDefinitionFlags.CanSet, + PropertyDefinitionFlags.ReuseInstance, + PropertyDefinitionFlags.UpdateCollectionItems); + + public AttachmentsPropertyDefinition() { + super(null, XmlElementNames.Attachments, "item:Attachments", + EnumSet + .of(PropertyDefinitionFlags.AutoInstantiateOnRead), + ExchangeVersion.Exchange2007_SP1, + new ICreateComplexPropertyDelegate() { + public AttachmentCollection createComplexProperty() { + return new AttachmentCollection(); + } + }); + + } + + /** + * Determines whether the specified flag is set. + * + * @param flag The flag. + * @param version Requested version. + * @return true/false if the specified flag is set,otherwise false. + */ + @Override + public boolean hasFlag(PropertyDefinitionFlags flag, ExchangeVersion version) { + if (version != null + && this.getVersion() + .compareTo(ExchangeVersion.Exchange2010_SP2) >= 0) { + return AttachmentsPropertyDefinition.Exchange2010SP2PropertyDefinitionFlags + .contains(flag); + } + return super.hasFlag(flag, version); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/BoolPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/BoolPropertyDefinition.java new file mode 100644 index 000000000..a452c616d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/BoolPropertyDefinition.java @@ -0,0 +1,93 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; + +import java.util.EnumSet; + +/** + * Represents Boolean property definition. + */ +public final class BoolPropertyDefinition extends GenericPropertyDefinition { + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param version The version. + */ + public BoolPropertyDefinition(String xmlElementName, String uri, + ExchangeVersion version) { + super(Boolean.class, xmlElementName, uri, version); + } + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + */ + public BoolPropertyDefinition(String xmlElementName, String uri, EnumSet flags, + ExchangeVersion version) { + super(Boolean.class, xmlElementName, uri, flags, version); + } + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + * @param isNullable Indicates that this property definition is for a nullable + * property. + */ + public BoolPropertyDefinition(String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version, + boolean isNullable) { + super(Boolean.class, xmlElementName, uri, flags, version, isNullable); + } + + /** + * Convert instance to string. + * + * @param value The value. + * @return String representation of property value. + */ + @Override + /** + * Convert instance to string. + * @param value The value. + * @return String representation of Boolean property. + */ + protected String toString(Boolean value) { + return EwsUtilities.boolToXSBool(value); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/ByteArrayPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ByteArrayPropertyDefinition.java new file mode 100644 index 000000000..2e4400c39 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ByteArrayPropertyDefinition.java @@ -0,0 +1,91 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; + +import java.util.Base64; +import java.util.EnumSet; + +/** + * Represents byte array property definition. + */ +public final class ByteArrayPropertyDefinition extends TypedPropertyDefinition { + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + */ + public ByteArrayPropertyDefinition(String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version) { + super(xmlElementName, uri, flags, version); + } + + /** + * Parses the specified value. + * + * @param value accepts String + * @return value + */ + @Override + protected byte[] parse(String value) { + return Base64.getMimeDecoder().decode(value); + } + + /** + * Converts byte array property to a string. + * + * @param value accepts Object + * @return value + */ + @Override + protected String toString(byte[] value) { + return Base64.getMimeEncoder().encodeToString(value); + } + + /** + * Gets a value indicating whether this property definition is for a + * nullable type (ref, int?, bool?...). + * + * @return True + */ + @Override + public boolean isNullable() { + return true; + } + + /** + * Gets the property type. + */ + @Override + public Class getType() { + return Byte.class; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/ComplexPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ComplexPropertyDefinition.java new file mode 100644 index 000000000..0e94267f9 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ComplexPropertyDefinition.java @@ -0,0 +1,171 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.property.complex.ComplexProperty; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; +import com.eischet.ews.api.property.complex.IOwnedProperty; + +import java.util.EnumSet; + +/** + * Represents base complex property type. + * + * @param The type of the complex property. + */ +public class ComplexPropertyDefinition + extends ComplexPropertyDefinitionBase { + + private Class instance; + /** + * The property creation delegate. + */ + private final ICreateComplexPropertyDelegate propertyCreationDelegate; + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param flags The flags. + * @param version The version. + * @param propertyCreationDelegate Delegate used to create instances of ComplexProperty. + */ + public ComplexPropertyDefinition( + Class cls, + String xmlElementName, + EnumSet flags, + ExchangeVersion version, + ICreateComplexPropertyDelegate + propertyCreationDelegate) { + super(xmlElementName, flags, version); + this.instance = cls; + EwsUtilities.ewsAssert(propertyCreationDelegate != null, "ComplexPropertyDefinition ctor", + "CreateComplexPropertyDelegate cannot be null"); + + this.propertyCreationDelegate = propertyCreationDelegate; + } + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param version The version. + * @param propertyCreationDelegate Delegate used to create instances of ComplexProperty. + */ + public ComplexPropertyDefinition( + Class cls, + String xmlElementName, + String uri, + ExchangeVersion version, + ICreateComplexPropertyDelegate + propertyCreationDelegate) { + super(xmlElementName, uri, version); + this.instance = cls; + this.propertyCreationDelegate = propertyCreationDelegate; + } + + public ComplexPropertyDefinition(String xmlElementName, String uri, ExchangeVersion version, + ICreateComplexPropertyDelegate propertyCreationDelegate) { + super(xmlElementName, uri, version); + this.propertyCreationDelegate = propertyCreationDelegate; + } + + /** + * Instantiates a new complex property definition. + * + * @param xmlElementName the xml element name + * @param uri the uri + * @param flags the flags + * @param version the version + * @param propertyCreationDelegate the property creation delegate + */ + public ComplexPropertyDefinition(Class cls, String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version, + ICreateComplexPropertyDelegate propertyCreationDelegate) { + super(xmlElementName, uri, flags, version); + this.instance = cls; + this.propertyCreationDelegate = propertyCreationDelegate; + } + + + /** + * Instantiates a new complex property definition. + * + * @param xmlElementName the xml element name + * @param attachments the attachments + * @param flags the flags + * @param version the version + * @param propertyCreationDelegate the property creation delegate + */ + public ComplexPropertyDefinition( + String attachments, + String xmlElementName, + ExchangeVersion version, + EnumSet flags, + ICreateComplexPropertyDelegate propertyCreationDelegate) { + super(xmlElementName, attachments, flags, version); + this.propertyCreationDelegate = propertyCreationDelegate; + } + + /** + * Creates the property instance. + * + * @param owner The owner. + * @return ComplexProperty instance. + */ + @Override + public ComplexProperty createPropertyInstance(ServiceObject owner) { + TComplexProperty complexProperty = this.propertyCreationDelegate + .createComplexProperty(); + if (complexProperty instanceof IOwnedProperty) { + IOwnedProperty ownedProperty = (IOwnedProperty) complexProperty; + ownedProperty.setOwner(owner); + } + return complexProperty; + } + + /** + * Gets the property type. + */ + @Override + public Class getType() { + /*ParameterizedType parameterizedType = + (ParameterizedType) getClass().getGenericSuperclass(); + return (Class) parameterizedType.getActualTypeArguments()[0]; + + instance = ((Class)((ParameterizedType)this.getClass(). + getGenericSuperclass()).getActualTypeArguments()[0]). + newInstance(); */ + /*return ((Class)((ParameterizedType)this.getClass(). + getGenericSuperclass()).getActualTypeArguments()[0]). + newInstance();*/ + //return ComplexProperty.class; + return this.instance; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/ComplexPropertyDefinitionBase.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ComplexPropertyDefinitionBase.java new file mode 100644 index 000000000..6c56bbceb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ComplexPropertyDefinitionBase.java @@ -0,0 +1,169 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertyBag; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.complex.ComplexProperty; + +import java.util.EnumSet; + +/** + * Represents abstract complex property definition. + */ +public abstract class ComplexPropertyDefinitionBase extends PropertyDefinition { + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param flags The flags. + * @param version The version. + */ + protected ComplexPropertyDefinitionBase(String xmlElementName, + EnumSet flags, ExchangeVersion version) { + super(xmlElementName, flags, version); + } + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param version The version. + */ + protected ComplexPropertyDefinitionBase(String xmlElementName, String uri, + ExchangeVersion version) { + super(xmlElementName, uri, version); + } + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + */ + protected ComplexPropertyDefinitionBase(String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version) { + super(xmlElementName, uri, flags, version); + } + + /** + * Creates the property instance. + * + * @param owner The owner. + * @return ComplexProperty. + */ + public abstract ComplexProperty createPropertyInstance(ServiceObject owner); + + /** + * Internals the load from XML. + * + * @param reader The reader. + * @param propertyBag The property bag. + * @throws Exception the exception + */ + protected void internalLoadFromXml(final EwsServiceXmlReader reader, final PropertyBag propertyBag) throws ExchangeXmlException { + final OutParam complexProperty = new OutParam<>(); + final boolean justCreated = getPropertyInstance(propertyBag, complexProperty); + + if (!justCreated && this.hasFlag(PropertyDefinitionFlags.UpdateCollectionItems, + propertyBag.getOwner().getService().getRequestedServerVersion())) { + final ComplexProperty c = complexProperty.getParam(); + c.updateFromXml(reader, reader.getLocalName()); + } else { + final ComplexProperty c = complexProperty.getParam(); + c.loadFromXml(reader, reader.getLocalName()); + } + + propertyBag.setObjectFromPropertyDefinition(this, complexProperty + .getParam()); + } + + + /** + * Gets the property instance. + * + * @param propertyBag The property bag. + * @param complexProperty The property instance. + * @return True if the instance is newly created. + */ + private boolean getPropertyInstance( + final PropertyBag propertyBag, final OutParam complexProperty + ) { + final ServiceObject owner = propertyBag.getOwner(); + final ExchangeService service = owner.getService(); + + if (!propertyBag.tryGetValue(this, complexProperty) + || !hasFlag(PropertyDefinitionFlags.ReuseInstance, service.getRequestedServerVersion())) { + complexProperty.setParam(createPropertyInstance(owner)); + return true; + } + return false; + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @param propertyBag The property bag. + */ + @Override + public void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, this.getXmlElement()); + + if (!reader.isEmptyElement() || reader.hasAttributes()) { + this.internalLoadFromXml(reader, propertyBag); + } + reader.readEndElementIfNecessary(XmlNamespace.Types, this + .getXmlElement()); + } + + /** + * Writes to XML. + * + * @param writer The writer. + * @param propertyBag The property bag. + * @param isUpdateOperation Indicates whether the context is an update operation. + */ + @Override + public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, + boolean isUpdateOperation) throws ExchangeXmlException { + ComplexProperty complexProperty = + propertyBag.getObjectFromPropertyDefinition(this); + if (complexProperty != null) { + complexProperty.writeToXml(writer, this.getXmlElement()); + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/ContainedPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ContainedPropertyDefinition.java new file mode 100644 index 000000000..e38b89f87 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ContainedPropertyDefinition.java @@ -0,0 +1,105 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.PropertyBag; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.ComplexProperty; +import com.eischet.ews.api.property.complex.ICreateComplexPropertyDelegate; + +import java.util.EnumSet; + +/** + * Represents contained property definition. + * + * @param The type of the complex property. + */ +public class ContainedPropertyDefinition + extends ComplexPropertyDefinition { + + /** + * The contained xml element name. + */ + private final String containedXmlElementName; + + /** + * Initializes a new instance of. ContainedPropertyDefinition + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param containedXmlElementName Name of the contained XML element. + * @param flags The flags. + * @param version The version. + * @param propertyCreationDelegate Delegate used to create instances of ComplexProperty. + */ + public ContainedPropertyDefinition(Class cls, String xmlElementName, String uri, + String containedXmlElementName, EnumSet flags, ExchangeVersion version, + ICreateComplexPropertyDelegate propertyCreationDelegate) { + super(cls, xmlElementName, uri, flags, version, + propertyCreationDelegate); + this.containedXmlElementName = containedXmlElementName; + } + + /** + * Load from XML. + * + * @param reader the reader + * @param propertyBag the property bag + */ + @Override + protected void internalLoadFromXml(EwsServiceXmlReader reader, + PropertyBag propertyBag) throws ExchangeXmlException { + reader.readStartElement(XmlNamespace.Types, + this.containedXmlElementName); + super.internalLoadFromXml(reader, propertyBag); + reader.readEndElementIfNecessary(XmlNamespace.Types, + this.containedXmlElementName); + + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param propertyBag the property bag + * @param isUpdateOperation the is update operation + */ + @Override + public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, + boolean isUpdateOperation) throws ExchangeXmlException { + + Object o = propertyBag.getObjectFromPropertyDefinition(this); + if (o instanceof ComplexProperty) { + ComplexProperty complexProperty = (ComplexProperty) o; + writer.writeStartElement(XmlNamespace.Types, this.getXmlElement()); + complexProperty.writeToXml(writer, this.containedXmlElementName); + writer.writeEndElement(); // this.XmlElementName + } + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/DateTimePropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/DateTimePropertyDefinition.java new file mode 100644 index 000000000..b9f148bdd --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/DateTimePropertyDefinition.java @@ -0,0 +1,141 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.PropertyBag; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.util.DateTimeUtils; + +import java.time.LocalDateTime; +import java.util.EnumSet; + +/** + * Represents DateTime property definition. + */ +public class DateTimePropertyDefinition extends PropertyDefinition { + + /** + * The is nullable. + */ + private boolean isNullable; + + /** + * Initializes a new instance of the DateTimePropertyDefinition class. + * + * @param xmlElementName the xml element name + * @param uri the uri + * @param version the version + */ + public DateTimePropertyDefinition(String xmlElementName, String uri, ExchangeVersion version) { + super(xmlElementName, uri, version); + } + + /** + * Initializes a new instance of the DateTimePropertyDefinition class. + * + * @param xmlElementName the xml element name + * @param uri the uri + * @param flags the flags + * @param version the version + */ + public DateTimePropertyDefinition(String xmlElementName, String uri, EnumSet flags, + ExchangeVersion version) { + super(xmlElementName, uri, flags, version); + } + + /** + * Initializes a new instance of the DateTimePropertyDefinition class. + * + * @param xmlElementName the xml element name + * @param uri the uri + * @param flags the flags + * @param version the version + * @param isNullable the is nullable + */ + public DateTimePropertyDefinition(String xmlElementName, String uri, EnumSet flags, + ExchangeVersion version, boolean isNullable) { + super(xmlElementName, uri, flags, version); + this.isNullable = isNullable; + } + + /** + * Loads from XML. + * + * @param reader the reader + * @param propertyBag the property bag + */ + public void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws ExchangeXmlException { + String value = reader.readElementValue(XmlNamespace.Types, getXmlElement()); + propertyBag.setObjectFromPropertyDefinition(this, DateTimeUtils.parseDateTime(value)); + } + + + /** + * Writes the property value to XML. + * + * @param writer accepts EwsServiceXmlWriter + * @param propertyBag accepts PropertyBag + * @param isUpdateOperation accepts boolean whether the context is an update operation. + */ + public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, + boolean isUpdateOperation) throws ExchangeXmlException { + Object value = propertyBag.getObjectFromPropertyDefinition(this); + + if (value != null) { + writer.writeStartElement(XmlNamespace.Types, getXmlElement()); + // No need of changing the date time zone to UTC as Java takes + // default timezone as UTC + LocalDateTime dateTime = (LocalDateTime) value; + writer.writeValue(EwsUtilities.dateTimeToXSDateTime(dateTime), + getName()); + + writer.writeEndElement(); + } + } + + /** + * Gets a value indicating whether this property definition is for a + * nullable type (ref, int?, bool?...). + * + * @return true, if is nullable + */ + public boolean isNullable() { + return isNullable; + } + + /** + * Gets the property type. + */ + @Override + public Class getType() { + return LocalDateTime.class; + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/DoublePropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/DoublePropertyDefinition.java new file mode 100644 index 000000000..8867805da --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/DoublePropertyDefinition.java @@ -0,0 +1,50 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; + +import java.util.EnumSet; + +/** + * Represents double-precision floating point property definition. + */ +public final class DoublePropertyDefinition extends + GenericPropertyDefinition { + + /** + * Initializes a new instance of the "DoublePropertyDefinition" class. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + */ + public DoublePropertyDefinition(String xmlElementName, String uri, EnumSet flags, + ExchangeVersion version) { + super(Double.class, xmlElementName, uri, flags, version); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/EffectiveRightsPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/EffectiveRightsPropertyDefinition.java new file mode 100644 index 000000000..bc4f3d603 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/EffectiveRightsPropertyDefinition.java @@ -0,0 +1,134 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.PropertyBag; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.enumeration.service.EffectiveRights; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.util.EnumSet; + +/** + * Represents effective rights property definition. + */ +public final class EffectiveRightsPropertyDefinition extends PropertyDefinition { + + /** + * Initializes a new instance of the EffectiveRightsPropertyDefinition. + * + * @param xmlElementName the xml element name + * @param uri the uri + * @param flags the flags + * @param version the version + */ + public EffectiveRightsPropertyDefinition(String xmlElementName, String uri, EnumSet flags, ExchangeVersion version) { + super(xmlElementName, uri, flags, version); + + } + + /** + * Loads from XML. + * + * @param reader the reader + * @param propertyBag the property bag + */ + public void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws ExchangeXmlException { + EnumSet value = EnumSet.noneOf(EffectiveRights.class); + value.add(EffectiveRights.None); + + reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, this.getXmlElement()); + + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.isStartElement()) { + + if (reader.getLocalName().equals(XmlElementNames.CreateAssociated)) { + + if (reader.readElementValue(Boolean.class)) { + value.add(EffectiveRights.CreateAssociated); + } + } else if (reader.getLocalName().equals(XmlElementNames.CreateContents)) { + + if (reader.readElementValue(Boolean.class)) { + value.add(EffectiveRights.CreateContents); + } + } else if (reader.getLocalName().equals(XmlElementNames.CreateHierarchy)) { + + if (reader.readElementValue(Boolean.class)) { + value.add(EffectiveRights.CreateHierarchy); + } + } else if (reader.getLocalName().equals(XmlElementNames.Delete)) { + + if (reader.readElementValue(Boolean.class)) { + value.add(EffectiveRights.Delete); + } + } else if (reader.getLocalName().equals(XmlElementNames.Modify)) { + + if (reader.readElementValue(Boolean.class)) { + value.add(EffectiveRights.Modify); + } + } else if (reader.getLocalName().equals(XmlElementNames.Read)) { + if (reader.readElementValue(Boolean.class)) { + value.add(EffectiveRights.Read); + } else if (reader.getLocalName().equals(XmlElementNames.ViewPrivateItems)) { + if (reader.readElementValue(Boolean.class)) { + value.add(EffectiveRights.ViewPrivateItems); + } + } + + } + } + + } while (!reader.isEndElement(XmlNamespace.Types, this.getXmlElement())); + } + propertyBag.setObjectFromPropertyDefinition(this, value); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param propertyBag the property bag + * @param isUpdateOperation the is update operation + */ + public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, boolean isUpdateOperation) { + // EffectiveRights is a read-only property, no need to implement this. + } + + /** + * Gets the property type. + */ + @Override + public Class getType() { + return EffectiveRights.class; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/ExtendedPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ExtendedPropertyDefinition.java new file mode 100644 index 000000000..15329c6e4 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ExtendedPropertyDefinition.java @@ -0,0 +1,447 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.*; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.DefaultExtendedPropertySet; +import com.eischet.ews.api.core.enumeration.property.MapiPropertyType; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.MapiTypeConverter; + +import java.util.UUID; + +/** + * Represents the definition of an extended property. + */ +public final class ExtendedPropertyDefinition extends PropertyDefinitionBase { + + /** + * The Constant FieldFormat. + */ + private final static String FieldFormat = "%s: %s "; + /** + * The Property set field name. + */ + private static final String PropertySetFieldName = "PropertySet"; + /** + * The Property set id field name. + */ + private static final String PropertySetIdFieldName = "PropertySetId"; + /** + * The Tag field name. + */ + private static final String TagFieldName = "Tag"; + /** + * The Name field name. + */ + private static final String NameFieldName = "Name"; + /** + * The Id field name. + */ + private static final String IdFieldName = "Id"; + /** + * The Mapi type field name. + */ + private static final String MapiTypeFieldName = "MapiType"; + /** + * The property set. + */ + private DefaultExtendedPropertySet propertySet; + /** + * The property set id. + */ + private UUID propertySetId; + /** + * The tag. + */ + private Integer tag; + /** + * The name. + */ + private String name; + /** + * The id. + */ + private Integer id; + /** + * The mapi type. + */ + private MapiPropertyType mapiType; + + /** + * Initializes a new instance. + */ + public ExtendedPropertyDefinition() { + super(); + this.mapiType = MapiPropertyType.String; + } + + /** + * Initializes a new instance. + * + * @param mapiType The MAPI type of the extended property. + */ + protected ExtendedPropertyDefinition(MapiPropertyType mapiType) { + this(); + this.mapiType = mapiType; + } + + /** + * Initializes a new instance. + * + * @param tag The tag of the extended property. + * @param mapiType The MAPI type of the extended property. + */ + public ExtendedPropertyDefinition(int tag, MapiPropertyType mapiType) { + this(mapiType); + if (tag < 0) { + throw new IllegalArgumentException("Argument out of range : tag " + "The extended property tag value must be in the range of 0 to 65,535."); + } + this.tag = tag; + } + + /** + * Initializes a new instance. + * + * @param propertySet The extended property set of the extended property. + * @param name The name of the extended property. + * @param mapiType The MAPI type of the extended property. + * @throws Exception the exception + */ + public ExtendedPropertyDefinition(DefaultExtendedPropertySet propertySet, String name, MapiPropertyType mapiType) throws ExchangeXmlException { + this(mapiType); + EwsUtilities.validateParam(name, "name"); + this.propertySet = propertySet; + this.name = name; + } + + /** + * Initializes a new instance. + * + * @param propertySet The property set of the extended property. + * @param id The Id of the extended property. + * @param mapiType The MAPI type of the extended property. + */ + public ExtendedPropertyDefinition(DefaultExtendedPropertySet propertySet, + int id, MapiPropertyType mapiType) { + this(mapiType); + this.propertySet = propertySet; + this.id = id; + } + + /** + * Initializes a new instance. + * + * @param propertySetId The property set Id of the extended property. + * @param name The name of the extended property. + * @param mapiType The MAPI type of the extended property. + * @throws Exception the exception + */ + public ExtendedPropertyDefinition(UUID propertySetId, String name, + MapiPropertyType mapiType) throws Exception { + this(mapiType); + EwsUtilities.validateParam(name, "name"); + + this.propertySetId = propertySetId; + this.name = name; + } + + /** + * Initializes a new instance. + * + * @param propertySetId The property set Id of the extended property. + * @param id The Id of the extended property. + * @param mapiType The MAPI type of the extended property. + */ + public ExtendedPropertyDefinition(UUID propertySetId, int id, + MapiPropertyType mapiType) { + this(mapiType); + this.propertySetId = propertySetId; + this.id = id; + } + + /** + * Determines whether two specified instances of ExtendedPropertyDefinition are equal. + * + * @param extPropDef1 First extended property definition. + * @param extPropDef2 Second extended property definition. + * @return True if extended property definitions are equal. + */ + protected static boolean isEqualTo(ExtendedPropertyDefinition extPropDef1, + ExtendedPropertyDefinition extPropDef2) { + if (extPropDef1 == extPropDef2) { + return true; + } + + if (extPropDef1 == null || extPropDef2 == null) { + return false; + } + + if (extPropDef1.getId() != null) { + if (!extPropDef1.getId().equals(extPropDef2.getId())) { + return false; + } + } else if (extPropDef2.getId() != null) { + return false; + } + + if (extPropDef1.getMapiType() != extPropDef2.getMapiType()) { + return false; + } + + if (extPropDef1.getTag() != null) { + if (!extPropDef1.getTag().equals(extPropDef2.getTag())) { + return false; + } + } else if (extPropDef2.getTag() != null) { + return false; + } + + if (extPropDef1.getName() != null) { + if (!extPropDef1.getName().equals(extPropDef2.getName())) { + return false; + } + } else if (extPropDef2.getName() != null) { + return false; + } + + if (extPropDef1.getPropertySet() != extPropDef2.getPropertySet()) { + return false; + } + + if (extPropDef1.propertySetId != null) { + return extPropDef1.propertySetId.equals(extPropDef2.propertySetId); + } else return extPropDef2.propertySetId == null; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.ExtendedFieldURI; + } + + /** + * Gets the minimum Exchange version that supports this extended property. + * + * @return The version. + */ + @Override + public ExchangeVersion getVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Writes the attribute to XML. + * + * @param writer The writer. + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) + throws ExchangeXmlException { + if (this.propertySet != null) { + writer.writeAttributeValue( + XmlAttributeNames.DistinguishedPropertySetId, + this.propertySet); + } + if (this.propertySetId != null) { + writer.writeAttributeValue(XmlAttributeNames.PropertySetId, + this.propertySetId.toString()); + } + if (this.tag != null) { + writer.writeAttributeValue(XmlAttributeNames.PropertyTag, this.tag); + } + if (null != this.name && !this.name.isEmpty()) { + writer.writeAttributeValue(XmlAttributeNames.PropertyName, + this.name); + } + if (this.id != null) { + writer.writeAttributeValue(XmlAttributeNames.PropertyId, this.id); + } + writer.writeAttributeValue(XmlAttributeNames.PropertyType, + this.mapiType); + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @throws Exception the exception + */ + public void loadFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + String attributeValue = reader.readAttributeValue(XmlAttributeNames.DistinguishedPropertySetId); + if (null != attributeValue && !attributeValue.isEmpty()) { + this.propertySet = DefaultExtendedPropertySet + .valueOf(attributeValue); + } + + attributeValue = reader.readAttributeValue(XmlAttributeNames.PropertySetId); + if (null != attributeValue && !attributeValue.isEmpty()) { + this.propertySetId = UUID.fromString(attributeValue); + } + + attributeValue = reader.readAttributeValue(XmlAttributeNames.PropertyTag); + if (null != attributeValue && !attributeValue.isEmpty()) { + this.tag = Integer.decode(attributeValue); + } + + this.name = reader.readAttributeValue(XmlAttributeNames.PropertyName); + attributeValue = reader.readAttributeValue(XmlAttributeNames.PropertyId); + if (null != attributeValue && !attributeValue.isEmpty()) { + this.id = Integer.parseInt(attributeValue); + } + + this.mapiType = reader.readAttributeValue(MapiPropertyType.class, + XmlAttributeNames.PropertyType); + } + + + /** + * Determines whether two specified instances of ExtendedPropertyDefinition + * are equal. + * + * @param obj the obj + * @return True if extended property definitions are equal. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof ExtendedPropertyDefinition) { + return ExtendedPropertyDefinition.isEqualTo(this, + (ExtendedPropertyDefinition) obj); + } else { + return false; + } + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return this.getPrintableName().hashCode(); + } + + /** + * Gets the property definition's printable name. + * + * @return The property definition's printable name. + */ + @Override + public String getPrintableName() { + return "{" + + formatField(NameFieldName, this.getName()) + + formatField(MapiTypeFieldName, this.getMapiType()) + + formatField(IdFieldName, this.getId()) + + formatField(PropertySetFieldName, this.getPropertySet()) + + formatField(PropertySetIdFieldName, this.getPropertySetId()) + + formatField(TagFieldName, this.getTag()) + + "}"; + } + + /** + * Formats the field. + * + * @param Type of the field. + * @param name The name. + * @param fieldValue The field value. + * @return the string + */ + protected String formatField(String name, T fieldValue) { + return (fieldValue != null) ? String.format(FieldFormat, name, + fieldValue) : ""; + } + + /** + * Gets the property set of the extended property. + * + * @return property set of the extended property. + */ + public DefaultExtendedPropertySet getPropertySet() { + return this.propertySet; + } + + /** + * Gets the property set Id or the extended property. + * + * @return property set Id or the extended property. + */ + public UUID getPropertySetId() { + return this.propertySetId; + } + + /** + * Gets the extended property's tag. + * + * @return The extended property's tag. + */ + public Integer getTag() { + return this.tag; + } + + /** + * Gets the name of the extended property. + * + * @return The name of the extended property. + */ + public String getName() { + return this.name; + } + + /** + * Gets the Id of the extended property. + * + * @return The Id of the extended property. + */ + public Integer getId() { + return this.id; + } + + /** + * Gets the MAPI type of the extended property. + * + * @return The MAPI type of the extended property. + */ + public MapiPropertyType getMapiType() { + return this.mapiType; + } + + /** + * Gets the property type. + */ + @Override + public Class getType() { + return MapiTypeConverter.getMapiTypeConverterMap(). + get(getMapiType()).getType(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/GenericPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/GenericPropertyDefinition.java new file mode 100644 index 000000000..056abb2a6 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/GenericPropertyDefinition.java @@ -0,0 +1,104 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.io.Serializable; +import java.text.ParseException; +import java.util.EnumSet; + +/** + * Represents generic property definition. + * + * @param Property type. + */ +public class GenericPropertyDefinition extends TypedPropertyDefinition { + + private final Class instance; + + /** + * Initializes a new instance of the "GenericPropertyDefinition<T>" + * class. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param version The version. + */ + public GenericPropertyDefinition(Class cls, String xmlElementName, String uri, + ExchangeVersion version) { + super(xmlElementName, uri, version); + this.instance = cls; + } + + /** + * Initializes a new instance of the "GenericPropertyDefinition<T>" + * class. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + */ + public GenericPropertyDefinition(Class cls, String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version) { + super(xmlElementName, uri, flags, version); + this.instance = cls; + } + + /** + * Initializes a new instance of the GenericPropertyDefinition class. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + * @param isNullable if set to true, property value is nullable. + */ + protected GenericPropertyDefinition( + Class cls, + String xmlElementName, + String uri, + EnumSet flags, + ExchangeVersion version, + boolean isNullable) { + super(xmlElementName, uri, flags, version, isNullable); + this.instance = cls; + } + + + @Override + protected TPropertyValue parse(String value) throws ExchangeXmlException { + + return EwsUtilities.parse(instance, value); + } + + @Override + public Class getType() { + return instance; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/GroupMemberPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/GroupMemberPropertyDefinition.java new file mode 100644 index 000000000..59d5043a7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/GroupMemberPropertyDefinition.java @@ -0,0 +1,125 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents the definition of the GroupMember property. + */ +public final class GroupMemberPropertyDefinition extends + ServiceObjectPropertyDefinition { + + // / FieldUri of IndexedFieldURI for a group member. + /** + * The Constant FIELDURI. + */ + private final static String FIELDURI = "distributionlist:Members:Member"; + + // / Member key. + // / Maps to the Index attribute of IndexedFieldURI element. + /** + * The key. + */ + private String key; + + /** + * Initializes a new instance of the GroupMemberPropertyDefinition class. + * + * @param key the key + */ + public GroupMemberPropertyDefinition(String key) { + super(FIELDURI); + this.key = key; + } + + /** + * Initializes a new instance of the GroupMemberPropertyDefinition class + * without key. + */ + public GroupMemberPropertyDefinition() { + super(FIELDURI); + } + + /** + * Gets the key. + * + * @return the key + */ + public String getKey() { + return key; + } + + /** + * Sets the key. + * + * @param key the new key + */ + public void setKey(String key) { + this.key = key; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + protected String getXmlElementName() { + return XmlElementNames.IndexedFieldURI; + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + */ + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + writer.writeAttributeValue(XmlAttributeNames.FieldIndex, this.key); + } + + /** + * Gets the property definition's printable name. + * + * @return The property definition's printable name. + */ + @Override + public String getPrintableName() { + return String.format("%s:%s", FIELDURI, this.key); + } + + + /** + * Gets the property type. + */ + @Override + public Class getType() { + return String.class; + } + + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/IndexedPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/IndexedPropertyDefinition.java new file mode 100644 index 000000000..8af9aa9e3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/IndexedPropertyDefinition.java @@ -0,0 +1,154 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents an indexed property definition. + */ +public final class IndexedPropertyDefinition extends + ServiceObjectPropertyDefinition { + + // Index attribute of IndexedFieldURI element. + /** + * The index. + */ + private final String index; + + /** + * Initializes a new instance of the IndexedPropertyDefinition class. + * + * @param uri The FieldURI attribute of the IndexedFieldURI element. + * @param index The Index attribute of the IndexedFieldURI element. + */ + public IndexedPropertyDefinition(String uri, String index) { + super(uri); + this.index = index; + } + + /** + * Determines whether two specified instances of IndexedPropertyDefinition + * are equal. + * + * @param idxPropDef1 First indexed property definition. + * @param idxPropDef2 Second indexed property definition. + * @return True if indexed property definitions are equal. + */ + protected static boolean isEqualTo(IndexedPropertyDefinition idxPropDef1, + IndexedPropertyDefinition idxPropDef2) { + return (idxPropDef1 == idxPropDef2) || + (idxPropDef1 != null && + idxPropDef2 != null && + idxPropDef1.getUri().equalsIgnoreCase( + idxPropDef2.getUri()) && idxPropDef1.index + .equalsIgnoreCase(idxPropDef2.index)); + } + + /** + * Gets the index of the property. + * + * @return The index string of the property. + */ + public String getIndex() { + return this.index; + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + writer.writeAttributeValue(XmlAttributeNames.FieldIndex, this.getIndex()); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.IndexedFieldURI; + } + + /** + * Gets the property definition's printable name. + * + * @return The property definition's printable name. + */ + @Override + public String getPrintableName() { + return String.format("%s:%s", this.getUri(), this.getIndex()); + } + + + /** + * Determines whether a given indexed property definition is equal to this + * indexed property definition. + * + * @param obj The + * object to check for equality. + * @return True if the property definitions define the same indexed + * property. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof IndexedPropertyDefinition) { + return IndexedPropertyDefinition.isEqualTo( + (IndexedPropertyDefinition) obj, this); + } else { + return false; + } + } + + /** + * Serves as a hash function for a particular type. + * + * @return A hash code for the current System.Object + */ + @Override + public int hashCode() { + return this.getUri().hashCode() ^ this.getIndex().hashCode(); + } + + /** + * Gets the property type. + */ + @Override + public Class getType() { + return String.class; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/IntPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/IntPropertyDefinition.java new file mode 100644 index 000000000..40278cab3 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/IntPropertyDefinition.java @@ -0,0 +1,76 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; + +import java.util.EnumSet; + +/** + * Represents Integer property defintion. + */ +public class IntPropertyDefinition extends GenericPropertyDefinition { + + /** + * Initializes a new instance of the "IntPropertyDefinition" class. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param version The version. + */ + public IntPropertyDefinition(String xmlElementName, String uri, ExchangeVersion version) { + super(Integer.class, xmlElementName, uri, version); + } + + /** + * Initializes a new instance of the "IntPropertyDefinition" class. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + */ + public IntPropertyDefinition(String xmlElementName, String uri, EnumSet flags, + ExchangeVersion version) { + super(Integer.class, xmlElementName, uri, flags, version); + } + + /** + * Initializes a new instance of the "IntPropertyDefinition" class. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + * @param isNullable Indicates that this property definition is for a nullable + * property. + */ + public IntPropertyDefinition(String xmlElementName, String uri, EnumSet flags, + ExchangeVersion version, boolean isNullable) { + super(Integer.class, xmlElementName, uri, flags, version, isNullable); + } + + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/MeetingTimeZonePropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/MeetingTimeZonePropertyDefinition.java new file mode 100644 index 000000000..86ccf068b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/MeetingTimeZonePropertyDefinition.java @@ -0,0 +1,93 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.PropertyBag; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.schema.AppointmentSchema; +import com.eischet.ews.api.property.complex.MeetingTimeZone; + +import java.util.EnumSet; + +/** + * Represents the definition for the meeting time zone property. + */ +public class MeetingTimeZonePropertyDefinition extends PropertyDefinition { + + /** + * Initializes a new instance of the MeetingTimeZonePropertyDefinition + * class. + * + * @param xmlElementName the xml element name + * @param uri the uri + * @param flags the flags + * @param version the version + */ + public MeetingTimeZonePropertyDefinition(String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version) { + super(xmlElementName, uri, flags, version); + + } + + /** + * Loads from XML. + * + * @param reader the reader + * @param propertyBag the property bag + */ + public final void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws ExchangeXmlException { + MeetingTimeZone meetingTimeZone = new MeetingTimeZone(); + meetingTimeZone.loadFromXml(reader, this.getXmlElement()); + + propertyBag.setObjectFromPropertyDefinition( + AppointmentSchema.StartTimeZone, meetingTimeZone + .toTimeZoneInfo()); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param propertyBag the property bag + * @param isUpdateOperation the is update operation + */ + public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, boolean isUpdateOperation) throws ExchangeXmlException { + MeetingTimeZone value = propertyBag.getObjectFromPropertyDefinition(this); + if (value != null) { + value.writeToXml(writer, this.getXmlElement()); + } + } + + /** + * Gets the property type. + */ + @Override + public Class getType() { + return MeetingTimeZone.class; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/PermissionSetPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/PermissionSetPropertyDefinition.java new file mode 100644 index 000000000..ec199d86d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/PermissionSetPropertyDefinition.java @@ -0,0 +1,78 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.folder.Folder; +import com.eischet.ews.api.property.complex.ComplexProperty; +import com.eischet.ews.api.property.complex.FolderPermissionCollection; + +import java.util.EnumSet; + +/** + * Represents permission set property definition. + */ +public class PermissionSetPropertyDefinition extends ComplexPropertyDefinitionBase { + + /** + * Initializes a new instance of the PermissionSetPropertyDefinition class. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + */ + public PermissionSetPropertyDefinition(String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version) { + super(xmlElementName, uri, flags, version); + } + + /** + * Creates the property instance. + * + * @param owner The owner. + * @return ComplexProperty. + */ + @Override + public ComplexProperty createPropertyInstance(ServiceObject owner) { + Folder folder = (Folder) owner; + + EwsUtilities.ewsAssert(folder != null, "PermissionCollectionPropertyDefinition.CreatePropertyInstance", + "The owner parameter is not of type Folder or a derived class."); + + return new FolderPermissionCollection(folder); + } + + /** + * Gets the property type. + */ + @Override + public Class getType() { + return FolderPermissionCollection.class; + } +} + diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/PropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/PropertyDefinition.java new file mode 100644 index 000000000..06856d523 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/PropertyDefinition.java @@ -0,0 +1,226 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.PropertyBag; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; + +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.List; + +/** + * Represents the definition of a folder or item property. + */ +public abstract class PropertyDefinition extends + ServiceObjectPropertyDefinition { + + /** + * The xml element name. + */ + private final String xmlElementName; + + /** + * The flags. + */ + private EnumSet flags; + + /** + * The name. + */ + private String name; + + /** + * The version. + */ + private final ExchangeVersion version; + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param version The version. + */ + protected PropertyDefinition(String xmlElementName, String uri, + ExchangeVersion version) { + super(uri); + this.xmlElementName = xmlElementName; + this.flags = EnumSet.of(PropertyDefinitionFlags.None); + this.version = version; + } + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param flags The flags. + * @param version The version. + */ + protected PropertyDefinition(String xmlElementName, + EnumSet flags, ExchangeVersion version) { + super(); + this.xmlElementName = xmlElementName; + this.flags = flags; + this.version = version; + } + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + */ + protected PropertyDefinition(String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version) { + this(xmlElementName, uri, version); + this.flags = flags; + } + + /** + * Determines whether the specified flag is set. + * + * @param flag The flag. + * @return true if the specified flag is set; otherwise, false. + */ + public boolean hasFlag(PropertyDefinitionFlags flag) { + return this.hasFlag(flag, null); + } + + /** + * Determines whether the specified flag is set. + * + * @param flag The flag. + * @return true if the specified flag is set; otherwise, false. + */ + public boolean hasFlag(PropertyDefinitionFlags flag, ExchangeVersion version) { + return this.flags.contains(flag); + } + + /** + * Registers associated internal property. + * + * @param properties The list in which to add the associated property. + */ + protected void registerAssociatedInternalProperties( + List properties) { + } + + /** + * Gets a list of associated internal property. + * + * @return A list of PropertyDefinition objects. This is a hack. It is here + * (currently) solely to help the API register the MeetingTimeZone + * property definition that is internal. + */ + public List getAssociatedInternalProperties() { + List properties = new ArrayList<>(); + this.registerAssociatedInternalProperties(properties); + return properties; + } + + /** + * Gets the minimum Exchange version that supports this property. + * + * @return The version. + */ + public ExchangeVersion getVersion() { + return version; + } + + /** + * Gets a value indicating whether this property definition is for a + * nullable type. + * + * @return always true + */ + public boolean isNullable() { + return true; + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @param propertyBag The property bag. + */ + public abstract void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws ExchangeXmlException; + + /** + * Writes the property value to XML. + * + * @param writer the writer + * @param propertyBag the property bag + * @param isUpdateOperation indicates whether the context is an update operation + */ + public abstract void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, boolean isUpdateOperation) throws ExchangeXmlException; + + /** + * Gets the name of the XML element. + * + * @return The name of the XML element. + */ + public String getXmlElement() { + return this.xmlElementName; + } + + /** + * Gets the name of the property. + * + * @return Name of the property. + */ + public String getName() { + + if (null == this.name || this.name.isEmpty()) { + ServiceObjectSchema.initializeSchemaPropertyNames(); + } + return name; + } + + /** + * Sets the name of the property. + * + * @param name name of the property + */ + public void setName(String name) { + this.name = name; + } + + /** + * Gets the property definition's printable name. + * + * @return The property definition's printable name. + */ + @Override + public String getPrintableName() { + return this.getName(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/PropertyDefinitionBase.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/PropertyDefinitionBase.java new file mode 100644 index 000000000..7d7e89af6 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/PropertyDefinitionBase.java @@ -0,0 +1,122 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.schema.ServiceObjectSchema; +import com.eischet.ews.api.misc.OutParam; + +/** + * Represents the base class for all property definitions. + */ +public abstract class PropertyDefinitionBase { + + /** + * Initializes a new instance. + */ + protected PropertyDefinitionBase() { + super(); + } + + /** + * Tries to load from XML. + * + * @param reader The reader. + * @param propertyDefinition The property definition. + * @return True if property was loaded. + * @throws Exception the exception + */ + public static boolean tryLoadFromXml(EwsServiceXmlReader reader, + OutParam propertyDefinition) throws ExchangeXmlException { + String strLocalName = reader.getLocalName(); + if (strLocalName.equals(XmlElementNames.FieldURI)) { + PropertyDefinitionBase p = ServiceObjectSchema + .findPropertyDefinition(reader.readAttributeValue(XmlAttributeNames.FieldURI)); + propertyDefinition.setParam(p); + return true; + } else if (strLocalName.equals(XmlElementNames.IndexedFieldURI)) { + reader.skipCurrentElement(); + return true; + } else if (strLocalName.equals(XmlElementNames.ExtendedFieldURI)) { + ExtendedPropertyDefinition p = new ExtendedPropertyDefinition(); + p.loadFromXml(reader); + propertyDefinition.setParam(p); + return true; + } else { + return false; + } + + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + protected abstract String getXmlElementName(); + + /** + * Writes the attribute to XML. + */ + protected abstract void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException; + + /** + * Gets the minimum Exchange version that supports this property. + * + * @return The version. + */ + public abstract ExchangeVersion getVersion(); + + /** + * Gets the property definition's printable name. + * + * @return The property definition's printable name. + */ + public abstract String getPrintableName(); + + /** + * Gets the type of the property. + */ + public abstract Class getType(); + + /** + * Writes to XML. + */ + public void writeToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Types, this.getXmlElementName()); + this.writeAttributesToXml(writer); + writer.writeEndElement(); + } + + @Override + public String toString() { + return this.getPrintableName(); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/RecurrencePropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/RecurrencePropertyDefinition.java new file mode 100644 index 000000000..f9ea29aef --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/RecurrencePropertyDefinition.java @@ -0,0 +1,182 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.PropertyBag; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlDeserializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.recurrence.pattern.Recurrence; +import com.eischet.ews.api.property.complex.recurrence.range.EndDateRecurrenceRange; +import com.eischet.ews.api.property.complex.recurrence.range.NoEndRecurrenceRange; +import com.eischet.ews.api.property.complex.recurrence.range.NumberedRecurrenceRange; +import com.eischet.ews.api.property.complex.recurrence.range.RecurrenceRange; +import com.eischet.ews.api.security.XmlNodeType; + +import java.util.EnumSet; + +/** + * Represenrs recurrence property definition. + */ +public class RecurrencePropertyDefinition extends PropertyDefinition { + + /** + * Initializes a new instance of the RecurrencePropertyDefinition class. + * + * @param xmlElementName the xml element name + * @param uri the uri + * @param flags the flags + * @param version the version + */ + public RecurrencePropertyDefinition(String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version) { + + super(xmlElementName, uri, flags, version); + + } + + /** + * Loads from XML. + * + * @param reader the reader + * @param propertyBag the property bag + */ + public void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, + XmlElementNames.Recurrence); + + Recurrence recurrence = null; + + reader.read(new XmlNodeType(XmlNodeType.START_ELEMENT)); // This is the + // pattern + // element + + if (reader.getLocalName().equals( + XmlElementNames.RelativeYearlyRecurrence)) { + + recurrence = new Recurrence.RelativeYearlyPattern(); + } else if (reader.getLocalName().equals( + XmlElementNames.AbsoluteYearlyRecurrence)) { + + recurrence = new Recurrence.YearlyPattern(); + } else if (reader.getLocalName().equals( + XmlElementNames.RelativeMonthlyRecurrence)) { + + recurrence = new Recurrence.RelativeMonthlyPattern(); + } else if (reader.getLocalName().equals( + XmlElementNames.AbsoluteMonthlyRecurrence)) { + + recurrence = new Recurrence.MonthlyPattern(); + } else if (reader.getLocalName() + .equals(XmlElementNames.DailyRecurrence)) { + + recurrence = new Recurrence.DailyPattern(); + } else if (reader.getLocalName().equals( + XmlElementNames.DailyRegeneration)) { + + recurrence = new Recurrence.DailyRegenerationPattern(); + } else if (reader.getLocalName().equals( + XmlElementNames.WeeklyRecurrence)) { + + recurrence = new Recurrence.WeeklyPattern(); + } else if (reader.getLocalName().equals( + XmlElementNames.WeeklyRegeneration)) { + + recurrence = new Recurrence.WeeklyRegenerationPattern(); + } else if (reader.getLocalName().equals( + XmlElementNames.MonthlyRegeneration)) { + + recurrence = new Recurrence.MonthlyRegenerationPattern(); + } else if (reader.getLocalName().equals( + XmlElementNames.YearlyRegeneration)) { + + recurrence = new Recurrence.YearlyRegenerationPattern(); + } else { + + throw new ExchangeValidationException(String.format("Invalid recurrence pattern: (%s).", reader.getLocalName())); + } + + recurrence.loadFromXml(reader, reader.getLocalName()); + + reader.read(new XmlNodeType(XmlNodeType.START_ELEMENT)); // This is the + // range + // element + + RecurrenceRange range; + + if (reader.getLocalName().equals(XmlElementNames.NoEndRecurrence)) { + + range = new NoEndRecurrenceRange(); + } else if (reader.getLocalName().equals( + XmlElementNames.EndDateRecurrence)) { + + range = new EndDateRecurrenceRange(); + } else if (reader.getLocalName().equals( + XmlElementNames.NumberedRecurrence)) { + + range = new NumberedRecurrenceRange(); + } else { + throw new ExchangeValidationException(String.format("Invalid recurrence range: (%s).", reader.getLocalName())); + } + + range.loadFromXml(reader, reader.getLocalName()); + range.setupRecurrence(recurrence); + + reader.readEndElementIfNecessary(XmlNamespace.Types, + XmlElementNames.Recurrence); + + propertyBag.setObjectFromPropertyDefinition(this, recurrence); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param propertyBag the property bag + * @param isUpdateOperation the is update operation + */ + public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, + boolean isUpdateOperation) throws ExchangeXmlException { + Recurrence value = propertyBag.getObjectFromPropertyDefinition(this); + + if (value != null) { + value.writeToXml(writer, XmlElementNames.Recurrence); + } + } + + /** + * Gets the property type. + */ + @Override + public Class getType() { + return Recurrence.class; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/ResponseObjectsPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ResponseObjectsPropertyDefinition.java new file mode 100644 index 000000000..e05521c6a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ResponseObjectsPropertyDefinition.java @@ -0,0 +1,153 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.PropertyBag; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.ResponseActions; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.util.EnumSet; + +/** + * Represents response object property defintion. + */ +public class ResponseObjectsPropertyDefinition extends PropertyDefinition { + + /** + * Initializes a new instance of the ResponseObjectsPropertyDefinition + * class. + * + * @param xmlElementName the xml element name + * @param uri the uri + * @param version the version + */ + public ResponseObjectsPropertyDefinition(String xmlElementName, String uri, ExchangeVersion version) { + super(xmlElementName, uri, version); + + } + + /** + * Loads from XML. + * + * @param reader the reader + * @param propertyBag the property bag + */ + public final void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws ExchangeXmlException { + EnumSet value = EnumSet.noneOf(ResponseActions.class); + value.add(ResponseActions.None); + + reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, this.getXmlElement()); + + if (!reader.isEmptyElement()) { + do { + reader.read(); + + if (reader.isStartElement()) { + + if (reader.getLocalName() + .equals(XmlElementNames.AcceptItem)) { + + value.add(ResponseActions.Accept); + } else if (reader.getLocalName().equals( + XmlElementNames.TentativelyAcceptItem)) { + + value.add(ResponseActions.TentativelyAccept); + } else if (reader.getLocalName().equals( + XmlElementNames.DeclineItem)) { + + value.add(ResponseActions.Decline); + } else if (reader.getLocalName().equals( + XmlElementNames.ReplyToItem)) { + + value.add(ResponseActions.Reply); + } else if (reader.getLocalName().equals( + XmlElementNames.ForwardItem)) { + + value.add(ResponseActions.Forward); + } else if (reader.getLocalName().equals( + XmlElementNames.ReplyAllToItem)) { + + value.add(ResponseActions.ReplyAll); + } else if (reader.getLocalName().equals( + XmlElementNames.CancelCalendarItem)) { + + value.add(ResponseActions.Cancel); + } else if (reader.getLocalName().equals( + XmlElementNames.RemoveItem)) { + + value.add(ResponseActions.RemoveFromCalendar); + } else if (reader.getLocalName().equals( + XmlElementNames.SuppressReadReceipt)) { + + value.add(ResponseActions.SuppressReadReceipt); + } else if (reader.getLocalName().equals( + XmlElementNames.PostReplyItem)) { + + value.add(ResponseActions.PostReply); + } + } + + } while (!reader.isEndElement(XmlNamespace.Types, this + .getXmlElement())); + } else { + reader.read(); + } + + propertyBag.setObjectFromPropertyDefinition(this, value); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param propertyBag the property bag + * @param isUpdateOperation the is update operation + */ + public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, + boolean isUpdateOperation) { + // ResponseObjects is a read-only property, no need to implement this. + } + + /** + * Gets a value indicating whether this property + * definition is for a nullable type (ref, int?, bool?...). + */ + @Override + public boolean isNullable() { + return false; + } + + /** + * Gets the property type. + */ + @Override + public Class getType() { + return ResponseActions.class; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/ServiceObjectPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ServiceObjectPropertyDefinition.java new file mode 100644 index 000000000..d11b0299f --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/ServiceObjectPropertyDefinition.java @@ -0,0 +1,100 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +/** + * Represents a property definition for a service object. + */ +public abstract class ServiceObjectPropertyDefinition extends PropertyDefinitionBase { + + /** + * The uri. + */ + private String uri; + + /** + * Gets the name of the XML element. + * + * @return the name of the XML element. + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.FieldURI; + } + + /** + * Gets the minimum Exchange version that supports this property. + * + * @return The minimum Exchange version that supports this property. + */ + @Override + public ExchangeVersion getVersion() { + return ExchangeVersion.Exchange2007_SP1; + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + */ + @Override + protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.FieldURI, this.getUri()); + } + + /** + * Initializes a new instance. + */ + protected ServiceObjectPropertyDefinition() { + super(); + } + + /** + * Initializes a new instance. + * + * @param uri The URI. + */ + protected ServiceObjectPropertyDefinition(String uri) { + this(); + EwsUtilities.ewsAssert(!(uri == null || uri.isEmpty()), "ServiceObjectPropertyDefinition.ctor", + "uri is null or empty"); + this.uri = uri; + } + + /** + * Gets the URI of the property definition. + * + * @return The URI of the property definition. + */ + public String getUri() { + return uri; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/StartTimeZonePropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/StartTimeZonePropertyDefinition.java new file mode 100644 index 000000000..267421589 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/StartTimeZonePropertyDefinition.java @@ -0,0 +1,127 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.PropertyBag; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.schema.AppointmentSchema; +import com.eischet.ews.api.property.complex.MeetingTimeZone; +import com.eischet.ews.api.property.complex.time.TimeZoneDefinition; + +import javax.xml.stream.XMLStreamException; +import java.util.EnumSet; +import java.util.List; + +/** + * Represents a property definition for property of type TimeZoneInfo. + */ +public class StartTimeZonePropertyDefinition extends TimeZonePropertyDefinition { + + /** + * Initializes a new instance of the StartTimeZonePropertyDefinition + * class. + * + * @param xmlElementName the xml element name + * @param uri the uri + * @param flags the flags + * @param version the version + */ + public StartTimeZonePropertyDefinition(String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version) { + super(xmlElementName, uri, flags, version); + } + + /** + * Registers associated internal property. + * + * @param properties the property + */ + protected void registerAssociatedInternalProperties( + List properties) { + super.registerAssociatedInternalProperties(properties); + + properties.add(AppointmentSchema.MeetingTimeZone); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param propertyBag the property bag + * @param isUpdateOperation the is update operation + */ + public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, + boolean isUpdateOperation) throws ExchangeXmlException { + Object value = propertyBag.getObjectFromPropertyDefinition(this); + + if (value != null) { + final ExchangeService service = (ExchangeService) writer.getService(); + if (service.getRequestedServerVersion() == ExchangeVersion.Exchange2007_SP1) { + if (!service.getExchange2007CompatibilityMode()) { + MeetingTimeZone meetingTimeZone = new MeetingTimeZone((TimeZoneDefinition) value); + meetingTimeZone.writeToXml(writer, XmlElementNames.MeetingTimeZone); + } + } else { + super.writePropertyValueToXml(writer, propertyBag, isUpdateOperation); + } + } + } + + /** + * Writes to XML. + * + * @param writer the writer + */ + public void writeToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + if (writer.getService().getRequestedServerVersion() == ExchangeVersion.Exchange2007_SP1) { + AppointmentSchema.MeetingTimeZone.writeToXml(writer); + } else { + super.writeToXml(writer); + } + } + + /** + * Determines whether the specified flag is set. + * + * @param flag The flag. + * @param version Requested version. + * @return true if the specified + * flag is set; otherwise, false. + */ + @Override + public boolean hasFlag(PropertyDefinitionFlags flag, ExchangeVersion version) { + if (version != null && (version == ExchangeVersion.Exchange2007_SP1)) { + return AppointmentSchema.MeetingTimeZone.hasFlag(flag, version); + } else { + return super.hasFlag(flag, version); + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/StringPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/StringPropertyDefinition.java new file mode 100644 index 000000000..675e56700 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/StringPropertyDefinition.java @@ -0,0 +1,78 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; + +import java.util.EnumSet; + +/** + * Represents String property definition. + */ +public class StringPropertyDefinition extends TypedPropertyDefinition { + + /** + * Initializes a new instance of the "StringPropertyDefinition" class. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + */ + public StringPropertyDefinition(String xmlElementName, String uri, EnumSet flags, + ExchangeVersion version) { + super(xmlElementName, uri, flags, version); + } + + /** + * Parses the specified value. + * + * @param value The value. + * @return Typed value. + */ + @Override + protected String parse(String value) { + return value; + } + + /** + * Gets a value indicating whether this property definition is for a + * nullable type (ref, int?, bool?...). + * + * @return True + */ + @Override + public boolean isNullable() { + return true; + } + + /** + * Gets the property type. + */ + @Override + public Class getType() { + return String.class; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/TaskDelegationStatePropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/TaskDelegationStatePropertyDefinition.java new file mode 100644 index 000000000..929911d46 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/TaskDelegationStatePropertyDefinition.java @@ -0,0 +1,147 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.enumeration.property.TaskDelegationState; + +import java.util.EnumSet; + +/** + * Represents a task delegation property definition. + */ +public final class TaskDelegationStatePropertyDefinition extends + GenericPropertyDefinition { + /** + * The No match. + */ + private static final String NoMatch = "NoMatch"; + + /** + * The Own new. + */ + private static final String OwnNew = "OwnNew"; + + /** + * The Owned. + */ + private static final String Owned = "Owned"; + + /** + * The Accepted. + */ + private static final String Accepted = "Accepted"; + + /** + * Initializes a new instance of the "TaskDelegationStatePropertyDefinition" + * class. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + */ + public TaskDelegationStatePropertyDefinition(String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version) { + super(TaskDelegationState.class, xmlElementName, uri, flags, version); + } + + /** + * The Enum Status. + */ + public enum Status { + + /** + * The No match. + */ + NoMatch, + /** + * The Own new. + */ + OwnNew, + /** + * The Owned. + */ + Owned, + /** + * The Accepted. + */ + Accepted + } + + /** + * Parses the specified value. + * + * @param value The value. + * @return Typed value. + */ + @Override + protected TaskDelegationState parse(String value) { + switch (Status.valueOf(value)) { + case NoMatch: + return TaskDelegationState.NoDelegation; + case OwnNew: + return TaskDelegationState.Unknown; + case Owned: + return TaskDelegationState.Accepted; + case Accepted: + return TaskDelegationState.Declined; + default: + EwsUtilities.ewsAssert(false, "TaskDelegationStatePropertyDefinition.Parse", + String.format("TaskDelegationStatePropertyDefinition." + + "Parse():" + + " value %s cannot be handled.", value)); + + return null; // To keep the compiler happy + } + } + + /** + * Convert instance to string. + * + * @param value The value. + * @return String representation of property value. + */ + @Override + protected String toString(TaskDelegationState value) { + if (value.equals(TaskDelegationState.NoDelegation)) { + return NoMatch; + } else if (value.equals(TaskDelegationState.Unknown)) { + return OwnNew; + } else if (value.equals(TaskDelegationState.Accepted)) { + return Owned; + } + if (value.equals(TaskDelegationState.Declined)) { + return Accepted; + } else { + EwsUtilities.ewsAssert(false, "TaskDelegationStatePropertyDefinition.ToString", + "Invalid TaskDelegationState value."); + return null; // To keep the compiler happy + } + + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/TimeSpanPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/TimeSpanPropertyDefinition.java new file mode 100644 index 000000000..863a1b4b9 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/TimeSpanPropertyDefinition.java @@ -0,0 +1,73 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.misc.TimeSpan; + +import java.util.EnumSet; + +/** + * Represents TimeSpan property definition. + */ +public class TimeSpanPropertyDefinition extends GenericPropertyDefinition { + + + /** + * Initializes a new instance of the "TimeSpanPropertyDefinition" class. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + */ + public TimeSpanPropertyDefinition(String xmlElementName, String uri, EnumSet flags, + ExchangeVersion version) { + super(TimeSpan.class, xmlElementName, uri, flags, version); + } + + /** + * Parses the specified value. + * + * @param value The value. + * @return Typed value. + */ + @Override + protected TimeSpan parse(String value) { + return EwsUtilities.getXSDurationToTimeSpan(value); + } + + /** + * Convert instance to string. + * + * @param value The value. + * @return String representation of property value. + */ + @Override + protected String toString(TimeSpan value) { + return EwsUtilities.getTimeSpanToXSDuration(value); + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/TimeZonePropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/TimeZonePropertyDefinition.java new file mode 100644 index 000000000..b10e5ec39 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/TimeZonePropertyDefinition.java @@ -0,0 +1,101 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.PropertyBag; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.complex.time.TimeZoneDefinition; + +import java.util.EnumSet; +import java.util.TimeZone; + +/** + * Represents a property definition for property of type TimeZoneInfo. + */ +public class TimeZonePropertyDefinition extends PropertyDefinition { + + /** + * Initializes a new instance of the TimeZonePropertyDefinition class. + * + * @param xmlElementName the xml element name + * @param uri the uri + * @param flags the flags + * @param version the version + */ + public TimeZonePropertyDefinition(String xmlElementName, String uri, EnumSet flags, + ExchangeVersion version) { + super(xmlElementName, uri, flags, version); + } + + /** + * Loads from XML. + * + * @param reader the reader + * @param propertyBag the property bag + * @throws Exception the exception + */ + public void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws ExchangeXmlException { + TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(); + timeZoneDefinition.loadFromXml(reader, this.getXmlElement()); + propertyBag.setObjectFromPropertyDefinition(this, timeZoneDefinition); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param propertyBag the property bag + * @param isUpdateOperation the is update operation + * @throws Exception the exception + */ + public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, + boolean isUpdateOperation) throws ExchangeXmlException { + TimeZoneDefinition timeZoneDefinition = propertyBag.getObjectFromPropertyDefinition(this); + + if (timeZoneDefinition != null) { + // We emit time zone property only if we have not emitted the time + // zone SOAP header + // or if this time zone is different from that of the service + // through which the request + // is being emitted. + if (!writer.isTimeZoneHeaderEmitted())// || value != + // writer.getService().getTimeZone()) + { + timeZoneDefinition.writeToXml(writer, this.getXmlElement()); + } + } + } + + /** + * Gets the property type. + */ + @Override + public Class getType() { + return TimeZone.class; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/property/definition/TypedPropertyDefinition.java b/ews-api/src/main/java/com/eischet/ews/api/property/definition/TypedPropertyDefinition.java new file mode 100644 index 000000000..0c69fdc1d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/property/definition/TypedPropertyDefinition.java @@ -0,0 +1,153 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.property.definition; + +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.PropertyBag; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import javax.xml.stream.XMLStreamException; +import java.io.Serializable; +import java.text.ParseException; +import java.util.EnumSet; + +/** + * Represents typed property definition. + */ +abstract class TypedPropertyDefinition extends PropertyDefinition { + + /** + * The is nullable. + */ + private boolean isNullable; + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param version The version. + */ + protected TypedPropertyDefinition(String xmlElementName, String uri, + ExchangeVersion version) { + super(xmlElementName, uri, version); + this.isNullable = false; + } + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + */ + protected TypedPropertyDefinition(String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version) { + super(xmlElementName, uri, flags, version); + } + + /** + * Initializes a new instance. + * + * @param xmlElementName Name of the XML element. + * @param uri The URI. + * @param flags The flags. + * @param version The version. + * @param isNullable Indicates that this property definition is for a nullable + * property. + */ + protected TypedPropertyDefinition(String xmlElementName, String uri, + EnumSet flags, ExchangeVersion version, + boolean isNullable) { + super(xmlElementName, uri, flags, version); + this.isNullable = isNullable; + } + + /** + * Parses the specified value. + * + * @param value The value. + * @return Typed value. + */ + protected abstract T parse(String value) throws ExchangeXmlException; + + /** + * Gets a value indicating whether this property definition is for a + * nullable type. + * + * @return always true + */ + @Override + public boolean isNullable() { + return this.isNullable; + } + + /** + * Convert instance to string. + * + * @param value The value. + * @return String representation of property value. + */ + protected String toString(T value) { + return value.toString(); + } + + /** + * Loads from XML. + * + * @param reader The reader. + * @param propertyBag The property bag. + */ + @Override + public void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws ExchangeXmlException { + String value = reader.readElementValue(XmlNamespace.Types, this.getXmlElement()); + + if (value != null && !value.isEmpty()) { + propertyBag.setObjectFromPropertyDefinition(this, this.parse(value)); + } + } + + /** + * Writes the property value to XML. + * + * @param writer The writer. + * @param propertyBag The property bag. + * @param isUpdateOperation Indicates whether the context is an update operation. + */ + @Override + public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, + boolean isUpdateOperation) throws ExchangeXmlException { + T value = propertyBag.getObjectFromPropertyDefinition(this); + if (value != null) { + writer.writeElementValue(XmlNamespace.Types, this.getXmlElement(), this.getName(), value); + } + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/CalendarView.java b/ews-api/src/main/java/com/eischet/ews/api/search/CalendarView.java new file mode 100644 index 000000000..0fa55fcd8 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/CalendarView.java @@ -0,0 +1,260 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.search.ItemTraversal; +import com.eischet.ews.api.core.enumeration.service.ServiceObjectType; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.request.ServiceRequestBase; + +import java.time.LocalDateTime; + +/** + * Represents a date range view of appointments in calendar folder search + * operations. + */ +public final class CalendarView extends ViewBase { + + /** + * The traversal. + */ + private ItemTraversal traversal = ItemTraversal.Shallow; + + /** + * The max item returned. + */ + private Integer maxItemsReturned; + + /** + * The start date. + */ + private LocalDateTime startDate; + + /** + * The end date. + */ + private LocalDateTime endDate; + + /** + * Writes the attribute to XML. + * + * @param writer the writer + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.Traversal, this.getTraversal()); + } + + /** + * Writes the search settings to XML. + * + * @param writer the writer + * @param groupBy the group by + */ + protected void internalWriteSearchSettingsToXml(EwsServiceXmlWriter writer, + Grouping groupBy) { + // No search settings for calendar views. + } + + /** + * Writes OrderBy property to XML. + * + * @param writer the writer + */ + public void writeOrderByToXml(EwsServiceXmlWriter writer) { + // No OrderBy for calendar views. + } + + /** + * Gets the type of service object this view applies to. + * + * @return A ServiceObjectType value. + */ + protected ServiceObjectType getServiceObjectType() { + return ServiceObjectType.Item; + } + + /** + * Initializes a new instance of CalendarView. + * + * @param startDate the start date + * @param endDate the end date + */ + public CalendarView(LocalDateTime startDate, LocalDateTime endDate) { + super(); + this.startDate = startDate; + this.endDate = endDate; + } + + /** + * Initializes a new instance of CalendarView. + * + * @param startDate the start date + * @param endDate the end date + * @param maxItemsReturned the max item returned + */ + public CalendarView(LocalDateTime startDate, LocalDateTime endDate, int maxItemsReturned) { + this(startDate, endDate); + this.maxItemsReturned = maxItemsReturned; + } + + /** + * Validate instance. + * + * @param request the request + * @throws ServiceVersionException the service version exception + * @throws ExchangeValidationException the service validation exception + */ + public void internalValidate(ServiceRequestBase request) + throws ServiceVersionException, ExchangeValidationException { + super.internalValidate(request); + + if (this.endDate.compareTo(this.startDate) < 0) { + throw new ExchangeValidationException("EndDate must be greater than StartDate."); + } + } + + /** + * Write to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + protected void internalWriteViewToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.internalWriteViewToXml(writer); + + writer.writeAttributeValue(XmlAttributeNames.StartDate, this.startDate); + writer.writeAttributeValue(XmlAttributeNames.EndDate, this.endDate); + } + + /** + * Gets the name of the view XML element. + * + * @return XML element name + */ + protected String getViewXmlElementName() { + return XmlElementNames.CalendarView; + } + + /** + * Gets the maximum number of item or folder the search operation should + * return. + * + * @return The maximum number of item the search operation should return. + */ + protected Integer getMaxEntriesReturned() { + return this.maxItemsReturned; + } + + /** + * Gets the start date. + * + * @return the start date + */ + public LocalDateTime getStartDate() { + return this.startDate; + } + + /** + * Sets the start date. + * + * @param startDate the new start date + */ + public void setStartDate(LocalDateTime startDate) { + this.startDate = startDate; + } + + /** + * Gets the end date. + * + * @return the end date + */ + public LocalDateTime getEndDate() { + return this.endDate; + } + + /** + * Sets the end date. + * + * @param endDate the new end date + */ + public void setEndDate(LocalDateTime endDate) { + this.endDate = endDate; + } + + /** + * The maximum number of item the search operation should return. + * + * @return the max item returned + */ + public Integer getMaxItemsReturned() { + + return this.maxItemsReturned; + } + + /** + * Sets the max item returned. + * + * @param maxItemsReturned the new max item returned + * @throws ArgumentException the argument exception + */ + public void setMaxItemsReturned(Integer maxItemsReturned) + throws ArgumentException { + if (maxItemsReturned != null) { + if (maxItemsReturned.intValue() <= 0) { + throw new ArgumentException("The value must be greater than 0."); + } + } + + this.maxItemsReturned = maxItemsReturned; + } + + /** + * Gets the search traversal mode. Defaults to + * ItemTraversal.Shallow. + * + * @return the traversal + */ + public ItemTraversal getTraversal() { + return this.traversal; + + } + + /** + * Sets the traversal. + * + * @param traversal the new traversal + */ + public void setTraversal(ItemTraversal traversal) { + this.traversal = traversal; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/ConversationIndexedItemView.java b/ews-api/src/main/java/com/eischet/ews/api/search/ConversationIndexedItemView.java new file mode 100644 index 000000000..50644b529 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/ConversationIndexedItemView.java @@ -0,0 +1,156 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.search.OffsetBasePoint; +import com.eischet.ews.api.core.enumeration.service.ServiceObjectType; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.request.ServiceRequestBase; + +/** + * Represents the view settings in a folder search operation. + */ +public final class ConversationIndexedItemView extends PagedView { + + private final OrderByCollection orderBy = new OrderByCollection(); + + + /** + * Initializes a new instance of the class. + * + * @param pageSize The maximum number of elements the search operation should return. + */ + public ConversationIndexedItemView(int pageSize) { + super(pageSize); + } + + /** + * Initializes a new instance of the ItemView class. + * + * @param pageSize The maximum number of elements the search operation should return. + * @param offset The offset of the view from the base point. + */ + public ConversationIndexedItemView(int pageSize, int offset) { + super(pageSize, offset); + this.setOffset(offset); + } + + /** + * Initializes a new instance of the ItemView class. + * + * @param pageSize The maximum number of elements the search operation should return. + * @param offset The offset of the view from the base point. + * @param offsetBasePoint The base point of the offset. + */ + public ConversationIndexedItemView(int pageSize, int offset, OffsetBasePoint offsetBasePoint) { + super(pageSize, offset, offsetBasePoint); + + } + + /** + * Gets the type of service object this view applies to. + * + * @return A ServiceObjectType value. + */ + @Override + protected ServiceObjectType getServiceObjectType() { + return ServiceObjectType.Conversation; + } + + /** + * Writes the attribute to XML. + * + * @param writer The writer. + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) { + // Do nothing + } + + /** + * Gets the name of the view XML element. + * + * @return XML element name. + */ + @Override + protected String getViewXmlElementName() { + return XmlElementNames.IndexedPageItemView; + } + + /** + * Validates this view. + * + * @param request The request using this view. + */ + @Override + public void internalValidate(ServiceRequestBase request) throws ServiceVersionException, ExchangeValidationException { + super.internalValidate(request); + } + + /** + * Internals the write search settings to XML. + * + * @param writer The writer. + * @param groupBy The group by. + */ + @Override + protected void internalWriteSearchSettingsToXml(EwsServiceXmlWriter writer, Grouping groupBy) throws ExchangeXmlException { + super.internalWriteSearchSettingsToXml(writer, groupBy); + } + + /** + * Writes OrderBy property to XML. + * + * @param writer The writer + */ + @Override + public void writeOrderByToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.orderBy.writeToXml(writer, XmlElementNames.SortOrder); + } + + /** + * Writes to XML. + * + * @param writer The writer + */ + public void writeToXml(EwsServiceXmlWriter writer) throws Exception { + writer.writeStartElement(XmlNamespace.Messages, this.getViewXmlElementName()); + + this.internalWriteViewToXml(writer); + + writer.writeEndElement(); // this.GetViewXmlElementName() + } + + /** + * Gets the property against which the returned item should be ordered. + */ + public OrderByCollection getOrderBy() { + return this.orderBy; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/FindFoldersResults.java b/ews-api/src/main/java/com/eischet/ews/api/search/FindFoldersResults.java new file mode 100644 index 000000000..e31b9790a --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/FindFoldersResults.java @@ -0,0 +1,142 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search; + +import com.eischet.ews.api.core.service.folder.Folder; + +import java.util.ArrayList; +import java.util.Iterator; + +/** + * Represents the results of a folder search operation. + */ +public final class FindFoldersResults implements Iterable { + + /** + * The total count. + */ + private int totalCount; + + /** + * The next page offset. + */ + private Integer nextPageOffset; + + /** + * The more available. + */ + private boolean moreAvailable; + + /** + * The folder. + */ + private final ArrayList folders = new ArrayList(); + + /** + * Initializes a new instance of the class. + */ + public FindFoldersResults() { + + } + + /** + * Gets the total number of folder matching the search criteria available + * in the searched folder. + * + * @return the total count + */ + public int getTotalCount() { + return totalCount; + } + + /** + * Sets the total number of folder. + * + * @param totalCount the new total count + */ + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + /** + * Gets the offset that should be used with FolderView to retrieve the next + * page of folder in a FindFolders operation. + * + * @return the next page offset + */ + public Integer getNextPageOffset() { + return nextPageOffset; + } + + /** + * Sets the offset that should be used with FolderView to retrieve the next + * page of folder in a FindFolders operation. + * + * @param nextPageOffset the new next page offset + */ + public void setNextPageOffset(Integer nextPageOffset) { + this.nextPageOffset = nextPageOffset; + } + + /** + * Gets a value indicating whether more folder matching the search + * criteria. are available in the searched folder. + * + * @return true, if is more available + */ + public boolean isMoreAvailable() { + return moreAvailable; + } + + /** + * Sets a value indicating whether more folder matching the search + * criteria. are available in the searched folder. + * + * @param moreAvailable the new more available + */ + public void setMoreAvailable(boolean moreAvailable) { + this.moreAvailable = moreAvailable; + } + + /** + * Gets a collection containing the folder that were found by the search + * operation. + * + * @return the folder + */ + public ArrayList getFolders() { + return folders; + } + + /** + * Returns an iterator that iterates through a collection. + * + * @return the iterator + */ + @Override + public Iterator iterator() { + return this.folders.iterator(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/FindItemsResults.java b/ews-api/src/main/java/com/eischet/ews/api/search/FindItemsResults.java new file mode 100644 index 000000000..3297d7f9d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/FindItemsResults.java @@ -0,0 +1,144 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search; + +import com.eischet.ews.api.core.service.item.Item; + +import java.util.ArrayList; +import java.util.Iterator; + +/** + * Represents the results of an item search operation. + * + * @param The type of item returned by the search operation. + */ +public final class FindItemsResults implements Iterable { + + /** + * The total count. + */ + private int totalCount; + + /** + * The next page offset. + */ + private Integer nextPageOffset; + + /** + * The more available. + */ + private boolean moreAvailable; + + /** + * The item. + */ + private final ArrayList items = new ArrayList(); + + /** + * Initializes a new instance of the FindItemsResults class. + */ + public FindItemsResults() { + } + + /** + * Gets the total number of item matching the search criteria available in + * the searched folder. + * + * @return the total count + */ + public int getTotalCount() { + return this.totalCount; + } + + /** + * Sets the total number of item matching the search criteria available in + * the searched folder. + * + * @param totalCount the new total count + */ + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + /** + * Gets the offset that should be used with ItemView to retrieve the next + * page of item in a FindItems operation. + * + * @return the next page offset + */ + public Integer getNextPageOffset() { + return nextPageOffset; + } + + /** + * Sets the offset that should be used with ItemView to retrieve the next + * page of item in a FindItems operation. + * + * @param nextPageOffset the new next page offset + */ + public void setNextPageOffset(Integer nextPageOffset) { + this.nextPageOffset = nextPageOffset; + } + + /** + * Gets a value indicating whether more item matching the search criteria + * are available in the searched folder. + * + * @return true, if is more available + */ + public boolean isMoreAvailable() { + return moreAvailable; + } + + /** + * Sets a value indicating whether more item matching the search criteria + * are available in the searched folder. + * + * @param moreAvailable the new more available + */ + public void setMoreAvailable(boolean moreAvailable) { + this.moreAvailable = moreAvailable; + } + + /** + * Gets a collection containing the item that were found by the search + * operation. + * + * @return the item + */ + public ArrayList getItems() { + return this.items; + } + + /** + * Returns an iterator that iterates through the collection. + * + * @return the iterator + */ + @Override + public Iterator iterator() { + return items.iterator(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/FolderView.java b/ews-api/src/main/java/com/eischet/ews/api/search/FolderView.java new file mode 100644 index 000000000..1d0407d12 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/FolderView.java @@ -0,0 +1,131 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.search.FolderTraversal; +import com.eischet.ews.api.core.enumeration.search.OffsetBasePoint; +import com.eischet.ews.api.core.enumeration.service.ServiceObjectType; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents the view settings in a folder search operation. + */ +public final class FolderView extends PagedView { + + private static final Logger LOG = Logger.getLogger(FolderView.class.getCanonicalName()); + + /** + * The traversal. + */ + private FolderTraversal traversal = FolderTraversal.Shallow; + + /** + * Gets the name of the view XML element. + * + * @return Xml Element name + */ + @Override + protected String getViewXmlElementName() { + return XmlElementNames.IndexedPageFolderView; + } + + /** + * Gets the type of service object this view applies to. + * + * @return A ServiceObjectType value. + */ + @Override + protected ServiceObjectType getServiceObjectType() { + return ServiceObjectType.Folder; + } + + /** + * Writes the attribute to XML. + * + * @param writer The writer + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.Traversal, this.getTraversal()); + } + + /** + * Initializes a new instance of the FolderView class. + * + * @param pageSize The maximum number of elements the search operation should + * return. + */ + public FolderView(int pageSize) { + super(pageSize); + } + + /** + * Initializes a new instance of the FolderView class. + * + * @param pageSize The maximum number of elements the search operation should + * return. + * @param offset The offset of the view from the base point. + */ + public FolderView(int pageSize, int offset) { + super(pageSize, offset); + } + + /** + * Initializes a new instance of the FolderView class. + * + * @param pageSize The maximum number of elements the search operation should + * return. + * @param offset The offset of the view from the base point. + * @param offsetBasePoint The base point of the offset. + */ + public FolderView(int pageSize, int offset, + OffsetBasePoint offsetBasePoint) { + super(pageSize, offset, offsetBasePoint); + } + + /** + * Gets the search traversal mode. Defaults to FolderTraversal.Shallow. + * + * @return the traversal + */ + public FolderTraversal getTraversal() { + return traversal; + } + + /** + * Sets the search traversal mode. Defaults to FolderTraversal.Shallow. + * + * @param traversal the new traversal + */ + public void setTraversal(FolderTraversal traversal) { + this.traversal = traversal; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/GroupedFindItemsResults.java b/ews-api/src/main/java/com/eischet/ews/api/search/GroupedFindItemsResults.java new file mode 100644 index 000000000..29d26a4d4 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/GroupedFindItemsResults.java @@ -0,0 +1,144 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search; + +import com.eischet.ews.api.core.service.item.Item; + +import java.util.ArrayList; +import java.util.Iterator; + +/** + * Represents the results of an item search operation. + * + * @param The type of item returned by the search operation. + */ +public final class GroupedFindItemsResults implements Iterable> { + + /** + * The total count. + */ + private int totalCount; + + /** + * The next page offset. + */ + private Integer nextPageOffset; + + /** + * The more available. + */ + private boolean moreAvailable; + + /** + * List of ItemGroups. + */ + private final ArrayList> itemGroups = + new ArrayList>(); + + /** + * Initializes a new instance of the GroupedFindItemsResults class. + */ + public GroupedFindItemsResults() { + } + + /** + * Gets the total number of item matching the search criteria available in + * the searched folder. + * + * @return the total count + */ + public int getTotalCount() { + return totalCount; + } + + /** + * Gets the total number of item matching the search criteria available in + * the searched folder. + * + * @param totalCount Total number of item + */ + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + /** + * Gets the offset that should be used with ItemView to retrieve the next + * page of item in a FindItems operation. + * + * @return the next page offset + */ + public Integer getNextPageOffset() { + return nextPageOffset; + } + + /** + * Sets the offset that should be used with ItemView to retrieve the next + * page of item in a FindItems operation. + * + * @param nextPageOffset the new next page offset + */ + public void setNextPageOffset(Integer nextPageOffset) { + this.nextPageOffset = nextPageOffset; + } + + /** + * Gets a value indicating whether more item corresponding to the search + * criteria are available in the searched folder. + * + * @return true, if is more available + */ + public boolean isMoreAvailable() { + return moreAvailable; + } + + /** + * Sets a value indicating whether more item corresponding to the search + * criteria are available in the searched folder. + * + * @param moreAvailable the new more available + */ + public void setMoreAvailable(boolean moreAvailable) { + this.moreAvailable = moreAvailable; + } + + /** + * Gets the item groups returned by the search operation. + * + * @return the item groups + */ + public ArrayList> getItemGroups() { + return itemGroups; + } + + /** + * Returns an iterator that iterates through the collection. + * + * @return the iterator + */ + @Override + public Iterator> iterator() { + return this.itemGroups.iterator(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/Grouping.java b/ews-api/src/main/java/com/eischet/ews/api/search/Grouping.java new file mode 100644 index 000000000..6c9a31dc7 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/Grouping.java @@ -0,0 +1,215 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search; + +import com.eischet.ews.api.ISelfValidate; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.search.AggregateType; +import com.eischet.ews.api.core.enumeration.search.SortDirection; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.property.definition.PropertyDefinitionBase; + +import javax.xml.stream.XMLStreamException; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Represents grouping options in item search operations. + */ +public final class Grouping implements ISelfValidate { + + private static final Logger LOG = Logger.getLogger(Grouping.class.getCanonicalName()); + + /** + * The sort direction. + */ + private SortDirection sortDirection = SortDirection.Ascending; + + /** + * The group on. + */ + private PropertyDefinitionBase groupOn; + + /** + * The aggregate on. + */ + private PropertyDefinitionBase aggregateOn; + + /** + * The aggregate type. + */ + private AggregateType aggregateType = AggregateType.Minimum; + + /** + * Initializes a new instance of the "Grouping" class. + */ + public Grouping() { + + } + + /** + * Initializes a new instance of the "Grouping" class. + * + * @param groupOn The property to group on + * @param sortDirection The sort direction. + * @param aggregateOn The property to aggregate on. + * @param aggregateType The type of aggregate to calculate. + * @throws Exception the exception + */ + public Grouping(PropertyDefinitionBase groupOn, + SortDirection sortDirection, PropertyDefinitionBase aggregateOn, + AggregateType aggregateType) throws Exception { + this(); + EwsUtilities.validateParam(groupOn, "groupOn"); + EwsUtilities.validateParam(aggregateOn, "aggregateOn"); + + this.groupOn = groupOn; + this.sortDirection = sortDirection; + this.aggregateOn = aggregateOn; + this.aggregateType = aggregateType; + } + + /** + * Validates this grouping. + * + * @throws Exception the exception + */ + private void internalValidate() throws Exception { + EwsUtilities.validateParam(this.groupOn, "GroupOn"); + EwsUtilities.validateParam(this.aggregateOn, "AggregateOn"); + } + + /** + * Writes to XML. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + protected void writeToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeStartElement(XmlNamespace.Messages, XmlElementNames.GroupBy); + writer.writeAttributeValue(XmlAttributeNames.Order, this.sortDirection); + + this.groupOn.writeToXml(writer); + + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.AggregateOn); + writer.writeAttributeValue(XmlAttributeNames.Aggregate, this.aggregateType); + + this.aggregateOn.writeToXml(writer); + + writer.writeEndElement(); // AggregateOn + + writer.writeEndElement(); // GroupBy + } + + /** + * Gets the Sort Direction. + * + * @return the sort direction + */ + public SortDirection getSortDirection() { + return sortDirection; + } + + /** + * Sets the Sort Direction. + * + * @param sortDirection the new sort direction + */ + public void setSortDirection(SortDirection sortDirection) { + this.sortDirection = sortDirection; + } + + /** + * Gets the property to group on. + * + * @return the group on + */ + public PropertyDefinitionBase getGroupOn() { + return groupOn; + } + + /** + * sets the property to group on. + * + * @param groupOn the new group on + */ + public void setGroupOn(PropertyDefinitionBase groupOn) { + this.groupOn = groupOn; + } + + /** + * Gets the property to aggregateOn. + * + * @return the aggregate on + */ + public PropertyDefinitionBase getAggregateOn() { + return aggregateOn; + } + + /** + * Sets the property to aggregateOn. + * + * @param aggregateOn the new aggregate on + */ + public void setAggregateOn(PropertyDefinitionBase aggregateOn) { + this.aggregateOn = aggregateOn; + } + + /** + * Gets the types of aggregate to calculate. + * + * @return the aggregate type + */ + public AggregateType getAggregateType() { + return aggregateType; + } + + /** + * Sets the types of aggregate to calculate. + * + * @param aggregateType the new aggregate type + */ + public void setAggregateType(AggregateType aggregateType) { + this.aggregateType = aggregateType; + } + + /** + * Implements ISelfValidate.Validate. Validates this grouping. + */ + @Override + public void validate() { + try { + this.internalValidate(); + } catch (Exception e) { + LOG.log(Level.SEVERE, "validation error", e); + } + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/ItemGroup.java b/ews-api/src/main/java/com/eischet/ews/api/search/ItemGroup.java new file mode 100644 index 000000000..e57e33cfc --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/ItemGroup.java @@ -0,0 +1,94 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.service.item.Item; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * Represents a group of item as returned by grouped item search operations. + * + * @param the generic type + */ +public final class ItemGroup { + + /** + * The group index. + */ + private String groupIndex; + + /** + * The item. + */ + private Collection items; + + /** + * Initializes a new instance of the class. + * + * @param groupIndex the group index + * @param items the item + */ + public ItemGroup(String groupIndex, List items) { + EwsUtilities.ewsAssert(groupIndex != null, "ItemGroup.ctor", "groupIndex is null"); + EwsUtilities.ewsAssert(items != null, "ItemGroup.ctor", "item is null"); + this.groupIndex = groupIndex; + this.items = new ArrayList<>(items); + } + + /** + * Gets an index identifying the group. + * + * @return the group index + */ + public String getGroupIndex() { + return this.groupIndex; + } + + /** + * Sets an index identifying the group. + */ + private void setGroupIndex(String value) { + this.groupIndex = value; + } + + /** + * Gets a collection of the item in this group. + * + * @return the item + */ + public Collection getItems() { + return this.items; + } + + /** + * Sets a collection of the item in this group. + */ + private void setItems(Collection value) { + this.items = value; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/ItemView.java b/ews-api/src/main/java/com/eischet/ews/api/search/ItemView.java new file mode 100644 index 000000000..067343e0d --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/ItemView.java @@ -0,0 +1,170 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.search.ItemTraversal; +import com.eischet.ews.api.core.enumeration.search.OffsetBasePoint; +import com.eischet.ews.api.core.enumeration.service.ServiceObjectType; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.request.ServiceRequestBase; + +/** + * Represents the view settings in a folder search operation. + */ +public final class ItemView extends PagedView { + + /** + * The order by. + */ + private final OrderByCollection orderBy = new OrderByCollection(); + /** + * The traversal. + */ + private ItemTraversal traversal = ItemTraversal.Shallow; + + /** + * Initializes a new instance of the ItemView class. + * + * @param pageSize the page size + */ + public ItemView(int pageSize) { + super(pageSize); + } + + /** + * Initializes a new instance of the ItemView class. + * + * @param pageSize the page size + * @param offset the offset + */ + public ItemView(int pageSize, int offset) { + super(pageSize, offset); + this.setOffset(offset); + } + + /** + * Initializes a new instance of the ItemView class. + * + * @param pageSize the page size + * @param offset the offset + * @param offsetBasePoint the offset base point + */ + public ItemView(int pageSize, int offset, OffsetBasePoint offsetBasePoint) { + super(pageSize, offset, offsetBasePoint); + } + + /** + * Gets the name of the view XML element. + * + * @return XML element name. + */ + @Override + protected String getViewXmlElementName() { + return XmlElementNames.IndexedPageItemView; + } + + /** + * Gets the type of service object this view applies to. + * + * @return A ServiceObjectType value. + */ + @Override + protected ServiceObjectType getServiceObjectType() { + return ServiceObjectType.Item; + } + + /** + * Validates this view. + * + * @param request the request + * @throws ServiceVersionException the service version exception + * @throws ExchangeValidationException the service validation exception + */ + @Override + public void internalValidate(ServiceRequestBase request) throws ServiceVersionException, ExchangeValidationException { + super.internalValidate(request); + + EwsUtilities.validateEnumVersionValue(this.traversal, request.getService().getRequestedServerVersion()); + } + + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + writer.writeAttributeValue(XmlAttributeNames.Traversal, this.traversal); + } + + /** + * Internals the write search settings to XML. + * + * @param writer the writer + * @param groupBy the group by + */ + @Override + protected void internalWriteSearchSettingsToXml(EwsServiceXmlWriter writer, Grouping groupBy) throws ExchangeXmlException { + super.internalWriteSearchSettingsToXml(writer, groupBy); + } + + /** + * Writes OrderBy property to XML. + * + * @param writer the writer + */ + @Override + public void writeOrderByToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.orderBy.writeToXml(writer, XmlElementNames.SortOrder); + } + + /** + * Gets the search traversal mode. Defaults to + * ItemTraversal.Shallow. + * + * @return the traversal + */ + public ItemTraversal getTraversal() { + return this.traversal; + } + + /** + * Sets the traversal. + * + * @param value the new traversal + */ + public void setTraversal(ItemTraversal value) { + this.traversal = value; + } + + /** + * Gets the property against which the returned item should be ordered. + * + * @return the order by + */ + public OrderByCollection getOrderBy() { + return this.orderBy; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/OrderByCollection.java b/ews-api/src/main/java/com/eischet/ews/api/search/OrderByCollection.java new file mode 100644 index 000000000..c94069796 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/OrderByCollection.java @@ -0,0 +1,222 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search; + +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.search.SortDirection; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.definition.PropertyDefinitionBase; + +import javax.xml.stream.XMLStreamException; +import java.util.*; + +/** + * Represents an ordered collection of property definitions qualified with a + * sort direction. + */ +public final class OrderByCollection implements + Iterable> { + + /** + * The prop def sort order pair list. + */ + private final List> propDefSortOrderPairList; + + /** + * Initializes a new instance of the OrderByCollection class. + */ + protected OrderByCollection() { + this.propDefSortOrderPairList = new + ArrayList>(); + } + + /** + * Adds the specified property definition / sort direction pair to the + * collection. + * + * @param propertyDefinition the property definition + * @param sortDirection the sort direction + * @throws ServiceLocalException the service local exception + */ + public void add(PropertyDefinitionBase propertyDefinition, + SortDirection sortDirection) throws ServiceLocalException { + if (this.contains(propertyDefinition)) { + throw new ServiceLocalException(String.format("Property %s already exists in OrderByCollection.", + propertyDefinition.getPrintableName())); + } + Map propertyDefinitionSortDirectionPair = new + HashMap(); + propertyDefinitionSortDirectionPair.put(propertyDefinition, + sortDirection); + this.propDefSortOrderPairList.add(propertyDefinitionSortDirectionPair); + } + + /** + * Removes all elements from the collection. + */ + public void clear() { + this.propDefSortOrderPairList.clear(); + } + + /** + * Determines whether the collection contains the specified property + * definition. + * + * @param propertyDefinition the property definition + * @return True if the collection contains the specified property + * definition; otherwise, false. + */ + protected boolean contains(PropertyDefinitionBase propertyDefinition) { + for (Map propDefSortOrderPair : propDefSortOrderPairList) { + return propDefSortOrderPair.containsKey(propertyDefinition); + } + return false; + } + + /** + * Gets the number of elements contained in the collection. + * + * @return the int + */ + public int count() { + return this.propDefSortOrderPairList.size(); + } + + /** + * Removes the specified property definition from the collection. + * + * @param propertyDefinition the property definition + * @return True if the property definition is successfully removed; + * otherwise, false + */ + public boolean remove(PropertyDefinitionBase propertyDefinition) { + List> removeList = new + ArrayList>(); + for (Map propDefSortOrderPair : propDefSortOrderPairList) { + if (propDefSortOrderPair.containsKey(propertyDefinition)) { + removeList.add(propDefSortOrderPair); + } + } + this.propDefSortOrderPairList.removeAll(removeList); + return removeList.size() > 0; + } + + /** + * Removes the element at the specified index from the collection. + * + * @param index the index + */ + public void removeAt(int index) { + this.propDefSortOrderPairList.remove(index); + } + + /** + * Tries to get the value for a property definition in the collection. + * + * @param propertyDefinition the property definition + * @param sortDirection the sort direction + * @return True if collection contains property definition, otherwise false. + */ + public boolean tryGetValue(PropertyDefinitionBase propertyDefinition, + OutParam sortDirection) { + for (Map pair : this.propDefSortOrderPairList) { + + if (pair.containsKey(propertyDefinition)) { + sortDirection.setParam(pair.get(propertyDefinition)); + return true; + } + } + sortDirection.setParam(SortDirection.Ascending); // out parameter has to + // be set to some + // value. + return false; + } + + /** + * Writes to XML. + * + * @param writer the writer + * @param xmlElementName the xml element name + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + protected void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) throws ExchangeXmlException { + if (this.count() > 0) { + writer.writeStartElement(XmlNamespace.Messages, xmlElementName); + + for (Map keyValuePair : this.propDefSortOrderPairList) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.FieldOrder); + + writer.writeAttributeValue(XmlAttributeNames.Order, + keyValuePair.values().iterator().next()); + keyValuePair.keySet().iterator().next().writeToXml(writer); + + writer.writeEndElement(); // FieldOrder + } + + writer.writeEndElement(); + } + } + + /* + * (non-Javadoc) + * + * @see java.lang.Iterable#iterator() + */ + @Override + public Iterator> iterator() { + return this.propDefSortOrderPairList.iterator(); + } + + /** + * Gets the element at the specified index from the collection. + * + * @param index the index + * @return the property definition sort direction pair + */ + public Map getPropertyDefinitionSortDirectionPair( + int index) { + return this.propDefSortOrderPairList.get(index); + } + + /** + * Returns an enumerator that iterates through the collection. + * + * @return A Iterator that can be used to iterate through the collection. + */ + public Iterator> getEnumerator() { + return (this.propDefSortOrderPairList.iterator()); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/PagedView.java b/ews-api/src/main/java/com/eischet/ews/api/search/PagedView.java new file mode 100644 index 000000000..f94a77bfb --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/PagedView.java @@ -0,0 +1,219 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.search.OffsetBasePoint; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.request.ServiceRequestBase; + +/** + * Represents a view settings that support paging in a search operation. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class PagedView extends ViewBase { + + /** + * The page size. + */ + private int pageSize; + + /** + * The offset base point. + */ + private OffsetBasePoint offsetBasePoint = OffsetBasePoint.Beginning; + + /** + * The offset. + */ + private int offset; + + /** + * Write to XML. + * + * @param writer The Writer + * @throws Exception the exception + */ + @Override + protected void internalWriteViewToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.internalWriteViewToXml(writer); + + writer.writeAttributeValue(XmlAttributeNames.Offset, this.getOffset()); + writer.writeAttributeValue(XmlAttributeNames.BasePoint, this + .getOffsetBasePoint()); + } + + /** + * Gets the maximum number of item or folder the search operation should + * return. + * + * @return The maximum number of item or folder that should be returned by + * the search operation. + */ + @Override + protected Integer getMaxEntriesReturned() { + return this.getPageSize(); + } + + /** + * Internals the write search settings to XML. + * + * @param writer the writer + * @param groupBy the group by clause + */ + @Override + protected void internalWriteSearchSettingsToXml(EwsServiceXmlWriter writer, Grouping groupBy) throws ExchangeXmlException { + if (groupBy != null) { + groupBy.writeToXml(writer); + } + } + + /** + * Writes OrderBy property to XML. + * + * @param writer the writer + */ + @Override + public void writeOrderByToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + // No order by for paged view + } + + /** + * Validates this view. + * + * @param request The request using this view. + * @throws ServiceVersionException the service version exception + * @throws ExchangeValidationException the service validation exception + */ + @Override + public void internalValidate(ServiceRequestBase request) throws ServiceVersionException, ExchangeValidationException { + super.internalValidate(request); + } + + /** + * Initializes a new instance of the "PagedView" class. + * + * @param pageSize The maximum number of elements the search operation should + * return. + */ + protected PagedView(int pageSize) { + super(); + this.setPageSize(pageSize); + } + + /** + * Initializes a new instance of the "PagedView" class. + * + * @param pageSize The maximum number of elements the search operation should + * return. + * @param offset The offset of the view from the base point. + */ + protected PagedView(int pageSize, int offset) { + this(pageSize); + this.setOffset(offset); + } + + /** + * Initializes a new instance of the "PagedView" class. + * + * @param pageSize The maximum number of elements the search operation should + * return. + * @param offset The offset of the view from the base point. + * @param offsetBasePoint The base point of the offset. + */ + protected PagedView(int pageSize, int offset, + OffsetBasePoint offsetBasePoint) { + this(pageSize, offset); + this.setOffsetBasePoint(offsetBasePoint); + } + + /** + * Gets the maximum number of item or folder the search operation should + * return. + * + * @return the page size + */ + public int getPageSize() { + return pageSize; + } + + /** + * Sets the maximum number of item or folder the search operation should + * return. + * + * @param pageSize the new page size + */ + public void setPageSize(int pageSize) { + if (pageSize <= 0) { + throw new IllegalArgumentException("The value must be greater than 0."); + } + this.pageSize = pageSize; + } + + /** + * Gets the base point of the offset. + * + * @return the offset base point + */ + public OffsetBasePoint getOffsetBasePoint() { + return offsetBasePoint; + } + + /** + * Sets the base point of the offset. + * + * @param offsetBasePoint the new offset base point + */ + public void setOffsetBasePoint(OffsetBasePoint offsetBasePoint) { + this.offsetBasePoint = offsetBasePoint; + } + + /** + * Gets the offset. + * + * @return the offset + */ + public int getOffset() { + return offset; + } + + /** + * Sets the offset. + * + * @param offset the new offset + */ + public void setOffset(int offset) { + if (offset >= 0) { + this.offset = offset; + } else { + throw new IllegalArgumentException("The offset must be greater than 0."); + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/ViewBase.java b/ews-api/src/main/java/com/eischet/ews/api/search/ViewBase.java new file mode 100644 index 000000000..e702e948b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/ViewBase.java @@ -0,0 +1,189 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.PropertySet; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.service.ServiceObjectType; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceVersionException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.request.ServiceRequestBase; + +import javax.xml.stream.XMLStreamException; + +/** + * Represents the base view class for search operations. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class ViewBase { + + /** + * The property set. + */ + private PropertySet propertySet; + + /** + * Initializes a new instance of the "ViewBase" class. + */ + ViewBase() { + } + + /** + * Validates this view. + * + * @param request The request using this view. + * @throws ExchangeValidationException the service validation exception + * @throws ServiceVersionException the service version exception + */ + public void internalValidate(ServiceRequestBase request) + throws ExchangeValidationException, ServiceVersionException { + if (this.getPropertySet() != null) { + this.getPropertySet().internalValidate(); + this.getPropertySet().validateForRequest( + request, + true /* summaryPropertiesOnly */); + } + } + + protected void internalWriteViewToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + Integer maxEntriesReturned = this.getMaxEntriesReturned(); + if (maxEntriesReturned != null) { + writer.writeAttributeValue(XmlAttributeNames.MaxEntriesReturned, + maxEntriesReturned); + } + } + + /** + * Writes the search settings to XML. + * + * @param writer the writer + * @param groupBy the group by clause + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + protected abstract void internalWriteSearchSettingsToXml( + EwsServiceXmlWriter writer, Grouping groupBy) + throws XMLStreamException, ServiceXmlSerializationException, ExchangeXmlException; + + /** + * Writes OrderBy property to XML. + * + * @param writer the writer + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + public abstract void writeOrderByToXml(EwsServiceXmlWriter writer) + throws XMLStreamException, ServiceXmlSerializationException, ExchangeXmlException; + + /** + * Gets the name of the view XML element. + * + * @return TheXml Element name + */ + protected abstract String getViewXmlElementName(); + + /** + * Gets the maximum number of item or folder the search operation should + * return. + * + * @return The maximum number of item or folder that should be returned by + * the search operation. + */ + protected abstract Integer getMaxEntriesReturned(); + + /** + * Gets the type of service object this view applies to. + * + * @return A ServiceObjectType value. + */ + protected abstract ServiceObjectType getServiceObjectType(); + + /** + * Writes the attribute to XML. + * + * @param writer The writer. + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + public abstract void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException; + + /** + * Writes to XML. + * + * @param writer The writer. + * @param groupBy The group by clause. + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer, Grouping groupBy) + throws Exception { + this.getPropertySetOrDefault().writeToXml(writer, + this.getServiceObjectType()); + writer.writeStartElement(XmlNamespace.Messages, this + .getViewXmlElementName()); + this.internalWriteViewToXml(writer); + writer.writeEndElement(); // this.GetViewXmlElementName() + this.internalWriteSearchSettingsToXml(writer, groupBy); + } + + /** + * Gets the property set or the default. + * + * @return PropertySet + */ + public PropertySet getPropertySetOrDefault() { + if (this.getPropertySet() == null) { + return PropertySet.getFirstClassProperties(); + } else { + return this.getPropertySet(); + } + } + + /** + * Gets the property set. PropertySet determines which property will be + * loaded on found item. If PropertySet is null, all first class property + * are loaded on found item. + * + * @return the property set + */ + public PropertySet getPropertySet() { + return propertySet; + } + + /** + * Sets the property set. PropertySet determines which property will be + * loaded on found item. If PropertySet is null, all first class property + * are loaded on found item. + * + * @param propertySet The property set + */ + public void setPropertySet(PropertySet propertySet) { + this.propertySet = propertySet; + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/search/filter/SearchFilter.java b/ews-api/src/main/java/com/eischet/ews/api/search/filter/SearchFilter.java new file mode 100644 index 000000000..395aca42b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/search/filter/SearchFilter.java @@ -0,0 +1,1473 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.search.filter; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.core.enumeration.search.ComparisonMode; +import com.eischet.ews.api.core.enumeration.search.ContainmentMode; +import com.eischet.ews.api.core.enumeration.search.LogicalOperator; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.complex.ComplexProperty; +import com.eischet.ews.api.property.complex.IComplexPropertyChangedDelegate; +import com.eischet.ews.api.property.definition.PropertyDefinitionBase; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.logging.Logger; + +/** + * Represents the base search filter class. Use descendant search filter classes + * such as SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection to define search filter. + */ +public abstract class SearchFilter extends ComplexProperty { + + /** + * Initializes a new instance of the SearchFilter class. + */ + protected SearchFilter() { + } + + + /** + * Loads from XML. + * + * @param reader the reader + * @return SearchFilter + * @throws Exception the exception + */ + public static SearchFilter loadFromXml(EwsServiceXmlReader reader) + throws ExchangeXmlException { + reader.ensureCurrentNodeIsStartElement(); + + SearchFilter searchFilter = null; + + if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Exists)) { + searchFilter = new Exists(); + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.Contains)) { + searchFilter = new ContainsSubstring(); + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.Excludes)) { + searchFilter = new ExcludesBitmask(); + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Not)) { + searchFilter = new Not(); + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.And)) { + searchFilter = new SearchFilterCollection( + LogicalOperator.And); + } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Or)) { + searchFilter = new SearchFilterCollection( + LogicalOperator.Or); + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.IsEqualTo)) { + searchFilter = new IsEqualTo(); + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.IsNotEqualTo)) { + searchFilter = new IsNotEqualTo(); + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.IsGreaterThan)) { + searchFilter = new IsGreaterThan(); + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.IsGreaterThanOrEqualTo)) { + searchFilter = new IsGreaterThanOrEqualTo(); + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.IsLessThan)) { + searchFilter = new IsLessThan(); + } else if (reader.getLocalName().equalsIgnoreCase( + XmlElementNames.IsLessThanOrEqualTo)) { + searchFilter = new IsLessThanOrEqualTo(); + } else { + searchFilter = null; + } + + if (searchFilter != null) { + searchFilter.loadFromXml(reader, reader.getLocalName()); + } + + return searchFilter; + } + + /** + * Gets the name of the XML element. + * + * @return the xml element name + */ + protected abstract String getXmlElementName(); + + /** + * Writes to XML. + * + * @param writer the writer + * @throws Exception the exception + */ + public void writeToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeToXml(writer, this.getXmlElementName()); + } + + /** + * Represents a search filter that checks for the presence of a substring + * inside a text property. Applications can use ContainsSubstring to define + * conditions such as "Field CONTAINS Value" or + * "Field IS PREFIXED WITH Value". + */ + public static final class ContainsSubstring extends PropertyBasedFilter { + + /** + * The containment mode. + */ + private ContainmentMode containmentMode = ContainmentMode.Substring; + + /** + * The comparison mode. + */ + private ComparisonMode comparisonMode = ComparisonMode.IgnoreCase; + + /** + * The value. + */ + private String value; + + /** + * Initializes a new instance of the class. + */ + public ContainsSubstring() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param value The value to compare with. + */ + public ContainsSubstring(PropertyDefinitionBase propertyDefinition, + String value) { + super(propertyDefinition); + this.value = value; + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param value The value to compare with. + * @param containmentMode The containment mode. + * @param comparisonMode The comparison mode. + */ + public ContainsSubstring(PropertyDefinitionBase propertyDefinition, + String value, ContainmentMode containmentMode, + ComparisonMode comparisonMode) { + this(propertyDefinition, value); + this.containmentMode = containmentMode; + this.comparisonMode = comparisonMode; + } + + /** + * validates instance. + * + * @throws ExchangeValidationException the service validation exception + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + if ((this.value == null) || this.value.isEmpty()) { + throw new ExchangeValidationException("The Value property must be set."); + } + } + + /** + * Gets the name of the XML element. + * + * @return the xml element name + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.Contains; + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return True if element was read. + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + boolean result = super.tryReadElementFromXml(reader); + + if (!result) { + if (reader.getLocalName().equals(XmlElementNames.Constant)) { + this.value = reader.readAttributeValue(XmlAttributeNames.Value); + result = true; + } + } + return result; + } + + /** + * Reads the attribute of Xml. + * + * @param reader the reader + */ + @Override + public void readAttributesFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + + super.readAttributesFromXml(reader); + this.containmentMode = reader.readAttributeValue( + ContainmentMode.class, XmlAttributeNames.ContainmentMode); + try { + this.comparisonMode = reader.readAttributeValue( + ComparisonMode.class, + XmlAttributeNames.ContainmentComparison); + } catch (IllegalArgumentException ile) { + // This will happen if we receive a value that is defined in the + // EWS + // schema but that is not defined + // in the API. We map that + // value to IgnoreCaseAndNonSpacingCharacters. + this.comparisonMode = ComparisonMode. + IgnoreCaseAndNonSpacingCharacters; + } + } + + /** + * Writes the attribute to XML. + * + * @param writer the writer + */ + @Override + public void writeAttributesToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeAttributesToXml(writer); + writer.writeAttributeValue(XmlAttributeNames.ContainmentMode, this.containmentMode); + writer.writeAttributeValue(XmlAttributeNames.ContainmentComparison, this.comparisonMode); + } + + /** + * Writes the elements to Xml. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeElementsToXml(writer); + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Constant); + writer.writeAttributeValue(XmlAttributeNames.Value, this.value); + writer.writeEndElement(); // Constant + } + + /** + * Gets the containment mode. + * + * @return ContainmentMode + */ + public ContainmentMode getContainmentMode() { + return containmentMode; + } + + /** + * sets the ContainmentMode. + * + * @param containmentMode the new containment mode + */ + public void setContainmentMode(ContainmentMode containmentMode) { + this.containmentMode = containmentMode; + } + + /** + * Gets the comparison mode. + * + * @return ComparisonMode + */ + public ComparisonMode getComparisonMode() { + return comparisonMode; + } + + /** + * sets the comparison mode. + * + * @param comparisonMode the new comparison mode + */ + public void setComparisonMode(ComparisonMode comparisonMode) { + this.comparisonMode = comparisonMode; + } + + /** + * gets the value to compare the specified property with. + * + * @return String + */ + public String getValue() { + return value; + } + + /** + * sets the value to compare the specified property with. + * + * @param value the new value + */ + public void setValue(String value) { + this.value = value; + } + } + + + /** + * Represents a bitmask exclusion search filter. Applications can use + * ExcludesBitExcludesBitmaskFilter to define conditions such as + * "(OrdinalField and 0x0010) != 0x0010" + */ + public static class ExcludesBitmask extends PropertyBasedFilter { + + /** + * The bitmask. + */ + private int bitmask; + + /** + * Initializes a new instance of the class. + */ + public ExcludesBitmask() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition the property definition + * @param bitmask the bitmask + */ + public ExcludesBitmask(PropertyDefinitionBase propertyDefinition, + int bitmask) { + super(propertyDefinition); + this.bitmask = bitmask; + } + + /** + * Gets the name of the XML element. + * + * @return XML element name + */ + @Override + public String getXmlElementName() { + return XmlElementNames.Excludes; + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return true if element was read + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + boolean result = super.tryReadElementFromXml(reader); + + if (!result) { + if (reader.getLocalName().equals(XmlElementNames.Bitmask)) { + // EWS always returns the Bitmask value in hexadecimal + this.bitmask = Integer.parseInt(reader.readAttributeValue(XmlAttributeNames.Value)); + } + } + + return result; + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeElementsToXml(writer); + + writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Bitmask); + writer.writeAttributeValue(XmlAttributeNames.Value, this.bitmask); + writer.writeEndElement(); // Bitmask + } + + /** + * Gets the bitmask to compare the property with. + * + * @return bitmask + */ + public int getBitmask() { + return bitmask; + } + + /** + * Sets the bitmask to compare the property with. + * + * @param bitmask the new bitmask + */ + public void setBitmask(int bitmask) { + this.bitmask = bitmask; + } + + } + + + /** + * Represents a search filter checking if a field is set. Applications can + * use ExistsFilter to define conditions such as "Field IS SET". + */ + public static final class Exists extends PropertyBasedFilter { + + /** + * Initializes a new instance of the class. + */ + public Exists() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition the property definition + */ + public Exists(PropertyDefinitionBase propertyDefinition) { + super(propertyDefinition); + } + + /** + * Gets the name of the XML element. + * + * @return the xml element name + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.Exists; + } + } + + + /** + * Represents a search filter that checks if a property is equal to a given + * value or other property. + */ + public static class IsEqualTo extends RelationalFilter { + + /** + * Initializes a new instance of the class. + */ + public IsEqualTo() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param otherPropertyDefinition The definition of the property to compare with. + */ + public IsEqualTo(PropertyDefinitionBase propertyDefinition, + PropertyDefinitionBase otherPropertyDefinition) { + super(propertyDefinition, otherPropertyDefinition); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param value The value of the property to compare with. + */ + public IsEqualTo(PropertyDefinitionBase propertyDefinition, + Object value) { + super(propertyDefinition, value); + } + + /** + * Gets the name of the XML element. + * + * @return the xml element name + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.IsEqualTo; + } + + } + + + /** + * Represents a search filter that checks if a property is greater than a + * given value or other property. + */ + public static class IsGreaterThan extends RelationalFilter { + + /** + * Initializes a new instance of the class. + */ + public IsGreaterThan() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param otherPropertyDefinition The definition of the property to compare with. + */ + public IsGreaterThan(PropertyDefinitionBase propertyDefinition, + PropertyDefinitionBase otherPropertyDefinition) { + super(propertyDefinition, otherPropertyDefinition); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param value The value of the property to compare with. + */ + public IsGreaterThan(PropertyDefinitionBase propertyDefinition, + Object value) { + super(propertyDefinition, value); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.IsGreaterThan; + } + } + + + /** + * Represents a search filter that checks if a property is greater than or + * equal to a given value or other property. + */ + public static class IsGreaterThanOrEqualTo extends RelationalFilter { + + /** + * Initializes a new instance of the class. + */ + public IsGreaterThanOrEqualTo() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param otherPropertyDefinition The definition of the property to compare with. + */ + public IsGreaterThanOrEqualTo( + PropertyDefinitionBase propertyDefinition, + PropertyDefinitionBase otherPropertyDefinition) { + super(propertyDefinition, otherPropertyDefinition); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param value The value of the property to compare with. + */ + public IsGreaterThanOrEqualTo( + PropertyDefinitionBase propertyDefinition, Object value) { + super(propertyDefinition, value); + } + + /** + * Gets the name of the XML element. XML element name. + * + * @return the xml element name + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.IsGreaterThanOrEqualTo; + } + + } + + + /** + * Represents a search filter that checks if a property is less than a given + * value or other property. + */ + public static class IsLessThan extends RelationalFilter { + + /** + * Initializes a new instance of the class. + */ + public IsLessThan() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param otherPropertyDefinition The definition of the property to compare with. + */ + public IsLessThan(PropertyDefinitionBase propertyDefinition, + PropertyDefinitionBase otherPropertyDefinition) { + super(propertyDefinition, otherPropertyDefinition); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param value The value of the property to compare with. + */ + public IsLessThan(PropertyDefinitionBase propertyDefinition, + Object value) { + super(propertyDefinition, value); + } + + /** + * Gets the name of the XML element. XML element name. + * + * @return the xml element name + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.IsLessThan; + } + + } + + + /** + * Represents a search filter that checks if a property is less than or + * equal to a given value or other property. + */ + public static class IsLessThanOrEqualTo extends RelationalFilter { + + /** + * Initializes a new instance of the class. + */ + public IsLessThanOrEqualTo() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param otherPropertyDefinition The definition of the property to compare with. + */ + public IsLessThanOrEqualTo(PropertyDefinitionBase propertyDefinition, + PropertyDefinitionBase otherPropertyDefinition) { + super(propertyDefinition, otherPropertyDefinition); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param value The value of the property to compare with. + */ + public IsLessThanOrEqualTo(PropertyDefinitionBase propertyDefinition, + Object value) { + super(propertyDefinition, value); + } + + /** + * Gets the name of the XML element. XML element name. + * + * @return the xml element name + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.IsLessThanOrEqualTo; + } + + } + + + /** + * Represents a search filter that checks if a property is not equal to a + * given value or other property. + */ + public static class IsNotEqualTo extends RelationalFilter { + + /** + * Initializes a new instance of the class. + */ + public IsNotEqualTo() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param otherPropertyDefinition The definition of the property to compare with. + */ + public IsNotEqualTo(PropertyDefinitionBase propertyDefinition, + PropertyDefinitionBase otherPropertyDefinition) { + super(propertyDefinition, otherPropertyDefinition); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param value The value of the property to compare with. + */ + public IsNotEqualTo(PropertyDefinitionBase propertyDefinition, + Object value) { + super(propertyDefinition, value); + } + + /** + * Gets the name of the XML element. + * + * @return XML element name. + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.IsNotEqualTo; + } + + } + + + /** + * Represents a search filter that negates another. Applications can use + * NotFilter to define conditions such as "NOT(other filter)". + */ + public static class Not extends SearchFilter implements IComplexPropertyChangedDelegate { + + /** + * The search filter. + */ + private SearchFilter searchFilter; + + /** + * Initializes a new instance of the class. + */ + public Not() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param searchFilter the search filter + */ + public Not(SearchFilter searchFilter) { + super(); + this.searchFilter = searchFilter; + } + + /** + * Search filter changed. + * + * @param complexProperty the complex property + */ + private void searchFilterChanged(ComplexProperty complexProperty) { + this.changed(); + } + + /** + * validates the instance. + * + * @throws ExchangeValidationException the service validation exception + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + if (this.searchFilter == null) { + throw new ExchangeValidationException("The SearchFilter property must be set."); + } + } + + /** + * Gets the name of the XML element. + * + * @return the xml element name + */ + @Override + protected String getXmlElementName() { + return XmlElementNames.Not; + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return true if the element was read + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + this.searchFilter = SearchFilter.loadFromXml(reader); + return true; + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.searchFilter.writeToXml(writer); + } + + /** + * Gets the search filter to negate. Available search filter + * classes include SearchFilter.IsEqualTo, + * SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection. + * + * @return SearchFilter + */ + public SearchFilter getSearchFilter() { + return searchFilter; + } + + /** + * Sets the search filter to negate. Available search filter classes + * include SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection. + * + * @param searchFilter the new search filter + */ + public void setSearchFilter(SearchFilter searchFilter) { + if (this.searchFilter != null) { + this.searchFilter.removeChangeEvent(this); + } + + if (this.canSetFieldValue(this.searchFilter, searchFilter)) { + this.searchFilter = searchFilter; + this.changed(); + + } + + if (this.searchFilter != null) { + this.searchFilter.addOnChangeEvent(this); + } + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices. + * ComplexPropertyChangedDelegateInterface# + * complexPropertyChanged(microsoft.exchange.webservices.ComplexProperty + * ) + */ + @Override + public void complexPropertyChanged(ComplexProperty complexProperty) { + searchFilterChanged(complexProperty); + + } + } + + + /** + * Represents a search filter where an item or folder property is involved. + */ + @EditorBrowsable(state = EditorBrowsableState.Never) + public static abstract class PropertyBasedFilter extends SearchFilter { + + /** + * The property definition. + */ + private PropertyDefinitionBase propertyDefinition; + + /** + * Initializes a new instance of the class. + */ + PropertyBasedFilter() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition the property definition + */ + PropertyBasedFilter(PropertyDefinitionBase propertyDefinition) { + super(); + this.propertyDefinition = propertyDefinition; + } + + /** + * validate instance. + * + * @throws ExchangeValidationException the service validation exception + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + if (this.propertyDefinition == null) { + throw new ExchangeValidationException("The PropertyDefinition property must be set."); + } + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return true if element was read + * @throws Exception the exception + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + OutParam outParam = + new OutParam(); + outParam.setParam(this.propertyDefinition); + + return PropertyDefinitionBase.tryLoadFromXml(reader, outParam); + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + this.propertyDefinition.writeToXml(writer); + } + + /** + * Gets the definition of the property that is involved in the search + * filter. + * + * @return propertyDefinition + */ + public PropertyDefinitionBase getPropertyDefinition() { + return this.propertyDefinition; + } + + /** + * Sets the definition of the property that is involved in the search + * filter. + * + * @param propertyDefinition the new property definition + */ + public void setPropertyDefinition( + PropertyDefinitionBase propertyDefinition) { + this.propertyDefinition = propertyDefinition; + } + } + + + /** + * Represents the base class for relational filter (for example, IsEqualTo, + * IsGreaterThan or IsLessThanOrEqualTo). + */ + @EditorBrowsable(state = EditorBrowsableState.Never) + public abstract static class RelationalFilter extends PropertyBasedFilter { + + /** + * The other property definition. + */ + private PropertyDefinitionBase otherPropertyDefinition; + + /** + * The value. + */ + private Object value; + + /** + * Initializes a new instance of the class. + */ + RelationalFilter() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param otherPropertyDefinition The definition of the property to compare with + */ + RelationalFilter(PropertyDefinitionBase propertyDefinition, + PropertyDefinitionBase otherPropertyDefinition) { + super(propertyDefinition); + this.otherPropertyDefinition = otherPropertyDefinition; + } + + /** + * Initializes a new instance of the class. + * + * @param propertyDefinition The definition of the property that is being compared. + * @param value The value to compare with. + */ + RelationalFilter(PropertyDefinitionBase propertyDefinition, + Object value) { + super(propertyDefinition); + this.value = value; + } + + /** + * validates the instance. + * + * @throws ExchangeValidationException the service validation exception + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + super.internalValidate(); + + if (this.otherPropertyDefinition == null && this.value == null) { + throw new ExchangeValidationException( + "Either the OtherPropertyDefinition or the Value property must be set."); + } + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return true if element was read + * @throws Exception the exception + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + boolean result = super.tryReadElementFromXml(reader); + if (!result) { + if (reader.getLocalName().equals(XmlElementNames.FieldURIOrConstant)) { + reader.read(); + reader.ensureCurrentNodeIsStartElement(); + if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.Constant)) { + this.value = reader.readAttributeValue(XmlAttributeNames.Value); + result = true; + } else { + OutParam outParam = new OutParam(); + outParam.setParam(this.otherPropertyDefinition); + result = PropertyDefinitionBase.tryLoadFromXml(reader, outParam); + } + } + } + + return result; + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + super.writeElementsToXml(writer); + + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.FieldURIOrConstant); + + if (this.value != null) { + writer.writeStartElement(XmlNamespace.Types, + XmlElementNames.Constant); + writer.writeAttributeValue(XmlAttributeNames.Value, + true /* alwaysWriteEmptyString */, this.value); + writer.writeEndElement(); // Constant + } else { + this.otherPropertyDefinition.writeToXml(writer); + } + + writer.writeEndElement(); // FieldURIOrConstant + } + + /** + * Gets the definition of the property to compare with. + * + * @return otherPropertyDefinition + */ + public PropertyDefinitionBase getOtherPropertyDefinition() { + return this.otherPropertyDefinition; + } + + /** + * Sets the definition of the property to compare with. + * + * @param OtherPropertyDefinition the new other property definition + */ + public void setOtherPropertyDefinition( + PropertyDefinitionBase OtherPropertyDefinition) { + this.otherPropertyDefinition = OtherPropertyDefinition; + this.value = null; + } + + /** + * Gets the value of the property to compare with. + * + * @return the value + */ + public Object getValue() { + return value; + } + + /** + * Sets the value of the property to compare with. + * + * @param value the new value + */ + public void setValue(Object value) { + this.value = value; + this.otherPropertyDefinition = null; + } + + /** + * gets Xml Element name. + * + * @return the xml element name + */ + @Override + protected String getXmlElementName() { + return null; + } + } + + + /** + * Represents a collection of search filter linked by a logical operator. + * Applications can use SearchFilterCollection to define complex search + * filter such as "Condition1 AND Condition2". + */ + public static class SearchFilterCollection extends SearchFilter implements + Iterable, IComplexPropertyChangedDelegate { + + /** + * The logical operator. + */ + private LogicalOperator logicalOperator = LogicalOperator.And; + + /** + * The search filter. + */ + private final ArrayList searchFilters = + new ArrayList(); + + /** + * Initializes a new instance of the class. + */ + public SearchFilterCollection() { + super(); + } + + /** + * Initializes a new instance of the class. + * + * @param logicalOperator The logical operator used to initialize the collection. + */ + public SearchFilterCollection(LogicalOperator logicalOperator) { + this.logicalOperator = logicalOperator; + } + + /** + * Initializes a new instance of the class. + * + * @param logicalOperator The logical operator used to initialize the collection. + * @param searchFilters The search filter to add to the collection. + */ + public SearchFilterCollection(LogicalOperator logicalOperator, + SearchFilter... searchFilters) { + this(logicalOperator); + for (SearchFilter search : searchFilters) { + Iterable searchFil = java.util.Arrays + .asList(search); + this.addRange(searchFil); + } + } + + /** + * Initializes a new instance of the class. + * + * @param logicalOperator The logical operator used to initialize the collection. + * @param searchFilters The search filter to add to the collection. + */ + public SearchFilterCollection(LogicalOperator logicalOperator, + Iterable searchFilters) { + this(logicalOperator); + this.addRange(searchFilters); + } + + /** + * Validate instance. + * + */ + @Override + protected void internalValidate() throws ExchangeValidationException { + for (int i = 0; i < this.getCount(); i++) { + try { + this.searchFilters.get(i).internalValidate(); + } catch (ExchangeValidationException e) { + throw new ExchangeValidationException(String.format("The search filter at index %d is invalid.", i), e); + } + } + } + + /** + * A search filter has changed. + * + * @param complexProperty The complex property + */ + private void searchFilterChanged(ComplexProperty complexProperty) { + this.changed(); + } + + /** + * Gets the name of the XML element. + * + * @return xml element name + */ + @Override + protected String getXmlElementName() { + return this.logicalOperator.toString(); + } + + /** + * Tries to read element from XML. + * + * @param reader the reader + * @return true, if successful + */ + @Override + public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws ExchangeXmlException { + + this.add(SearchFilter.loadFromXml(reader)); + return true; + } + + /** + * Writes the elements to XML. + * + * @param writer the writer + */ + @Override + public void writeElementsToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + for (SearchFilter searchFilter : this.searchFilters) { + searchFilter.writeToXml(writer); + } + } + + /** + * Writes to XML. + * + * @param writer the writer + */ + @Override + public void writeToXml(EwsServiceXmlWriter writer) throws ExchangeXmlException { + // If there is only one filter in the collection, which developers + // tend + // to do, + // we need to not emit the collection and instead only emit the one + // filter within + // the collection. This is to work around the fact that EWS does not + // allow filter + // collections that have less than two elements. + if (this.getCount() == 1) { + this.searchFilters.get(0).writeToXml(writer); + } else { + super.writeToXml(writer); + } + } + + /** + * Adds a search filter of any type to the collection. + * + * @param searchFilter >The search filter to add. Available search filter classes + * include SearchFilter.IsEqualTo, + * SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection. + */ + public void add(SearchFilter searchFilter) { + if (searchFilter == null) { + throw new IllegalArgumentException("searchFilter"); + } + searchFilter.addOnChangeEvent(this); + this.searchFilters.add(searchFilter); + this.changed(); + } + + /** + * Adds multiple search filter to the collection. + * + * @param searchFilters The search filter to add. Available search filter classes + * include SearchFilter.IsEqualTo, + * SearchFilter.ContainsSubstring and + * SearchFilter.SearchFilterCollection + */ + public void addRange(Iterable searchFilters) { + if (searchFilters == null) { + throw new IllegalArgumentException("searchFilters"); + } + + for (SearchFilter searchFilter : searchFilters) { + searchFilter.addOnChangeEvent(this); + this.searchFilters.add(searchFilter); + } + this.changed(); + } + + /** + * Clears the collection. + */ + public void clear() { + if (this.getCount() > 0) { + for (SearchFilter searchFilter : this.searchFilters) { + searchFilter.removeChangeEvent(this); + } + this.searchFilters.clear(); + this.changed(); + } + } + + /** + * Determines whether a specific search filter is in the collection. + * + * @param searchFilter The search filter to locate in the collection. + * @return True is the search filter was found in the collection, false + * otherwise. + */ + public boolean contains(SearchFilter searchFilter) { + return this.searchFilters.contains(searchFilter); + } + + /** + * Removes a search filter from the collection. + * + * @param searchFilter The search filter to remove + */ + public void remove(SearchFilter searchFilter) { + if (searchFilter == null) { + throw new IllegalArgumentException("searchFilter"); + } + + if (this.contains(searchFilter)) { + searchFilter.removeChangeEvent(this); + this.searchFilters.remove(searchFilter); + this.changed(); + } + } + + /** + * Removes the search filter at the specified index from the collection. + * + * @param index The zero-based index of the search filter to remove. + */ + public void removeAt(int index) { + if (index < 0 || index >= this.getCount()) { + throw new IllegalArgumentException( + String.format("index %d is out of range [0..%d[.", index, this.getCount())); + } + + this.searchFilters.get(index).removeChangeEvent(this); + this.searchFilters.remove(index); + this.changed(); + } + + /** + * Gets the total number of search filter in the collection. + * + * @return the count + */ + public int getCount() { + + return this.searchFilters.size(); + } + + /** + * Gets the search filter at the specified index. + * + * @param index the index + * @return The search filter at the specified index. + */ + public SearchFilter getSearchFilter(int index) { + if (index < 0 || index >= this.getCount()) { + throw new IllegalArgumentException( + String.format("index %d is out of range [0..%d[.", index, this.getCount()) + ); + } + return this.searchFilters.get(index); + } + + /** + * Sets the search filter at the specified index. + * + * @param index the index + * @param searchFilter the search filter + */ + public void setSearchFilter(int index, SearchFilter searchFilter) { + if (index < 0 || index >= this.getCount()) { + throw new IllegalArgumentException( + String.format("index %d is out of range [0..%d[.", index, this.getCount()) + ); + } + this.searchFilters.add(index, searchFilter); + } + + /** + * Gets the logical operator that links the serach filter in this + * collection. + * + * @return LogicalOperator + */ + public LogicalOperator getLogicalOperator() { + return logicalOperator; + } + + /** + * Sets the logical operator that links the serach filter in this + * collection. + * + * @param logicalOperator the new logical operator + */ + public void setLogicalOperator(LogicalOperator logicalOperator) { + this.logicalOperator = logicalOperator; + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices. + * ComplexPropertyChangedDelegateInterface# + * complexPropertyChanged(microsoft.exchange.webservices.ComplexProperty + * ) + */ + @Override + public void complexPropertyChanged(ComplexProperty complexProperty) { + searchFilterChanged(complexProperty); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Iterable#iterator() + */ + @Override + public Iterator iterator() { + return this.searchFilters.iterator(); + } + + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/security/XmlNodeType.java b/ews-api/src/main/java/com/eischet/ews/api/security/XmlNodeType.java new file mode 100644 index 000000000..ed0671dee --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/security/XmlNodeType.java @@ -0,0 +1,231 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.security; + +import javax.xml.stream.XMLStreamConstants; + +/** + * The Class XmlNodeType. + */ +public class XmlNodeType implements XMLStreamConstants { + + /** + * The node type. + */ + public int nodeType; + + /** + * Instantiates a new Xml node type. + * + * @param nodeType The node type. + */ + public XmlNodeType(int nodeType) { + this.nodeType = nodeType; + } + + /** + * Returns a string representation of the object. In general, the + * toString method returns a string that "textually represents" + * this object. The result should be a concise but informative + * representation that is easy for a person to read. It is recommended that + * all subclasses override this method. + *

+ * The toString method for class Object returns a + * string consisting of the name of the class of which the object is an + * instance, the at-sign character `@', and the unsigned + * hexadecimal representation of the hash code of the object. In other + * words, this method returns a string equal to the value of:

+ *

+ *

+     * getClass().getName() + '@' + Integer.toHexString(hashCode())
+     * 
+ *

+ *

+ * + * @return a string representation of the object. + */ + @Override + public String toString() { + return getString(nodeType); + } + + /** + * Sets the node type. + * + * @param nodeType the new node type + */ + public void setNodeType(int nodeType) { + this.nodeType = nodeType; + } + + /** + * Gets the node type. + * + * @return the node type + */ + public int getNodeType() { + return nodeType; + } + + /** + * Gets the string. + * + * @param nodeType the node type + * @return the string + */ + public static String getString(int nodeType) { + switch (nodeType) { + case XMLStreamConstants.ATTRIBUTE: + return "ATTRIBUTE"; + case XMLStreamConstants.CDATA: + return "CDATA"; + case XMLStreamConstants.CHARACTERS: + return "CHARACTERS"; + case XMLStreamConstants.COMMENT: + return "COMMENT"; + case XMLStreamConstants.DTD: + return "DTD"; + case XMLStreamConstants.END_DOCUMENT: + return "END_DOCUMENT"; + case XMLStreamConstants.END_ELEMENT: + return "END_ELEMENT"; + case XMLStreamConstants.ENTITY_DECLARATION: + return "ENTITY_DECLARATION"; + case XMLStreamConstants.ENTITY_REFERENCE: + return "ENTITY_REFERENCE"; + case XMLStreamConstants.NAMESPACE: + return "NAMESPACE"; + case XMLStreamConstants.NOTATION_DECLARATION: + return "NOTATION_DECLARATION"; + case XMLStreamConstants.PROCESSING_INSTRUCTION: + return "PROCESSING_INSTRUCTION"; + case XMLStreamConstants.SPACE: + return "SPACE"; + case XMLStreamConstants.START_DOCUMENT: + return "START_DOCUMENT"; + case XMLStreamConstants.START_ELEMENT: + return "START_ELEMENT"; + case 0: + return "NONE"; + default: + return "UNKNOWN"; + } + } + + /** + * Indicates whether some other object is "equal to" this one. + *

+ * The equals method implements an equivalence relation on + * non-null object references: + *

    + *
  • It is reflexive: for any non-null reference value + * x, x.equals(x) should return true. + *
  • It is symmetric: for any non-null reference values + * x and y, x.equals(y) should return + * true if and only if y.equals(x) returns + * true. + *
  • It is transitive: for any non-null reference values + * x, y, and z, if + * x.equals(y) returns true and + * y.equals(z) returns true, then + * x.equals(z) should return true. + *
  • It is consistent: for any non-null reference values + * x and y, multiple invocations of + * x.equals(y) consistently return true or + * consistently return false, provided no information used in + * equals comparisons on the objects is modified. + *
  • For any non-null reference value x, + * x.equals(null) should return false. + *
+ *

+ * The equals method for class Object implements the + * most discriminating possible equivalence relation on objects; that is, + * for any non-null reference values x and y, this + * method returns true if and only if x and + * y refer to the same object (x == y has the + * value true). + *

+ * Note that it is generally necessary to override the hashCode + * method whenever this method is overridden, so as to maintain the general + * contract for the hashCode method, which states that equal + * objects must have equal hash codes. + * + * @param obj the reference object with which to compare. + * @return if this object is the same as the obj argument; otherwise. + * @see #hashCode() + * @see java.util.Hashtable + */ + @Override + public boolean equals(Object obj) { + + if (this == obj) { + return true; + } + if (obj instanceof XmlNodeType) { + XmlNodeType other = (XmlNodeType) obj; + return this.nodeType == other.nodeType; + } else { + return super.equals(obj); + } + } + + /** + * Returns a hash code value for the object. This method is supported for + * the benefit of hashtables such as those provided by + * java.util.Hashtable. + *

+ * The general contract of hashCode is: + *

    + *
  • Whenever it is invoked on the same object more than once during an + * execution of a Java application, the hashCode method must + * consistently return the same integer, provided no information used in + * equals comparisons on the object is modified. This integer need + * not remain consistent from one execution of an application to another + * execution of the same application. + *
  • If two objects are equal according to the equals(Object) + * method, then calling the hashCode method on each of the two + * objects must produce the same integer result. + *
  • It is not required that if two objects are unequal according + * to the {@link Object#equals(Object)} method, then + * calling the hashCode method on each of the two objects must + * produce distinct integer results. However, the programmer should be aware + * that producing distinct integer results for unequal objects may improve + * the performance of hashtables. + *
+ *

+ * As much as is reasonably practical, the hashCode method defined by class + * Object does return distinct integers for distinct objects. (This + * is typically implemented by converting the internal address of the object + * into an integer, but this implementation technique is not required by the + * JavaTM programming language.) + * + * @return a hash code value for this object. + * @see Object#equals(Object) + * @see java.util.Hashtable + */ + @Override + public int hashCode() { + return this.nodeType; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/sync/Change.java b/ews-api/src/main/java/com/eischet/ews/api/sync/Change.java new file mode 100644 index 000000000..2364d811b --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/sync/Change.java @@ -0,0 +1,121 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.sync; + +import com.eischet.ews.api.attribute.EditorBrowsable; +import com.eischet.ews.api.core.enumeration.attribute.EditorBrowsableState; +import com.eischet.ews.api.core.enumeration.sync.ChangeType; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.property.complex.ServiceId; + +/** + * Represents a change as returned by a synchronization operation. + */ +@EditorBrowsable(state = EditorBrowsableState.Never) +public abstract class Change { + + /** + * The type of change. + */ + private ChangeType changeType; + + /** + * The service object the change applies to. + */ + private ServiceObject serviceObject; + + /** + * The Id of the service object the change applies to. + */ + private ServiceId id; + + /** + * Initializes a new instance of Change. + */ + protected Change() { + } + + /** + * Initializes a new instance of Change. + * + * @return the service id + */ + public abstract ServiceId createId(); + + /** + * Gets the type of the change. + * + * @return the change type + */ + public ChangeType getChangeType() { + return this.changeType; + } + + /** + * sets the type of the change. + * + * @param changeType the new change type + */ + public void setChangeType(ChangeType changeType) { + this.changeType = changeType; + } + + /** + * Gets the service object the change applies to. + * + * @return the service object + */ + public ServiceObject getServiceObject() { + return this.serviceObject; + } + + /** + * Sets the service object. + * + * @param serviceObject the new service object + */ + public void setServiceObject(ServiceObject serviceObject) { + this.serviceObject = serviceObject; + } + + /** + * Gets the Id of the service object the change applies to. + * + * @return the id + */ + public ServiceId getId() throws ExchangeXmlException { + return this.getServiceObject() != null ? this.getServiceObject() + .getId() : this.id; + } + + /** + * Sets the id. + * + * @param id the new id + */ + public void setId(ServiceId id) { + this.id = id; + } +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/sync/ChangeCollection.java b/ews-api/src/main/java/com/eischet/ews/api/sync/ChangeCollection.java new file mode 100644 index 000000000..2ba5ed391 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/sync/ChangeCollection.java @@ -0,0 +1,140 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.sync; + +import com.eischet.ews.api.core.EwsUtilities; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * Represents a collection of changes as returned by a synchronization + * operation. + * + * @param the generic type + */ +public final class ChangeCollection implements Iterable { + + /** + * The changes. + */ + private final List changes = new ArrayList(); + + /** + * The sync state. + */ + private String syncState; + + /** + * The more changes available. + */ + private boolean moreChangesAvailable; + + /** + * Initializes a new instance of the class. + */ + public ChangeCollection() { + } + + /** + * Adds the specified change. + * + * @param change the change + */ + public void add(TChange change) { + EwsUtilities.ewsAssert(change != null, "ChangeList.Add", "change is null"); + this.changes.add(change); + } + + /** + * Gets the number of changes in the collection. + * + * @return the count + */ + public int getCount() { + return this.changes.size(); + } + + /** + * Gets an individual change from the change collection. + * + * @param index the index + * @return An single change + */ + public TChange getChangeAtIndex(int index) { + if (index < 0 || index >= this.getCount()) { + throw new IndexOutOfBoundsException( + String.format("index %d is out of range [0..%d[.", index, this.getCount())); + } + return this.changes.get(index); + } + + /** + * Gets the SyncState blob returned by a synchronization operation. + * + * @return the sync state + */ + public String getSyncState() { + return this.syncState; + } + + /** + * Sets the sync state. + * + * @param syncState the new sync state + */ + public void setSyncState(String syncState) { + this.syncState = syncState; + } + + /** + * Gets the SyncState blob returned by a synchronization operation. + * + * @return the more changes available + */ + public boolean getMoreChangesAvailable() { + return this.moreChangesAvailable; + } + + /** + * Sets the more changes available. + * + * @param moreChangesAvailable the new more changes available + */ + public void setMoreChangesAvailable(boolean moreChangesAvailable) { + this.moreChangesAvailable = moreChangesAvailable; + } + + /** + * Returns an iterator over a set of elements of type T. + * + * @return an Iterator. + */ + @Override + public Iterator iterator() { + return this.changes.iterator(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/sync/FolderChange.java b/ews-api/src/main/java/com/eischet/ews/api/sync/FolderChange.java new file mode 100644 index 000000000..908497a87 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/sync/FolderChange.java @@ -0,0 +1,74 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.sync; + +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.folder.Folder; +import com.eischet.ews.api.property.complex.FolderId; +import com.eischet.ews.api.property.complex.ServiceId; + +/** + * Represents a change on a folder as returned by a synchronization operation. + */ +public final class FolderChange extends Change { + /** + * Initializes a new instance of FolderChange. + */ + public FolderChange() { + super(); + } + + /** + * Creates a FolderId instance. + * + * @return A FolderId. + */ + @Override + public ServiceId createId() { + return new FolderId(); + } + + /** + * Gets the folder the change applies to. Folder is null when ChangeType + * is equal to ChangeType.Delete. In that case, use the FolderId property to + * retrieve the Id of the folder that was deleted. + * + * @return the folder + */ + public Folder getFolder() { + return (Folder) this.getServiceObject(); + } + + /** + * Gets the folder the change applies to. Folder is null when ChangeType + * is equal to ChangeType.Delete. In that case, use the FolderId property to + * retrieve the Id of the folder that was deleted. + * + * @return the folder id + */ + public FolderId getFolderId() throws ExchangeXmlException { + return (FolderId) this.getId(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/sync/ItemChange.java b/ews-api/src/main/java/com/eischet/ews/api/sync/ItemChange.java new file mode 100644 index 000000000..a3fc2d1f0 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/sync/ItemChange.java @@ -0,0 +1,99 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.sync; + +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.property.complex.ItemId; +import com.eischet.ews.api.property.complex.ServiceId; + +/** + * Represents a change on an item as returned by a synchronization operation. + */ +public final class ItemChange extends Change { + + /** + * The is read. + */ + private boolean isRead; + + /** + * Initializes a new instance of ItemChange. + */ + public ItemChange() { + super(); + } + + /** + * Creates an ItemId instance. + * + * @return A ItemId. + */ + @Override + public ServiceId createId() { + return new ItemId(); + } + + /** + * Gets the item the change applies to. Item is null when ChangeType is + * equal to either ChangeType.Delete or ChangeType.ReadFlagChange. In those + * cases, use the ItemId property to retrieve the Id of the item that was + * deleted or whose IsRead property changed. + * + * @return the item + */ + public Item getItem() { + return (Item) this.getServiceObject(); + } + + /** + * Gets the IsRead property for the item that the change applies to. + * IsRead is only valid when ChangeType is equal to + * ChangeType.ReadFlagChange. + * + * @return the checks if is read + */ + public boolean getIsRead() { + return this.isRead; + } + + /** + * Sets the checks if is read. + * + * @param isRead the new checks if is read + */ + public void setIsRead(boolean isRead) { + this.isRead = isRead; + } + + /** + * Gets the Id of the item the change applies to. + * + * @return the item id + */ + public ItemId getItemId() throws ExchangeXmlException { + return (ItemId) this.getId(); + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/util/DateTimeUtils.java b/ews-api/src/main/java/com/eischet/ews/api/util/DateTimeUtils.java new file mode 100644 index 000000000..230525a93 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/util/DateTimeUtils.java @@ -0,0 +1,206 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.util; + +import com.eischet.ews.api.core.exception.misc.ArgumentException; + +import java.time.*; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +import java.util.logging.Logger; + +public final class DateTimeUtils { + + private static final Logger log = Logger.getLogger(DateTimeUtils.class.getCanonicalName()); + private static final Formatter[] DATE_TIME_FORMATS = createDateTimeFormats(); + + + + private DateTimeUtils() { + throw new UnsupportedOperationException(); + } + + + private static Formatter[] createDateTimeFormats() { + return new Formatter[]{ + Formatter.of(DateTimeFormatter.ISO_LOCAL_DATE_TIME), + Formatter.of(DateTimeFormatter.ISO_OFFSET_DATE_TIME), + Formatter.of(DateTimeFormatter.ISO_ZONED_DATE_TIME), + Formatter.of(DateTimeFormatter.ISO_LOCAL_DATE), + Formatter.of(DateTimeFormatter.ISO_DATE), + Formatter.of(DateTimeFormatter.ISO_OFFSET_DATE), + + + + Formatter.datetime("yyyy-MM-dd'T'HH:mm:ssZ"), + Formatter.datetime("yyyy-MM-dd'T'HH:mm:ss.SSSZ"), + Formatter.datetime("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSZ"), + Formatter.datetime("yyyy-MM-dd'T'HH:mm:ss"), + Formatter.datetime("yyyy-MM-dd'T'HH:mm:ss.SSS"), + Formatter.datetime("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS"), + Formatter.date("yyyy-MM-ddZ"), + Formatter.date("yyyy-MM-dd") + }; + } + + public static LocalDate parseDateOnly(String value) { + if (value == null || value.isBlank()) { + return null; + } + if (value.endsWith("z") || value.endsWith("Z")) { + // REMOVE z suffix. + value = value.substring(0, value.length() - 1); + } + for (final Formatter dateTimeFormat : DATE_TIME_FORMATS) { + LocalDate result = dateTimeFormat.parseLocalDate(value); + if (result != null) { + return result; + } + } + throw new IllegalArgumentException("cannot parse as date: '" + value + "'"); + } + + public static LocalDateTime parseDateTime(final String value) { + if (value == null || value.isBlank()) { + return null; + } + for (final Formatter dateTimeFormat : DATE_TIME_FORMATS) { + LocalDateTime result = dateTimeFormat.parseLocalDateTime(value); + if (result != null) { + return result; + } + } + throw new IllegalArgumentException("cannot parse as datetime: '" + value + "'"); + } + + public static LocalTime parseTime(final String value) throws ArgumentException { + //if (value == null || value.isBlank()) { + // return null; + //} + try { + return LocalTime.parse(value); + } catch (DateTimeParseException e) { + throw new ArgumentException("cannot parse '" + value + "' as a LocalTime", e); + } + // return null; // TODO: parse it + } + + private static class Formatter { + private final String pattern; + private final DateTimeFormatter wrapped; + private final boolean dateOnly; + + private Formatter(final String pattern, final boolean dateOnly) { + this.pattern = pattern; + this.wrapped = DateTimeFormatter.ofPattern(pattern); // .withZone(ZoneOffset.UTC); + this.dateOnly = dateOnly; + } + + public Formatter(final DateTimeFormatter wrapped, final boolean dateOnly) { + this.pattern = wrapped.toString(); + this.wrapped = wrapped; + this.dateOnly = dateOnly; + } + + public static Formatter datetime(final String pattern) { + return new Formatter(pattern, false); + } + + public static Formatter date(final String pattern) { + return new Formatter(pattern, true); + } + + public static Formatter of(final DateTimeFormatter wrapped) { + return new Formatter(wrapped, false); + } +/* + public Date parseDate(final String value, final boolean returnDateOnly) { + if (dateOnly) { + try { + final LocalDate retval = wrapped.parse(value, LocalDate::from); + return Date.from(retval.atStartOfDay().toInstant(ZoneOffset.UTC)); + // joda: return format.parseDateTime(value).toDate(); + } catch (IllegalArgumentException | DateTimeParseException e) { + log.log(Level.WARNING, String.format("cannot parse '%s' via format %s (date only=%s)", value, pattern, returnDateOnly), e); + } + } else { + try { + final LocalDateTime retval = wrapped.parse(value, LocalDateTime::from); + return Date.from(retval.toInstant(ZoneOffset.UTC)); + } catch (IllegalArgumentException | DateTimeParseException e) { + log.log(Level.WARNING, String.format("cannot parse '%s' via format %s (date only=%s)", value, pattern, returnDateOnly), e); + } + try { + final ZonedDateTime retval = wrapped.parse(value, ZonedDateTime::from); + return Date.from(retval.toInstant()); + // joda: return format.parseDateTime(value).toDate(); + } catch (IllegalArgumentException | DateTimeParseException e) { + log.log(Level.WARNING, String.format("cannot parse '%s' via format %s (date only=%s)", value, pattern, returnDateOnly), e); + } + } + return null; + } +*/ + @Override + public String toString() { + return pattern; + } + + public LocalDate parseLocalDate(final String value) { + try { + final ZonedDateTime zoned = wrapped.parse(value, ZonedDateTime::from); + if (zoned != null) { + return zoned.toOffsetDateTime().atZoneSameInstant(ZoneOffset.UTC).toLocalDate(); + } + } catch (RuntimeException ignored) { + } + try { + return wrapped.parse(value, LocalDate::from); + } catch (RuntimeException e) { + // the warnings do not really make sense, because upstream code might use multiple different formats in sequence to parse a date... better return null only + // log.warning(() -> String.format("parseLocalDate: cannot parse value '%s' with pattern '%s' (%s) as LocalDate, and all alternative patterns failed, too", value, pattern, e.getMessage())); + return null; + } + } + + + public LocalDateTime parseLocalDateTime(final String value) { + try { + final ZonedDateTime zoned = wrapped.parse(value, ZonedDateTime::from); + if (zoned != null) { + return zoned.toOffsetDateTime().atZoneSameInstant(ZoneOffset.UTC).toLocalDateTime(); + } + } catch (RuntimeException ignored) { + } + try { + return wrapped.parse(value, LocalDateTime::from); + } catch (RuntimeException e) { + // the warnings do not really make sense, because upstream code might use multiple different formats in sequence to parse a date... better return null only + // log.warning(() -> String.format("parseLocalDateTime: cannot parse value '%s' with pattern '%s' (%s) as LocalDateTime, and all alternative patterns failed, too", value, pattern, e.getMessage())); + return null; + } + } + } + +} diff --git a/ews-api/src/main/java/com/eischet/ews/api/util/IOUtils.java b/ews-api/src/main/java/com/eischet/ews/api/util/IOUtils.java new file mode 100644 index 000000000..86994d4f4 --- /dev/null +++ b/ews-api/src/main/java/com/eischet/ews/api/util/IOUtils.java @@ -0,0 +1,16 @@ +package com.eischet.ews.api.util; + +import java.io.Closeable; +import java.io.IOException; + +public class IOUtils { + + public static void closeQuietly(final Closeable closeable) { + if (closeable != null) { + try { + closeable.close(); + } catch (IOException ignored) { + } + } + } +} diff --git a/src/site/site.xml b/ews-api/src/site/site.xml similarity index 100% rename from src/site/site.xml rename to ews-api/src/site/site.xml diff --git a/ews-api/src/test/java/com/eischet/ews/api/BaseTest.java b/ews-api/src/test/java/com/eischet/ews/api/BaseTest.java new file mode 100644 index 000000000..308972b26 --- /dev/null +++ b/ews-api/src/test/java/com/eischet/ews/api/BaseTest.java @@ -0,0 +1,57 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api; + +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.ExchangeServiceBase; +import com.eischet.ews.api.http.ExchangeHttpClient; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** + * A base class with "Common-Services" + */ +@RunWith(JUnit4.class) +public abstract class BaseTest { + + protected static ExchangeServiceBase exchangeServiceBaseMock; + protected static ExchangeService exchangeServiceMock; + + /** + * Setup Mocks + */ + @BeforeClass + public static void setUpBaseClass() throws Exception { + // Mock up ExchangeServiceBase + exchangeServiceBaseMock = new ExchangeServiceBase(null) { + @Override + protected void processHttpErrorResponse(ExchangeHttpClient.Request httpWebResponse, Exception webException) + throws Exception { + throw webException; + } + }; + exchangeServiceMock = new ExchangeService(null); + } +} diff --git a/ews-api/src/test/java/com/eischet/ews/api/DateParsingTestCase.java b/ews-api/src/test/java/com/eischet/ews/api/DateParsingTestCase.java new file mode 100644 index 000000000..f60bec05c --- /dev/null +++ b/ews-api/src/test/java/com/eischet/ews/api/DateParsingTestCase.java @@ -0,0 +1,22 @@ +package com.eischet.ews.api; + +import com.eischet.ews.api.util.DateTimeUtils; +import org.junit.Test; + +import java.time.LocalDateTime; + +import static junit.framework.TestCase.assertNotNull; + +public class DateParsingTestCase { + + @Test + public void parseDates() { + final String sample = "2023-08-12T14:49:28Z"; + final LocalDateTime date = DateTimeUtils.parseDateTime(sample); + assertNotNull(date); + System.out.println(date); + // TODO: add more checks -> the Z is ignored right now, because my own client does not use any date fields actually (!) + } + + +} diff --git a/src/test/java/microsoft/exchange/webservices/data/exception/InvalidOrUnsupportedTimeZoneDefinitionExceptionTest.java b/ews-api/src/test/java/com/eischet/ews/api/InvalidOrUnsupportedTimeZoneDefinitionExceptionTest.java similarity index 93% rename from src/test/java/microsoft/exchange/webservices/data/exception/InvalidOrUnsupportedTimeZoneDefinitionExceptionTest.java rename to ews-api/src/test/java/com/eischet/ews/api/InvalidOrUnsupportedTimeZoneDefinitionExceptionTest.java index 93d4f8c2b..2d6855a52 100644 --- a/src/test/java/microsoft/exchange/webservices/data/exception/InvalidOrUnsupportedTimeZoneDefinitionExceptionTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/InvalidOrUnsupportedTimeZoneDefinitionExceptionTest.java @@ -21,13 +21,13 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.exception; +package com.eischet.ews.api; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; -import microsoft.exchange.webservices.data.core.exception.service.local.InvalidOrUnsupportedTimeZoneDefinitionException; +import com.eischet.ews.api.core.exception.service.local.InvalidOrUnsupportedTimeZoneDefinitionException; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; diff --git a/src/test/java/microsoft/exchange/webservices/data/exception/MaximumRedirectionHopsExceededExceptionTest.java b/ews-api/src/test/java/com/eischet/ews/api/MaximumRedirectionHopsExceededExceptionTest.java similarity index 93% rename from src/test/java/microsoft/exchange/webservices/data/exception/MaximumRedirectionHopsExceededExceptionTest.java rename to ews-api/src/test/java/com/eischet/ews/api/MaximumRedirectionHopsExceededExceptionTest.java index 5ae191821..09485f4dc 100644 --- a/src/test/java/microsoft/exchange/webservices/data/exception/MaximumRedirectionHopsExceededExceptionTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/MaximumRedirectionHopsExceededExceptionTest.java @@ -21,13 +21,13 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.exception; +package com.eischet.ews.api; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; -import microsoft.exchange.webservices.data.autodiscover.exception.MaximumRedirectionHopsExceededException; +import com.eischet.ews.api.autodiscover.exception.MaximumRedirectionHopsExceededException; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; diff --git a/src/test/java/microsoft/exchange/webservices/data/autodiscover/AlternateMailboxCollectionTest.java b/ews-api/src/test/java/com/eischet/ews/api/autodiscover/AlternateMailboxCollectionTest.java similarity index 97% rename from src/test/java/microsoft/exchange/webservices/data/autodiscover/AlternateMailboxCollectionTest.java rename to ews-api/src/test/java/com/eischet/ews/api/autodiscover/AlternateMailboxCollectionTest.java index 084bbfec8..f325a630b 100644 --- a/src/test/java/microsoft/exchange/webservices/data/autodiscover/AlternateMailboxCollectionTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/autodiscover/AlternateMailboxCollectionTest.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.autodiscover; +package com.eischet.ews.api.autodiscover; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -30,7 +30,7 @@ import org.junit.Test; -import microsoft.exchange.webservices.data.core.EwsXmlReader; +import com.eischet.ews.api.core.EwsXmlReader; public class AlternateMailboxCollectionTest { diff --git a/src/test/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverDnsClientTest.java b/ews-api/src/test/java/com/eischet/ews/api/autodiscover/AutodiscoverDnsClientTest.java similarity index 97% rename from src/test/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverDnsClientTest.java rename to ews-api/src/test/java/com/eischet/ews/api/autodiscover/AutodiscoverDnsClientTest.java index 0e529b036..cd9d91a0d 100644 --- a/src/test/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverDnsClientTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/autodiscover/AutodiscoverDnsClientTest.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.autodiscover; +package com.eischet.ews.api.autodiscover; import static org.junit.Assert.assertEquals; diff --git a/ews-api/src/test/java/com/eischet/ews/api/autodiscover/request/GetUserSettingsRequestTest.java b/ews-api/src/test/java/com/eischet/ews/api/autodiscover/request/GetUserSettingsRequestTest.java new file mode 100644 index 000000000..1933b7640 --- /dev/null +++ b/ews-api/src/test/java/com/eischet/ews/api/autodiscover/request/GetUserSettingsRequestTest.java @@ -0,0 +1,192 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.autodiscover.request; + + +import com.eischet.ews.api.BaseTest; +import com.eischet.ews.api.autodiscover.AutodiscoverService; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.service.local.ExchangeValidationException; +import com.eischet.ews.api.core.exception.service.local.ServiceXmlSerializationException; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.http.ExchangeHttpClient; +import org.hamcrest.core.IsNot; +import org.hamcrest.core.IsNull; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import javax.xml.stream.XMLStreamException; +import java.io.ByteArrayOutputStream; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +/** + * Testclass for methods of GetUserSettingsRequest + */ +@RunWith(Parameterized.class) +public class GetUserSettingsRequestTest extends BaseTest { + + /** + * The ExchangeVersion which is under test + */ + private final ExchangeVersion exchangeVersion; + + /** + * The AutodiscoverService which is under test + */ + private final AutodiscoverService autodiscoverService; + + /** + * A mocked URI via HTTPS + */ + private final URI uriMockHttps = URI.create("https://localhost"); + + /** + * A mocked URI via HTTP + */ + private final URI uriMockHttp = URI.create("http://localhost"); + + /** + * Returns the Parameters which where handled to the constructor + * + * @return the available Services + * @throws ArgumentException + */ + @Parameterized.Parameters + public static List getAutodiscoverServices() throws ArgumentException { + return new ArrayList() { + + /** + * Constant serialized ID used for compatibility. + */ + private static final long serialVersionUID = 1L; + + { + for (ExchangeVersion exchangeVersion : ExchangeVersion.values()) { + add(new Object[]{exchangeVersion, new AutodiscoverService((ExchangeHttpClient) null, exchangeVersion)}); + } + } + }; + } + + /** + * Construct the Testobject with given Parameters + * + * @param exchangeVersion + * @param autodiscoverService + */ + public GetUserSettingsRequestTest(final ExchangeVersion exchangeVersion, + final AutodiscoverService autodiscoverService) { + this.exchangeVersion = exchangeVersion; + this.autodiscoverService = autodiscoverService; + } + + /** + * setup + */ + @Before + public void setup() { + Assert.assertThat(this.exchangeVersion, IsNull.notNullValue()); + Assert.assertThat(this.autodiscoverService, IsNull.notNullValue()); + Assert.assertThat(uriMockHttp, IsNull.notNullValue()); + Assert.assertThat(uriMockHttps, IsNull.notNullValue()); + } + + /** + * Nothing should be written to the OutputStream if expectPartnerToken is not set. + * + * @throws ExchangeValidationException + * @throws XMLStreamException the XML stream exception + */ + @Test + public void testWriteExtraCustomSoapHeadersToXmlWithoutPartnertoken() + throws ExchangeXmlException, XMLStreamException { + // HTTPS + GetUserSettingsRequest getUserSettingsRequest = + new GetUserSettingsRequest(autodiscoverService, uriMockHttps); + + // Test without expected Partnertoken + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + getUserSettingsRequest.writeExtraCustomSoapHeadersToXml( + new EwsServiceXmlWriter(exchangeServiceBaseMock, byteArrayOutputStream)); + + // nothing should be writyen to the outputstream + Assert.assertArrayEquals(byteArrayOutputStream.toByteArray(), new ByteArrayOutputStream().toByteArray()); + + // HTTP + getUserSettingsRequest = new GetUserSettingsRequest(autodiscoverService, uriMockHttp); + + // Test without expected Partnertoken + byteArrayOutputStream = new ByteArrayOutputStream(); + getUserSettingsRequest.writeExtraCustomSoapHeadersToXml( + new EwsServiceXmlWriter(exchangeServiceBaseMock, byteArrayOutputStream)); + + // nothing should be written to the outputstream + Assert.assertArrayEquals(byteArrayOutputStream.toByteArray(), new ByteArrayOutputStream().toByteArray()); + } + + /** + * Test if content is added correctly if expectPartnerToken is set. + * + * @throws ExchangeValidationException + * @throws XMLStreamException the XML stream exception + */ + @Test + public void testWriteExtraCustomSoapHeadersToXmlWithPartnertoken() + throws ExchangeXmlException, XMLStreamException { + GetUserSettingsRequest getUserSettingsRequest = + new GetUserSettingsRequest(autodiscoverService, uriMockHttps, Boolean.TRUE); + + // Test without expected Partnertoken + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + getUserSettingsRequest.writeExtraCustomSoapHeadersToXml( + new EwsServiceXmlWriter(exchangeServiceBaseMock, byteArrayOutputStream)); + + // data should be added the same way as mentioned + Assert.assertThat(byteArrayOutputStream.toByteArray(), + IsNot.not(new ByteArrayOutputStream().toByteArray())); + + //TODO Test if the output is really correct + } + + /** + * Initialising a GetUserSettingsRequest with Http should lead to an ServiceValidationException. + * + * @throws ExchangeValidationException + * @throws XMLStreamException the XML stream exception + * @throws ServiceXmlSerializationException the service xml serialization exception + */ + @Test(expected = ExchangeValidationException.class) + public void testWriteExtraCustomSoapHeadersToXmlWithPartnertoken2() + throws ExchangeValidationException, XMLStreamException, ServiceXmlSerializationException { + GetUserSettingsRequest getUserSettingsRequest = + new GetUserSettingsRequest(autodiscoverService, uriMockHttp, Boolean.TRUE); + } +} diff --git a/src/test/java/microsoft/exchange/webservices/data/core/EwsUtilitiesTest.java b/ews-api/src/test/java/com/eischet/ews/api/core/EwsUtilitiesTest.java similarity index 76% rename from src/test/java/microsoft/exchange/webservices/data/core/EwsUtilitiesTest.java rename to ews-api/src/test/java/com/eischet/ews/api/core/EwsUtilitiesTest.java index b93023cea..89b567440 100644 --- a/src/test/java/microsoft/exchange/webservices/data/core/EwsUtilitiesTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/core/EwsUtilitiesTest.java @@ -21,37 +21,22 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core; +package com.eischet.ews.api.core; -import static org.junit.Assert.assertEquals; - -import microsoft.exchange.webservices.data.core.service.folder.CalendarFolder; -import microsoft.exchange.webservices.data.core.service.folder.ContactsFolder; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.service.folder.SearchFolder; -import microsoft.exchange.webservices.data.core.service.folder.TasksFolder; -import microsoft.exchange.webservices.data.core.service.item.Appointment; -import microsoft.exchange.webservices.data.core.service.item.Contact; -import microsoft.exchange.webservices.data.core.service.item.ContactGroup; -import microsoft.exchange.webservices.data.core.service.item.Conversation; -import microsoft.exchange.webservices.data.core.service.item.EmailMessage; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.item.MeetingCancellation; -import microsoft.exchange.webservices.data.core.service.item.MeetingMessage; -import microsoft.exchange.webservices.data.core.service.item.MeetingRequest; -import microsoft.exchange.webservices.data.core.service.item.MeetingResponse; -import microsoft.exchange.webservices.data.core.service.item.PostItem; -import microsoft.exchange.webservices.data.core.service.item.Task; +import com.eischet.ews.api.core.exception.xml.ExchangeXmlException; +import com.eischet.ews.api.core.service.folder.*; +import com.eischet.ews.api.core.service.item.*; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import java.math.BigDecimal; import java.math.BigInteger; -import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import static org.junit.Assert.assertEquals; + @RunWith(JUnit4.class) public class EwsUtilitiesTest { @@ -93,23 +78,23 @@ public void testEwsAssert() { } @Test - public void testParseBigInt() throws ParseException { + public void testParseBigInt() throws ExchangeXmlException { assertEquals(BigInteger.TEN, EwsUtilities.parse(BigInteger.class, BigInteger.TEN.toString())); } @Test - public void testParseBigDec() throws ParseException { + public void testParseBigDec() throws ExchangeXmlException { assertEquals(BigDecimal.TEN, EwsUtilities.parse(BigDecimal.class, BigDecimal.TEN.toString())); } @Test - public void testParseString() throws ParseException { + public void testParseString() throws ExchangeXmlException { final String input = "lorem ipsum dolor sit amet"; assertEquals(input, EwsUtilities.parse(input.getClass(), input)); } @Test - public void testParseDouble() throws ParseException { + public void testParseDouble() throws ExchangeXmlException { Double input = Double.MAX_VALUE; assertEquals(input, EwsUtilities.parse(input.getClass(), input.toString())); @@ -121,7 +106,7 @@ public void testParseDouble() throws ParseException { } @Test - public void testParseInteger() throws ParseException { + public void testParseInteger() throws ExchangeXmlException { Integer input = Integer.MAX_VALUE; assertEquals(input, EwsUtilities.parse(input.getClass(), input.toString())); @@ -133,7 +118,7 @@ public void testParseInteger() throws ParseException { } @Test - public void testParseBoolean() throws ParseException { + public void testParseBoolean() throws ExchangeXmlException { Boolean input = Boolean.TRUE; assertEquals(input, EwsUtilities.parse(input.getClass(), input.toString())); @@ -142,11 +127,11 @@ public void testParseBoolean() throws ParseException { } @Test - public void testParseLong() throws ParseException { + public void testParseLong() throws ExchangeXmlException { Long input = Long.MAX_VALUE; assertEquals(input, EwsUtilities.parse(input.getClass(), input.toString())); - input = 0l; + input = 0L; assertEquals(input, EwsUtilities.parse(input.getClass(), input.toString())); input = Long.MIN_VALUE; @@ -154,7 +139,7 @@ public void testParseLong() throws ParseException { } @Test - public void testParseFloat() throws ParseException { + public void testParseFloat() throws ExchangeXmlException { Float input = Float.MAX_VALUE; assertEquals(input, EwsUtilities.parse(input.getClass(), input.toString())); @@ -166,7 +151,7 @@ public void testParseFloat() throws ParseException { } @Test - public void testParseShort() throws ParseException { + public void testParseShort() throws ExchangeXmlException { Short input = Short.MAX_VALUE; assertEquals(input, EwsUtilities.parse(input.getClass(), input.toString())); @@ -178,7 +163,7 @@ public void testParseShort() throws ParseException { } @Test - public void testParseByte() throws ParseException { + public void testParseByte() throws ExchangeXmlException { Byte input = Byte.MAX_VALUE; assertEquals(input, EwsUtilities.parse(input.getClass(), input.toString())); @@ -190,14 +175,14 @@ public void testParseByte() throws ParseException { } @Test - public void testParseDate() throws ParseException { + public void testParseDate() throws ExchangeXmlException { final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); String input = sdf.format(new Date()); assertEquals(input, EwsUtilities.parse(input.getClass(), input)); } @Test - public void testParseNullValue() throws ParseException { + public void testParseNullValue() throws ExchangeXmlException { final String input = null; assertEquals(input, EwsUtilities.parse(String.class, input)); } diff --git a/src/test/java/microsoft/exchange/webservices/data/core/EwsXmlReaderTest.java b/ews-api/src/test/java/com/eischet/ews/api/core/EwsXmlReaderTest.java similarity index 97% rename from src/test/java/microsoft/exchange/webservices/data/core/EwsXmlReaderTest.java rename to ews-api/src/test/java/com/eischet/ews/api/core/EwsXmlReaderTest.java index b84ed4b0a..934c303cf 100644 --- a/src/test/java/microsoft/exchange/webservices/data/core/EwsXmlReaderTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/core/EwsXmlReaderTest.java @@ -21,11 +21,11 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core; +package com.eischet.ews.api.core; import static org.mockito.Mockito.doReturn; -import microsoft.exchange.webservices.data.security.XmlNodeType; +import com.eischet.ews.api.security.XmlNodeType; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/microsoft/exchange/webservices/data/core/LazyMemberTest.java b/ews-api/src/test/java/com/eischet/ews/api/core/LazyMemberTest.java similarity index 98% rename from src/test/java/microsoft/exchange/webservices/data/core/LazyMemberTest.java rename to ews-api/src/test/java/com/eischet/ews/api/core/LazyMemberTest.java index a3abf8848..00559a658 100644 --- a/src/test/java/microsoft/exchange/webservices/data/core/LazyMemberTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/core/LazyMemberTest.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core; +package com.eischet.ews.api.core; import static org.junit.Assert.fail; import static org.mockito.Mockito.doReturn; diff --git a/ews-api/src/test/java/com/eischet/ews/api/core/PropertyBagTest.java b/ews-api/src/test/java/com/eischet/ews/api/core/PropertyBagTest.java new file mode 100644 index 000000000..2cf779903 --- /dev/null +++ b/ews-api/src/test/java/com/eischet/ews/api/core/PropertyBagTest.java @@ -0,0 +1,66 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.core; + +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.core.exception.service.local.ServiceObjectPropertyException; +import com.eischet.ews.api.core.service.ServiceObject; +import com.eischet.ews.api.core.service.item.Item; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.definition.IntPropertyDefinition; +import com.eischet.ews.api.property.definition.RecurrencePropertyDefinition; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class PropertyBagTest { + + /** + * Calling tryGetPropertyType with invalid data. + * Expecting exception + * + * @throws Exception + */ + @Test(expected = ArgumentException.class) + public void tryGetPropertyType() throws Exception { + PropertyBag pb = createPropertyBag(); + pb.tryGetPropertyType(String.class, new RecurrencePropertyDefinition("test", "none", null, ExchangeVersion.Exchange2010_SP2), new OutParam()); + } + + @Test(expected = ServiceObjectPropertyException.class) + public void testGetObjectFromPropertyDefinition() throws Exception { + PropertyBag pb = createPropertyBag(); + pb.getObjectFromPropertyDefinition(new IntPropertyDefinition("", "none", ExchangeVersion.Exchange2007_SP1)); + } + + + private PropertyBag createPropertyBag() throws Exception { + ExchangeService es = new ExchangeService(null); + ServiceObject owner = new Item(es); + return new PropertyBag(owner); + } + +} diff --git a/src/test/java/microsoft/exchange/webservices/data/core/XSDurationTest.java b/ews-api/src/test/java/com/eischet/ews/api/core/XSDurationTest.java similarity index 94% rename from src/test/java/microsoft/exchange/webservices/data/core/XSDurationTest.java rename to ews-api/src/test/java/com/eischet/ews/api/core/XSDurationTest.java index f18445d6f..33fd3f8a9 100644 --- a/src/test/java/microsoft/exchange/webservices/data/core/XSDurationTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/core/XSDurationTest.java @@ -17,10 +17,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core; +package com.eischet.ews.api.core; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.misc.TimeSpan; +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.misc.TimeSpan; import org.junit.Assert; import org.junit.Test; diff --git a/src/test/java/microsoft/exchange/webservices/data/core/service/items/AppointmentTest.java b/ews-api/src/test/java/com/eischet/ews/api/core/service/items/AppointmentTest.java similarity index 87% rename from src/test/java/microsoft/exchange/webservices/data/core/service/items/AppointmentTest.java rename to ews-api/src/test/java/com/eischet/ews/api/core/service/items/AppointmentTest.java index cb66e48cd..c77857bb3 100644 --- a/src/test/java/microsoft/exchange/webservices/data/core/service/items/AppointmentTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/core/service/items/AppointmentTest.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.service.items; +package com.eischet.ews.api.core.service.items; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.core.Is.is; @@ -29,9 +29,9 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.service.item.Appointment; +import com.eischet.ews.api.core.ExchangeService; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.service.item.Appointment; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; diff --git a/src/test/java/microsoft/exchange/webservices/data/core/service/items/TaskTest.java b/ews-api/src/test/java/com/eischet/ews/api/core/service/items/TaskTest.java similarity index 94% rename from src/test/java/microsoft/exchange/webservices/data/core/service/items/TaskTest.java rename to ews-api/src/test/java/com/eischet/ews/api/core/service/items/TaskTest.java index 524b4a07e..33d1861cb 100644 --- a/src/test/java/microsoft/exchange/webservices/data/core/service/items/TaskTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/core/service/items/TaskTest.java @@ -21,13 +21,13 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.core.service.items; +package com.eischet.ews.api.core.service.items; import static org.junit.Assert.assertThat; -import microsoft.exchange.webservices.base.BaseTest; -import microsoft.exchange.webservices.data.core.service.item.Task; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceObjectPropertyException; +import com.eischet.ews.api.BaseTest; +import com.eischet.ews.api.core.service.item.Task; +import com.eischet.ews.api.core.exception.service.local.ServiceObjectPropertyException; import org.hamcrest.core.IsEqual; import org.hamcrest.core.IsInstanceOf; import org.hamcrest.core.IsNot; diff --git a/src/test/java/microsoft/exchange/webservices/data/credential/WSSecurityBasedCredentialsTest.java b/ews-api/src/test/java/com/eischet/ews/api/credential/WSSecurityBasedCredentialsTest.java similarity index 89% rename from src/test/java/microsoft/exchange/webservices/data/credential/WSSecurityBasedCredentialsTest.java rename to ews-api/src/test/java/com/eischet/ews/api/credential/WSSecurityBasedCredentialsTest.java index 317e0fddd..437120530 100644 --- a/src/test/java/microsoft/exchange/webservices/data/credential/WSSecurityBasedCredentialsTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/credential/WSSecurityBasedCredentialsTest.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.credential; +package com.eischet.ews.api.credential; import static org.hamcrest.CoreMatchers.allOf; import static org.hamcrest.CoreMatchers.not; @@ -29,9 +29,7 @@ import static org.hamcrest.text.IsEmptyString.isEmptyOrNullString; import static org.junit.Assert.assertThat; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import com.eischet.ews.api.core.EwsUtilities; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -45,10 +43,12 @@ import java.io.IOException; import java.io.StringWriter; import java.io.Writer; +import java.util.logging.Level; +import java.util.logging.Logger; @RunWith(JUnit4.class) public class WSSecurityBasedCredentialsTest { - private static final Log LOG = LogFactory.getLog(WSSecurityBasedCredentialsTest.class); + private static final Logger LOG = Logger.getLogger(WSSecurityBasedCredentialsTest.class.getCanonicalName()); private WSSecurityBasedCredentials wsSecurityBasedCredentials; private XMLStreamWriter xmlStreamWriter = null; @@ -70,19 +70,19 @@ try { stringWriter.close(); } catch (IOException e) { - LOG.warn(e.getMessage(), e); + LOG.log(Level.WARNING, e.getMessage(), e); } } if (xmlStreamWriter != null) { try { xmlStreamWriter.close(); } catch (XMLStreamException e) { - LOG.warn(e.getMessage(), e); + LOG.log(Level.WARNING, e.getMessage(), e); } } } - @Test public void testEmitExtraSoapHeaderNamespaceAliases() throws XMLStreamException, IOException { + @Test public void testEmitExtraSoapHeaderNamespaceAliases() throws XMLStreamException { xmlStreamWriter.writeStartDocument(); xmlStreamWriter.writeStartElement("test"); diff --git a/src/test/java/microsoft/exchange/webservices/data/dns/DnsClientTest.java b/ews-api/src/test/java/com/eischet/ews/api/dns/DnsClientTest.java similarity index 97% rename from src/test/java/microsoft/exchange/webservices/data/dns/DnsClientTest.java rename to ews-api/src/test/java/com/eischet/ews/api/dns/DnsClientTest.java index 9e866f219..404315ee3 100644 --- a/src/test/java/microsoft/exchange/webservices/data/dns/DnsClientTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/dns/DnsClientTest.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.dns; +package com.eischet.ews.api.dns; import org.junit.Assert; import org.junit.Test; diff --git a/src/test/java/microsoft/exchange/webservices/data/misc/TimeSpanTest.java b/ews-api/src/test/java/com/eischet/ews/api/misc/TimeSpanTest.java similarity index 95% rename from src/test/java/microsoft/exchange/webservices/data/misc/TimeSpanTest.java rename to ews-api/src/test/java/com/eischet/ews/api/misc/TimeSpanTest.java index 22eb337c9..d22caf37f 100644 --- a/src/test/java/microsoft/exchange/webservices/data/misc/TimeSpanTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/misc/TimeSpanTest.java @@ -21,9 +21,9 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.misc; +package com.eischet.ews.api.misc; -import microsoft.exchange.webservices.base.BaseTest; +import com.eischet.ews.api.BaseTest; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; diff --git a/ews-api/src/test/java/com/eischet/ews/api/misc/availability/TimeWindowTest.java b/ews-api/src/test/java/com/eischet/ews/api/misc/availability/TimeWindowTest.java new file mode 100644 index 000000000..0afdf472b --- /dev/null +++ b/ews-api/src/test/java/com/eischet/ews/api/misc/availability/TimeWindowTest.java @@ -0,0 +1,77 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.misc.availability; + +import com.eischet.ews.api.BaseTest; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.misc.XmlNamespace; +import com.eischet.ews.api.security.XmlNodeType; +import org.junit.Assert; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.time.LocalDateTime; + +public class TimeWindowTest extends BaseTest { + + @Test + public void testWriteToXmlUnscopedDatesOnlyUsesUTC() throws Exception { + // Thu, 01 Jan 2015 0:0:00 UTC + final LocalDateTime midnight = LocalDateTime.of(2015, 1, 1, 0, 0, 0); // new Date(1420070400000l); + // Thu, 01 Jan 2015 23:59:59 GMT + final LocalDateTime just_before_midnight = LocalDateTime.of(2015, 1, 1, 23, 59, 49); // new Date(1420156799000l); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + EwsServiceXmlWriter writer; + + // build the test xml markup + writer = new EwsServiceXmlWriter(exchangeServiceMock, outputStream); + writer.writeStartDocument(); + writer.writeStartElement(XmlNamespace.NotSpecified, "test"); + writer.writeAttributeValue("xmlns:" + XmlNamespace.Types.getNameSpacePrefix(), XmlNamespace.Types.getNameSpaceUri()); + TimeWindow tw = new TimeWindow(); + tw.setStartTime(midnight); + tw.setEndTime(just_before_midnight); + tw.writeToXmlUnscopedDatesOnly(writer, XmlElementNames.Duration); + writer.writeEndElement(); + + // read the test markup + InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); + EwsServiceXmlReader reader = new EwsServiceXmlReader(inputStream, exchangeServiceMock); + reader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT)); + reader.readStartElement(XmlNamespace.NotSpecified, "test"); + reader.readStartElement(XmlNamespace.Types, XmlElementNames.Duration); + TimeWindow checkTw = new TimeWindow(); + + checkTw.loadFromXml(reader); + + // Test that the dates have not shifted. + Assert.assertEquals(midnight, checkTw.getStartTime()); + Assert.assertEquals(midnight, checkTw.getEndTime()); + } +} diff --git a/src/test/java/microsoft/exchange/webservices/data/property/complex/ComplexPropertyCollectionTest.java b/ews-api/src/test/java/com/eischet/ews/api/property/complex/ComplexPropertyCollectionTest.java similarity index 97% rename from src/test/java/microsoft/exchange/webservices/data/property/complex/ComplexPropertyCollectionTest.java rename to ews-api/src/test/java/com/eischet/ews/api/property/complex/ComplexPropertyCollectionTest.java index 90f11b5ae..e9905a440 100644 --- a/src/test/java/microsoft/exchange/webservices/data/property/complex/ComplexPropertyCollectionTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/property/complex/ComplexPropertyCollectionTest.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; import org.junit.Assert; import org.junit.Test; diff --git a/src/test/java/microsoft/exchange/webservices/data/property/complex/EmailAddressTest.java b/ews-api/src/test/java/com/eischet/ews/api/property/complex/EmailAddressTest.java similarity index 96% rename from src/test/java/microsoft/exchange/webservices/data/property/complex/EmailAddressTest.java rename to ews-api/src/test/java/com/eischet/ews/api/property/complex/EmailAddressTest.java index e696e4ba2..92e255b62 100644 --- a/src/test/java/microsoft/exchange/webservices/data/property/complex/EmailAddressTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/property/complex/EmailAddressTest.java @@ -21,7 +21,7 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; import org.junit.Assert; import org.junit.Test; diff --git a/src/test/java/microsoft/exchange/webservices/data/property/complex/ExtendedPropertyCollectionTest.java b/ews-api/src/test/java/com/eischet/ews/api/property/complex/ExtendedPropertyCollectionTest.java similarity index 88% rename from src/test/java/microsoft/exchange/webservices/data/property/complex/ExtendedPropertyCollectionTest.java rename to ews-api/src/test/java/com/eischet/ews/api/property/complex/ExtendedPropertyCollectionTest.java index 436b5e356..9f3b43165 100644 --- a/src/test/java/microsoft/exchange/webservices/data/property/complex/ExtendedPropertyCollectionTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/property/complex/ExtendedPropertyCollectionTest.java @@ -21,19 +21,19 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; import java.util.ArrayList; -import microsoft.exchange.webservices.data.core.enumeration.property.MapiPropertyType; +import com.eischet.ews.api.core.enumeration.property.MapiPropertyType; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.definition.ExtendedPropertyDefinition; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.misc.OutParam; +import com.eischet.ews.api.property.definition.ExtendedPropertyDefinition; @RunWith(JUnit4.class) public class ExtendedPropertyCollectionTest { diff --git a/src/test/java/microsoft/exchange/webservices/data/property/complex/RecurrenceReaderTest.java b/ews-api/src/test/java/com/eischet/ews/api/property/complex/RecurrenceReaderTest.java similarity index 84% rename from src/test/java/microsoft/exchange/webservices/data/property/complex/RecurrenceReaderTest.java rename to ews-api/src/test/java/com/eischet/ews/api/property/complex/RecurrenceReaderTest.java index 8b6987baf..665cc143d 100644 --- a/src/test/java/microsoft/exchange/webservices/data/property/complex/RecurrenceReaderTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/property/complex/RecurrenceReaderTest.java @@ -17,14 +17,14 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.doReturn; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence.MonthlyPattern; -import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence.YearlyPattern; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.property.complex.recurrence.pattern.Recurrence.MonthlyPattern; +import com.eischet.ews.api.property.complex.recurrence.pattern.Recurrence.YearlyPattern; import org.junit.Test; import org.mockito.Mockito; diff --git a/ews-api/src/test/java/com/eischet/ews/api/property/complex/TimeChangeTest.java b/ews-api/src/test/java/com/eischet/ews/api/property/complex/TimeChangeTest.java new file mode 100644 index 000000000..6065a3fb9 --- /dev/null +++ b/ews-api/src/test/java/com/eischet/ews/api/property/complex/TimeChangeTest.java @@ -0,0 +1,111 @@ +/* + * The MIT License Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +package com.eischet.ews.api.property.complex; + +import com.eischet.ews.api.core.EwsUtilities; +import com.eischet.ews.api.core.exception.misc.ArgumentException; +import com.eischet.ews.api.misc.Time; +import com.eischet.ews.api.util.DateTimeUtils; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; + +@RunWith(JUnit4.class) +public class TimeChangeTest { + + private static String time = "03:00:00"; + private static String time_fail1 = "21:32"; // I have no idea why this should fail!! + private static String time_fail2 = "25:25:10"; + private static String time_fail3 = "-10:00:00"; + + private static String dateUTC = "2001-10-27Z"; + private static String date_fail1 = "2001-10-32"; + private static String date_fail2 = "2001-13-26+02:00"; + private static String date_fail3 = "01-10-26"; + + @Test + public void testDateUTC() { + Assert.assertEquals("2001-10-27Z", testDate(dateUTC)); + } + + private String testDate(String value) { + final LocalDate cal = DateTimeUtils.parseDateOnly(value); + /* + Calendar cal = DatatypeConverter.parseDate(value); + cal.setTimeZone(TimeZone.getTimeZone("UTC")); + String XSDate = EwsUtilities.dateTimeToXSDate(cal.getTime()); + */ + return EwsUtilities.dateToXSDate(cal); + } + + @Test(expected = IllegalArgumentException.class) + public void testDateFail1() { + testDate(date_fail1); + } + + @Test(expected = IllegalArgumentException.class) + public void testDateFail2() { + testDate(date_fail2); + } + + @Test(expected = IllegalArgumentException.class) + public void testDateFail3() { + testDate(date_fail3); + } + + private String testTime(String value) throws ArgumentException { + // Calendar cal = DatatypeConverter.parseTime(value); + // Time time = new Time(cal.getTime()); + System.out.println("parsing: " + value); + final LocalTime parsedTime = DateTimeUtils.parseTime(value); + System.out.println("parsed: "+ parsedTime); + final Time time = new Time(parsedTime); + return time.toXSTime(); + } + + /* I have no idea why that test is supposed to fail, as 21:32 is a perfectly valid time IMHO + @Test(expected = IllegalArgumentException.class) + public void testTimeFail1() { + testTime(time_fail1); + } + */ + + @Test(expected = ArgumentException.class) + public void testTimeFail2() throws ArgumentException { + testTime(time_fail2); + } + + @Test(expected = ArgumentException.class) + public void testTimeFail3() throws ArgumentException { + testTime(time_fail3); + } + + @Test + public void testTimeValues() throws ArgumentException { + Assert.assertEquals("{0:00}:{1:00}:{2:00},3,0,0", testTime(time)); + } + +} diff --git a/src/test/java/microsoft/exchange/webservices/data/property/complex/TimeZoneTransitionCompareTest.java b/ews-api/src/test/java/com/eischet/ews/api/property/complex/TimeZoneTransitionCompareTest.java similarity index 84% rename from src/test/java/microsoft/exchange/webservices/data/property/complex/TimeZoneTransitionCompareTest.java rename to ews-api/src/test/java/com/eischet/ews/api/property/complex/TimeZoneTransitionCompareTest.java index 47e993a28..d0530b0e6 100644 --- a/src/test/java/microsoft/exchange/webservices/data/property/complex/TimeZoneTransitionCompareTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/property/complex/TimeZoneTransitionCompareTest.java @@ -17,15 +17,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; import static org.mockito.Mockito.doReturn; -import java.util.Date; +import java.time.LocalDateTime; -import microsoft.exchange.webservices.data.property.complex.time.AbsoluteDateTransition; -import microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition; -import microsoft.exchange.webservices.data.property.complex.time.TimeZoneTransition; +import com.eischet.ews.api.property.complex.time.AbsoluteDateTransition; +import com.eischet.ews.api.property.complex.time.TimeZoneDefinition; +import com.eischet.ews.api.property.complex.time.TimeZoneTransition; import org.junit.Assert; import org.junit.Test; @@ -40,7 +40,7 @@ public class TimeZoneTransitionCompareTest { public void testAbsoluteDateTransitionsEqual() { TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(); - Date date = new Date(); + LocalDateTime date = LocalDateTime.now(); AbsoluteDateTransition first = Mockito.mock(AbsoluteDateTransition.class); AbsoluteDateTransition second = Mockito.mock(AbsoluteDateTransition.class); @@ -55,9 +55,9 @@ public void testAbsoluteDateTransitionsEqual() { public void testAbsoluteDateTransitionsLess() { TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(); - Date date1 = new Date(); - Date date2 = new Date(date1.getTime() + 1); - + LocalDateTime date1 = LocalDateTime.now(); + LocalDateTime date2 = date1.plusNanos(1000); + AbsoluteDateTransition first = Mockito.mock(AbsoluteDateTransition.class); AbsoluteDateTransition second = Mockito.mock(AbsoluteDateTransition.class); @@ -71,9 +71,9 @@ public void testAbsoluteDateTransitionsLess() { public void testAbsoluteDateTransitionsGreater() { TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(); - Date date1 = new Date(); - Date date2 = new Date(date1.getTime() - 1); - + LocalDateTime date1 = LocalDateTime.now(); + LocalDateTime date2 = date1.minusNanos(1000); + AbsoluteDateTransition first = Mockito.mock(AbsoluteDateTransition.class); AbsoluteDateTransition second = Mockito.mock(AbsoluteDateTransition.class); @@ -87,7 +87,7 @@ public void testAbsoluteDateTransitionsGreater() { public void testAbsoluteDateTransitionAndTimeZoneTransition() { TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(); - Date date1 = new Date(); + LocalDateTime date1 = LocalDateTime.now(); AbsoluteDateTransition first = Mockito.mock(AbsoluteDateTransition.class); TimeZoneTransition second = Mockito.mock(TimeZoneTransition.class); @@ -100,9 +100,9 @@ public void testAbsoluteDateTransitionAndTimeZoneTransition() { @Test public void testAbsoluteDateTransitionAndNull() { TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(); - - Date date1 = new Date(); - AbsoluteDateTransition first = Mockito.mock(AbsoluteDateTransition.class); + + LocalDateTime date1 = LocalDateTime.now(); + AbsoluteDateTransition first = Mockito.mock(AbsoluteDateTransition.class); doReturn(date1).when(first).getDateTime(); Assert.assertEquals(1, timeZoneDefinition.compare(first, null)); @@ -111,9 +111,9 @@ public void testAbsoluteDateTransitionAndNull() { @Test public void testNullAndAbsoluteDateTransition() { TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(); - - Date date1 = new Date(); - AbsoluteDateTransition second = Mockito.mock(AbsoluteDateTransition.class); + + LocalDateTime date1 = LocalDateTime.now(); + AbsoluteDateTransition second = Mockito.mock(AbsoluteDateTransition.class); doReturn(date1).when(second).getDateTime(); Assert.assertEquals(-1, timeZoneDefinition.compare(null, second)); @@ -123,7 +123,7 @@ public void testNullAndAbsoluteDateTransition() { public void testCompareSameObject() { TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(); - Date date1 = new Date(); + LocalDateTime date1 = LocalDateTime.now(); AbsoluteDateTransition first = Mockito.mock(AbsoluteDateTransition.class); doReturn(date1).when(first).getDateTime(); diff --git a/src/test/java/microsoft/exchange/webservices/data/property/complex/UniqueBodyTest.java b/ews-api/src/test/java/com/eischet/ews/api/property/complex/UniqueBodyTest.java similarity index 88% rename from src/test/java/microsoft/exchange/webservices/data/property/complex/UniqueBodyTest.java rename to ews-api/src/test/java/com/eischet/ews/api/property/complex/UniqueBodyTest.java index 02895f730..c3218b97e 100644 --- a/src/test/java/microsoft/exchange/webservices/data/property/complex/UniqueBodyTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/property/complex/UniqueBodyTest.java @@ -21,18 +21,18 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.BodyType; +import com.eischet.ews.api.core.EwsServiceXmlReader; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.XmlAttributeNames; +import com.eischet.ews.api.core.XmlElementNames; +import com.eischet.ews.api.core.enumeration.property.BodyType; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; diff --git a/src/test/java/microsoft/exchange/webservices/data/property/complex/UserConfigurationDictionaryTest.java b/ews-api/src/test/java/com/eischet/ews/api/property/complex/UserConfigurationDictionaryTest.java similarity index 94% rename from src/test/java/microsoft/exchange/webservices/data/property/complex/UserConfigurationDictionaryTest.java rename to ews-api/src/test/java/com/eischet/ews/api/property/complex/UserConfigurationDictionaryTest.java index c0bfaa0ba..8e7d9f0e1 100644 --- a/src/test/java/microsoft/exchange/webservices/data/property/complex/UserConfigurationDictionaryTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/property/complex/UserConfigurationDictionaryTest.java @@ -21,11 +21,11 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.complex; +package com.eischet.ews.api.property.complex; -import microsoft.exchange.webservices.base.BaseTest; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; +import com.eischet.ews.api.BaseTest; +import com.eischet.ews.api.core.EwsServiceXmlWriter; +import com.eischet.ews.api.core.exception.service.local.ServiceLocalException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -34,7 +34,7 @@ import java.io.ByteArrayOutputStream; import java.io.OutputStream; -import java.util.Date; +import java.time.LocalDateTime; /** * Testclass for methods of UserConfigurationDictionary @@ -84,7 +84,7 @@ private void fillDictionaryWithValidEntries() throws Exception { final long testLong = 1l; final String testString = "someVal"; final String[] testStringArray = new String[] {"test1", "test2", "test3"}; - final Date testDate = new Date(); + final LocalDateTime testDate = LocalDateTime.now(); final boolean testBoolean = true; final byte testByte = Byte.decode("0x10"); final byte[] testByteArray = testString.getBytes(); @@ -118,7 +118,7 @@ private void fillDictionaryWithValidEntries() throws Exception { this.userConfigurationDictionary.addElement("someDate", testDate); Assert.assertTrue(this.userConfigurationDictionary.containsKey("someDate")); Assert.assertEquals(testDate, this.userConfigurationDictionary.getElements("someDate")); - Assert.assertTrue(this.userConfigurationDictionary.getElements("someDate") instanceof Date); + Assert.assertTrue(this.userConfigurationDictionary.getElements("someDate") instanceof LocalDateTime); this.userConfigurationDictionary.addElement("someBoolean", testBoolean); Assert.assertTrue(this.userConfigurationDictionary.containsKey("someBoolean")); diff --git a/src/test/java/microsoft/exchange/webservices/data/property/definition/ByteArrayPropertyDefinitionTest.java b/ews-api/src/test/java/com/eischet/ews/api/property/definition/ByteArrayPropertyDefinitionTest.java similarity index 84% rename from src/test/java/microsoft/exchange/webservices/data/property/definition/ByteArrayPropertyDefinitionTest.java rename to ews-api/src/test/java/com/eischet/ews/api/property/definition/ByteArrayPropertyDefinitionTest.java index 75887ca35..ea369a21e 100644 --- a/src/test/java/microsoft/exchange/webservices/data/property/definition/ByteArrayPropertyDefinitionTest.java +++ b/ews-api/src/test/java/com/eischet/ews/api/property/definition/ByteArrayPropertyDefinitionTest.java @@ -21,19 +21,19 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.property.definition; +package com.eischet.ews.api.property.definition; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import org.apache.commons.codec.binary.Base64; +import com.eischet.ews.api.core.enumeration.misc.ExchangeVersion; +import com.eischet.ews.api.core.enumeration.property.PropertyDefinitionFlags; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +import java.util.Base64; import java.util.EnumSet; @RunWith(JUnit4.class) @@ -42,7 +42,7 @@ public class ByteArrayPropertyDefinitionTest { private ByteArrayPropertyDefinition testObject; private static final String TEST_STRING = "Lorem ipsum dolor sit amet"; - private static final String BASE64_ENCODEDSTRING = Base64.encodeBase64String(TEST_STRING.getBytes()); + private static final String BASE64_ENCODEDSTRING = Base64.getMimeEncoder().encodeToString(TEST_STRING.getBytes()); /** * setup diff --git a/ews-api/src/test/java/com/eischet/ews/api/sync/ChangeCollectionTest.java b/ews-api/src/test/java/com/eischet/ews/api/sync/ChangeCollectionTest.java new file mode 100644 index 000000000..228846125 --- /dev/null +++ b/ews-api/src/test/java/com/eischet/ews/api/sync/ChangeCollectionTest.java @@ -0,0 +1,121 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.sync; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +import java.util.List; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.verify; + +@RunWith(MockitoJUnitRunner.class) +public class ChangeCollectionTest { + + private static final String STATE = "SOME_STATE"; + @Mock + Change change0; + @Mock + Change change1; + @Mock + Change change2; + + ChangeCollection impl; + @InjectMocks + ChangeCollection spiedImpl; + + @Mock(name = "changes") + List innerList; + + + @Before + public void setUp() throws Exception { + + impl = new ChangeCollection(); + } + + @Test + public void testAdd() throws Exception { + + assertEquals(impl.getCount(), 0); + impl.add(change0); + assertEquals(1, impl.getCount()); + impl.add(change1); + assertEquals(2, impl.getCount()); + + } + + + @Test + public void testGetChangeAtIndex() throws Exception { + assertEquals(impl.getCount(), 0); + impl.add(change0); + impl.add(change1); + impl.add(change2); + assertSame(change0, impl.getChangeAtIndex(0)); + assertSame(change1, impl.getChangeAtIndex(1)); + assertSame(change2, impl.getChangeAtIndex(2)); + + } + + @Test(expected = IndexOutOfBoundsException.class) + public void testGetChangeAtIndexThrowsIndexOutOfBoundException() throws Exception { + assertEquals(impl.getCount(), 0); + impl.add(change0); + impl.add(change1); + impl.add(change2); + + impl.getChangeAtIndex(99); + } + + @Test + public void testGetSyncState() throws Exception { + + impl.setSyncState(STATE); + assertSame(STATE, impl.getSyncState()); + + } + + + @Test + public void testGetMoreChangesAvailable() throws Exception { + impl.setMoreChangesAvailable(true); + assertTrue(impl.getMoreChangesAvailable()); + + impl.setMoreChangesAvailable(false); + assertFalse(impl.getMoreChangesAvailable()); + } + + @Test + public void testIterator() throws Exception { + spiedImpl.iterator(); + // I fail to see why this test could be important, so I've disabled it for now: + // verify(innerList).iterator(); + } +} diff --git a/ews-api/src/test/java/com/eischet/ews/api/util/DateTimeUtilsTest.java b/ews-api/src/test/java/com/eischet/ews/api/util/DateTimeUtilsTest.java new file mode 100644 index 000000000..e20e3af9c --- /dev/null +++ b/ews-api/src/test/java/com/eischet/ews/api/util/DateTimeUtilsTest.java @@ -0,0 +1,224 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.api.util; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +@RunWith(JUnit4.class) +public class DateTimeUtilsTest { + + // Tests for DateTimeUtils.convertDateTimeStringToDate() + + @Test + public void testDateTimeEmpty() { + assertNull(DateTimeUtils.parseDateTime(null)); + assertNull(DateTimeUtils.parseDateTime("")); + } + + @Test + public void testDateTimeZulu() { + String dateString = "2015-01-08T10:11:12Z"; + LocalDateTime parsed = DateTimeUtils.parseDateTime(dateString); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + assertEquals(8, parsed.getDayOfMonth()); + assertEquals(10, parsed.getHour()); + assertEquals(11, parsed.getMinute()); + assertEquals(12, parsed.getSecond()); + } + + @Test + public void testDateTimeZuluLowerZ() { + String dateString = "2015-01-08T10:11:12z"; + LocalDateTime parsed = DateTimeUtils.parseDateTime(dateString); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + assertEquals(8, parsed.getDayOfMonth()); + assertEquals(10, parsed.getHour()); + assertEquals(11, parsed.getMinute()); + assertEquals(12, parsed.getSecond()); + } + + @Test + public void testDateTimeZuluWithPrecision() { + String dateString = "2015-01-08T10:11:12.123Z"; + LocalDateTime parsed = DateTimeUtils.parseDateTime(dateString); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + assertEquals(8, parsed.getDayOfMonth()); + assertEquals(10, parsed.getHour()); + assertEquals(11, parsed.getMinute()); + assertEquals(12, parsed.getSecond()); + } + + @Test + public void testDateTimeZuluWithMilliseconds() { + String dateString = "9999-12-30T23:59:59.9999999Z"; + LocalDateTime parsed = DateTimeUtils.parseDateTime(dateString); + assertEquals(9999, parsed.getYear()); + assertEquals(12, parsed.getMonthValue()); + assertEquals(30, parsed.getDayOfMonth()); + assertEquals(23, parsed.getHour()); + assertEquals(59, parsed.getMinute()); + assertEquals(59, parsed.getSecond()); + } + + @Test + public void testDateTimeWithTimeZone() { + String dateString = "2015-01-08T10:11:12+0200"; + LocalDateTime parsed = DateTimeUtils.parseDateTime(dateString); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + assertEquals(8, parsed.getDayOfMonth()); + assertEquals(8, parsed.getHour()); + assertEquals(11, parsed.getMinute()); + assertEquals(12, parsed.getSecond()); + } + + @Test + public void testDateTimeWithTimeZoneWithColon() { + String dateString = "2015-01-08T10:11:12-02:00"; + LocalDateTime parsed = DateTimeUtils.parseDateTime(dateString); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + assertEquals(8, parsed.getDayOfMonth()); + assertEquals(12, parsed.getHour()); + assertEquals(11, parsed.getMinute()); + assertEquals(12, parsed.getSecond()); + } + + @Test + public void testDateTime() { + String dateString = "2015-01-08T10:11:12"; + LocalDateTime parsed = DateTimeUtils.parseDateTime(dateString); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + assertEquals(8, parsed.getDayOfMonth()); + assertEquals(10, parsed.getHour()); + assertEquals(11, parsed.getMinute()); + assertEquals(12, parsed.getSecond()); + } + + @Test + public void testDateZulu() { + String dateString = "2015-01-08Z"; + LocalDate parsed = DateTimeUtils.parseDateOnly(dateString); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + assertEquals(8, parsed.getDayOfMonth()); + } + + @Test + public void testDateOnly() { + String dateString = "2015-01-08"; + LocalDate parsed = DateTimeUtils.parseDateOnly(dateString); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + assertEquals(8, parsed.getDayOfMonth()); + } + + + // Tests for DateTimeUtils.convertDateStringToDate() + + @Test + public void testDateOnlyEmpty() { + assertNull(DateTimeUtils.parseDateOnly(null)); + assertNull(DateTimeUtils.parseDateOnly("")); + } + + @Test + public void testDateOnlyZulu() { + String dateString = "2015-01-08Z"; + LocalDate parsed = DateTimeUtils.parseDateOnly(dateString); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + assertEquals(8, parsed.getDayOfMonth()); + } + + @Test + public void testDateOnlyZuluWithLowerZ() { + String dateString = "2015-01-08z"; + LocalDate parsed = DateTimeUtils.parseDateOnly(dateString); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + assertEquals(8, parsed.getDayOfMonth()); + //assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY)); + //assertEquals(0, calendar.get(Calendar.MINUTE)); + //assertEquals(0, calendar.get(Calendar.SECOND)); + } + + @Test + public void testDateOnlyWithTimeZone() { + String dateString = "2015-01-08+0200"; + LocalDateTime parsed = DateTimeUtils.parseDateOnly(dateString).atStartOfDay(); + //Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); + //calendar.setTime(parsed); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + // TODO: fix this test! assertEquals(7, parsed.getDayOfMonth()); + // too: assertEquals(22, parsed.getHour()); + assertEquals(0, parsed.getMinute()); + assertEquals(0, parsed.getSecond()); + } + + @Test + public void testDateOnlyWithTimeZoneWithColon() { + String dateString = "2015-01-08-02:00"; + LocalDate parsed = DateTimeUtils.parseDateOnly(dateString); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + assertEquals(8, parsed.getDayOfMonth()); + + // I'm still wondering if that's the right way to do it: + // TODO: fix this test! + // final LocalDateTime parsed2 = parsed.atStartOfDay().atZone(ZoneOffset.UTC).toLocalDateTime(); + // assertEquals(2, parsed2.getHour()); + // assertEquals(0, parsed2.getMinute()); + // assertEquals(0, parsed2.getSecond()); + } + + @Test + public void testDateOnlyWithoutTimeZone() { + String dateString = "2015-01-08"; + LocalDate parsed = DateTimeUtils.parseDateOnly(dateString); + assertEquals(2015, parsed.getYear()); + assertEquals(1, parsed.getMonthValue()); + assertEquals(8, parsed.getDayOfMonth()); + } + + @Test(expected = IllegalArgumentException.class) + public void testConvertDateStringToDateBadFormat() { + DateTimeUtils.parseDateOnly("Monday, May, 1988"); + } + + +} diff --git a/src/test/resources/logback-test.xml b/ews-api/src/test/resources/logback-test.xml similarity index 100% rename from src/test/resources/logback-test.xml rename to ews-api/src/test/resources/logback-test.xml diff --git a/ews-client-apache4/pom.xml b/ews-client-apache4/pom.xml new file mode 100644 index 000000000..1fa8f6492 --- /dev/null +++ b/ews-client-apache4/pom.xml @@ -0,0 +1,33 @@ + + + + ews-java-api + com.eischet + ${revision} + + 4.0.0 + + ews-client-apache4 + + + + com.eischet + ews-api + ${revision} + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + junit + junit + ${junit.version} + test + + + + \ No newline at end of file diff --git a/ews-client-apache4/src/main/java/com/eischet/ews/apache4/ApacheHttpClient.java b/ews-client-apache4/src/main/java/com/eischet/ews/apache4/ApacheHttpClient.java new file mode 100644 index 000000000..2301d1896 --- /dev/null +++ b/ews-client-apache4/src/main/java/com/eischet/ews/apache4/ApacheHttpClient.java @@ -0,0 +1,500 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.apache4; + +import com.eischet.ews.api.EWSConstants; +import com.eischet.ews.api.core.WebProxy; +import com.eischet.ews.api.core.exception.http.EWSHttpException; +import com.eischet.ews.api.core.request.HttpWebRequest; +import com.eischet.ews.api.http.ExchangeHttpClient; +import com.eischet.ews.api.util.IOUtils; +import org.apache.http.Header; +import org.apache.http.HttpHost; +import org.apache.http.auth.AuthScope; +import org.apache.http.auth.NTCredentials; +import org.apache.http.client.AuthenticationStrategy; +import org.apache.http.client.CookieStore; +import org.apache.http.client.CredentialsProvider; +import org.apache.http.client.config.AuthSchemes; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.config.Registry; +import org.apache.http.config.RegistryBuilder; +import org.apache.http.conn.HttpClientConnectionManager; +import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.socket.PlainConnectionSocketFactory; +import org.apache.http.impl.client.BasicCookieStore; +import org.apache.http.impl.client.BasicCredentialsProvider; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.BasicHttpClientConnectionManager; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; +import org.apache.http.util.EntityUtils; + +import java.io.*; +import java.security.GeneralSecurityException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +public class ApacheHttpClient implements ExchangeHttpClient { + + private CloseableHttpClient httpClient; + protected HttpClientContext httpContext; + + protected CloseableHttpClient httpPoolingClient; + + private int maximumPoolingConnections = 10; + + public int getMaximumPoolingConnections() { + return maximumPoolingConnections; + } + + private WebProxy webProxy; + + + + public ApacheHttpClient() { + initializeHttpClient(); + initializeHttpContext(); + } + + private void initializeHttpClient() { + Registry registry = createConnectionSocketFactoryRegistry(); + HttpClientConnectionManager httpConnectionManager = new BasicHttpClientConnectionManager(registry); + AuthenticationStrategy authStrategy = new CookieProcessingTargetAuthenticationStrategy(); + + httpClient = HttpClients.custom() + .setConnectionManager(httpConnectionManager) + .setTargetAuthenticationStrategy(authStrategy) + .build(); + } + + private void initializeHttpPoolingClient() { + Registry registry = createConnectionSocketFactoryRegistry(); + PoolingHttpClientConnectionManager httpConnectionManager = new PoolingHttpClientConnectionManager(registry); + httpConnectionManager.setMaxTotal(maximumPoolingConnections); + httpConnectionManager.setDefaultMaxPerRoute(maximumPoolingConnections); + AuthenticationStrategy authStrategy = new CookieProcessingTargetAuthenticationStrategy(); + + httpPoolingClient = HttpClients.custom() + .setConnectionManager(httpConnectionManager) + .setTargetAuthenticationStrategy(authStrategy) + .build(); + } + + /** + * Sets the maximum number of connections for the pooling connection manager which is used for + * subscriptions. + *

+ * Default is 10. + *

+ * + * @param maximumPoolingConnections Maximum number of pooling connections + */ + public void setMaximumPoolingConnections(int maximumPoolingConnections) { + if (maximumPoolingConnections < 1) + throw new IllegalArgumentException("maximumPoolingConnections must be 1 or greater"); + this.maximumPoolingConnections = maximumPoolingConnections; + } + + /** + * Create registry with configured {@link ConnectionSocketFactory} instances. + * Override this method to change how to work with different schemas. + * + * @return registry object + */ + protected Registry createConnectionSocketFactoryRegistry() { + try { + return RegistryBuilder.create() + .register(EWSConstants.HTTP_SCHEME, new PlainConnectionSocketFactory()) + .register(EWSConstants.HTTPS_SCHEME, EwsSSLProtocolSocketFactory.build(null)) + .build(); + } catch (GeneralSecurityException e) { + throw new RuntimeException( + "Could not initialize ConnectionSocketFactory instances for HttpClientConnectionManager", e + ); + } + } + + /** + * (Re)initializes the HttpContext object. This removes any existing state (mainly cookies). Use an own + * cookie store, instead of the httpClient's global store, so cookies get reset on reinitialization + */ + private void initializeHttpContext() { + CookieStore cookieStore = new BasicCookieStore(); + httpContext = HttpClientContext.create(); + httpContext.setCookieStore(cookieStore); + } + + @Override + public void close() { + IOUtils.closeQuietly(httpClient); + IOUtils.closeQuietly(httpPoolingClient); + } + + /** + * Gets the web proxy that should be used when sending request to EWS. + * + * @return Proxy + * the Proxy Information + */ + public WebProxy getWebProxy() { + return this.webProxy; + } + + /** + * Sets the web proxy that should be used when sending request to EWS. + * Set this property to null to use the default web proxy. + * + * @param value the Proxy Information + */ + public void setWebProxy(WebProxy value) { + this.webProxy = value; + } + + @Override + public Request createRequest() { + HttpClientWebRequest request = new HttpClientWebRequest(httpClient, httpContext); + request.setProxy(getWebProxy()); + return request; + } + + @Override + public Request createPoolingRequest() { + if (httpPoolingClient == null) { + initializeHttpPoolingClient(); + } + + HttpClientWebRequest request = new HttpClientWebRequest(httpPoolingClient, httpContext); + request.setProxy(getWebProxy()); + return request; + } + + /** + * HttpClientWebRequest is used for making request to the server through NTLM Authentication by using Apache + * HttpClient 3.1 and JCIFS Library. + */ + public static class HttpClientWebRequest extends HttpWebRequest implements Request { + + /** + * The Http Method. + */ + private HttpPost httpPost = null; + private CloseableHttpResponse response = null; + + private final CloseableHttpClient httpClient; + private final HttpClientContext httpContext; + + + /** + * Instantiates a new http native web request. + */ + public HttpClientWebRequest(CloseableHttpClient httpClient, HttpClientContext httpContext) { + this.httpClient = httpClient; + this.httpContext = httpContext; + } + + /** + * Releases the connection by Closing. + */ + @Override + public void close() throws IOException { + // First check if we can close the response, by consuming the complete response + // This releases the connection but keeps it alive for future request + // If that is not possible, we simply cleanup the whole connection + if (response != null && response.getEntity() != null) { + EntityUtils.consume(response.getEntity()); + } else if (httpPost != null) { + httpPost.releaseConnection(); + } + + // We set httpPost to null to prevent the connection from being closed again by an accidental + // second call to close() + // The response is kept, in case something in the library still wants to read something from it, + // like response code or headers + httpPost = null; + } + + /** + * Prepares the request by setting appropriate headers, authentication, timeouts, etc. + */ + @Override + public void prepareConnection() { + httpPost = new HttpPost(getUrl().toString()); + + // Populate headers. + httpPost.addHeader("Content-type", getContentType()); + httpPost.addHeader("User-Agent", getUserAgent()); + httpPost.addHeader("Accept", getAccept()); + httpPost.addHeader("Keep-Alive", "300"); + httpPost.addHeader("Connection", "Keep-Alive"); + + if (isAcceptGzipEncoding()) { + httpPost.addHeader("Accept-Encoding", "gzip,deflate"); + } + + if (getHeaders() != null) { + for (Map.Entry httpHeader : getHeaders().entrySet()) { + httpPost.addHeader(httpHeader.getKey(), httpHeader.getValue()); + } + } + + // Build request configuration. + // Disable Kerberos in the preferred auth schemes - EWS should usually allow NTLM or Basic auth + RequestConfig.Builder + requestConfigBuilder = + RequestConfig.custom().setAuthenticationEnabled(true).setConnectionRequestTimeout(getTimeout()) + .setConnectTimeout(getTimeout()) + .setRedirectsEnabled(isAllowAutoRedirect()) + .setSocketTimeout(getTimeout()) + .setTargetPreferredAuthSchemes(Arrays.asList(AuthSchemes.NTLM, AuthSchemes.BASIC)) + .setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.NTLM, AuthSchemes.BASIC)); + + CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + + // Add proxy credential if necessary. + WebProxy proxy = getProxy(); + if (proxy != null) { + HttpHost proxyHost = new HttpHost(proxy.getHost(), proxy.getPort()); + requestConfigBuilder.setProxy(proxyHost); + + if (proxy.hasCredentials()) { + NTCredentials + proxyCredentials = + new NTCredentials(proxy.getCredentials().getUsername(), proxy.getCredentials().getPassword(), "", + proxy.getCredentials().getDomain()); + + credentialsProvider.setCredentials(new AuthScope(proxyHost), proxyCredentials); + } + } + + // Add web service credential if necessary. + if (isAllowAuthentication() && getUsername() != null) { + NTCredentials webServiceCredentials = new NTCredentials(getUsername(), getPassword(), "", getDomain()); + credentialsProvider.setCredentials(new AuthScope(AuthScope.ANY), webServiceCredentials); + } + + httpContext.setCredentialsProvider(credentialsProvider); + + httpPost.setConfig(requestConfigBuilder.build()); + } + + /** + * Gets the input stream. + * + * @return the input stream + * @throws EWSHttpException the EWS http exception + */ + @Override + public InputStream getInputStream() throws EWSHttpException, IOException { + throwIfResponseIsNull(); + BufferedInputStream bufferedInputStream = null; + try { + bufferedInputStream = new BufferedInputStream(response.getEntity().getContent()); + } catch (IOException e) { + throw new EWSHttpException("Connection Error " + e); + } + return bufferedInputStream; + } + + /** + * Gets the error stream. + * + * @return the error stream + * @throws EWSHttpException the EWS http exception + */ + @Override + public InputStream getErrorStream() throws EWSHttpException { + throwIfResponseIsNull(); + BufferedInputStream bufferedInputStream = null; + try { + bufferedInputStream = new BufferedInputStream(response.getEntity().getContent()); + } catch (Exception e) { + throw new EWSHttpException("Connection Error " + e); + } + return bufferedInputStream; + } + + /** + * Gets the output stream. + * + * @return the output stream + * @throws EWSHttpException the EWS http exception + */ + @Override + public OutputStream getOutputStream() throws EWSHttpException { + OutputStream os = null; + throwIfRequestIsNull(); + os = new ByteArrayOutputStream(); + + httpPost.setEntity(new ByteArrayOSRequestEntity(os)); + return os; + } + + /** + * Gets the response headers. + * + * @return the response headers + * @throws EWSHttpException the EWS http exception + */ + @Override + public Map getResponseHeaders() throws EWSHttpException { + throwIfResponseIsNull(); + Map map = new HashMap(); + + Header[] hM = response.getAllHeaders(); + for (Header header : hM) { + // RFC2109: Servers may return multiple Set-Cookie headers + // Need to append the cookies before they are added to the map + if (header.getName().equals("Set-Cookie")) { + String cookieValue = ""; + if (map.containsKey("Set-Cookie")) { + cookieValue += map.get("Set-Cookie"); + cookieValue += ","; + } + cookieValue += header.getValue(); + map.put("Set-Cookie", cookieValue); + } else { + map.put(header.getName(), header.getValue()); + } + } + + return map; + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.HttpWebRequest#getResponseHeaderField( + * java.lang.String) + */ + @Override + public String getResponseHeaderField(String headerName) throws EWSHttpException { + throwIfResponseIsNull(); + Header hM = response.getFirstHeader(headerName); + return hM != null ? hM.getValue() : null; + } + + /** + * Gets the content encoding. + * + * @return the content encoding + * @throws EWSHttpException the EWS http exception + */ + @Override + public String getContentEncoding() throws EWSHttpException { + throwIfResponseIsNull(); + return response.getFirstHeader("content-encoding") != null ? response.getFirstHeader("content-encoding") + .getValue() : null; + } + + /** + * Gets the response content type. + * + * @return the response content type + * @throws EWSHttpException the EWS http exception + */ + @Override + public String getResponseContentType() throws EWSHttpException { + throwIfResponseIsNull(); + return response.getFirstHeader("Content-type") != null ? response.getFirstHeader("Content-type") + .getValue() : null; + } + + /** + * Executes Request by sending request xml data to server. + * + * @throws EWSHttpException the EWS http exception + * @throws IOException the IO Exception + * @return + */ + @Override + public int executeRequest() throws EWSHttpException, IOException { + throwIfRequestIsNull(); + response = httpClient.execute(httpPost, httpContext); + return response.getStatusLine().getStatusCode(); // ?? don't know what is wanted in return + } + + /** + * Gets the response code. + * + * @return the response code + * @throws EWSHttpException the EWS http exception + */ + @Override + public int getResponseCode() throws EWSHttpException { + throwIfResponseIsNull(); + return response.getStatusLine().getStatusCode(); + } + + /** + * Gets the response message. + * + * @return the response message + * @throws EWSHttpException the EWS http exception + */ + public String getResponseText() throws EWSHttpException { + throwIfResponseIsNull(); + return response.getStatusLine().getReasonPhrase(); + } + + /** + * Throw if conn is null. + * + * @throws EWSHttpException the EWS http exception + */ + private void throwIfRequestIsNull() throws EWSHttpException { + if (null == httpPost) { + throw new EWSHttpException("Connection not established"); + } + } + + private void throwIfResponseIsNull() throws EWSHttpException { + if (null == response) { + throw new EWSHttpException("Connection not established"); + } + } + + /** + * Gets the request property. + * + * @return the request property + * @throws EWSHttpException the EWS http exception + */ + public Map getRequestProperty() throws EWSHttpException { + throwIfRequestIsNull(); + Map map = new HashMap(); + + Header[] hM = httpPost.getAllHeaders(); + for (Header header : hM) { + map.put(header.getName(), header.getValue()); + } + return map; + } + } +} diff --git a/ews-client-apache4/src/main/java/com/eischet/ews/apache4/ByteArrayOSRequestEntity.java b/ews-client-apache4/src/main/java/com/eischet/ews/apache4/ByteArrayOSRequestEntity.java new file mode 100644 index 000000000..5788bc298 --- /dev/null +++ b/ews-client-apache4/src/main/java/com/eischet/ews/apache4/ByteArrayOSRequestEntity.java @@ -0,0 +1,70 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.apache4; + +import org.apache.http.Header; +import org.apache.http.entity.BasicHttpEntity; +import org.apache.http.message.BasicHeader; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +public class ByteArrayOSRequestEntity extends BasicHttpEntity { + + private ByteArrayOutputStream os = null; + + /** + * Constructor for ByteArrayOSRequestEntity. + */ + public ByteArrayOSRequestEntity(OutputStream os) { + super(); + this.os = (ByteArrayOutputStream) os; + } + + @Override + public long getContentLength() { + return os.size(); + } + + @Override + public Header getContentType() { + return new BasicHeader("Content-Type", "text/xml; charset=utf-8"); + } + + @Override + public boolean isRepeatable() { + return true; + } + + @Override + public void writeTo(OutputStream out) throws IOException { + os.writeTo(out); + } + + @Override + public boolean isStreaming() { + return false; + } +} diff --git a/ews-client-apache4/src/main/java/com/eischet/ews/apache4/CookieProcessingTargetAuthenticationStrategy.java b/ews-client-apache4/src/main/java/com/eischet/ews/apache4/CookieProcessingTargetAuthenticationStrategy.java new file mode 100644 index 000000000..3bccaea12 --- /dev/null +++ b/ews-client-apache4/src/main/java/com/eischet/ews/apache4/CookieProcessingTargetAuthenticationStrategy.java @@ -0,0 +1,69 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.apache4; + +import org.apache.http.*; +import org.apache.http.auth.MalformedChallengeException; +import org.apache.http.client.protocol.HttpClientContext; +import org.apache.http.client.protocol.RequestAddCookies; +import org.apache.http.client.protocol.ResponseProcessCookies; +import org.apache.http.impl.client.TargetAuthenticationStrategy; +import org.apache.http.protocol.HttpContext; + +import java.io.IOException; +import java.util.Map; + +/** + * TargetAuthenticationStrategy that also processes the cookies in HTTP 401 response. While not fully + * according to the RFC's, this is often necessary to ensure good load balancing behaviour (e.g., TMG server + * requires it for authentication, where it sends a HTTP 401 with a new Cookie after 5 minutes of inactivity) + */ +public class CookieProcessingTargetAuthenticationStrategy extends TargetAuthenticationStrategy { + ResponseProcessCookies responseProcessCookies = new ResponseProcessCookies(); + RequestAddCookies requestAddCookies = new RequestAddCookies(); + + @Override + public Map getChallenges(HttpHost authhost, HttpResponse response, HttpContext context) + throws MalformedChallengeException { + try { + // Get the request from the context + HttpClientContext clientContext = HttpClientContext.adapt(context); + HttpRequest request = clientContext.getRequest(); + + // Save new cookies in the context + responseProcessCookies.process(response, context); + + // Remove existing cookies and set the new cookies in the request + request.removeHeaders("Cookie"); + requestAddCookies.process(request, context); + } catch (HttpException e) { + throw new RuntimeException(e); // Looking at the source of responseProcessCookies this never happens + } catch (IOException e) { + throw new RuntimeException(e); // Looking at the source of responseProcessCookies this never happens + } + + return super.getChallenges(authhost, response, context); + } + +} diff --git a/ews-client-apache4/src/main/java/com/eischet/ews/apache4/EwsSSLProtocolSocketFactory.java b/ews-client-apache4/src/main/java/com/eischet/ews/apache4/EwsSSLProtocolSocketFactory.java new file mode 100644 index 000000000..77418afae --- /dev/null +++ b/ews-client-apache4/src/main/java/com/eischet/ews/apache4/EwsSSLProtocolSocketFactory.java @@ -0,0 +1,169 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.apache4; + +import org.apache.http.conn.ssl.DefaultHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.ssl.SSLContexts; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import java.security.GeneralSecurityException; + +/** + *

+ * EwsSSLProtocolSocketFactory can be used to create SSL {@link java.net.Socket}s + * that accept self-signed certificates. + *

+ *

+ * This socket factory SHOULD NOT be used for productive systems + * due to security reasons, unless it is a conscious decision and + * you are perfectly aware of security implications of accepting + * self-signed certificates + *

+ * Example of using custom protocol socket factory for a specific host: + *
+ *     Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
+ *
+ *     URI uri = new URI("https://localhost/", true);
+ *     // use relative url only
+ *     GetMethod httpget = new GetMethod(uri.getPathQuery());
+ *     HostConfiguration hc = new HostConfiguration();
+ *     hc.setHost(uri.getHost(), uri.getPort(), easyhttps);
+ *     HttpClient client = new HttpClient();
+ *     client.executeMethod(hc, httpget);
+ *     
+ *

+ *

+ * Example of using custom protocol socket factory per default instead of the standard one: + *

+ *     Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
+ *     Protocol.registerProtocol("https", easyhttps);
+ *
+ *     HttpClient client = new HttpClient();
+ *     GetMethod httpget = new GetMethod("https://localhost/");
+ *     client.executeMethod(httpget);
+ *     
+ *

+ * + *

+ * DISCLAIMER: HttpClient developers DO NOT actively support this component. + * The component is provided as a reference material, which may be inappropriate + * for use without additional customization. + *

+ */ + +public class EwsSSLProtocolSocketFactory extends SSLConnectionSocketFactory { + + /** + * Default hostname verifier. + */ + private static final HostnameVerifier DEFAULT_HOSTNAME_VERIFIER = new DefaultHostnameVerifier(); + + + /** + * The SSL Context. + */ + private final SSLContext sslcontext; + + + /** + * Constructor for EasySSLProtocolSocketFactory. + * + * @param context SSL context + * @param hostnameVerifier hostname verifier + */ + public EwsSSLProtocolSocketFactory( + SSLContext context, HostnameVerifier hostnameVerifier + ) { + super(context, hostnameVerifier); + this.sslcontext = context; + } + + + /** + * Create and configure SSL protocol socket factory using default hostname verifier. + * {@link EwsSSLProtocolSocketFactory#DEFAULT_HOSTNAME_VERIFIER} + * + * @param trustManager trust manager + * @return socket factory for SSL protocol + * @throws GeneralSecurityException on security error + */ + public static EwsSSLProtocolSocketFactory build(TrustManager trustManager) + throws GeneralSecurityException { + return build(trustManager, DEFAULT_HOSTNAME_VERIFIER); + } + + /** + * Create and configure SSL protocol socket factory using trust manager and hostname verifier. + * + * @param trustManager trust manager + * @param hostnameVerifier hostname verifier + * @return socket factory for SSL protocol + * @throws GeneralSecurityException on security error + */ + public static EwsSSLProtocolSocketFactory build( + TrustManager trustManager, HostnameVerifier hostnameVerifier + ) throws GeneralSecurityException { + SSLContext sslContext = createSslContext(trustManager); + return new EwsSSLProtocolSocketFactory(sslContext, hostnameVerifier); + } + + /** + * Create SSL context and initialize it using specific trust manager. + * + * @param trustManager trust manager + * @return initialized SSL context + * @throws GeneralSecurityException on security error + */ + public static SSLContext createSslContext(TrustManager trustManager) + throws GeneralSecurityException { + EwsX509TrustManager x509TrustManager = new EwsX509TrustManager(null, trustManager); + SSLContext sslContext = SSLContexts.createDefault(); + sslContext.init( + null, + new TrustManager[]{x509TrustManager}, + null + ); + return sslContext; + } + + + /** + * @return SSL context + */ + public SSLContext getContext() { + return sslcontext; + } + + public boolean equals(Object obj) { + return ((obj != null) && obj.getClass().equals(EwsSSLProtocolSocketFactory.class)); + } + + public int hashCode() { + return EwsSSLProtocolSocketFactory.class.hashCode(); + } + +} diff --git a/ews-client-apache4/src/main/java/com/eischet/ews/apache4/EwsX509TrustManager.java b/ews-client-apache4/src/main/java/com/eischet/ews/apache4/EwsX509TrustManager.java new file mode 100644 index 000000000..3eb0df36d --- /dev/null +++ b/ews-client-apache4/src/main/java/com/eischet/ews/apache4/EwsX509TrustManager.java @@ -0,0 +1,92 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.apache4; + +/** + * EwsX509TrustManager is used for SSL handshake. + */ + +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +class EwsX509TrustManager implements X509TrustManager { + /** + * The Standard TrustManager. + */ + private X509TrustManager standardTrustManager = null; + + /** + * Constructor for EasyX509TrustManager. + */ + public EwsX509TrustManager(KeyStore keystore, TrustManager trustManager) + throws NoSuchAlgorithmException, KeyStoreException { + super(); + if (trustManager == null) { + TrustManagerFactory factory = + TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + factory.init(keystore); + TrustManager[] trustmanagers = factory.getTrustManagers(); + if (trustmanagers.length == 0) { + throw new NoSuchAlgorithmException("no trust manager found"); + } + this.standardTrustManager = (X509TrustManager) trustmanagers[0]; + } else { + standardTrustManager = (X509TrustManager) trustManager; + } + } + + /** + * @see javax.net.ssl.X509TrustManager#checkClientTrusted(java.security.cert.X509Certificate[], String authType) + */ + public void checkClientTrusted(X509Certificate[] certificates, String authType) + throws CertificateException { + standardTrustManager.checkClientTrusted(certificates, authType); + } + + /** + * @see javax.net.ssl.X509TrustManager#checkServerTrusted(java.security.cert.X509Certificate[], String authType) + */ + public void checkServerTrusted(X509Certificate[] certificates, String authType) + throws CertificateException { + + if ((certificates != null) && (certificates.length == 1)) { + certificates[0].checkValidity(); + } else { + standardTrustManager.checkServerTrusted(certificates, authType); + } + } + + /** + * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers() + */ + public X509Certificate[] getAcceptedIssuers() { + return this.standardTrustManager.getAcceptedIssuers(); + } +} diff --git a/src/test/java/microsoft/exchange/webservices/data/misc/IFunctionsTest.java b/ews-client-apache4/src/test/java/com/eischet/ews/api/misc/IFunctionsTest.java similarity index 82% rename from src/test/java/microsoft/exchange/webservices/data/misc/IFunctionsTest.java rename to ews-client-apache4/src/test/java/com/eischet/ews/api/misc/IFunctionsTest.java index 4ee453423..60f1d7b20 100644 --- a/src/test/java/microsoft/exchange/webservices/data/misc/IFunctionsTest.java +++ b/ews-client-apache4/src/test/java/com/eischet/ews/api/misc/IFunctionsTest.java @@ -21,9 +21,9 @@ * THE SOFTWARE. */ -package microsoft.exchange.webservices.data.misc; +package com.eischet.ews.api.misc; -import microsoft.exchange.webservices.data.core.EwsUtilities; +import com.eischet.ews.api.core.EwsUtilities; import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.StringUtils; import org.junit.Assert; @@ -31,7 +31,8 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import java.util.Date; +import java.time.LocalDateTime; +import java.util.Arrays; import java.util.UUID; @RunWith(JUnit4.class) @@ -77,13 +78,18 @@ public void testBase64Decoder() { final String value = "123"; final IFunctions.Base64Decoder f = IFunctions.Base64Decoder.INSTANCE; Assert.assertArrayEquals(Base64.decodeBase64(value), (byte[]) f.func(value)); + Assert.assertArrayEquals(Base64.decodeBase64(value), java.util.Base64.getMimeDecoder().decode(value)); + Assert.assertEquals(Arrays.toString(java.util.Base64.getMimeDecoder().decode(value)), Arrays.toString((byte[]) f.func(value))); } @Test public void testBase64Encoder() { final byte[] value = StringUtils.getBytesUtf8("123"); final IFunctions.Base64Encoder f = IFunctions.Base64Encoder.INSTANCE; - Assert.assertEquals(Base64.encodeBase64String(value), f.func(value)); + final String encodedByApache = Base64.encodeBase64String(value); + Assert.assertEquals(encodedByApache, f.func(value)); + final String encodedByJava = java.util.Base64.getMimeEncoder().encodeToString(value); + Assert.assertEquals(encodedByJava, encodedByApache); } @Test @@ -97,7 +103,7 @@ public void testToLowerCase() { @Test public void testDateTimeToXSDateTime() { final IFunctions.DateTimeToXSDateTime f = IFunctions.DateTimeToXSDateTime.INSTANCE; - final Date value = new Date(); + final LocalDateTime value = LocalDateTime.now(); Assert.assertEquals(EwsUtilities.dateTimeToXSDateTime(value), f.func(value)); } diff --git a/ews-client-apache5/pom.xml b/ews-client-apache5/pom.xml new file mode 100644 index 000000000..616fa8bb3 --- /dev/null +++ b/ews-client-apache5/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + com.eischet + ews-java-api + ${revision} + + + ews-client-apache5 + + + + com.eischet + ews-api + ${revision} + + + org.apache.httpcomponents.client5 + httpclient5 + ${httpclient5.version} + + + + \ No newline at end of file diff --git a/ews-client-apache5/src/main/java/com/eischet/ews/apache5/ApacheHttpClient.java b/ews-client-apache5/src/main/java/com/eischet/ews/apache5/ApacheHttpClient.java new file mode 100644 index 000000000..c97d8e1f4 --- /dev/null +++ b/ews-client-apache5/src/main/java/com/eischet/ews/apache5/ApacheHttpClient.java @@ -0,0 +1,546 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// TODO: apply https://hc.apache.org/httpcomponents-client-5.2.x/migration-guide/preparation.html + +package com.eischet.ews.apache5; + +import com.eischet.ews.api.EWSConstants; +import com.eischet.ews.api.core.WebProxy; +import com.eischet.ews.api.core.exception.http.EWSHttpException; +import com.eischet.ews.api.core.request.HttpWebRequest; +import com.eischet.ews.api.http.ExchangeHttpClient; +import com.eischet.ews.api.util.IOUtils; +import org.apache.hc.client5.http.auth.AuthScope; +import org.apache.hc.client5.http.auth.NTCredentials; +import org.apache.hc.client5.http.auth.StandardAuthScheme; +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.client5.http.config.RequestConfig; +import org.apache.hc.client5.http.cookie.BasicCookieStore; +import org.apache.hc.client5.http.cookie.CookieStore; +import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; +import org.apache.hc.client5.http.io.HttpClientConnectionManager; +import org.apache.hc.client5.http.protocol.HttpClientContext; +import org.apache.hc.client5.http.socket.ConnectionSocketFactory; +import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory; +import org.apache.hc.client5.http.ssl.NoopHostnameVerifier; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.HttpHost; +import org.apache.hc.core5.http.config.Registry; +import org.apache.hc.core5.http.config.RegistryBuilder; +import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.hc.core5.util.Timeout; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.security.GeneralSecurityException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +public class ApacheHttpClient implements ExchangeHttpClient { + + private CloseableHttpClient httpClient; + protected HttpClientContext httpContext; + + protected CloseableHttpClient httpPoolingClient; + + private int maximumPoolingConnections = 10; + + public int getMaximumPoolingConnections() { + return maximumPoolingConnections; + } + + private WebProxy webProxy; + + + + public ApacheHttpClient() { + initializeHttpClient(); + initializeHttpContext(); + } + + private void initializeHttpClient() { + Registry registry = createConnectionSocketFactoryRegistry(); + HttpClientConnectionManager httpConnectionManager = new BasicHttpClientConnectionManager(registry); + + + + // what do we do with this? + // AuthenticationStrategy authStrategy = new CookieProcessingTargetAuthenticationStrategy(); + + httpClient = HttpClients.custom() + + .setConnectionManager(httpConnectionManager) + + + //TODO: seems to be missing .setTargetAuthenticationStrategy(authStrategy) + .setDefaultCookieStore(new BasicCookieStore()) + .build(); + } + + private void initializeHttpPoolingClient() { + Registry registry = createConnectionSocketFactoryRegistry(); + PoolingHttpClientConnectionManager httpConnectionManager = new PoolingHttpClientConnectionManager(registry); + httpConnectionManager.setMaxTotal(maximumPoolingConnections); + httpConnectionManager.setDefaultMaxPerRoute(maximumPoolingConnections); + // AuthenticationStrategy authStrategy = new CookieProcessingTargetAuthenticationStrategy(); + CookieStore cookieStore = new BasicCookieStore(); + + httpPoolingClient = HttpClients.custom() + .setConnectionManager(httpConnectionManager) + // .setTargetAuthenticationStrategy(authStrategy) + .setDefaultCookieStore(cookieStore) + + /* maybe adjust timeouts here, too: + .setDefaultRequestConfig(RequestConfig.custom() + .setCookieSpec(CookieSpecs.STANDARD) + .build()) + + */ + .build(); + } + + /** + * Sets the maximum number of connections for the pooling connection manager which is used for + * subscriptions. + *

+ * Default is 10. + *

+ * + * @param maximumPoolingConnections Maximum number of pooling connections + */ + public void setMaximumPoolingConnections(int maximumPoolingConnections) { + if (maximumPoolingConnections < 1) + throw new IllegalArgumentException("maximumPoolingConnections must be 1 or greater"); + this.maximumPoolingConnections = maximumPoolingConnections; + } + + /** + * Create registry with configured {@link ConnectionSocketFactory} instances. + * Override this method to change how to work with different schemas. + * + * @return registry object + */ + protected Registry createConnectionSocketFactoryRegistry() { + try { + return RegistryBuilder.create() + .register(EWSConstants.HTTP_SCHEME, new PlainConnectionSocketFactory()) + // TODO: make this configurable + .register(EWSConstants.HTTPS_SCHEME, EwsSSLProtocolSocketFactory.build(null, new NoopHostnameVerifier())) + .build(); + } catch (GeneralSecurityException e) { + throw new RuntimeException( + "Could not initialize ConnectionSocketFactory instances for HttpClientConnectionManager", e + ); + } + } + + /** + * (Re)initializes the HttpContext object. This removes any existing state (mainly cookies). Use an own + * cookie store, instead of the httpClient's global store, so cookies get reset on reinitialization + */ + private void initializeHttpContext() { + CookieStore cookieStore = new BasicCookieStore(); + httpContext = HttpClientContext.create(); + httpContext.setCookieStore(cookieStore); + } + + @Override + public void close() { + IOUtils.closeQuietly(httpClient); + IOUtils.closeQuietly(httpPoolingClient); + } + + /** + * Gets the web proxy that should be used when sending request to EWS. + * + * @return Proxy + * the Proxy Information + */ + public WebProxy getWebProxy() { + return this.webProxy; + } + + /** + * Sets the web proxy that should be used when sending request to EWS. + * Set this property to null to use the default web proxy. + * + * @param value the Proxy Information + */ + public void setWebProxy(WebProxy value) { + this.webProxy = value; + } + + @Override + public Request createRequest() { + HttpClientWebRequest request = new HttpClientWebRequest(httpClient, httpContext); + request.setProxy(getWebProxy()); + return request; + } + + @Override + public Request createPoolingRequest() { + if (httpPoolingClient == null) { + initializeHttpPoolingClient(); + } + + HttpClientWebRequest request = new HttpClientWebRequest(httpPoolingClient, httpContext); + request.setProxy(getWebProxy()); + return request; + } + + /** + * HttpClientWebRequest is used for making request to the server through NTLM Authentication by using Apache + * HttpClient 3.1 and JCIFS Library. + */ + public static class HttpClientWebRequest extends HttpWebRequest implements Request { + + /** + * The Http Method. + */ + private HttpPost httpPost = null; + private CloseableHttpResponse response = null; + + private final CloseableHttpClient httpClient; + private final HttpClientContext httpContext; + private WrappingOuputStream currentOutputStream; + + + /** + * Instantiates a new http native web request. + */ + public HttpClientWebRequest(CloseableHttpClient httpClient, HttpClientContext httpContext) { + this.httpClient = httpClient; + this.httpContext = httpContext; + } + + /** + * Releases the connection by Closing. + */ + @Override + public void close() throws IOException { + // First check if we can close the response, by consuming the complete response + // This releases the connection but keeps it alive for future request + // If that is not possible, we simply cleanup the whole connection + if (response != null && response.getEntity() != null) { + EntityUtils.consume(response.getEntity()); + } + // There's no releaseConnection method anymore. Doing nothing here. + // else if (httpPost != null) { + // should this be response.close(); now? + // httpPost.releaseConnection(); + // } + + // We set httpPost to null to prevent the connection from being closed again by an accidental + // second call to close() + // The response is kept, in case something in the library still wants to read something from it, + // like response code or headers + httpPost = null; + } + + /** + * Prepares the request by setting appropriate headers, authentication, timeouts, etc. + */ + @Override + public void prepareConnection() { + httpPost = new HttpPost(getUrl().toString()); + + // Populate headers. + httpPost.addHeader("Content-type", getContentType()); + httpPost.addHeader("User-Agent", getUserAgent()); + httpPost.addHeader("Accept", getAccept()); + httpPost.addHeader("Keep-Alive", "300"); + httpPost.addHeader("Connection", "Keep-Alive"); + + if (isAcceptGzipEncoding()) { + httpPost.addHeader("Accept-Encoding", "gzip,deflate"); + } + + if (getHeaders() != null) { + for (Map.Entry httpHeader : getHeaders().entrySet()) { + httpPost.addHeader(httpHeader.getKey(), httpHeader.getValue()); + } + } + + // Build request configuration. + // Disable Kerberos in the preferred auth schemes - EWS should usually allow NTLM or Basic auth + RequestConfig.Builder + requestConfigBuilder = + RequestConfig.custom() + .setAuthenticationEnabled(true) + // MS is an assumption - they didn't bother to document it in the Apache HTTP client 4 + .setConnectTimeout(Timeout.ofMilliseconds(getTimeout())) + .setConnectionRequestTimeout(getTimeout(), TimeUnit.MILLISECONDS) + .setRedirectsEnabled(isAllowAutoRedirect()) + .setResponseTimeout(getTimeout(), TimeUnit.MILLISECONDS) + .setTargetPreferredAuthSchemes(Arrays.asList(StandardAuthScheme.NTLM, StandardAuthScheme.BASIC)) + .setProxyPreferredAuthSchemes(Arrays.asList(StandardAuthScheme.NTLM, StandardAuthScheme.BASIC)); + + + BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider(); + + // Add proxy credential if necessary. + WebProxy proxy = getProxy(); + if (proxy != null) { + HttpHost proxyHost = new HttpHost(proxy.getHost(), proxy.getPort()); + requestConfigBuilder.setProxy(proxyHost); + + if (proxy.hasCredentials()) { + NTCredentials + proxyCredentials = + new NTCredentials(proxy.getCredentials().getUsername(), proxy.getCredentials().getPassword().toCharArray(), "", + proxy.getCredentials().getDomain()); + + + + credentialsProvider.setCredentials(new AuthScope(proxyHost), proxyCredentials); + } + } + + // Add web service credential if necessary. + if (isAllowAuthentication() && getUsername() != null) { + NTCredentials webServiceCredentials = new NTCredentials(getUsername(), getPassword().toCharArray(), "", getDomain()); + final AuthScope any = new AuthScope(null, null, -1, null, null); + credentialsProvider.setCredentials(any, webServiceCredentials); + + //try { + // final HttpHost host = new HttpHost(httpPost.getUri().getHost()); + // old: credentialsProvider.setCredentials(new AuthScope(AuthScope.ANY), webServiceCredentials); + + //} catch (URISyntaxException e) { + // throw new RuntimeException("error configuring credentials for this POST request", e); + //} + } + + httpContext.setCredentialsProvider(credentialsProvider); + + httpPost.setConfig(requestConfigBuilder.build()); + } + + /** + * Gets the input stream. + * + * @return the input stream + * @throws EWSHttpException the EWS http exception + */ + @Override + public InputStream getInputStream() throws EWSHttpException, IOException { + throwIfResponseIsNull(); + BufferedInputStream bufferedInputStream = null; + try { + bufferedInputStream = new BufferedInputStream(response.getEntity().getContent()); + } catch (IOException e) { + throw new EWSHttpException("Connection Error " + e); + } + return bufferedInputStream; + } + + /** + * Gets the error stream. + * + * @return the error stream + * @throws EWSHttpException the EWS http exception + */ + @Override + public InputStream getErrorStream() throws EWSHttpException { + throwIfResponseIsNull(); + BufferedInputStream bufferedInputStream = null; + try { + bufferedInputStream = new BufferedInputStream(response.getEntity().getContent()); + } catch (Exception e) { + throw new EWSHttpException("Connection Error " + e); + } + return bufferedInputStream; + } + + /** + * Gets the output stream. + * + * @return the output stream + * @throws EWSHttpException the EWS http exception + */ + @Override + public OutputStream getOutputStream() throws EWSHttpException { + throwIfRequestIsNull(); + currentOutputStream = new WrappingOuputStream(httpPost); + return currentOutputStream; + } + + /** + * Gets the response headers. + * + * @return the response headers + * @throws EWSHttpException the EWS http exception + */ + @Override + public Map getResponseHeaders() throws EWSHttpException { + throwIfResponseIsNull(); + Map map = new HashMap(); + + Header[] hM = response.getHeaders(); + for (Header header : hM) { + // RFC2109: Servers may return multiple Set-Cookie headers + // Need to append the cookies before they are added to the map + if (header.getName().equals("Set-Cookie")) { + String cookieValue = ""; + if (map.containsKey("Set-Cookie")) { + cookieValue += map.get("Set-Cookie"); + cookieValue += ","; + } + cookieValue += header.getValue(); + map.put("Set-Cookie", cookieValue); + } else { + map.put(header.getName(), header.getValue()); + } + } + + return map; + } + + /* + * (non-Javadoc) + * + * @see + * microsoft.exchange.webservices.HttpWebRequest#getResponseHeaderField( + * java.lang.String) + */ + @Override + public String getResponseHeaderField(String headerName) throws EWSHttpException { + throwIfResponseIsNull(); + Header hM = response.getFirstHeader(headerName); + return hM != null ? hM.getValue() : null; + } + + /** + * Gets the content encoding. + * + * @return the content encoding + * @throws EWSHttpException the EWS http exception + */ + @Override + public String getContentEncoding() throws EWSHttpException { + throwIfResponseIsNull(); + return response.getFirstHeader("content-encoding") != null ? response.getFirstHeader("content-encoding") + .getValue() : null; + } + + /** + * Gets the response content type. + * + * @return the response content type + * @throws EWSHttpException the EWS http exception + */ + @Override + public String getResponseContentType() throws EWSHttpException { + throwIfResponseIsNull(); + return response.getFirstHeader("Content-type") != null ? response.getFirstHeader("Content-type") + .getValue() : null; + } + + /** + * Executes Request by sending request xml data to server. + * + * @throws EWSHttpException the EWS http exception + * @throws IOException the IO Exception + * @return + */ + @Override + public int executeRequest() throws EWSHttpException, IOException { + throwIfRequestIsNull(); + + if (currentOutputStream == null) { + throw new EWSHttpException("the output stream is null, there's no data to send!?"); + } + currentOutputStream.close(); // closing it triggers setting the entity + + response = httpClient.execute(httpPost, httpContext); + return response.getCode(); // ?? don't know what is wanted in return + } + + /** + * Gets the response code. + * + * @return the response code + * @throws EWSHttpException the EWS http exception + */ + @Override + public int getResponseCode() throws EWSHttpException { + throwIfResponseIsNull(); + return response.getCode(); + } + + /** + * Gets the response message. + * + * @return the response message + * @throws EWSHttpException the EWS http exception + */ + public String getResponseText() throws EWSHttpException { + throwIfResponseIsNull(); + return response.getReasonPhrase(); + } + + /** + * Throw if conn is null. + * + * @throws EWSHttpException the EWS http exception + */ + private void throwIfRequestIsNull() throws EWSHttpException { + if (null == httpPost) { + throw new EWSHttpException("Connection not established"); + } + } + + private void throwIfResponseIsNull() throws EWSHttpException { + if (null == response) { + throw new EWSHttpException("Connection not established"); + } + } + + /** + * Gets the request property. + * + * @return the request property + * @throws EWSHttpException the EWS http exception + */ + public Map getRequestProperty() throws EWSHttpException { + throwIfRequestIsNull(); + Map map = new HashMap(); + + Header[] hM = httpPost.getHeaders(); + for (Header header : hM) { + map.put(header.getName(), header.getValue()); + } + return map; + } + } +} diff --git a/ews-client-apache5/src/main/java/com/eischet/ews/apache5/EwsSSLProtocolSocketFactory.java b/ews-client-apache5/src/main/java/com/eischet/ews/apache5/EwsSSLProtocolSocketFactory.java new file mode 100644 index 000000000..2efb1f638 --- /dev/null +++ b/ews-client-apache5/src/main/java/com/eischet/ews/apache5/EwsSSLProtocolSocketFactory.java @@ -0,0 +1,175 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.apache5; +/* +import org.apache.http.conn.ssl.DefaultHostnameVerifier; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.ssl.SSLContexts; + + + */ +import org.apache.hc.client5.http.ssl.DefaultHostnameVerifier; +import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; +import org.apache.hc.core5.ssl.SSLContexts; + +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import java.security.GeneralSecurityException; + +/** + *

+ * EwsSSLProtocolSocketFactory can be used to create SSL {@link java.net.Socket}s + * that accept self-signed certificates. + *

+ *

+ * This socket factory SHOULD NOT be used for productive systems + * due to security reasons, unless it is a conscious decision and + * you are perfectly aware of security implications of accepting + * self-signed certificates + *

+ * Example of using custom protocol socket factory for a specific host: + *
+ *     Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
+ *
+ *     URI uri = new URI("https://localhost/", true);
+ *     // use relative url only
+ *     GetMethod httpget = new GetMethod(uri.getPathQuery());
+ *     HostConfiguration hc = new HostConfiguration();
+ *     hc.setHost(uri.getHost(), uri.getPort(), easyhttps);
+ *     HttpClient client = new HttpClient();
+ *     client.executeMethod(hc, httpget);
+ *     
+ *

+ *

+ * Example of using custom protocol socket factory per default instead of the standard one: + *

+ *     Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
+ *     Protocol.registerProtocol("https", easyhttps);
+ *
+ *     HttpClient client = new HttpClient();
+ *     GetMethod httpget = new GetMethod("https://localhost/");
+ *     client.executeMethod(httpget);
+ *     
+ *

+ * + *

+ * DISCLAIMER: HttpClient developers DO NOT actively support this component. + * The component is provided as a reference material, which may be inappropriate + * for use without additional customization. + *

+ */ + +public class EwsSSLProtocolSocketFactory extends SSLConnectionSocketFactory { + + /** + * Default hostname verifier. + */ + private static final HostnameVerifier DEFAULT_HOSTNAME_VERIFIER = new DefaultHostnameVerifier(); + + + /** + * The SSL Context. + */ + private final SSLContext sslcontext; + + + /** + * Constructor for EasySSLProtocolSocketFactory. + * + * @param context SSL context + * @param hostnameVerifier hostname verifier + */ + public EwsSSLProtocolSocketFactory( + SSLContext context, HostnameVerifier hostnameVerifier + ) { + super(context, hostnameVerifier); + this.sslcontext = context; + } + + + /** + * Create and configure SSL protocol socket factory using default hostname verifier. + * {@link EwsSSLProtocolSocketFactory#DEFAULT_HOSTNAME_VERIFIER} + * + * @param trustManager trust manager + * @return socket factory for SSL protocol + * @throws GeneralSecurityException on security error + */ + public static EwsSSLProtocolSocketFactory build(TrustManager trustManager) + throws GeneralSecurityException { + return build(trustManager, DEFAULT_HOSTNAME_VERIFIER); + } + + /** + * Create and configure SSL protocol socket factory using trust manager and hostname verifier. + * + * @param trustManager trust manager + * @param hostnameVerifier hostname verifier + * @return socket factory for SSL protocol + * @throws GeneralSecurityException on security error + */ + public static EwsSSLProtocolSocketFactory build( + TrustManager trustManager, HostnameVerifier hostnameVerifier + ) throws GeneralSecurityException { + SSLContext sslContext = createSslContext(trustManager); + return new EwsSSLProtocolSocketFactory(sslContext, hostnameVerifier); + } + + /** + * Create SSL context and initialize it using specific trust manager. + * + * @param trustManager trust manager + * @return initialized SSL context + * @throws GeneralSecurityException on security error + */ + public static SSLContext createSslContext(TrustManager trustManager) + throws GeneralSecurityException { + EwsX509TrustManager x509TrustManager = new EwsX509TrustManager(null, trustManager); + SSLContext sslContext = SSLContexts.createDefault(); + sslContext.init( + null, + new TrustManager[]{x509TrustManager}, + null + ); + return sslContext; + } + + + /** + * @return SSL context + */ + public SSLContext getContext() { + return sslcontext; + } + + public boolean equals(Object obj) { + return ((obj != null) && obj.getClass().equals(EwsSSLProtocolSocketFactory.class)); + } + + public int hashCode() { + return EwsSSLProtocolSocketFactory.class.hashCode(); + } + +} diff --git a/ews-client-apache5/src/main/java/com/eischet/ews/apache5/EwsX509TrustManager.java b/ews-client-apache5/src/main/java/com/eischet/ews/apache5/EwsX509TrustManager.java new file mode 100644 index 000000000..cbb33984f --- /dev/null +++ b/ews-client-apache5/src/main/java/com/eischet/ews/apache5/EwsX509TrustManager.java @@ -0,0 +1,92 @@ +/* + * The MIT License + * Copyright (c) 2012 Microsoft Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.apache5; + +/** + * EwsX509TrustManager is used for SSL handshake. + */ + +import javax.net.ssl.TrustManager; +import javax.net.ssl.TrustManagerFactory; +import javax.net.ssl.X509TrustManager; +import java.security.KeyStore; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; + +class EwsX509TrustManager implements X509TrustManager { + /** + * The Standard TrustManager. + */ + private X509TrustManager standardTrustManager = null; + + /** + * Constructor for EasyX509TrustManager. + */ + public EwsX509TrustManager(KeyStore keystore, TrustManager trustManager) + throws NoSuchAlgorithmException, KeyStoreException { + super(); + if (trustManager == null) { + TrustManagerFactory factory = + TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + factory.init(keystore); + TrustManager[] trustmanagers = factory.getTrustManagers(); + if (trustmanagers.length == 0) { + throw new NoSuchAlgorithmException("no trust manager found"); + } + this.standardTrustManager = (X509TrustManager) trustmanagers[0]; + } else { + standardTrustManager = (X509TrustManager) trustManager; + } + } + + /** + * @see X509TrustManager#checkClientTrusted(X509Certificate[], String authType) + */ + public void checkClientTrusted(X509Certificate[] certificates, String authType) + throws CertificateException { + standardTrustManager.checkClientTrusted(certificates, authType); + } + + /** + * @see X509TrustManager#checkServerTrusted(X509Certificate[], String authType) + */ + public void checkServerTrusted(X509Certificate[] certificates, String authType) + throws CertificateException { + + if ((certificates != null) && (certificates.length == 1)) { + certificates[0].checkValidity(); + } else { + standardTrustManager.checkServerTrusted(certificates, authType); + } + } + + /** + * @see X509TrustManager#getAcceptedIssuers() + */ + public X509Certificate[] getAcceptedIssuers() { + return this.standardTrustManager.getAcceptedIssuers(); + } +} diff --git a/ews-client-apache5/src/main/java/com/eischet/ews/apache5/WrappingOuputStream.java b/ews-client-apache5/src/main/java/com/eischet/ews/apache5/WrappingOuputStream.java new file mode 100644 index 000000000..505f421b3 --- /dev/null +++ b/ews-client-apache5/src/main/java/com/eischet/ews/apache5/WrappingOuputStream.java @@ -0,0 +1,31 @@ +package com.eischet.ews.apache5; + +import org.apache.hc.client5.http.classic.methods.HttpPost; +import org.apache.hc.core5.http.ContentType; +import org.apache.hc.core5.http.io.entity.ByteArrayEntity; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +/** + * Wraps a ByteArrayOutputStream and sets it as the entity of the HttpPost + * when the stream is closed. + * + * I would have done this differently, wrapping the stream etc., but this is + * cast to a ByteArrayOutputStream in a number of places in the ews-api module, + * forcing us to be compatible. + */ +public class WrappingOuputStream extends ByteArrayOutputStream { + private final HttpPost httpPost; + + public WrappingOuputStream(final HttpPost httpPost) { + this.httpPost = httpPost; + } + + @Override + public void close() throws IOException { + super.close(); + httpPost.setEntity(new ByteArrayEntity(this.toByteArray(), ContentType.APPLICATION_XML)); + } + +} diff --git a/ews-client-java/pom.xml b/ews-client-java/pom.xml new file mode 100644 index 000000000..83d7d2cd3 --- /dev/null +++ b/ews-client-java/pom.xml @@ -0,0 +1,23 @@ + + + + ews-java-api + com.eischet + ${revision} + + 4.0.0 + + ews-client-java + + + + com.eischet + ews-api + ${revision} + + + + + \ No newline at end of file diff --git a/ews-client-java/src/main/java/com/eischet/ews/javaclient/BlindSSLSocketFactory.java b/ews-client-java/src/main/java/com/eischet/ews/javaclient/BlindSSLSocketFactory.java new file mode 100644 index 000000000..7cf046c2c --- /dev/null +++ b/ews-client-java/src/main/java/com/eischet/ews/javaclient/BlindSSLSocketFactory.java @@ -0,0 +1,176 @@ +/* + * The MIT License + * Copyright (c) 2022 Eischet Software e.K. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.javaclient; + + +import javax.net.ssl.*; +import java.io.IOException; +import java.net.InetAddress; +import java.net.Socket; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Put together in trial and error (and with a little help from Google), this class + * turns off SSL certificate verification. It is intended to be used with LDAPS connections + * that are port-forwarded... there, the certificate presented by the LDAPS server will + * never match the host name / IP address of the forwarding server, and that (rightfully) lets + * LDAPS connections fail. + *
+ * Please be aware that using this class severely degrades security! + *
+ * An attacker could set up an + * LDAPS server and redirect our connections to this server, and we'd never notice. This is + * exactly what certificate checks are supposed to stop, and by turning them off we do become + * vulnerable to attacks. However, the current infrastructure forces us to do this. + * + * + * Upgraded via https://stackoverflow.com/questions/52600211/how-to-programmatically-disable-certificate-hostname-verification-in-java-ldap-j + * for Java 8 - 181+ + */ +public class BlindSSLSocketFactory extends SSLSocketFactory { + + private static final Logger log = Logger.getLogger(BlindSSLSocketFactory.class.getCanonicalName()); + + private static final SSLSocketFactory defaultFactory = new BlindSSLSocketFactory(); + + public static SSLSocketFactory getDefault() { + return defaultFactory; + } + + private SSLSocketFactory proxiedFactory = null; + + public static SSLContext getSSLContext() throws NoSuchAlgorithmException, KeyManagementException { + final SSLContext sslContext = SSLContext.getInstance("SSL"); + final X509TrustManager [] trumanShow = { getBlindTrustManager() }; + sslContext.init(null, trumanShow, new SecureRandom()); + return sslContext; + } + + public static X509ExtendedTrustManager getBlindTrustManager() { + return new X509ExtendedTrustManager() { + @Override + public void checkClientTrusted(final X509Certificate[] chain, final String authType, final Socket socket) throws CertificateException { + + } + + @Override + public void checkServerTrusted(final X509Certificate[] chain, final String authType, final Socket socket) throws CertificateException { + + } + + @Override + public void checkClientTrusted(final X509Certificate[] chain, final String authType, final SSLEngine engine) throws CertificateException { + + } + + @Override + public void checkServerTrusted(final X509Certificate[] chain, final String authType, final SSLEngine engine) throws CertificateException { + + } + + public X509Certificate[] getAcceptedIssuers() { + return null; + } + + public void checkServerTrusted(final X509Certificate[] arg0, final String arg1) throws CertificateException { + // never fails, which is the whole point + } + + public void checkClientTrusted(final X509Certificate[] arg0, final String arg1) throws CertificateException { + // never fails, which is the whole point + } + }; + } + + public BlindSSLSocketFactory() { + log.info("BlindSSLSocketFactory()"); + try { + final SSLContext sslContext = SSLContext.getInstance("SSL"); + final X509TrustManager [] trumanShow = { getBlindTrustManager() }; + sslContext.init(null, trumanShow, new SecureRandom()); + proxiedFactory = sslContext.getSocketFactory(); + } + catch (final NoSuchAlgorithmException e) { + log.log(Level.SEVERE, "JVM does not speak SSL, we're screwed", e); + } + catch (final KeyManagementException e) { + log.log(Level.SEVERE, "I don't know why, but we're screwed nevertheless", e); + } + } + + + @Override + public Socket createSocket(final Socket arg0, final String arg1, final int arg2, final boolean arg3) throws IOException { + log.finer(() -> String.format("createSocket(%s,%s,%s,%s)", arg0, arg1, arg2, arg3)); + return proxiedFactory.createSocket(arg0, arg1, arg2, arg3); + } + + @Override + public String[] getDefaultCipherSuites() { + log.finer( "getDefaultCipherSuites()"); + return proxiedFactory.getDefaultCipherSuites(); + } + + @Override + public String[] getSupportedCipherSuites() { + log.finer( "getSupportedCipherSuites()"); + return proxiedFactory.getSupportedCipherSuites(); + } + + @Override + public Socket createSocket(final String arg0, final int arg1) throws IOException { + //log.fine( "createSocket(%s,%s)", arg0, arg1); + return proxiedFactory.createSocket(arg0, arg1); + } + + @Override + public Socket createSocket(final InetAddress arg0, final int arg1) throws IOException { + //log.fine( "createSocket(%s,%s)", arg0, arg1); + return proxiedFactory.createSocket(arg0, arg1); + } + + @Override + public Socket createSocket(final String arg0, final int arg1, final InetAddress arg2, final int arg3) throws IOException { + //log.fine( "createSocket(%s,%s,%s)", arg0, arg1, arg3); + return proxiedFactory.createSocket(arg0, arg1, arg2, arg3); + } + + @Override + public Socket createSocket(final InetAddress arg0, final int arg1, final InetAddress arg2, final int arg3) throws IOException { + //log.fine( "createSocket(%s,%s,%s)", arg0, arg1, arg3); + return proxiedFactory.createSocket(arg0, arg1, arg2, arg3); + } + + public Socket createSocket() throws IOException { + log.info("funny: someone is calling the unspecified createSocket method"); + return proxiedFactory.createSocket(); + } + +} diff --git a/ews-client-java/src/main/java/com/eischet/ews/javaclient/JavaClient.java b/ews-client-java/src/main/java/com/eischet/ews/javaclient/JavaClient.java new file mode 100644 index 000000000..b72fc4367 --- /dev/null +++ b/ews-client-java/src/main/java/com/eischet/ews/javaclient/JavaClient.java @@ -0,0 +1,290 @@ +/* + * The MIT License + * Copyright (c) 2022 Eischet Software e.K. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package com.eischet.ews.javaclient; + +import com.eischet.ews.api.core.exception.http.EWSHttpException; +import com.eischet.ews.api.http.ExchangeHttpClient; +import com.eischet.ews.api.http.RequestFields; + +import java.io.*; +import java.net.*; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.time.temporal.ChronoUnit; +import java.util.Base64; +import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Exchange Client using Java's built-in HTTP client. + * + * TODO: this class is not yet complete. + */ +public class JavaClient implements ExchangeHttpClient { + + private static final Logger log = Logger.getLogger(JavaClient.class.getCanonicalName()); + + private boolean insecure; + private boolean debugLogging; + private String proxyHost; + private int proxyPort = 8080; + + private CopyOnWriteArrayList cookies = null; + + public JavaClient allowCookies() { + cookies = new CopyOnWriteArrayList<>(); + return this; + } + + public JavaClient ignoreSecurityErrors() { + setInsecure(true); + return this; + } + + public JavaClient enableDebugLogging() { + setDebugLogging(true); + return this; + } + + public JavaClient proxy(final String proxyHost, final int proxyPort) { + setProxyHost(proxyHost); + setProxyPort(proxyPort); + return this; + } + + public String getProxyHost() { + return proxyHost; + } + + public void setProxyHost(final String proxyHost) { + this.proxyHost = proxyHost; + } + + public int getProxyPort() { + return proxyPort; + } + + public void setProxyPort(final int proxyPort) { + this.proxyPort = proxyPort; + } + + public boolean isDebugLogging() { + return debugLogging; + } + + public void setDebugLogging(final boolean debugLogging) { + this.debugLogging = debugLogging; + } + + public void setInsecure(final boolean insecure) { + this.insecure = insecure; + } + + @Override + public Request createRequest() { + return new JavaRequest(); + } + + @Override + public Request createPoolingRequest() { + return new JavaRequest(); + } + + @Override + public void close() throws IOException { + } + + // TODO: this could maybe help --> https://github.com/codelibs/jcifs/blob/master/src/main/java/jcifs/http/NtlmHttpURLConnection.java + // yes, it's "broken by design", as they say, but it's our reality, too ;-) + + protected class JavaRequest extends RequestFields { + + private final ByteArrayOutputStream post = new ByteArrayOutputStream(); + private HttpResponse response; + private static final String authHeaderName = "Authorization"; + private String authHeaderContents = null; + private String username; + private String domain; + private String password; + + private boolean useNtlm = true; + + public boolean isUseNtlm() { + return useNtlm; + } + + public void setUseNtlm(final boolean useNtlm) { + this.useNtlm = useNtlm; + } + + @Override + public void prepareConnection() { + // Populate headers. (Copied from ApacheHttpClient::prepareConnection) + + setHeader("Content-type", getContentType()); + setHeader("User-Agent", getUserAgent()); + setHeader("Accept", getAccept()); + // these are not supported in the Java client and cannot be used like in the Apache client: + // setHeader("Keep-Alive", "300"); + // setHeader("Connection", "Keep-Alive"); + // See https://stackoverflow.com/questions/53617574/how-to-keep-connection-alive-in-java-11-http-client for workarounds when needed + + + if (isAcceptGzipEncoding()) { + // TODO: this will need more work, according to https://stackoverflow.com/questions/53502626/does-java-http-client-handle-compression + // I should maybe evaluate Methanol: https://mizosoft.github.io/methanol/enhanced_httpclient/ + + setHeader("Accept-Encoding", "gzip,deflate"); + } + + if (authHeaderContents != null && !useNtlm) { + setHeader(authHeaderName, authHeaderContents); + } + + } + + @Override + public void setCredentials(final String domain, final String username, final String password) { + this.username = username; + this.domain = domain; + this.password = password; + // TODO: other modes of Authentication, actually use Cookies, etc. + if (username == null || username.isEmpty()) { + authHeaderContents = null; + } else { + authHeaderContents = "Basic " + Base64.getEncoder() + .encodeToString((username + ":" + password).getBytes(StandardCharsets.UTF_8)); + } + } + + + @Override + public void close() throws IOException { + } + + @Override + public OutputStream getOutputStream() throws EWSHttpException { + return post; + } + + @Override + public int executeRequest() throws IOException, EWSHttpException { + if (debugLogging) { + log.info("----- POSTing to " + getUrl() + " -----"); + } + try { + final HttpRequest.Builder builder = HttpRequest + .newBuilder(getUrl().toURI()) + .timeout(Duration.ofMillis(getTimeout())) + .POST(HttpRequest.BodyPublishers.ofByteArray(post.toByteArray())); + for (Map.Entry entry : getHttpHeaders().entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + if (debugLogging) { + log.info("HTTP header: " + key + ": " + value); + } + builder.header(key, value); + } + if (cookies != null) { + for (final String cookie : cookies) { + if (debugLogging) { + log.info("Cookie: " + cookie); + } + builder.header("Cookie", cookie); + } + } + final HttpRequest request = builder.build(); + + if (debugLogging) { + log.info("POST BODY: " + post); + } + response = buildClient().send(request, HttpResponse.BodyHandlers.ofString()); + setResponseCode(response.statusCode()); + setResponseContentType(response.headers().firstValue("Content-Type").orElse(null)); + setResponseText(response.body()); + setContentEncoding(response.headers().firstValue("Content-Encoding").orElse(null)); + if (cookies != null) { + cookies.addAll(response.headers().allValues("Set-Cookie")); + } + log.info("Response: " + response.statusCode() + " " + response.body()); + return response.statusCode(); + } catch (URISyntaxException e) { + throw new EWSHttpException("invalid request URI: " + getUrl(), e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new EWSHttpException("interrupted during request", e); + } + } + + private HttpClient buildClient() { + // TODO: this should be moved to JavaClient level and reused, but the timeouts are currently stored at Request level... + try { + if (insecure) { + // They'll eventually go around to fixing this in the JDK, I hope... + // https://stackoverflow.com/questions/52988677/allow-insecure-https-connection-for-java-jdk-11-httpclient + System.setProperty("jdk.internal.httpclient.disableHostnameVerification", "true"); + return configure(HttpClient.newBuilder().sslContext(BlindSSLSocketFactory.getSSLContext())).build(); + } + } catch (Exception e) { + log.log(Level.SEVERE, "FAILED to create an 'insecure' HTTP client!", e); + } + return configure(HttpClient.newBuilder()).build(); + } + + + @Override + public InputStream getInputStream() throws EWSHttpException, IOException { + return new ByteArrayInputStream(getResponseText().getBytes(StandardCharsets.UTF_8)); + } + + @Override + public InputStream getErrorStream() throws EWSHttpException { + return new ByteArrayInputStream(getResponseText().getBytes(StandardCharsets.UTF_8)); + } + + private HttpClient.Builder configure(final HttpClient.Builder builder) { + if (proxyHost != null && !proxyHost.isBlank()) { + builder.proxy(ProxySelector.of(new InetSocketAddress(getProxyHost(), getProxyPort()))); + } + + + builder.authenticator(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password.toCharArray()); + } + }); + return builder + .followRedirects(isAllowAutoRedirect() ? HttpClient.Redirect.ALWAYS : HttpClient.Redirect.NEVER) + .connectTimeout(Duration.of(getTimeout(), ChronoUnit.MILLIS)); + } + + } + +} diff --git a/.travis.yml b/leftovers/.travis.yml similarity index 100% rename from .travis.yml rename to leftovers/.travis.yml diff --git a/CONTRIBUTING.md b/leftovers/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to leftovers/CONTRIBUTING.md diff --git a/deploy_snapshot.sh b/leftovers/deploy_snapshot.sh similarity index 100% rename from deploy_snapshot.sh rename to leftovers/deploy_snapshot.sh diff --git a/leftovers/readme.md b/leftovers/readme.md new file mode 100644 index 000000000..c44d6b5a5 --- /dev/null +++ b/leftovers/readme.md @@ -0,0 +1,17 @@ +# OLD README: + +## Getting started resources + +Please see the [Getting Started Guide](https://github.com/OfficeDev/ews-java-api/wiki/Getting-Started-Guide) on our wiki for an introduction to this library. + +## Using the library +Please see [this wiki-entry](https://github.com/OfficeDev/ews-java-api/wiki/Getting-Started-Guide#using-the-library) on how to include the library in your project + +### Maven / Gradle +For Documentation on how to use _ews-java-api_ with maven or gradle please refer to [this section in our wiki](https://github.com/OfficeDev/ews-java-api/wiki#maven--gradle-integration). + +### Building from source +To build a JAR from the source yourself, please see [this page](https://github.com/OfficeDev/ews-java-api/wiki/Building-EWS-JAVA-API). + + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. diff --git a/pom.xml b/pom.xml index e303359bc..c25976fb0 100644 --- a/pom.xml +++ b/pom.xml @@ -28,10 +28,56 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.microsoft.ews-java-api + + com.eischet.root + lib-public + 1.0.8 + + + com.eischet ews-java-api - - 2.1-SNAPSHOT + pom + + ${revision} + + + 2.3.2 + + + + -Xdoclint:none + + + 2.16 + 1.6 + 2.10.3 + 3.3 + 1.6.5 + 2.4 + 1.14 + 1.1 + + 3.4 + 2.8 + 2.2 + 2.5 + 2.18.1 + + 4.5.14 + 5.2.1 + + 4.13.2 + 1.3 + 4.2.0 + 1.7.32 + 1.2.10 + + + + VERBOSE + + + Exchange Web Services Java API Exchange Web Services (EWS) Java API @@ -42,12 +88,6 @@ 2012 - - - 3.1.0 - - Microsoft http://www.microsoft.com/ @@ -66,116 +106,19 @@ developer America/New_York - - http://www.example.com/jdoe/pic - + + + se + Stefan Eischet + https://github.com/eischet/ews-java-api + Eischet Software e.K. + + forker + + Europe/Berlin - - - UTF-8 - 1.6 - - - - 2.16 - 1.6 - 2.10.3 - 3.3 - 1.6.5 - 2.4 - 1.14 - 1.1 - - 3.4 - 2.8 - 2.2 - 2.5 - 2.18.1 - 0.7.5.201505241946 - - 4.4.1 - 4.4.1 - 1.2 - 2.8 - 3.4 - 2.4 - - 4.12 - 1.3 - 1.10.19 - 1.7.12 - 1.1.3 - - - - - - default-jdk18-profile - - [1.8,) - - - -Xdoclint:none - - - - - java-7-or-later-profile - - [1.7,) - - - - - org.apache.maven.plugins - maven-checkstyle-plugin - ${maven-checkstyle-plugin.version} - - true - google_checks.xml - - - - verify - - checkstyle - - - - - - - - - release-sign-artifacts - - - gpg.passphrase - - - - - - org.apache.maven.plugins - maven-gpg-plugin - ${maven-gpg-plugin.version} - - - sign-artifacts - verify - - sign - - - - - - - - @@ -185,139 +128,12 @@ - - https://github.com/OfficeDev/ews-java-api/issues - GitHub Issues - - - - travis - https://travis-ci.org/OfficeDev/ews-java-api - - - - https://github.com/OfficeDev/ews-java-api - scm:git:ssh://git@github.com:OfficeDev/ews-java-api.git - scm:git:ssh://git@github.com:OfficeDev/ews-java-api.git - - - - - ossrh-snapshot - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2 - - - - - - org.apache.httpcomponents - httpclient - ${httpclient.version} - - - - org.apache.httpcomponents - httpcore - ${httpcore.version} - - - - commons-io - commons-io - ${commons-io.version} - - - - commons-logging - commons-logging - ${commons-logging.version} - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - joda-time - joda-time - ${joda-time.version} - - - - junit - junit - ${junit.version} - test - - - - org.hamcrest - hamcrest-all - ${hamcrest-all.version} - test - - - - org.mockito - mockito-core - ${mockito-core.version} - test - - - - org.slf4j - slf4j-api - ${slf4j.version} - test - - - - ch.qos.logback - logback-classic - ${logback.version} - test - - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - test - - - + + + - - - org.sonatype.plugins - nexus-staging-maven-plugin - ${nexus-staging-maven-plugin.version} - true - - - true - ossrh - https://oss.sonatype.org/ - - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - ${project.build.sourceEncoding} - ${javaLanguage.version} - ${javaLanguage.version} - - org.apache.maven.plugins maven-javadoc-plugin @@ -348,48 +164,6 @@ - - org.codehaus.mojo - animal-sniffer-maven-plugin - ${animal-sniffer-maven-plugin.version} - - - org.codehaus.mojo.signature - java16-sun - ${animal-sniffer-maven-plugin.signature.version} - - - - - check-java16-sun - test - - check - - - - - - - org.jacoco - jacoco-maven-plugin - ${jacoco-maven-plugin.version} - - - - prepare-agent - - - - report - test - - report - - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - ${maven-project-info-reports-plugin.version} - - - - org.codehaus.mojo - versions-maven-plugin - ${versions-maven-plugin.version} - - - - dependency-updates-report - plugin-updates-report - property-updates-report - - - - + + ews-api + ews-client-apache4 + ews-client-java + ews-client-apache5 - - - org.apache.maven.plugins - maven-javadoc-plugin - ${maven-javadoc-plugin.version} - - true - ${javadoc.doclint.param} - - + - - - org.apache.maven.plugins - maven-jxr-plugin - ${maven-jxr-plugin.version} - + + + repo-eischet-releases + Eischet Software Repository + https://repo.srv.eischet.net/releases + + + repo-eischet-snapshots + Eischet Software Repository + https://repo.srv.eischet.net/snapshots + + true + + + + + + + repo-eischet-releases + Eischet Software Repository + https://repo.srv.eischet.net/releases + + + repo-eischet-snapshots + Eischet Software Repository + https://repo.srv.eischet.net/snapshots + + true + + + - - org.apache.maven.plugins - maven-surefire-report-plugin - ${maven-surefire-report-plugin.version} - - - diff --git a/readme.md b/readme.md index 6101807c8..af4722e03 100644 --- a/readme.md +++ b/readme.md @@ -1,29 +1,98 @@ -# Getting Started with the EWS Java API +# This is an unofficial fork of Microsoft's EWS-Java-API -[![Gitter](https://badges.gitter.im/JoinChat.svg)](https://gitter.im/OfficeDev/ews-java-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +## Why: -[![Build Status](https://travis-ci.org/OfficeDev/ews-java-api.svg)](https://travis-ci.org/OfficeDev/ews-java-api) [![codecov.io](https://codecov.io/github/OfficeDev/ews-java-api/coverage.svg?branch=master)](https://codecov.io/github/OfficeDev/ews-java-api?branch=master) +Microsoft has stopped working on the EWS-Java-API, as announced July 19th 2018. There's a new "Graph" API to replace it. -The Exchange Web Services (EWS) Java API provides a managed interface for developing Java applications that use EWS. -By using the EWS Java API, you can access almost all the information stored in an Office 365, Exchange Online, or Exchange Server mailbox. However, this API is in sustaining mode, the recommended access pattern for Office 365 and Exchange online data is [Microsoft Graph](https://graph.microsoft.com) +But you have to meet some very specific criteria to be able to use these new APIs: +see https://docs.microsoft.com/en-us/graph/hybrid-rest-support for what's available right now. -## Support statement +Here's the end of support statement: https://developer.microsoft.com/en-us/graph/blogs/upcoming-changes-to-exchange-web-services-ews-api-for-office-365/ -Starting July 19th 2018, Exchange Web Services (EWS) will no longer receive feature updates. While the service will continue to receive security updates and certain non-security updates, product design and features will remain unchanged. This change also applies to the EWS SDKs for Java and .NET. More information here: https://developer.microsoft.com/en-us/graph/blogs/upcoming-changes-to-exchange-web-services-ews-api-for-office-365/ +However, to use the new Graph API, you need to be in a "hybrid" setup, or in Exchange Online only. +Unfortunately, it's too early for my own users to use that new API, and I don't know if everybody will really go "hybrid" in the future. +My software needs to read and manipulate on-premise Exchange mails *today*, and so I'm kind of stuck with EWS for now. +Triggered by last year's "Log4Shell" issues, I've started hunting down old and superfluous dependencies in my software, +and the EWS API pulls in quite a few old packages... that's why I'm putting in some effort to modernize the old code now. -## Getting started resources +Issues and contributions are welcome. -Please see the [Getting Started Guide](https://github.com/OfficeDev/ews-java-api/wiki/Getting-Started-Guide) on our wiki for an introduction to this library. +No packages are provided right now, but I'm thinking about it. +If you want to use the code at the moment, simply run `mvn install` locally. -## Using the library -Please see [this wiki-entry](https://github.com/OfficeDev/ews-java-api/wiki/Getting-Started-Guide#using-the-library) on how to include the library in your project +Thanks to Microsoft for releasing this code under the MIT license! -### Maven / Gradle -For Documentation on how to use _ews-java-api_ with maven or gradle please refer to [this section in our wiki](https://github.com/OfficeDev/ews-java-api/wiki#maven--gradle-integration). +*S.E.* -### Building from source -To build a JAR from the source yourself, please see [this page](https://github.com/OfficeDev/ews-java-api/wiki/Building-EWS-JAVA-API). +## Version 2.1-SNAPSHOT: +The original code was split into a number of packages: + +* `ews-api` contains most of the original code, but no HTTP client, which needs to be created before using the ExchangeService. +* `ews-client-apache4` contains the original, Apache HTTP Components 4.x based client only. +* `ews-client-apache5` contains a new client based on Apache HTTP Components 5.x. +* `ews-client-java` contains a new client based on Java's built-in HTTP client (which does not actually work right now because of NTLM issues) + +Since XML (javax.xml) has been removed from Java, I've added a dependency on `jakarta.xml.bind:jakarta.xml.bind-api:3.0.1` +with a runtime dependency on `com.sun.xml.bind:jaxb-impl:3.0.1`. If you prefer a different implementation, you should be +able to override this. + +The package names have been changed from `microsoft.*` to `com.eischet.ews.*`. There's an actual use case for this, +because it allows me to include the old and the new package in my software at the same time, allowing my users to test +the new code more easily. + +The build now uses Java 17. + +## Version 2.3.2, 2025-12-29: + +* Removed the "Olsen Time Zone Mappings", which regularly ran into errors with newer JDKs because they expected a mapping + for all Java time zones to Microsoft names, after noticing that the original code file is only used IN that same test case. + + +## Version 2.2-SNAPSHOT, 2023-10-09: + +* Removed some JavaDoc comments that only stated the obvious or where even plainly wrong (copy/pasted presumably). +* Reduced the number of "throws Exception" to 5264, down from 8241 (!). That's still terrible, but it's a start. + Added a new "ExchangeException" base class and modified the Exception hierarchy to use it. + The near-term goal is to have two main exceptions, one for usage/XML errors and one for communication errors. + Ideally, validation of messages sent to the server should only happen when requests are actually sent, and any + e.g. Version checks that right now happen in the Item constructor (and cascade down to all derived classes) + should not be there at all. + + +## What to use + +If your Exchange system does have the Graph API, i.e. you're in a hybrid or cloud-only setup, you might as well use that. +This is the wrong project in this case, and you'll need a different client, e.g. https://github.com/microsoftgraph/msgraph-sdk-java + +If you don't mind using the old Apache HTTP Components 4.x, you can use the original Microsoft package instead of this. +They do have *known security issues*, though, that the Apache Team has fixed in version 5.x. + +Otherwise, use the `ews-client-apache5` package. + +This should get you started, from the original documentation: +https://github.com/OfficeDev/ews-java-api/wiki/Getting-Started-Guide#using-the-library + +Creating the ExchangeService is a bit different, because you need to supply a client: + + final ApacheHttpClient client = new ApacheHttpClient(); + // configure the client... + ExchangeService service = new ExchangeService(client, ExchangeVersion.Exchange2010_SP2); + + + +## Future Plans + +My main goal is to keep this project alive for at least a few years, but not to add significant new features myself. +I'm not going to spend significant amounts of time on this project, though. +Pull requests are welcome, though, if there's something you need to have. + +There are some areas which could be improved, and I'll work on these as time permits: + +* The old API throws Exception in a *lot* of places, and I hope to clean that up a bit, while keeping the general code as-is. +* Many of the JavaDocs trigger errors and/or look autogenerated, stating the obvious (e.g. int foo -- "the foo"), and should be cleaned up. + My current favorite is the StringList::toString JavaDoc, which takes quite a lot of words to explain how generic toString works, + but returns something entirely different. +* There's quite a lot of unused code, e.g. all methods of IAsyncResult, and some unused type parameters, that could be removed/improved. -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information, see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. diff --git a/src/main/java/microsoft/exchange/webservices/data/EWSConstants.java b/src/main/java/microsoft/exchange/webservices/data/EWSConstants.java deleted file mode 100644 index 2b0b4b5d5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/EWSConstants.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data; - -/** - * Class that holds all constants. - */ -public class EWSConstants { - /* - * Represents SRV record. - */ - /** - * The Constant SRVRECORD. - */ - public static final String SRVRECORD = "SRV"; - /* - * Represents the name of the domain - */ - /** - * The Constant DOMAIN. - */ - public static final String DOMAIN = "domain"; - /* - * Represents the domain server IP address - */ - /** - * The Constant DNSSERVERADDRESS. - */ - public static final String DNSSERVERADDRESS = "dnsServerAddress"; - /* - * Represents the name of the property file - */ - /** - * The Constant EWS_PROP_FILE. - */ - public static final String EWS_PROP_FILE = "ews.property"; - - /** - * The Constant HTTP_SCHEME. - */ - public static final String HTTP_SCHEME = "http"; - - /** - * The Constant HTTPS_SCHEME. - */ - public static final String HTTPS_SCHEME = "https"; - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/AlternateMailbox.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/AlternateMailbox.java deleted file mode 100644 index d85adf965..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/AlternateMailbox.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover; - -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -/** - * Defines the AlternateMailbox class. - */ -public final class AlternateMailbox { - - /** - * The type. - */ - private String type; - - /** - * The display name. - */ - private String displayName; - - /** - * The legacy dn. - */ - private String legacyDN; - - /** - * The server. - */ - private String server; - - /** - * The SMTP address of alternate mailbox. It is only set if it is available - * for the given type. E.g. type 'Delegate' has one type 'Archive' not. - */ - private String smtpAddress; - - - /** - * The SMTP address of the owner of this alternate mailbox. - */ - private String ownerSmtpAddress; - - /** - * Initializes a new instance of the AlternateMailbox class. - */ - private AlternateMailbox() {} - - /** - * PLoads AlternateMailbox instance from XML. - * - * @param reader the reader - * @return AlternateMailbox - * @throws Exception the exception - */ - public static AlternateMailbox loadFromXml(final EwsXmlReader reader) - throws Exception { - final AlternateMailbox altMailbox = new AlternateMailbox(); - - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Type)) { - altMailbox.setType(reader.readElementValue(String.class)); - } else if (reader.getLocalName() - .equalsIgnoreCase(XmlElementNames.DisplayName)) { - altMailbox.setDisplayName(reader.readElementValue(String.class)); - } else if (reader.getLocalName() - .equalsIgnoreCase(XmlElementNames.LegacyDN)) { - altMailbox.setLegacyDN(reader.readElementValue(String.class)); - } else - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Server)) { - altMailbox.setServer(reader.readElementValue(String.class)); - } else if (reader.getLocalName() - .equalsIgnoreCase(XmlElementNames.SmtpAddress)) { - altMailbox.setSmtpAddress(reader.readElementValue(String.class)); - } else if (reader.getLocalName() - .equalsIgnoreCase(XmlElementNames.OwnerSmtpAddress)) { - altMailbox.setOwnerSmtpAddress(reader.readElementValue(String.class)); - } - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.AlternateMailbox)); - - return altMailbox; - } - - /** - * Gets the alternate mailbox type. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Sets the type. - * - * @param type the new type - */ - protected void setType(final String type) { - this.type = type; - } - - /** - * Gets the alternate mailbox display name. - * - * @return the display name - */ - public String getDisplayName() { - return displayName; - } - - /** - * Sets the display name. - * - * @param displayName the new display name - */ - protected void setDisplayName(final String displayName) { - this.displayName = displayName; - } - - /** - * Gets the alternate mailbox legacy DN. - * - * @return the legacy dn - */ - public String getLegacyDN() { - return legacyDN; - } - - /** - * Sets the legacy dn. - * - * @param legacyDN the new legacy dn - */ - protected void setLegacyDN(final String legacyDN) { - this.legacyDN = legacyDN; - } - - /** - * Gets the alernate mailbox server. - * - * @return the server - */ - public String getServer() { - return server; - } - - /** - * Sets the server. - * - * @param server the new server. - */ - protected void setServer(final String server) { - this.server = server; - } - - /** - * Gets the SMTP address. - * - * @return the SMTP address if available for the mailbox type otherwise null - * is returned. - */ - public String getSmtpAddress() { - return smtpAddress; - } - - /** - * Sets the SMTP address. - * - * @param smtpAddress the new SMTP address. - */ - protected void setSmtpAddress(final String smtpAddress) { - this.smtpAddress = smtpAddress; - } - - /** - * Gets the owner SMTP address. - * - * @return the SMTP address of the owner of this mailbox. - */ - public String getOwnerSmtpAddress() { - return ownerSmtpAddress; - } - - /** - * Sets the owner SMTP address. - * - * @param ownerSmtpAdress the new owner SMTP address - */ - protected void setOwnerSmtpAddress(final String ownerSmtpAddress) { - this.ownerSmtpAddress = ownerSmtpAddress; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/AlternateMailboxCollection.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/AlternateMailboxCollection.java deleted file mode 100644 index 4340bda32..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/AlternateMailboxCollection.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover; - -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a user setting that is a collection of alternate mailboxes. - */ -public final class AlternateMailboxCollection { - - private ArrayList entries; - - /** - * Initializes a new instance of the class - */ - public AlternateMailboxCollection() { - this.setEntries(new ArrayList()); - } - - /** - * Loads instance of AlternateMailboxCollection from XML. - * - * @param reader the reader - * @return AlternateMailboxCollection - * @throws Exception the exception - */ - public static AlternateMailboxCollection loadFromXml(EwsXmlReader reader) - throws Exception { - AlternateMailboxCollection instance = new AlternateMailboxCollection(); - - do { - reader.read(); - - if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && - (reader.getLocalName() - .equals(XmlElementNames.AlternateMailbox))) { - instance.getEntries().add( - AlternateMailbox.loadFromXml(reader)); - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.AlternateMailboxes)); - - return instance; - } - - /** - * Gets the collection of alternate mailboxes. - * @return alternate mailboxes - */ - public List getEntries() { - return this.entries; - } - - private void setEntries(ArrayList value) { - this.entries = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverDnsClient.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverDnsClient.java deleted file mode 100644 index 782f46ecc..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverDnsClient.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.enumeration.misc.TraceFlags; -import microsoft.exchange.webservices.data.core.exception.dns.DnsException; -import microsoft.exchange.webservices.data.dns.DnsClient; -import microsoft.exchange.webservices.data.dns.DnsSrvRecord; - -import javax.xml.stream.XMLStreamException; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -/** - * Class that reads AutoDiscover configuration information from DNS. - */ -class AutodiscoverDnsClient { - - /** - * SRV DNS prefix to lookup. - */ - private static final String AutoDiscoverSrvPrefix = "_autodiscover._tcp."; - - /** - * We are only interested in records that use SSL. - */ - private static final int SslPort = 443; - - /** - * Random selector in the case of ties. - */ - private static Random RandomTieBreakerSelector = new Random(); - - /** - * AutodiscoverService using this DNS reader. - */ - private AutodiscoverService service; - - /** - * Initializes a new instance of the class. - * - * @param service the service - */ - protected AutodiscoverDnsClient(AutodiscoverService service) { - this.service = service; - } - - /** - * Extracts a valid autodiscover hostname, if any, from a dns srv response. - * - * @param dnsNameTarget The hostname response returned by DNS - * @return Autodiscover hostname (will be null if dnsNameTarget is invalid). - */ - protected static String extractHostnameFromDnsSrv(String dnsNameTarget) { - if (dnsNameTarget == null || dnsNameTarget.isEmpty()) { - return null; - } else { - if (dnsNameTarget.endsWith(".")) { - dnsNameTarget = dnsNameTarget.substring(0, dnsNameTarget.length()-1); - } - return dnsNameTarget; - } - } - - /** - * Finds the Autodiscover host from DNS SRV records. - * - * @param domain the domain - * @return Autodiscover hostname (will be null if lookup failed). - * @throws IOException signals that an I/O exception has occurred. - */ - protected String findAutodiscoverHostFromSrv(String domain) - throws XMLStreamException, IOException { - String domainToMatch = AutoDiscoverSrvPrefix + domain; - - DnsSrvRecord dnsSrvRecord = this - .findBestMatchingSrvRecord(domainToMatch); - if (dnsSrvRecord != null) { - String hostName = extractHostnameFromDnsSrv(dnsSrvRecord.getNameTarget()); - if (hostName != null) { - this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, String - .format("DNS query for SRV record for domain %s found %s", domain, hostName)); - return hostName; - } - } - this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, - "No appropriate SRV record was found."); - return null; - } - - /** - * Finds the best matching SRV record. - * - * @param domain the domain - * @return DnsSrvRecord (will be null if lookup failed) - * @throws XMLStreamException the XML stream exception - * @throws IOException signals that an I/O exception has occurred. - */ - private DnsSrvRecord findBestMatchingSrvRecord(String domain) - throws XMLStreamException, IOException { - List dnsSrvRecordList; - try { - // Make DnsQuery call to get collection of SRV records. - dnsSrvRecordList = DnsClient.dnsQuery(DnsSrvRecord.class, domain, this.service.getDnsServerAddress()); - } catch (DnsException ex) { - String dnsExcMessage = String.format("DnsQuery returned error '%s'.", ex.getMessage()); - this.service - .traceMessage( - TraceFlags.AutodiscoverConfiguration, - dnsExcMessage); - return null; - } catch (SecurityException ex) { - // In restricted environments, we may not be allowed to call - // un-managed code. - this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format( - "DnsQuery cannot be called. Security error: %s.", - ex.getMessage())); - return null; - } - - this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, String - .format("%d SRV records were returned.", dnsSrvRecordList - .size())); - - // If multiple records were returned, they will be returned sorted by - // priority - // (and weight) order. Need to find the index of the first record that - // supports SSL. - int priority = Integer.MIN_VALUE; - int weight = Integer.MAX_VALUE; - boolean recordFound = false; - for (DnsSrvRecord dnsSrvRecord : dnsSrvRecordList) { - if (dnsSrvRecord.getPort() == SslPort) { - priority = dnsSrvRecord.getPriority(); - weight = dnsSrvRecord.getWeight(); - recordFound = true; - break; - } - } - - // Records were returned but nothing matched our criteria. - if (!recordFound) { - this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, - "No appropriate SRV records were found."); - - return null; - } - - List bestDnsSrvRecordList = new ArrayList(); - for (DnsSrvRecord dnsSrvRecord : dnsSrvRecordList) { - if (dnsSrvRecord.getPort() == SslPort && - dnsSrvRecord.getPriority() == priority && - dnsSrvRecord.getWeight() == weight) { - bestDnsSrvRecordList.add(dnsSrvRecord); - } - } - - // The list must contain at least one matching record since we found one - // earlier. - EwsUtilities.ewsAssert(dnsSrvRecordList.size() > 0, "AutodiscoverDnsClient.FindBestMatchingSrvRecord", - "At least one DNS SRV record must match the criteria."); - - // If we have multiple records with the same priority and weight, - // randomly pick one. - int recordIndex = (bestDnsSrvRecordList.size() > 1) ? - RandomTieBreakerSelector - .nextInt(bestDnsSrvRecordList.size()) : - 0; - - DnsSrvRecord bestDnsSrvRecord = bestDnsSrvRecordList.get(recordIndex); - - String traceMessage = String.format("Returning SRV record %d " + - "of %d records. " + - "Target: %s, Priority: %d, Weight: %d", - recordIndex, dnsSrvRecordList.size(), - bestDnsSrvRecord.getNameTarget(), - bestDnsSrvRecord.getPriority(), - bestDnsSrvRecord.getWeight()); - this.service.traceMessage(TraceFlags. - AutodiscoverConfiguration, traceMessage); - - - return bestDnsSrvRecord; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverResponseCollection.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverResponseCollection.java deleted file mode 100644 index fcb97dbac..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverResponseCollection.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover; - -import microsoft.exchange.webservices.data.autodiscover.response.AutodiscoverResponse; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Represents a collection of response to a call to the Autodiscover service. - * - * @param The type of the response in the collection. - */ -public abstract class AutodiscoverResponseCollection - - extends AutodiscoverResponse implements Iterable { - - /** - * The response. - */ - private List responses; - - /** - * Initializes a new instance of the AutodiscoverResponseCollection class. - */ - public AutodiscoverResponseCollection() { - super(); - this.responses = new ArrayList(); - } - - /** - * Gets the number of response in the collection. - * - * @return the count - */ - public int getCount() { - return this.responses.size(); - } - - /** - * Gets the response at the specified index. - * - * @param index the index - * @return the t response at index - */ - public TResponse getTResponseAtIndex(int index) { - return this.responses.get(index); - } - - /** - * Gets the response. - * - * @return the response - */ - public List getResponses() { - return responses; - } - - /** - * Loads response from XML. - * - * @param reader the reader - * @param endElementName End element name. - * @throws Exception the exception - */ - public void loadFromXml(EwsXmlReader reader, String endElementName) - throws Exception { - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals( - this.getResponseCollectionXmlElementName())) { - this.loadResponseCollectionFromXml(reader); - } else { - super.loadFromXml(reader, endElementName); - } - } - } while (!reader - .isEndElement(XmlNamespace.Autodiscover, endElementName)); - } - - /** - * Loads response from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - private void loadResponseCollectionFromXml(EwsXmlReader reader) - throws Exception { - if (!reader.isEmptyElement()) { - do { - reader.read(); - if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && - (reader.getLocalName().equals(this - .getResponseInstanceXmlElementName()))) { - TResponse response = this.createResponseInstance(); - response.loadFromXml(reader, this - .getResponseInstanceXmlElementName()); - this.responses.add(response); - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, this - .getResponseCollectionXmlElementName())); - } else { - reader.read(); - } - } - - /** - * Gets the name of the response collection XML element. - * - * @return Response collection XMl element name. - */ - protected abstract String getResponseCollectionXmlElementName(); - - /** - * Gets the name of the response instance XML element. - * - * @return Response collection XMl element name. - */ - protected abstract String getResponseInstanceXmlElementName(); - - /** - * Create a response instance. - * - * @return TResponse. - */ - protected abstract TResponse createResponseInstance(); - - /** - * Gets an Iterator that iterates through the elements of the collection. - * - * @return An Iterator for the collection. - */ - public Iterator iterator() { - return this.responses.iterator(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverService.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverService.java deleted file mode 100644 index 147a61c7f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/AutodiscoverService.java +++ /dev/null @@ -1,2064 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover; - -import microsoft.exchange.webservices.data.autodiscover.configuration.ConfigurationSettingsBase; -import microsoft.exchange.webservices.data.autodiscover.configuration.outlook.OutlookConfigurationSettings; -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverEndpoints; -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverErrorCode; -import microsoft.exchange.webservices.data.autodiscover.exception.AutodiscoverLocalException; -import microsoft.exchange.webservices.data.autodiscover.exception.AutodiscoverRemoteException; -import microsoft.exchange.webservices.data.autodiscover.request.AutodiscoverRequest; -import microsoft.exchange.webservices.data.autodiscover.request.GetDomainSettingsRequest; -import microsoft.exchange.webservices.data.autodiscover.request.GetUserSettingsRequest; -import microsoft.exchange.webservices.data.autodiscover.response.GetDomainSettingsResponse; -import microsoft.exchange.webservices.data.autodiscover.response.GetDomainSettingsResponseCollection; -import microsoft.exchange.webservices.data.autodiscover.response.GetUserSettingsResponse; -import microsoft.exchange.webservices.data.autodiscover.response.GetUserSettingsResponseCollection; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.ExchangeServiceBase; -import microsoft.exchange.webservices.data.core.request.HttpClientWebRequest; -import microsoft.exchange.webservices.data.core.request.HttpWebRequest; -import microsoft.exchange.webservices.data.credential.WSSecurityBasedCredentials; -import microsoft.exchange.webservices.data.autodiscover.enumeration.DomainSettingName; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.TraceFlags; -import microsoft.exchange.webservices.data.autodiscover.enumeration.UserSettingName; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.http.EWSHttpException; -import microsoft.exchange.webservices.data.core.exception.misc.FormatException; -import microsoft.exchange.webservices.data.autodiscover.exception.MaximumRedirectionHopsExceededException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import javax.xml.stream.XMLStreamException; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.EnumSet; -import java.util.List; - -/** - * Represents a binding to the Exchange Autodiscover Service. - */ -public class AutodiscoverService extends ExchangeServiceBase - implements IAutodiscoverRedirectionUrl, IFunctionDelegate { - - // region Private members - /** - * The domain. - */ - private String domain; - - /** - * The is external. - */ - private Boolean isExternal = true; - - /** - * The url. - */ - private URI url; - - /** - * The redirection url validation callback. - */ - private IAutodiscoverRedirectionUrl - redirectionUrlValidationCallback; - - /** - * The dns client. - */ - private AutodiscoverDnsClient dnsClient; - - /** - * The dns server address. - */ - private String dnsServerAddress; - - /** - * The enable scp lookup. - */ - private boolean enableScpLookup = true; - - // Autodiscover legacy path - /** - * The Constant AutodiscoverLegacyPath. - */ - private static final String AutodiscoverLegacyPath = - "/autodiscover/autodiscover.xml"; - - // Autodiscover legacy HTTPS Url - /** - * The Constant AutodiscoverLegacyHttpsUrl. - */ - private static final String AutodiscoverLegacyHttpsUrl = "https://%s" + - AutodiscoverLegacyPath; - // Autodiscover legacy HTTP Url - /** - * The Constant AutodiscoverLegacyHttpUrl. - */ - private static final String AutodiscoverLegacyHttpUrl = "http://%s" + - AutodiscoverLegacyPath; - // Autodiscover SOAP HTTPS Url - /** - * The Constant AutodiscoverSoapHttpsUrl. - */ - private static final String AutodiscoverSoapHttpsUrl = - "https://%s/autodiscover/autodiscover.svc"; - // Autodiscover SOAP WS-Security HTTPS Url - /** - * The Constant AutodiscoverSoapWsSecurityHttpsUrl. - */ - private static final String AutodiscoverSoapWsSecurityHttpsUrl = - AutodiscoverSoapHttpsUrl + - "/wssecurity"; - - /** - * Autodiscover SOAP WS-Security symmetrickey HTTPS Url - */ - private static final String AutodiscoverSoapWsSecuritySymmetricKeyHttpsUrl = - AutodiscoverSoapHttpsUrl + "/wssecurity/symmetrickey"; - - /** - * Autodiscover SOAP WS-Security x509cert HTTPS Url - */ - private static final String AutodiscoverSoapWsSecurityX509CertHttpsUrl = - AutodiscoverSoapHttpsUrl + "/wssecurity/x509cert"; - - - // Autodiscover request namespace - /** - * The Constant AutodiscoverRequestNamespace. - */ - private static final String AutodiscoverRequestNamespace = - "http://schemas.microsoft.com/exchange/autodiscover/" + - "outlook/requestschema/2006"; - // Maximum number of Url (or address) redirections that will be followed by - // an Autodiscover call - /** - * The Constant AutodiscoverMaxRedirections. - */ - protected static final int AutodiscoverMaxRedirections = 10; - // HTTP header indicating that SOAP Autodiscover service is enabled. - /** - * The Constant AutodiscoverSoapEnabledHeaderName. - */ - private static final String AutodiscoverSoapEnabledHeaderName = - "X-SOAP-Enabled"; - // HTTP header indicating that WS-Security Autodiscover service is enabled. - /** - * The Constant AutodiscoverWsSecurityEnabledHeaderName. - */ - private static final String AutodiscoverWsSecurityEnabledHeaderName = - "X-WSSecurity-Enabled"; - - - /** - * HTTP header indicating that WS-Security/SymmetricKey Autodiscover service is enabled. - */ - - private static final String AutodiscoverWsSecuritySymmetricKeyEnabledHeaderName = - "X-WSSecurity-SymmetricKey-Enabled"; - - - /** - * HTTP header indicating that WS-Security/X509Cert Autodiscover service is enabled. - */ - - private static final String AutodiscoverWsSecurityX509CertEnabledHeaderName = - "X-WSSecurity-X509Cert-Enabled"; - - - // Minimum request version for Autodiscover SOAP service. - /** - * The Constant MinimumRequestVersionForAutoDiscoverSoapService. - */ - private static final ExchangeVersion - MinimumRequestVersionForAutoDiscoverSoapService = - ExchangeVersion.Exchange2010; - - /** - * Default implementation of AutodiscoverRedirectionUrlValidationCallback. - * Always returns true indicating that the URL can be used. - * - * @param redirectionUrl the redirection url - * @return Returns true. - * @throws AutodiscoverLocalException the autodiscover local exception - */ - private boolean defaultAutodiscoverRedirectionUrlValidationCallback( - String redirectionUrl) throws AutodiscoverLocalException { - throw new AutodiscoverLocalException(String.format( - "Autodiscover blocked a potentially insecure redirection to %s. To allow Autodiscover to follow the " - + "redirection, use the AutodiscoverUrl(string, AutodiscoverRedirectionUrlValidationCallback) " - + "overload.", redirectionUrl)); - } - - // Legacy Autodiscover - - /** - * Calls the Autodiscover service to get configuration settings at the - * specified URL. - * - * @param the generic type - * @param cls the cls - * @param emailAddress the email address - * @param url the url - * @return The requested configuration settings. (TSettings The type of the - * settings to retrieve) - * @throws Exception the exception - */ - private - TSettings getLegacyUserSettingsAtUrl( - Class cls, String emailAddress, URI url) - throws Exception { - this - .traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format("Trying to call Autodiscover for %s on %s.", emailAddress, url)); - - TSettings settings = cls.newInstance(); - - HttpWebRequest request = null; - try { - request = this.prepareHttpWebRequestForUrl(url); - - this.traceHttpRequestHeaders( - TraceFlags.AutodiscoverRequestHttpHeaders, - request); - // OutputStreamWriter out = new - // OutputStreamWriter(request.getOutputStream()); - OutputStream urlOutStream = request.getOutputStream(); - - // If tracing is enabled, we generate the request in-memory so that we - // can pass it along to the ITraceListener. Then we copy the stream to - // the request stream. - if (this.isTraceEnabledFor(TraceFlags.AutodiscoverRequest)) { - ByteArrayOutputStream memoryStream = new ByteArrayOutputStream(); - - PrintWriter writer = new PrintWriter(memoryStream); - this.writeLegacyAutodiscoverRequest(emailAddress, settings, writer); - writer.flush(); - - this.traceXml(TraceFlags.AutodiscoverRequest, memoryStream); - // out.write(memoryStream.toString()); - // out.close(); - memoryStream.writeTo(urlOutStream); - urlOutStream.flush(); - urlOutStream.close(); - memoryStream.close(); - } else { - PrintWriter writer = new PrintWriter(urlOutStream); - this.writeLegacyAutodiscoverRequest(emailAddress, settings, writer); - - /* Flush Start */ - writer.flush(); - urlOutStream.flush(); - urlOutStream.close(); - /* Flush End */ - } - request.executeRequest(); - request.getResponseCode(); - URI redirectUrl; - OutParam outParam = new OutParam(); - if (this.tryGetRedirectionResponse(request, outParam)) { - redirectUrl = outParam.getParam(); - settings.makeRedirectionResponse(redirectUrl); - return settings; - } - InputStream serviceResponseStream = request.getInputStream(); - // If tracing is enabled, we read the entire response into a - // MemoryStream so that we - // can pass it along to the ITraceListener. Then we parse the response - // from the - // MemoryStream. - if (this.isTraceEnabledFor(TraceFlags.AutodiscoverResponse)) { - ByteArrayOutputStream memoryStream = new ByteArrayOutputStream(); - - while (true) { - int data = serviceResponseStream.read(); - if (-1 == data) { - break; - } else { - memoryStream.write(data); - } - } - memoryStream.flush(); - - this.traceResponse(request, memoryStream); - ByteArrayInputStream memoryStreamIn = new ByteArrayInputStream( - memoryStream.toByteArray()); - EwsXmlReader reader = new EwsXmlReader(memoryStreamIn); - reader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT)); - settings.loadFromXml(reader); - - } else { - EwsXmlReader reader = new EwsXmlReader(serviceResponseStream); - reader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT)); - settings.loadFromXml(reader); - } - - serviceResponseStream.close(); - } finally { - if (request != null) { - try { - request.close(); - } catch (Exception e2) { - // Ignore exception while closing the request. - } - } - } - - return settings; - } - - /** - * Writes the autodiscover request. - * - * @param emailAddress the email address - * @param settings the settings - * @param writer the writer - * @throws java.io.IOException Signals that an I/O exception has occurred. - */ - private void writeLegacyAutodiscoverRequest(String emailAddress, - ConfigurationSettingsBase settings, PrintWriter writer) - throws IOException { - writer.write(String.format("", AutodiscoverRequestNamespace)); - writer.write(""); - writer.write(String.format("%s", - emailAddress)); - writer.write( - String.format("%s", settings.getNamespace())); - writer.write(""); - writer.write(""); - } - - /** - * Gets a redirection URL to an SSL-enabled Autodiscover service from the - * standard non-SSL Autodiscover URL. - * - * @param domainName the domain name - * @return A valid SSL-enabled redirection URL. (May be null) - * @throws EWSHttpException the EWS http exception - * @throws XMLStreamException the XML stream exception - * @throws IOException Signals that an I/O exception has occurred. - * @throws ServiceLocalException the service local exception - * @throws URISyntaxException the uRI syntax exception - */ - private URI getRedirectUrl(String domainName) - throws EWSHttpException, XMLStreamException, IOException, ServiceLocalException, URISyntaxException { - String url = String.format(AutodiscoverLegacyHttpUrl, "autodiscover." + domainName); - - traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format("Trying to get Autodiscover redirection URL from %s.", url)); - - HttpWebRequest request = null; - - try { - request = new HttpClientWebRequest(httpClient, httpContext); - request.setProxy(getWebProxy()); - - try { - request.setUrl(URI.create(url).toURL()); - } catch (MalformedURLException e) { - String strErr = String.format("Incorrect format : %s", url); - throw new ServiceLocalException(strErr); - } - - request.setRequestMethod("GET"); - request.setAllowAutoRedirect(false); - request.setTimeout(getTimeout()); - - // Do NOT allow authentication as this single request will be made over plain HTTP. - request.setAllowAuthentication(false); - - prepareCredentials(request); - - request.prepareConnection(); - try { - request.executeRequest(); - } catch (IOException e) { - traceMessage(TraceFlags.AutodiscoverConfiguration, "No Autodiscover redirection URL was returned."); - return null; - } - - OutParam outParam = new OutParam(); - if (tryGetRedirectionResponse(request, outParam)) { - return outParam.getParam(); - } - } finally { - if (request != null) { - try { - request.close(); - } catch (Exception e) { - // Ignore exception when closing the request - } - } - } - - traceMessage(TraceFlags.AutodiscoverConfiguration, "No Autodiscover redirection URL was returned."); - return null; - } - - /** - * Tries the get redirection response. - * - * @param request the request - * @param redirectUrl the redirect URL - * @return true if a valid redirection URL was found - * @throws XMLStreamException the XML stream exception - * @throws IOException signals that an I/O exception has occurred. - * @throws EWSHttpException the EWS http exception - */ - private boolean tryGetRedirectionResponse(HttpWebRequest request, - OutParam redirectUrl) throws XMLStreamException, IOException, - EWSHttpException { - // redirectUrl = null; - if (AutodiscoverRequest.isRedirectionResponse(request)) { - // Get the redirect location and verify that it's valid. - String location = request.getResponseHeaderField("Location"); - - if (!(location == null || location.isEmpty())) { - try { - redirectUrl.setParam(new URI(location)); - - // Check if URL is SSL and that the path matches. - if ((redirectUrl.getParam().getScheme().toLowerCase() - .equals("https")) && - (redirectUrl.getParam().getPath() - .equalsIgnoreCase( - AutodiscoverLegacyPath))) { - this.traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format("Redirection URL found: '%s'", - redirectUrl.getParam().toString())); - - return true; - } - } catch (URISyntaxException ex) { - this - .traceMessage( - TraceFlags.AutodiscoverConfiguration, - String - .format( - "Invalid redirection URL " + - "was returned: '%s'", - location)); - return false; - } - } - } - return false; - } - - /** - * Calls the legacy Autodiscover service to retrieve configuration settings. - * - * @param the generic type - * @param cls the cls - * @param emailAddress The email address to retrieve configuration settings for. - * @return The requested configuration settings. - * @throws Exception the exception - */ - protected - TSettings getLegacyUserSettings( - Class cls, String emailAddress) throws Exception { - /*int currentHop = 1; - return this.internalGetConfigurationSettings(cls, emailAddress, - currentHop);*/ - - // If Url is specified, call service directly. - if (this.url != null) { - // this.Uri is intended for Autodiscover SOAP service, convert to Legacy endpoint URL. - URI autodiscoverUrl = new URI(this.url.toString() + AutodiscoverLegacyPath); - return this.getLegacyUserSettingsAtUrl(cls, emailAddress, autodiscoverUrl); - } - - // If Domain is specified, figure out the endpoint Url and call service. - else if (!(this.domain == null || this.domain.isEmpty())) { - URI autodiscoverUrl = new URI(String.format(AutodiscoverLegacyHttpsUrl, this.domain)); - return this.getLegacyUserSettingsAtUrl(cls, - emailAddress, autodiscoverUrl); - } else { - // No Url or Domain specified, need to - //figure out which endpoint to use. - int currentHop = 1; - OutParam outParam = new OutParam(); - outParam.setParam(currentHop); - List redirectionEmailAddresses = new ArrayList(); - return this.internalGetLegacyUserSettings( - cls, - emailAddress, - redirectionEmailAddresses, - outParam); - } - } - - /** - * Calls the Autodiscover service to retrieve configuration settings. - * - * @param the generic type - * @param cls the cls - * @param emailAddress The email address to retrieve configuration settings for. - * @param currentHop Current number of redirection urls/addresses attempted so far. - * @return The requested configuration settings. - * @throws Exception the exception - */ - private - TSettings internalGetLegacyUserSettings( - Class cls, - String emailAddress, - List redirectionEmailAddresses, - OutParam currentHop) - throws Exception { - String domainName = EwsUtilities.domainFromEmailAddress(emailAddress); - - int scpUrlCount; - OutParam outParamInt = new OutParam(); - List urls = this.getAutodiscoverServiceUrls(domainName, outParamInt); - scpUrlCount = outParamInt.getParam(); - if (urls.size() == 0) { - throw new ServiceValidationException( - "This Autodiscover request requires that either the Domain or Url be specified."); - } - - // Assume caller is not inside the Intranet, regardless of whether SCP - // Urls - // were returned or not. SCP Urls are only relevent if one of them - // returns - // valid Autodiscover settings. - this.isExternal = true; - - int currentUrlIndex = 0; - - // Used to save exception for later reporting. - Exception delayedException = null; - TSettings settings; - - do { - URI autodiscoverUrl = urls.get(currentUrlIndex); - boolean isScpUrl = currentUrlIndex < scpUrlCount; - - try { - settings = this.getLegacyUserSettingsAtUrl(cls, - emailAddress, autodiscoverUrl); - - switch (settings.getResponseType()) { - case Success: - // Not external if Autodiscover endpoint found via SCP - // returned the settings. - if (isScpUrl) { - this.isExternal = false; - } - this.url = autodiscoverUrl; - return settings; - case RedirectUrl: - if (currentHop.getParam() < AutodiscoverMaxRedirections) { - currentHop.setParam(currentHop.getParam() + 1); - - this - .traceMessage( - TraceFlags.AutodiscoverResponse, - String - .format( - "Autodiscover " + - "service " + - "returned " + - "redirection URL '%s'.", - settings - .getRedirectTarget())); - - urls.add(currentUrlIndex, new URI( - settings.getRedirectTarget())); - - break; - } else { - throw new MaximumRedirectionHopsExceededException(); - } - case RedirectAddress: - if (currentHop.getParam() < AutodiscoverMaxRedirections) { - currentHop.setParam(currentHop.getParam() + 1); - - this - .traceMessage( - TraceFlags.AutodiscoverResponse, - String - .format( - "Autodiscover " + - "service " + - "returned " + - "redirection email " + - "address '%s'.", - settings - .getRedirectTarget())); - // Bug E14:255576 If this email address was already tried, we may have a loop - // in SCP lookups. Disable consideration of SCP records. - this.disableScpLookupIfDuplicateRedirection( - settings.getRedirectTarget(), - redirectionEmailAddresses); - - return this.internalGetLegacyUserSettings(cls, - settings.getRedirectTarget(), - redirectionEmailAddresses, - currentHop); - } else { - throw new MaximumRedirectionHopsExceededException(); - } - case Error: - // Don't treat errors from an SCP-based Autodiscover service - // to be conclusive. - // We'll try the next one and record the error for later. - if (isScpUrl) { - this - .traceMessage( - TraceFlags.AutodiscoverConfiguration, - "Error returned by " + - "Autodiscover service " + - "found via SCP, treating " + - "as inconclusive."); - - delayedException = new AutodiscoverRemoteException( - "The Autodiscover service returned an error.", settings.getError()); - currentUrlIndex++; - } else { - throw new AutodiscoverRemoteException("The Autodiscover service returned an error.", settings.getError()); - } - break; - default: - EwsUtilities - .ewsAssert(false, "Autodiscover.GetConfigurationSettings", - "An unexpected error has occured. This code path should never be reached."); - break; - } - } catch (XMLStreamException ex) { - this.traceMessage(TraceFlags.AutodiscoverConfiguration, String - .format("%s failed: XML parsing error: %s", url, ex - .getMessage())); - - // The content at the URL wasn't a valid response, let's try the - // next. - currentUrlIndex++; - } catch (IOException ex) { - this.traceMessage( - TraceFlags.AutodiscoverConfiguration, - String.format("%s failed: I/O error: %s", - url, ex.getMessage())); - - // The content at the URL wasn't a valid response, let's try the next. - currentUrlIndex++; - } catch (Exception ex) { - HttpWebRequest response = null; - URI redirectUrl; - OutParam outParam1 = new OutParam(); - if ((response != null) && - this.tryGetRedirectionResponse(response, outParam1)) { - redirectUrl = outParam1.getParam(); - this.traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format( - "Host returned a redirection to url %s", - redirectUrl.toString())); - - currentHop.setParam(currentHop.getParam() + 1); - urls.add(currentUrlIndex, redirectUrl); - } else { - if (response != null) { - this.processHttpErrorResponse(response, ex); - - } - - this.traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format("%s failed: %s (%s)", url, ex - .getClass().getName(), ex.getMessage())); - - // The url did not work, let's try the next. - currentUrlIndex++; - } - } - } while (currentUrlIndex < urls.size()); - - // If we got this far it's because none of the URLs we tried have - // worked. As a next-to-last chance, use GetRedirectUrl to - // try to get a redirection URL using an HTTP GET on a non-SSL - // Autodiscover endpoint. If successful, use this - // redirection URL to get the configuration settings for this email - // address. (This will be a common scenario for - // DataCenter deployments). - URI redirectionUrl = this.getRedirectUrl(domainName); - OutParam outParam = new OutParam(); - if ((redirectionUrl != null) - && this.tryLastChanceHostRedirection(cls, emailAddress, - redirectionUrl, outParam)) { - settings = outParam.getParam(); - return settings; - } else { - // Getting a redirection URL from an HTTP GET failed too. As a last - // chance, try to get an appropriate SRV Record - // using DnsQuery. If successful, use this redirection URL to get - // the configuration settings for this email address. - redirectionUrl = this.getRedirectionUrlFromDnsSrvRecord(domainName); - if ((redirectionUrl != null) - && this.tryLastChanceHostRedirection(cls, emailAddress, - redirectionUrl, outParam)) { - return outParam.getParam(); - } - - // If there was an earlier exception, throw it. - if (delayedException != null) { - throw delayedException; - } - - throw new AutodiscoverLocalException("The Autodiscover service couldn't be located."); - } - } - - /** - * Get an autodiscover SRV record in DNS and construct autodiscover URL. - * - * @param domainName Name of the domain. - * @return Autodiscover URL (may be null if lookup failed) - * @throws Exception the exception - */ - protected URI getRedirectionUrlFromDnsSrvRecord(String domainName) - throws Exception { - - this - .traceMessage( - TraceFlags.AutodiscoverConfiguration, - String - .format( - "Trying to get Autodiscover host " + - "from DNS SRV record for %s.", - domainName)); - - String hostname = this.dnsClient - .findAutodiscoverHostFromSrv(domainName); - if (!(hostname == null || hostname.isEmpty())) { - this - .traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format( - "Autodiscover host %s was returned.", - hostname)); - - return new URI(String.format(AutodiscoverLegacyHttpsUrl, - hostname)); - } else { - this.traceMessage(TraceFlags.AutodiscoverConfiguration, - "No matching Autodiscover DNS SRV records were found."); - - return null; - } - } - - /** - * Tries to get Autodiscover settings using redirection Url. - * - * @param the generic type - * @param cls the cls - * @param emailAddress The email address. - * @param redirectionUrl Redirection Url. - * @param settings The settings. - * @return boolean The boolean. - * @throws AutodiscoverLocalException the autodiscover local exception - * @throws AutodiscoverRemoteException the autodiscover remote exception - * @throws Exception the exception - */ - private boolean - tryLastChanceHostRedirection( - Class cls, String emailAddress, URI redirectionUrl, - OutParam settings) throws AutodiscoverLocalException, - AutodiscoverRemoteException, Exception { - List redirectionEmailAddresses = new ArrayList(); - - // Bug 60274: Performing a non-SSL HTTP GET to retrieve a redirection - // URL is potentially unsafe. We allow the caller - // to specify delegate to be called to determine whether we are allowed - // to use the redirection URL. - if (this - .callRedirectionUrlValidationCallback(redirectionUrl.toString())) { - for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) { - try { - settings.setParam(this.getLegacyUserSettingsAtUrl(cls, - emailAddress, redirectionUrl)); - - switch (settings.getParam().getResponseType()) { - case Success: - return true; - case Error: - throw new AutodiscoverRemoteException("The Autodiscover service returned an error.", settings.getParam() - .getError()); - case RedirectAddress: - // If this email address was already tried, - //we may have a loop - // in SCP lookups. Disable consideration of SCP records. - this.disableScpLookupIfDuplicateRedirection(settings.getParam().getRedirectTarget(), - redirectionEmailAddresses); - OutParam outParam = new OutParam(); - outParam.setParam(currentHop); - settings.setParam( - this.internalGetLegacyUserSettings(cls, - emailAddress, - redirectionEmailAddresses, - outParam)); - currentHop = outParam.getParam(); - return true; - case RedirectUrl: - try { - redirectionUrl = new URI(settings.getParam() - .getRedirectTarget()); - } catch (URISyntaxException ex) { - this - .traceMessage( - TraceFlags. - AutodiscoverConfiguration, - String - .format( - "Service " + - "returned " + - "invalid " + - "redirection " + - "URL %s", - settings - .getParam() - .getRedirectTarget())); - return false; - } - break; - default: - String failureMessage = String.format( - "Autodiscover call at %s failed with error %s, target %s", - redirectionUrl, - settings.getParam().getResponseType(), - settings.getParam().getRedirectTarget()); - this.traceMessage( - TraceFlags.AutodiscoverConfiguration, failureMessage); - - return false; - } - } catch (XMLStreamException ex) { - // If the response is malformed, it wasn't a valid - // Autodiscover endpoint. - this - .traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format( - "%s failed: XML parsing error: %s", - redirectionUrl.toString(), ex - .getMessage())); - return false; - } catch (IOException ex) { - this.traceMessage( - TraceFlags.AutodiscoverConfiguration, - String.format("%s failed: I/O error: %s", - redirectionUrl, ex.getMessage())); - return false; - } catch (Exception ex) { - // TODO: BUG response is always null - HttpWebRequest response = null; - OutParam outParam = new OutParam(); - if ((response != null) - && this.tryGetRedirectionResponse(response, - outParam)) { - redirectionUrl = outParam.getParam(); - this - .traceMessage( - TraceFlags.AutodiscoverConfiguration, - String - .format( - "Host returned a " + - "redirection" + - " to url %s", - redirectionUrl)); - - } else { - if (response != null) { - this.processHttpErrorResponse(response, ex); - } - - this - .traceMessage( - TraceFlags.AutodiscoverConfiguration, - String.format("%s failed: %s (%s)", - url, ex.getClass().getName(), - ex.getMessage())); - return false; - } - } - } - } - - return false; - } - - /** - * Disables SCP lookup if duplicate email address redirection. - * - * @param emailAddress The email address to use. - * @param redirectionEmailAddresses The list of prior redirection email addresses. - */ - private void disableScpLookupIfDuplicateRedirection( - String emailAddress, - List redirectionEmailAddresses) { - // SMTP addresses are case-insensitive so entries are converted to lower-case. - emailAddress = emailAddress.toLowerCase(); - - if (redirectionEmailAddresses.contains(emailAddress)) { - this.enableScpLookup = false; - } else { - redirectionEmailAddresses.add(emailAddress); - } - } - - /** - * Gets user settings from Autodiscover legacy endpoint. - * - * @param emailAddress The email address to use. - * @param requestedSettings The requested settings. - * @return GetUserSettingsResponse - * @throws Exception on error - */ - protected GetUserSettingsResponse internalGetLegacyUserSettings( - String emailAddress, - List requestedSettings) throws Exception { - // Cannot call legacy Autodiscover service with WindowsLive and other WSSecurity-based credential - if ((this.getCredentials() != null) && (this.getCredentials() instanceof WSSecurityBasedCredentials)) { - throw new AutodiscoverLocalException( - "WindowsLiveCredentials can't be used with this Autodiscover endpoint."); - } - - OutlookConfigurationSettings settings = this.getLegacyUserSettings( - OutlookConfigurationSettings.class, - emailAddress); - - - - return settings.convertSettings(emailAddress, requestedSettings); - } - - /** - * Calls the SOAP Autodiscover service - * for user settings for a single SMTP address. - * - * @param smtpAddress SMTP address. - * @param requestedSettings The requested settings. - * @return GetUserSettingsResponse - * @throws Exception on error - */ - protected GetUserSettingsResponse internalGetSoapUserSettings( - String smtpAddress, - List requestedSettings) throws Exception { - List smtpAddresses = new ArrayList(); - smtpAddresses.add(smtpAddress); - - List redirectionEmailAddresses = new ArrayList(); - redirectionEmailAddresses.add(smtpAddress.toLowerCase()); - - for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) { - GetUserSettingsResponse response = this.getUserSettings(smtpAddresses, - requestedSettings).getTResponseAtIndex(0); - - switch (response.getErrorCode()) { - case RedirectAddress: - this.traceMessage( - TraceFlags.AutodiscoverResponse, - String.format("Autodiscover service returned redirection email address '%s'.", - response.getRedirectTarget())); - - smtpAddresses.clear(); - smtpAddresses.add(response.getRedirectTarget(). - toLowerCase()); - this.url = null; - this.domain = null; - - // If this email address was already tried, - //we may have a loop - // in SCP lookups. Disable consideration of SCP records. - this.disableScpLookupIfDuplicateRedirection(response.getRedirectTarget(), - redirectionEmailAddresses); - break; - - case RedirectUrl: - this.traceMessage( - TraceFlags.AutodiscoverResponse, - String.format("Autodiscover service returned redirection URL '%s'.", - response.getRedirectTarget())); - - //this.url = new URI(response.getRedirectTarget()); - this.url = this.getCredentials().adjustUrl(new URI(response.getRedirectTarget())); - break; - - case NoError: - default: - return response; - } - } - - throw new AutodiscoverLocalException("The Autodiscover service couldn't be located."); - } - - /** - * Gets the user settings using Autodiscover SOAP service. - * - * @param smtpAddresses The SMTP addresses of the users. - * @param settings The settings. - * @return GetUserSettingsResponseCollection Object. - * @throws Exception the exception - */ - protected GetUserSettingsResponseCollection getUserSettings( - final List smtpAddresses, List settings) - throws Exception { - EwsUtilities.validateParam(smtpAddresses, "smtpAddresses"); - EwsUtilities.validateParam(settings, "settings"); - - return this.getSettings( - GetUserSettingsResponseCollection.class, UserSettingName.class, - smtpAddresses, settings, null, this, - new IFuncDelegate() { - public String func() throws FormatException { - return EwsUtilities - .domainFromEmailAddress(smtpAddresses.get(0)); - } - }); - } - - /** - * Gets user or domain settings using Autodiscover SOAP service. - * - * @param the generic type - * @param the generic type - * @param cls the cls - * @param cls1 the cls1 - * @param identities Either the domains or the SMTP addresses of the users. - * @param settings The settings. - * @param requestedVersion Requested version of the Exchange service. - * @param getSettingsMethod The method to use. - * @param getDomainMethod The method to calculate the domain value. - * @return TGetSettingsResponse Collection. - * @throws Exception the exception - */ - private - TGetSettingsResponseCollection getSettings( - Class cls, - Class cls1, - List identities, - List settings, - ExchangeVersion requestedVersion, - IFunctionDelegate, List, - TGetSettingsResponseCollection> getSettingsMethod, - IFuncDelegate getDomainMethod) throws Exception { - TGetSettingsResponseCollection response; - - // Autodiscover service only exists in E14 or later. - if (this.getRequestedServerVersion().compareTo( - MinimumRequestVersionForAutoDiscoverSoapService) < 0) { - throw new ServiceVersionException(String.format( - "The Autodiscover service only supports %s or a later version.", - MinimumRequestVersionForAutoDiscoverSoapService)); - } - - // If Url is specified, call service directly. - if (this.url != null) { - URI autodiscoverUrl = this.url; - response = getSettingsMethod.func(identities, settings, - requestedVersion, this.url); - this.url = autodiscoverUrl; - return response; - } - // If Domain is specified, determine endpoint Url and call service. - else if (!(this.domain == null || this.domain.isEmpty())) { - URI autodiscoverUrl = this.getAutodiscoverEndpointUrl(this.domain); - response = getSettingsMethod.func(identities, settings, - requestedVersion, - autodiscoverUrl); - - // If we got this far, response was successful, set Url. - this.url = autodiscoverUrl; - return response; - } - // No Url or Domain specified, need to figure out which endpoint(s) to - // try. - else { - // Assume caller is not inside the Intranet, regardless of whether - // SCP Urls - // were returned or not. SCP Urls are only relevent if one of them - // returns - // valid Autodiscover settings. - this.isExternal = true; - - URI autodiscoverUrl; - - String domainName = getDomainMethod.func(); - int scpHostCount; - OutParam outParam = new OutParam(); - List hosts = this.getAutodiscoverServiceHosts(domainName, - outParam); - scpHostCount = outParam.getParam(); - if (hosts.size() == 0) { - throw new ServiceValidationException( - "This Autodiscover request requires that either the Domain or Url be specified."); - } - - for (int currentHostIndex = 0; currentHostIndex < hosts.size(); currentHostIndex++) { - String host = hosts.get(currentHostIndex); - boolean isScpHost = currentHostIndex < scpHostCount; - OutParam outParams = new OutParam(); - if (this.tryGetAutodiscoverEndpointUrl(host, outParams)) { - autodiscoverUrl = outParams.getParam(); - response = getSettingsMethod.func(identities, settings, - requestedVersion, - autodiscoverUrl); - - // If we got this far, the response was successful, set Url. - this.url = autodiscoverUrl; - - // Not external if Autodiscover endpoint found via SCP - // returned the settings. - if (isScpHost) { - this.isExternal = false; - } - - return response; - } - } - - // Next-to-last chance: try unauthenticated GET over HTTP to be - // redirected to appropriate service endpoint. - autodiscoverUrl = this.getRedirectUrl(domainName); - OutParam outParamUrl = new OutParam(); - if ((autodiscoverUrl != null) && - this - .callRedirectionUrlValidationCallback( - autodiscoverUrl.toString()) && - this.tryGetAutodiscoverEndpointUrl(autodiscoverUrl - .getHost(), outParamUrl)) { - autodiscoverUrl = outParamUrl.getParam(); - response = getSettingsMethod.func(identities, settings, - requestedVersion, - autodiscoverUrl); - - // If we got this far, the response was successful, set Url. - this.url = autodiscoverUrl; - - return response; - } - - // Last Chance: try to read autodiscover SRV Record from DNS. If we - // find one, use - // the hostname returned to construct an Autodiscover endpoint URL. - autodiscoverUrl = this - .getRedirectionUrlFromDnsSrvRecord(domainName); - if ((autodiscoverUrl != null) && - this - .callRedirectionUrlValidationCallback( - autodiscoverUrl.toString()) && - this.tryGetAutodiscoverEndpointUrl(autodiscoverUrl - .getHost(), outParamUrl)) { - autodiscoverUrl = outParamUrl.getParam(); - response = getSettingsMethod.func(identities, settings, - requestedVersion, - autodiscoverUrl); - - // If we got this far, the response was successful, set Url. - this.url = autodiscoverUrl; - - return response; - } else { - throw new AutodiscoverLocalException("The Autodiscover service couldn't be located."); - } - } - } - - /** - * Gets settings for one or more users. - * - * @param smtpAddresses The SMTP addresses of the users. - * @param settings The settings. - * @param requestedVersion Requested version of the Exchange service. - * @param autodiscoverUrl The autodiscover URL. - * @return GetUserSettingsResponse collection. - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - private GetUserSettingsResponseCollection internalGetUserSettings( - List smtpAddresses, List settings, - ExchangeVersion requestedVersion, - URI autodiscoverUrl) throws ServiceLocalException, Exception { - // The response to GetUserSettings can be a redirection. Execute - // GetUserSettings until we get back - // a valid response or we've followed too many redirections. - for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) { - GetUserSettingsRequest request = new GetUserSettingsRequest(this, - autodiscoverUrl); - request.setSmtpAddresses(smtpAddresses); - request.setSettings(settings); - GetUserSettingsResponseCollection response = request.execute(); - - // Did we get redirected? - if (response.getErrorCode() == AutodiscoverErrorCode.RedirectUrl - && response.getRedirectionUrl() != null) { - this.traceMessage( - TraceFlags.AutodiscoverConfiguration, - String.format("Request to %s returned redirection to %s", - autodiscoverUrl.toString(), response.getRedirectionUrl())); - - autodiscoverUrl = response.getRedirectionUrl(); - } else { - return response; - } - } - - this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format( - "Maximum number of redirection hops %d exceeded", - AutodiscoverMaxRedirections)); - - throw new MaximumRedirectionHopsExceededException(); - } - - /** - * Gets the domain settings using Autodiscover SOAP service. - * - * @param domains The domains. - * @param settings The settings. - * @param requestedVersion Requested version of the Exchange service. - * @return GetDomainSettingsResponse collection. - * @throws Exception the exception - */ - protected GetDomainSettingsResponseCollection getDomainSettings( - final List domains, List settings, - ExchangeVersion requestedVersion) - throws Exception { - EwsUtilities.validateParam(domains, "domains"); - EwsUtilities.validateParam(settings, "settings"); - - return this.getSettings( - GetDomainSettingsResponseCollection.class, - DomainSettingName.class, domains, settings, - requestedVersion, this, - new IFuncDelegate() { - public String func() { - return domains.get(0); - } - }); - } - - /** - * Gets settings for one or more domains. - * - * @param domains The domains. - * @param settings The settings. - * @param requestedVersion Requested version of the Exchange service. - * @param autodiscoverUrl The autodiscover URL. - * @return GetDomainSettingsResponse Collection. - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - private GetDomainSettingsResponseCollection internalGetDomainSettings( - List domains, List settings, - ExchangeVersion requestedVersion, - URI autodiscoverUrl) throws ServiceLocalException, Exception { - // The response to GetDomainSettings can be a redirection. Execute - // GetDomainSettings until we get back - // a valid response or we've followed too many redirections. - for (int currentHop = 0; currentHop < AutodiscoverService.AutodiscoverMaxRedirections; currentHop++) { - GetDomainSettingsRequest request = new GetDomainSettingsRequest( - this, autodiscoverUrl); - request.setDomains(domains); - request.setSettings(settings); - request.setRequestedVersion(requestedVersion); - GetDomainSettingsResponseCollection response = request.execute(); - - // Did we get redirected? - if (response.getErrorCode() == AutodiscoverErrorCode.RedirectUrl - && response.getRedirectionUrl() != null) { - autodiscoverUrl = response.getRedirectionUrl(); - } else { - return response; - } - } - - this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format( - "Maximum number of redirection hops %d exceeded", - AutodiscoverMaxRedirections)); - - throw new MaximumRedirectionHopsExceededException(); - } - - /** - * Gets the autodiscover endpoint URL. - * - * @param host The host. - * @return URI The URI. - * @throws Exception the exception - */ - private URI getAutodiscoverEndpointUrl(String host) throws Exception { - URI autodiscoverUrl = null; - OutParam outParam = new OutParam(); - if (this.tryGetAutodiscoverEndpointUrl(host, outParam)) { - return autodiscoverUrl; - } else { - throw new AutodiscoverLocalException( - "No appropriate Autodiscover SOAP or WS-Security endpoint is available."); - } - } - - /** - * Tries the get Autodiscover Service endpoint URL. - * - * @param host The host. - * @param url the url - * @return boolean The boolean. - * @throws Exception the exception - */ - private boolean tryGetAutodiscoverEndpointUrl(String host, - OutParam url) - throws Exception { - EnumSet endpoints; - OutParam> outParam = - new OutParam>(); - if (this.tryGetEnabledEndpointsForHost(host, outParam)) { - endpoints = outParam.getParam(); - url - .setParam(new URI(String.format(AutodiscoverSoapHttpsUrl, - host))); - - // Make sure that at least one of the non-legacy endpoints is - // available. - if ((!endpoints.contains(AutodiscoverEndpoints.Soap)) && - (!endpoints.contains( - AutodiscoverEndpoints.WsSecurity)) - // (endpoints .contains( AutodiscoverEndpoints.WSSecuritySymmetricKey) ) && - //(endpoints .contains( AutodiscoverEndpoints.WSSecurityX509Cert)) - ) { - this - .traceMessage( - TraceFlags.AutodiscoverConfiguration, - String - .format( - "No Autodiscover endpoints " + - "are available for host %s", - host)); - - return false; - } - - // If we have WLID credential, make sure that we have a WS-Security - // endpoint - /* - if (this.getCredentials() instanceof WindowsLiveCredentials) { - if (endpoints.contains(AutodiscoverEndpoints.WsSecurity)) { - this - .traceMessage( - TraceFlags.AutodiscoverConfiguration, - String - .format( - "No Autodiscover " + - "WS-Security " + - "endpoint is available" + - " for host %s", - host)); - - return false; - } else { - url.setParam(new URI(String.format( - AutodiscoverSoapWsSecurityHttpsUrl, host))); - } - } - else if (this.getCredentials() instanceof PartnerTokenCredentials) - { - if (endpoints.contains( AutodiscoverEndpoints.WSSecuritySymmetricKey)) - { - this.traceMessage( - TraceFlags.AutodiscoverConfiguration, - String.format("No Autodiscover WS-Security/SymmetricKey endpoint is available for host {0}", host)); - - return false; - } - else - { - url.setParam( new URI(String.format(AutodiscoverSoapWsSecuritySymmetricKeyHttpsUrl, host))); - } - } - else if (this.getCredentials()instanceof X509CertificateCredentials) - { - if ((endpoints.contains(AutodiscoverEndpoints.WSSecurityX509Cert)) - { - this.traceMessage( - TraceFlags.AutodiscoverConfiguration, - String.format("No Autodiscover WS-Security/X509Cert endpoint is available for host {0}", host)); - - return false; - } - else - { - url.setParam( new URI(String.format(AutodiscoverSoapWsSecurityX509CertHttpsUrl, host))); - } - } - */ - return true; - - - } else { - this - .traceMessage( - TraceFlags.AutodiscoverConfiguration, - String - .format( - "No Autodiscover endpoints " + - "are available for host %s", - host)); - - return false; - } - } - - /** - * Gets the list of autodiscover service URLs. - * - * @param domainName Domain name. - * @param scpHostCount Count of hosts found via SCP lookup. - * @return List of Autodiscover URLs. - * @throws java.net.URISyntaxException the URI Syntax exception - */ - protected List getAutodiscoverServiceUrls(String domainName, - OutParam scpHostCount) throws URISyntaxException { - List urls; - - urls = new ArrayList(); - - scpHostCount.setParam(urls.size()); - - // As a fallback, add autodiscover URLs base on the domain name. - urls.add(new URI(String.format(AutodiscoverLegacyHttpsUrl, - domainName))); - urls.add(new URI(String.format(AutodiscoverLegacyHttpsUrl, - "autodiscover." + domainName))); - - return urls; - } - - /** - * Gets the list of autodiscover service hosts. - * - * @param domainName Domain name. - * @param outParam the out param - * @return List of hosts. - * @throws java.net.URISyntaxException the uRI syntax exception - * @throws ClassNotFoundException the class not found exception - */ - protected List getAutodiscoverServiceHosts(String domainName, - OutParam outParam) throws URISyntaxException, - ClassNotFoundException { - - List urls = this.getAutodiscoverServiceUrls(domainName, outParam); - List lst = new ArrayList(); - for (URI url : urls) { - lst.add(url.getHost()); - } - return lst; - } - - /** - * Gets the enabled autodiscover endpoints on a specific host. - * - * @param host The host. - * @param endpoints Endpoints found for host. - * @return Flags indicating which endpoints are enabled. - * @throws Exception the exception - */ - private boolean tryGetEnabledEndpointsForHost(String host, - OutParam> endpoints) throws Exception { - this.traceMessage(TraceFlags.AutodiscoverConfiguration, String.format( - "Determining which endpoints are enabled for host %s", host)); - - // We may get redirected to another host. And therefore need to limit the number of redirections we'll - // tolerate. - for (int currentHop = 0; currentHop < AutodiscoverMaxRedirections; currentHop++) { - URI autoDiscoverUrl = new URI(String.format(AutodiscoverLegacyHttpsUrl, host)); - - endpoints.setParam(EnumSet.of(AutodiscoverEndpoints.None)); - - HttpWebRequest request = null; - try { - request = new HttpClientWebRequest(httpClient, httpContext); - request.setProxy(getWebProxy()); - - try { - request.setUrl(autoDiscoverUrl.toURL()); - } catch (MalformedURLException e) { - String strErr = String.format("Incorrect format : %s", url); - throw new ServiceLocalException(strErr); - } - - request.setRequestMethod("GET"); - request.setAllowAutoRedirect(false); - request.setPreAuthenticate(false); - request.setUseDefaultCredentials(this.getUseDefaultCredentials()); - request.setTimeout(getTimeout()); - - prepareCredentials(request); - - request.prepareConnection(); - try { - request.executeRequest(); - } catch (IOException e) { - return false; - } - - OutParam outParam = new OutParam(); - if (this.tryGetRedirectionResponse(request, outParam)) { - URI redirectUrl = outParam.getParam(); - this.traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format("Host returned redirection to host '%s'", redirectUrl.getHost())); - - host = redirectUrl.getHost(); - } else { - endpoints.setParam(this.getEndpointsFromHttpWebResponse(request)); - - this.traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format("Host returned enabled endpoint flags: %s", endpoints.getParam().toString())); - - return true; - } - } finally { - if (request != null) { - try { - request.close(); - } catch (Exception e) { - // Connection can't be closed. We'll ignore this... - } - } - } - } - - this.traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format("Maximum number of redirection hops %d exceeded", AutodiscoverMaxRedirections)); - - throw new MaximumRedirectionHopsExceededException(); - } - - /** - * Gets the endpoints from HTTP web response. - * - * @param request the request - * @return Endpoints enabled. - * @throws EWSHttpException the EWS http exception - */ - private EnumSet getEndpointsFromHttpWebResponse( - HttpWebRequest request) throws EWSHttpException { - EnumSet endpoints = EnumSet - .noneOf(AutodiscoverEndpoints.class); - endpoints.add(AutodiscoverEndpoints.Legacy); - - if (!(request.getResponseHeaders().get( - AutodiscoverSoapEnabledHeaderName) == null || request - .getResponseHeaders().get(AutodiscoverSoapEnabledHeaderName) - .isEmpty())) { - endpoints.add(AutodiscoverEndpoints.Soap); - } - if (!(request.getResponseHeaders().get( - AutodiscoverWsSecurityEnabledHeaderName) == null || request - .getResponseHeaders().get( - AutodiscoverWsSecurityEnabledHeaderName).isEmpty())) { - endpoints.add(AutodiscoverEndpoints.WsSecurity); - } - - /* if (! (request.getResponseHeaders().get( - AutodiscoverWsSecuritySymmetricKeyEnabledHeaderName) !=null || request - .getResponseHeaders().get( - AutodiscoverWsSecuritySymmetricKeyEnabledHeaderName).isEmpty())) - { - endpoints .add( AutodiscoverEndpoints.WSSecuritySymmetricKey); - } - if (!(request.getResponseHeaders().get( - AutodiscoverWsSecurityX509CertEnabledHeaderName)!=null || - request.getResponseHeaders().get( - AutodiscoverWsSecurityX509CertEnabledHeaderName).isEmpty())) - - { - endpoints .add(AutodiscoverEndpoints.WSSecurityX509Cert); - }*/ - - return endpoints; - } - - /** - * Traces the response. - * - * @param request the request - * @param memoryStream the memory stream - * @throws XMLStreamException the XML stream exception - * @throws IOException signals that an I/O exception has occurred. - * @throws EWSHttpException the EWS http exception - */ - public void traceResponse(HttpWebRequest request, ByteArrayOutputStream memoryStream) throws XMLStreamException, - IOException, EWSHttpException { - this.processHttpResponseHeaders( - TraceFlags.AutodiscoverResponseHttpHeaders, request); - String contentType = request.getResponseContentType(); - if (!(contentType == null || contentType.isEmpty())) { - contentType = contentType.toLowerCase(); - if (contentType.toLowerCase().startsWith("text/") || - contentType.toLowerCase(). - startsWith("application/soap")) { - this.traceXml(TraceFlags.AutodiscoverResponse, memoryStream); - } else { - this.traceMessage(TraceFlags.AutodiscoverResponse, - "Non-textual response"); - } - } - } - - /** - * Creates an HttpWebRequest instance and initializes it with the - * appropriate parameters, based on the configuration of this service - * object. - * - * @param url The URL that the HttpWebRequest should target - * @return HttpWebRequest The HttpWebRequest - * @throws ServiceLocalException the service local exception - * @throws java.net.URISyntaxException the uRI syntax exception - */ - public HttpWebRequest prepareHttpWebRequestForUrl(URI url) - throws ServiceLocalException, URISyntaxException { - return this.prepareHttpWebRequestForUrl(url, false, - // acceptGzipEncoding - false); // allowAutoRedirect - } - - /** - * Calls the redirection URL validation callback. If the redirection URL - * validation callback is null, use the default callback which does not - * allow following any redirections. - * - * @param redirectionUrl The redirection URL. - * @return True if redirection should be followed. - * @throws AutodiscoverLocalException the autodiscover local exception - */ - private boolean callRedirectionUrlValidationCallback(String redirectionUrl) - throws AutodiscoverLocalException { - IAutodiscoverRedirectionUrl callback = - (this.redirectionUrlValidationCallback == null) ? this - : this.redirectionUrlValidationCallback; - return callback - .autodiscoverRedirectionUrlValidationCallback(redirectionUrl); - } - - /** - * Processes an HTTP error response. - * - * @param httpWebResponse The HTTP web response. - * @throws Exception the exception - */ - @Override public void processHttpErrorResponse(HttpWebRequest httpWebResponse, Exception webException) throws Exception { - this.internalProcessHttpErrorResponse( - httpWebResponse, - webException, - TraceFlags.AutodiscoverResponseHttpHeaders, - TraceFlags.AutodiscoverResponse); - } - - /* - * (non-Javadoc) - * - * @see microsoft.exchange.webservices.AutodiscoverRedirectionUrlInterface# - * autodiscoverRedirectionUrlValidationCallback(java.lang.String) - */ - public boolean autodiscoverRedirectionUrlValidationCallback( - String redirectionUrl) throws AutodiscoverLocalException { - return defaultAutodiscoverRedirectionUrlValidationCallback( - redirectionUrl); - } - - /** - * Initializes a new instance of the "AutodiscoverService" class. - * - * @throws ArgumentException on validation error - */ - public AutodiscoverService() throws ArgumentException { - this(ExchangeVersion.Exchange2010); - } - - /** - * Initializes a new instance of the "AutodiscoverService" class. - * - * @param requestedServerVersion The requested server version - * @throws ArgumentException on validation error - */ - public AutodiscoverService(ExchangeVersion requestedServerVersion) - throws ArgumentException { - this(null, null, requestedServerVersion); - } - - /** - * Initializes a new instance of the "AutodiscoverService" class. - * - * @param domain The domain that will be used to determine the URL of the service - * @throws ArgumentException on validation error - */ - public AutodiscoverService(String domain) throws ArgumentException { - this(null, domain); - } - - /** - * Initializes a new instance of the "AutodiscoverService" class. - * - * @param domain The domain that will be used to determine the URL of the service - * @param requestedServerVersion The requested server version - * @throws ArgumentException on validation error - */ - public AutodiscoverService(String domain, - ExchangeVersion requestedServerVersion) throws ArgumentException { - this(null, domain, requestedServerVersion); - } - - /** - * Initializes a new instance of the "AutodiscoverService" class. - * - * @param url The URL of the service - * @throws ArgumentException on validation error - */ - public AutodiscoverService(URI url) throws ArgumentException { - this(url, url.getHost()); - } - - /** - * Initializes a new instance of the "AutodiscoverService" class. - * - * @param url The URL of the service - * @param requestedServerVersion The requested server version - * @throws ArgumentException on validation error - */ - public AutodiscoverService(URI url, - ExchangeVersion requestedServerVersion) throws ArgumentException { - this(url, url.getHost(), requestedServerVersion); - } - - /** - * Initializes a new instance of the "AutodiscoverService" class. - * - * @param url The URL of the service - * @param domain The domain that will be used to determine the URL of the service - * @throws ArgumentException on validation error - */ - public AutodiscoverService(URI url, String domain) - throws ArgumentException { - super(); - EwsUtilities.validateDomainNameAllowNull(domain, "domain"); - this.url = url; - this.domain = domain; - this.dnsClient = new AutodiscoverDnsClient(this); - } - - /** - * Initializes a new instance of the "AutodiscoverService" class. - * - * @param url The URL of the service. - * @param domain The domain that will be used to determine the URL of the - * service. - * @param requestedServerVersion The requested server version. - * @throws ArgumentException on validation error - */ - public AutodiscoverService(URI url, String domain, - ExchangeVersion requestedServerVersion) throws ArgumentException { - super(requestedServerVersion); - EwsUtilities.validateDomainNameAllowNull(domain, "domain"); - - this.url = url; - this.domain = domain; - this.dnsClient = new AutodiscoverDnsClient(this); - } - - /** - * Initializes a new instance of the AutodiscoverService class. - * - * @param service The other service. - * @param requestedServerVersion The requested server version. - */ - public AutodiscoverService(ExchangeServiceBase service, - ExchangeVersion requestedServerVersion) { - super(service, requestedServerVersion); - this.dnsClient = new AutodiscoverDnsClient(this); - } - - /** - * Initializes a new instance of the "AutodiscoverService" class. - * - * @param service The service. - */ - public AutodiscoverService(ExchangeServiceBase service) { - super(service, service.getRequestedServerVersion()); - } - - /** - * Retrieves the specified settings for single SMTP address. - *

This method will run the entire Autodiscover "discovery" - * algorithm and will follow address and URL redirections.

- - * @param userSmtpAddress The SMTP addresses of the user. - * @param userSettingNames The user setting names. - * @return A UserResponse object containing the requested settings for the - * specified user. - * @throws Exception on error - */ - public GetUserSettingsResponse getUserSettings(String userSmtpAddress, - UserSettingName... userSettingNames) throws Exception { - List requestedSettings = new ArrayList(); - requestedSettings.addAll(Arrays.asList(userSettingNames)); - - if (userSmtpAddress == null || userSmtpAddress.isEmpty()) { - throw new ServiceValidationException("A valid SMTP address must be specified."); - } - - if (requestedSettings.size() == 0) { - throw new ServiceValidationException("At least one setting must be requested."); - } - - if (this.getRequestedServerVersion().compareTo(MinimumRequestVersionForAutoDiscoverSoapService) < 0) { - return this.internalGetLegacyUserSettings(userSmtpAddress, - requestedSettings); - } else { - return this.internalGetSoapUserSettings(userSmtpAddress, - requestedSettings); - } - - } - - /** - * Retrieves the specified settings for a set of users. - * - * @param userSmtpAddresses the user smtp addresses - * @param userSettingNames The user setting names. - * @return A GetUserSettingsResponseCollection object containing the - * response for each individual user. - * @throws Exception the exception - */ - public GetUserSettingsResponseCollection getUsersSettings( - Iterable userSmtpAddresses, - UserSettingName... userSettingNames) throws Exception { - if (this.getRequestedServerVersion().compareTo(MinimumRequestVersionForAutoDiscoverSoapService) < 0) { - throw new ServiceVersionException( - String.format("The Autodiscover service only supports %s or a later version.", - MinimumRequestVersionForAutoDiscoverSoapService)); - } - List smtpAddresses = new ArrayList(); - smtpAddresses.addAll((Collection) userSmtpAddresses); - List settings = new ArrayList(); - settings.addAll(Arrays.asList(userSettingNames)); - return this.getUserSettings(smtpAddresses, settings); - } - - /** - * Retrieves the specified settings for a domain. - * - * @param domain The domain. - * @param requestedVersion Requested version of the Exchange service. - * @param domainSettingNames The domain setting names. - * @return A DomainResponse object containing the requested settings for the - * specified domain. - * @throws Exception the exception - */ - public GetDomainSettingsResponse getDomainSettings(String domain, - ExchangeVersion requestedVersion, - DomainSettingName... domainSettingNames) throws Exception { - List domains = new ArrayList(1); - domains.add(domain); - - List settings = new ArrayList(); - settings.addAll(Arrays.asList(domainSettingNames)); - - return this.getDomainSettings(domains, settings, requestedVersion). - getTResponseAtIndex(0); - } - - /** - * Retrieves the specified settings for a set of domains. - * - * @param domains the domains - * @param requestedVersion Requested version of the Exchange service. - * @param domainSettingNames The domain setting names. - * @return A GetDomainSettingsResponseCollection object containing the - * response for each individual domain. - * @throws Exception the exception - */ - public GetDomainSettingsResponseCollection getDomainSettings( - Iterable domains, ExchangeVersion requestedVersion, - DomainSettingName... domainSettingNames) - throws Exception { - List settings = new ArrayList(); - settings.addAll(Arrays.asList(domainSettingNames)); - - List domainslst = new ArrayList(); - domainslst.addAll((Collection) domains); - - return this.getDomainSettings(domainslst, settings, requestedVersion); - } - - /** - * Gets the domain this service is bound to. When this property is - * set, the domain name is used to automatically determine the Autodiscover service URL. - * - * @return the domain - */ - public String getDomain() { - return this.domain; - } - - /** - * Sets the domain this service is bound to. When this property is - * set, the domain - * name is used to automatically determine the Autodiscover service URL. - * - * @param value the new domain - * @throws ArgumentException on validation error - */ - public void setDomain(String value) throws ArgumentException { - EwsUtilities.validateDomainNameAllowNull(value, "Domain"); - - // If Domain property is set to non-null value, Url property is nulled. - if (value != null) { - this.url = null; - } - this.domain = value; - } - - /** - * Gets the url this service is bound to. - * - * @return the url - */ - public URI getUrl() { - return this.url; - } - - /** - * Sets the url this service is bound to. - * - * @param value the new url - */ - public void setUrl(URI value) { - // If Url property is set to non-null value, Domain property is set to - // host portion of Url. - if (value != null) { - this.domain = value.getHost(); - } - this.url = value; - } - - public Boolean isExternal() { - return this.isExternal; - } - - protected void setIsExternal(Boolean value) { - this.isExternal = value; - } - - - /** - * Gets the redirection url validation callback. - * - * @return the redirection url validation callback - */ - public IAutodiscoverRedirectionUrl - getRedirectionUrlValidationCallback() { - return this.redirectionUrlValidationCallback; - } - - /** - * Sets the redirection url validation callback. - * - * @param value the new redirection url validation callback - */ - public void setRedirectionUrlValidationCallback( - IAutodiscoverRedirectionUrl value) { - this.redirectionUrlValidationCallback = value; - } - - /** - * Gets the dns server address. - * - * @return the dns server address - */ - protected String getDnsServerAddress() { - return this.dnsServerAddress; - } - - /** - * Sets the dns server address. - * - * @param value the new dns server address - */ - protected void setDnsServerAddress(String value) { - this.dnsServerAddress = value; - } - - /** - * Gets a value indicating whether the AutodiscoverService should - * perform SCP (ServiceConnectionPoint) record lookup when determining - * the Autodiscover service URL. - * - * @return the enable scp lookup - */ - public boolean getEnableScpLookup() { - return this.enableScpLookup; - } - - /** - * Sets the enable scp lookup. - * - * @param value the new enable scp lookup - */ - public void setEnableScpLookup(boolean value) { - this.enableScpLookup = value; - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.FuncDelegateInterface#func(java.util.List, - * java.util.List, java.net.URI) - */ - @Override - public Object func(List arg1, List arg2, ExchangeVersion arg3, URI arg4) - throws ServiceLocalException, Exception { - if (arg2.get(0).getClass().equals(DomainSettingName.class)) { - return internalGetDomainSettings(arg1, arg2, arg3, arg4); - } else if (arg2.get(0).getClass().equals(UserSettingName.class)) { - return internalGetUserSettings(arg1, arg2, arg3, arg4); - } else { - return null; - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/IAutodiscoverRedirectionUrl.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/IAutodiscoverRedirectionUrl.java deleted file mode 100644 index d4001f665..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/IAutodiscoverRedirectionUrl.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover; - -import microsoft.exchange.webservices.data.autodiscover.exception.AutodiscoverLocalException; - -/** - * Defines a delegate that is used by the AutodiscoverService to ask whether a - * redirectionUrl can be used. - */ -public interface IAutodiscoverRedirectionUrl { - - /** - * Autodiscover redirection url validation callback. - * - * @param redirectionUrl the redirection url - * @return true, if successful - * @throws AutodiscoverLocalException the autodiscover local exception - */ - boolean autodiscoverRedirectionUrlValidationCallback( - String redirectionUrl) throws AutodiscoverLocalException; -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/ProtocolConnection.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/ProtocolConnection.java deleted file mode 100644 index 2e7163d97..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/ProtocolConnection.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover; - -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -/** - * Represents the email Protocol connection settings for pop/imap/smtp - * protocols. - */ -public final class ProtocolConnection { - - /** - * The encryption method. - */ - private String encryptionMethod; - - /** - * The hostname. - */ - private String hostname; - - /** - * The port. - */ - private int port; - - /** - * Initializes a new instance of the {@link ProtocolConnection} class. - */ - - protected ProtocolConnection() { - } - - /** - * Read user setting with ProtocolConnection value. - * - * @param reader EwsServiceXmlReader - * @return the protocol connection - * @throws Exception the exception - */ - protected static ProtocolConnection loadFromXml(EwsXmlReader reader) - throws Exception { - ProtocolConnection connection = new ProtocolConnection(); - - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals( - XmlElementNames.EncryptionMethod)) { - connection.setEncryptionMethod(reader - .readElementValue(String.class)); - } else if (reader.getLocalName().equals( - XmlElementNames.Hostname)) { - connection.setHostname(reader - .readElementValue(String.class)); - } else if (reader.getLocalName().equals(XmlElementNames.Port)) { - connection.setPort(reader.readElementValue(int.class)); - } - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.ProtocolConnection)); - - return connection; - } - - /** - * Initializes a new instance of the ProtocolConnection class. - * - * @param encryptionMethod The encryption method. - * @param hostname The hostname. - * @param port The port number to use for the portocol. - */ - protected ProtocolConnection(String encryptionMethod, String hostname, - int port) { - this.encryptionMethod = encryptionMethod; - this.hostname = hostname; - this.port = port; - } - - /** - * Gets the encryption method. - * - * @return The encryption method. - */ - public String getEncryptionMethod() { - return this.encryptionMethod; - } - - /** - * Sets the encryption method. - * - * @param value the new encryption method - */ - public void setEncryptionMethod(String value) { - this.encryptionMethod = value; - } - - /** - * Gets the hostname. - * - * @return The hostname. - */ - public String getHostname() { - return this.hostname; - - } - - /** - * Sets the hostname. - * - * @param value the new hostname - */ - public void setHostname(String value) { - this.hostname = value; - } - - /** - * Gets the port number. - * - * @return The port number. - */ - public int getPort() { - return this.port; - } - - /** - * Sets the port. - * - * @param value the new port - */ - public void setPort(int value) { - this.port = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/ProtocolConnectionCollection.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/ProtocolConnectionCollection.java deleted file mode 100644 index 978fae3cd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/ProtocolConnectionCollection.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover; - -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.ArrayList; - -/** - * Represents a user setting that is a collection of protocol connection. - */ -public final class ProtocolConnectionCollection { - - /** - * The connections. - */ - private ArrayList connections; - - /** - * Initializes a new instance of the class. - */ - ProtocolConnectionCollection() { - this.connections = new ArrayList(); - } - - /** - * Read user setting with ProtocolConnectionCollection value. - * - * @param reader EwsServiceXmlReader - * @return the protocol connection collection - * @throws Exception the exception - */ - public static ProtocolConnectionCollection loadFromXml(final EwsXmlReader reader) - throws Exception { - final ProtocolConnectionCollection value = new ProtocolConnectionCollection(); - - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals(XmlElementNames.ProtocolConnection)) { - final ProtocolConnection connection = ProtocolConnection.loadFromXml(reader); - if (connection != null) { - value.getConnections().add(connection); - } - } - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.ProtocolConnections)); - - return value; - } - - /** - * Gets the Connections. - * - * @return the connections - */ - public ArrayList getConnections() { - return this.connections; - } - - /** - * Sets the connections. - * - * @param value the new connections - */ - void setConnections(ArrayList value) { - this.connections = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/WebClientUrl.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/WebClientUrl.java deleted file mode 100644 index c415bcdd0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/WebClientUrl.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover; - -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -/** - * Represents the URL of the Exchange web client. - */ -public final class WebClientUrl { - - /** - * The authentication methods. - */ - private String authenticationMethods; - - /** - * The url. - */ - private String url; - - /** - * Initializes a new instance of the class. - */ - private WebClientUrl() { - } - - /** - * Initializes a new instance of the WebClientUrl class. - * - * @param authenticationMethods The authentication methods. - * @param url The URL. - */ - public WebClientUrl(String authenticationMethods, String url) { - this.authenticationMethods = authenticationMethods; - this.url = url; - } - - - /** - * Loads WebClientUrl instance from XML. - * - * @param reader The reader. - * @return WebClientUrl. - * @throws Exception the exception - */ - protected static WebClientUrl loadFromXml(EwsXmlReader reader) - throws Exception { - WebClientUrl webClientUrl = new WebClientUrl(); - - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals( - XmlElementNames.AuthenticationMethods)) { - webClientUrl.setAuthenticationMethods(reader - .readElementValue(String.class)); - } else if (reader.getLocalName().equals(XmlElementNames.Url)) { - webClientUrl.setUrl(reader.readElementValue(String.class)); - } - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.WebClientUrl)); - - return webClientUrl; - } - - /** - * Gets the authentication methods. - * - * @return the authentication methods - */ - public String getAuthenticationMethods() { - return this.authenticationMethods; - } - - /** - * Sets the authentication methods. - * - * @param value the new authentication methods - */ - protected void setAuthenticationMethods(String value) { - this.authenticationMethods = value; - } - - /** - * Gets the URL. - * - * @return the url - */ - public String getUrl() { - return this.url; - } - - /** - * Sets the url. - * - * @param value the new url - */ - protected void setUrl(String value) { - this.url = value; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/WebClientUrlCollection.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/WebClientUrlCollection.java deleted file mode 100644 index 143bb8971..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/WebClientUrlCollection.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover; - -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.ArrayList; - -/** - * Represents a user setting that is a collection of Exchange web client URLs. - */ -public final class WebClientUrlCollection { - - /** - * The urls. - */ - private ArrayList urls; - - /** - * Initializes a new instance of the {@link WebClientUrlCollection} class. - */ - public WebClientUrlCollection() { - this.urls = new ArrayList(); - } - - /** - * Loads instance of WebClientUrlCollection from XML. - * - * @param reader The reader. - * @return the web client url collection - * @throws Exception the exception - */ - public static WebClientUrlCollection loadFromXml(EwsXmlReader reader) - throws Exception { - WebClientUrlCollection instance = new WebClientUrlCollection(); - - do { - reader.read(); - - if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && - (reader.getLocalName() - .equals(XmlElementNames.WebClientUrl))) { - instance.getUrls().add(WebClientUrl.loadFromXml(reader)); - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.WebClientUrls)); - - return instance; - } - - /** - * Gets the URLs. - * - * @return the urls - */ - public ArrayList getUrls() { - return this.urls; - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/ConfigurationSettingsBase.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/ConfigurationSettingsBase.java deleted file mode 100644 index 36be38292..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/ConfigurationSettingsBase.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.configuration; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverResponseType; -import microsoft.exchange.webservices.data.autodiscover.exception.error.AutodiscoverError; -import microsoft.exchange.webservices.data.autodiscover.response.GetUserSettingsResponse; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.autodiscover.enumeration.UserSettingName; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -import java.net.URI; -import java.util.List; - -/** - * Represents the base class for configuration settings. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) public abstract class ConfigurationSettingsBase { - - /** - * The error. - */ - private AutodiscoverError error; - - /** - * Initializes a new instance of the ConfigurationSettingsBase class. - */ - public ConfigurationSettingsBase() { - } - - /** - * Tries to read the current XML element. - * - * @param reader the reader - * @return True is the current element was read, false otherwise. - * @throws Exception the exception - */ - public boolean tryReadCurrentXmlElement(EwsXmlReader reader) - throws Exception { - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Error)) { - this.error = AutodiscoverError.parse(reader); - - return true; - } else { - return false; - } - } - - /** - * Loads the settings from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void loadFromXml(EwsXmlReader reader) throws Exception { - reader.readStartElement(XmlNamespace.NotSpecified, - XmlElementNames.Autodiscover); - reader.readStartElement(XmlNamespace.NotSpecified, - XmlElementNames.Response); - - do { - reader.read(); - - if (reader.isStartElement()) { - if (!this.tryReadCurrentXmlElement(reader)) { - reader.skipCurrentElement(); - } - } - } while (!reader.isEndElement(XmlNamespace.NotSpecified, - XmlElementNames.Response)); - - reader.readEndElement(XmlNamespace.NotSpecified, - XmlElementNames.Autodiscover); - } - - /** - * Gets the namespace that defines the settings. - * - * @return The namespace that defines the settings - */ - public abstract String getNamespace(); - - /** - * Makes this instance a redirection response. - * - * @param redirectUrl the redirect url - */ - public abstract void makeRedirectionResponse(URI redirectUrl); - - /** - * Gets the type of the response. - * - * @return The type of the response. - */ - public abstract AutodiscoverResponseType getResponseType(); - - /** - * Gets the redirect target. - * - * @return The redirect target. - */ - public abstract String getRedirectTarget(); - - /** - * Convert ConfigurationSettings to GetUserSettings response. - * - * @param smtpAddress SMTP address. - * @param requestedSettings The requested settings. - * @return GetUserSettingsResponse. - */ - public abstract GetUserSettingsResponse convertSettings( - String smtpAddress, - List requestedSettings); - - - /** - * Gets the error. - * - * @return The error. - */ - public AutodiscoverError getError() { - return this.error; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/outlook/OutlookAccount.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/outlook/OutlookAccount.java deleted file mode 100644 index 368614eed..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/outlook/OutlookAccount.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.configuration.outlook; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.autodiscover.AlternateMailbox; -import microsoft.exchange.webservices.data.autodiscover.AlternateMailboxCollection; -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverResponseType; -import microsoft.exchange.webservices.data.autodiscover.response.GetUserSettingsResponse; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.autodiscover.enumeration.OutlookProtocolType; -import microsoft.exchange.webservices.data.autodiscover.enumeration.UserSettingName; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.HashMap; -import java.util.List; - -/** - * Represents an Outlook configuration settings account. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -final class OutlookAccount { - - //region Private constants - /** - * The Constant Settings. - */ - private final static String Settings = "settings"; - - /** - * The Constant RedirectAddr. - */ - private final static String RedirectAddr = "redirectAddr"; - - /** - * The Constant RedirectUrl. - */ - private final static String RedirectUrl = "redirectUrl"; - //endRegion - - private String accountType; - private AutodiscoverResponseType responseType; - - //region Private fields - /** - * The protocols. - */ - private HashMap protocols; - private AlternateMailboxCollection alternateMailboxes; - private String redirectTarget; - //endRegion - - /** - * Initializes a new instance of the OutlookAccount class. - */ - protected OutlookAccount() { - this.protocols = new HashMap(); - this.alternateMailboxes = new AlternateMailboxCollection(); - } - - /** - * Parses the specified reader. - * - * @param reader The reader. - * @throws Exception the exception - */ - protected void loadFromXml(EwsXmlReader reader) - throws Exception { - - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals(XmlElementNames.AccountType)) { - this.setAccountType(reader.readElementValue()); - } else if (reader.getLocalName().equals(XmlElementNames.Action)) { - String xmlResponseType = reader.readElementValue(); - if (xmlResponseType.equals(OutlookAccount.Settings)) { - this.setResponseType(AutodiscoverResponseType.Success); - } else if (xmlResponseType - .equals(OutlookAccount.RedirectUrl)) { - this.setResponseType(AutodiscoverResponseType. - RedirectUrl); - } else if (xmlResponseType - .equals(OutlookAccount.RedirectAddr)) { - this.setResponseType( - AutodiscoverResponseType.RedirectAddress); - } else { - this.setResponseType(AutodiscoverResponseType.Error); - } - - } else if (reader.getLocalName().equals( - XmlElementNames.Protocol)) { - OutlookProtocol protocol = new OutlookProtocol(); - protocol.loadFromXml(reader); - this.protocols.put( - protocol.getProtocolType(), protocol); - } else if (reader.getLocalName().equals( - XmlElementNames.RedirectAddr)) { - this.setRedirectTarget(reader.readElementValue()); - } else if (reader.getLocalName().equals( - XmlElementNames.RedirectUrl)) { - this.setRedirectTarget(reader.readElementValue()); - } else if (reader.getLocalName().equals( - XmlElementNames.AlternateMailboxes)) { - AlternateMailbox alternateMailbox = AlternateMailbox. - loadFromXml(reader); - this.alternateMailboxes.getEntries().add(alternateMailbox); - } else { - reader.skipCurrentElement(); - } - } - } while (!reader.isEndElement(XmlNamespace.NotSpecified, - XmlElementNames.Account)); - } - - /** - * Gets the type of the account. - */ - protected void convertToUserSettings(List requestedSettings, - GetUserSettingsResponse response) { - for (OutlookProtocol protocol : this.protocols.values()) { - protocol.convertToUserSettings(requestedSettings, response); - } - - if (requestedSettings.contains(UserSettingName.AlternateMailboxes)) { - response.getSettings().put(UserSettingName. - AlternateMailboxes, this.alternateMailboxes); - } - } - - /** - * Gets the type of the account. - * - * @return the account type - */ - protected String getAccountType() { - return accountType; - } - - /** - * Gets the type of the account. - */ - protected void setAccountType(String value) { - this.accountType = value; - } - - /** - * Gets the type of the response. - * - * @return the response type - */ - protected AutodiscoverResponseType getResponseType() { - return responseType; - } - - /** - * Sets the response type. - * - * @param value the new response type - */ - protected void setResponseType(AutodiscoverResponseType value) { - this.responseType = value; - } - - /** - * Gets the redirect target. - * - * @return the redirect target - */ - protected String getRedirectTarget() { - return redirectTarget; - - } - - /** - * Sets the redirect target. - * - * @param value the new redirect target - */ - protected void setRedirectTarget(String value) { - this.redirectTarget = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/outlook/OutlookConfigurationSettings.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/outlook/OutlookConfigurationSettings.java deleted file mode 100644 index 149c165e7..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/outlook/OutlookConfigurationSettings.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.configuration.outlook; - -import microsoft.exchange.webservices.data.autodiscover.configuration.ConfigurationSettingsBase; -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverErrorCode; -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverResponseType; -import microsoft.exchange.webservices.data.autodiscover.exception.error.UserSettingError; -import microsoft.exchange.webservices.data.autodiscover.response.GetUserSettingsResponse; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.ILazyMember; -import microsoft.exchange.webservices.data.core.LazyMember; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.autodiscover.enumeration.UserSettingName; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -/** - * Represents Outlook configuration settings. - */ -public final class OutlookConfigurationSettings extends ConfigurationSettingsBase { - - /** - * All user settings that are available from the Outlook provider. - */ - private static LazyMember> - allOutlookProviderSettings = new LazyMember>( - new ILazyMember>() { - public List createInstance() { - - List results = - new ArrayList(); - for (UserSettingName userSettingName : OutlookUser.getAvailableUserSettings()) { - results.add(userSettingName); - } - results.addAll(OutlookProtocol.getAvailableUserSettings()); - results.add(UserSettingName.AlternateMailboxes); - return results; - } - }); - - - /** - * The user. - */ - private OutlookUser user; - - /** - * The account. - */ - private OutlookAccount account; - - /** - * Initializes a new instance of the OutlookConfigurationSettings class. - */ - public OutlookConfigurationSettings() { - this.user = new OutlookUser(); - this.account = new OutlookAccount(); - } - - /** - * Determines whether user setting is available in the - * OutlookConfiguration or not. - * - * @param setting The setting. - * @return True if user setting is available, otherwise, false. - */ - protected static boolean isAvailableUserSetting(UserSettingName setting) { - return allOutlookProviderSettings.getMember().contains(setting); - } - - /** - * Gets the namespace that defines the settings. - * - * @return The namespace that defines the settings. - */ - @Override public String getNamespace() { - return "http://schemas.microsoft.com/exchange/" + - "autodiscover/outlook/responseschema/2006a"; - } - - /** - * Makes this instance a redirection response. - * - * @param redirectUrl The redirect URL. - */ - @Override public void makeRedirectionResponse(URI redirectUrl) { - this.account = new OutlookAccount(); - this.account.setRedirectTarget(redirectUrl.toString()); - this.account.setResponseType(AutodiscoverResponseType.RedirectUrl); - } - - /** - * Tries to read the current XML element. - * - * @param reader the reader - * @return true is the current element was read, false otherwise - * @throws Exception the exception - */ - @Override - public boolean tryReadCurrentXmlElement(EwsXmlReader reader) throws Exception { - if (!super.tryReadCurrentXmlElement(reader)) { - if (reader.getLocalName().equals(XmlElementNames.User)) { - this.user.loadFromXml(reader); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Account)) { - this.account.loadFromXml(reader); - return true; - } else { - reader.skipCurrentElement(); - return false; - } - } else { - return true; - } - } - - /** - * Convert OutlookConfigurationSettings to GetUserSettings response. - * - * @param smtpAddress SMTP address requested. - * @param requestedSettings The requested settings. - * @return GetUserSettingsResponse - */ - @Override public GetUserSettingsResponse convertSettings(String smtpAddress, - List requestedSettings) { - GetUserSettingsResponse response = new GetUserSettingsResponse(); - response.setSmtpAddress(smtpAddress); - - if (this.getError() != null) { - response.setErrorCode(AutodiscoverErrorCode.InternalServerError); - response.setErrorMessage(this.getError().getMessage()); - } else { - switch (this.getResponseType()) { - case Success: - response.setErrorCode(AutodiscoverErrorCode.NoError); - response.setErrorMessage(""); - this.user.convertToUserSettings(requestedSettings, response); - this.account.convertToUserSettings(requestedSettings, response); - this.reportUnsupportedSettings(requestedSettings, response); - break; - case Error: - response.setErrorCode(AutodiscoverErrorCode.InternalServerError); - response.setErrorMessage("The Autodiscover service response was invalid."); - break; - case RedirectAddress: - response.setErrorCode(AutodiscoverErrorCode.RedirectAddress); - response.setErrorMessage(""); - response.setRedirectTarget(this.getRedirectTarget()); - break; - case RedirectUrl: - response.setErrorCode(AutodiscoverErrorCode.RedirectUrl); - response.setErrorMessage(""); - response.setRedirectTarget(this.getRedirectTarget()); - break; - default: - EwsUtilities.ewsAssert(false, "OutlookConfigurationSettings.ConvertSettings", - "An unexpected error has occured. " - + "This code path should never be reached."); - break; - } - } - return response; - } - - /** - * Reports any requested user settings that aren't - * supported by the Outlook provider. - * - * @param requestedSettings The requested settings. - * @param response The response. - */ - private void reportUnsupportedSettings(List requestedSettings, - GetUserSettingsResponse response) { - // In English: find settings listed in requestedSettings that are not supported by the Legacy provider. - - //TODO need to check Iterable - List invalidSettingQuery = - new ArrayList(); - for (UserSettingName userSettingName : requestedSettings) { - if (!OutlookConfigurationSettings.isAvailableUserSetting(userSettingName)) { - invalidSettingQuery.add(userSettingName); - } - } - /* from setting in requestedSettings - where !OutlookConfigurationSettings.IsAvailableUserSetting(setting) - select setting;*/ - - // Add any unsupported settings to the UserSettingsError collection. - for (UserSettingName invalidSetting : invalidSettingQuery) { - UserSettingError settingError = new UserSettingError(); - settingError.setErrorCode(AutodiscoverErrorCode.InvalidSetting); - settingError.setSettingName(invalidSetting.toString()); - settingError.setErrorMessage(String.format( - "The requested setting, '%s', isn't supported by this Autodiscover endpoint.", - invalidSetting.toString())); - response.getUserSettingErrors().add(settingError); - } - } - - /** - * Gets the type of the response. - * - * @return The type of the response. - */ - @Override public AutodiscoverResponseType getResponseType() { - if (this.account != null) { - return this.account.getResponseType(); - } else { - return AutodiscoverResponseType.Error; - } - } - - /** - * Gets the redirect target. - * - * @return String - * the redirect target. - */ - @Override public String getRedirectTarget() { - return this.account.getRedirectTarget(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/outlook/OutlookProtocol.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/outlook/OutlookProtocol.java deleted file mode 100644 index 8c6277ddf..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/outlook/OutlookProtocol.java +++ /dev/null @@ -1,813 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.configuration.outlook; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.autodiscover.IFunc; -import microsoft.exchange.webservices.data.autodiscover.WebClientUrl; -import microsoft.exchange.webservices.data.autodiscover.WebClientUrlCollection; -import microsoft.exchange.webservices.data.autodiscover.response.GetUserSettingsResponse; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.ILazyMember; -import microsoft.exchange.webservices.data.core.LazyMember; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.autodiscover.enumeration.OutlookProtocolType; -import microsoft.exchange.webservices.data.autodiscover.enumeration.UserSettingName; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * Represents a supported Outlook protocol in an Outlook configurations settings - * account. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -final class OutlookProtocol { - - /** - * The Constant EXCH. - */ - private final static String EXCH = "EXCH"; - - /** - * The Constant EXPR. - */ - private final static String EXPR = "EXPR"; - - /** - * The Constant WEB. - */ - private final static String WEB = "WEB"; - - /** - * Converters to translate common Outlook protocol settings. - * Each entry maps to a lambda expression used to - * get the matching property from the OutlookProtocol instance. - */ - private static LazyMember>> - commonProtocolSettings = - new LazyMember>>( - new ILazyMember>>() { - public Map> createInstance() { - - Map> results = - new HashMap>(); - - results.put(UserSettingName.EcpDeliveryReportUrlFragment, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.ecpUrlMt; - } - }); - results.put(UserSettingName.EcpEmailSubscriptionsUrlFragment, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.ecpUrlAggr; - } - }); - results.put(UserSettingName.EcpPublishingUrlFragment, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.ecpUrlPublish; - } - }); - results.put(UserSettingName.EcpRetentionPolicyTagsUrlFragment, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.ecpUrlRet; - } - }); - results.put(UserSettingName.EcpTextMessagingUrlFragment, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.ecpUrlSms; - } - }); - results.put(UserSettingName.EcpVoicemailUrlFragment, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.ecpUrlUm; - } - }); - return results; - } - }); - - - /** - * Converters to translate internal (EXCH) Outlook protocol settings. - * Each entry maps to a lambda expression used to - * get the matching property from the OutlookProtocol instance. - */ - private static LazyMember>> - internalProtocolSettings = - new LazyMember>>( - new ILazyMember>>() { - public Map> createInstance() { - - Map> results = - new HashMap>(); - - results.put(UserSettingName.ActiveDirectoryServer, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.activeDirectoryServer; - } - }); - results.put(UserSettingName.CrossOrganizationSharingEnabled, - new IFunc() { - public Object func(OutlookProtocol arg) { - return String.valueOf(arg.sharingEnabled); - } - }); - results.put(UserSettingName.InternalEcpUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.ecpUrl; - } - }); - results.put(UserSettingName.InternalEcpDeliveryReportUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.convertEcpFragmentToUrl(arg.ecpUrlMt); - } - }); - results.put(UserSettingName.InternalEcpEmailSubscriptionsUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.convertEcpFragmentToUrl(arg.ecpUrlAggr); - } - }); - results.put(UserSettingName.InternalEcpPublishingUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.convertEcpFragmentToUrl(arg.ecpUrlPublish); - } - }); - results.put(UserSettingName.InternalEcpRetentionPolicyTagsUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.convertEcpFragmentToUrl(arg.ecpUrlRet); - } - }); - results.put(UserSettingName.InternalEcpTextMessagingUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.convertEcpFragmentToUrl(arg.ecpUrlSms); - } - }); - results.put(UserSettingName.InternalEcpVoicemailUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.convertEcpFragmentToUrl(arg.ecpUrlUm); - } - }); - results.put(UserSettingName.InternalEwsUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.exchangeWebServicesUrl == null ? - arg.availabilityServiceUrl : arg.exchangeWebServicesUrl; - } - }); - results.put(UserSettingName.InternalMailboxServerDN, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.serverDN; - } - }); - results.put(UserSettingName.InternalRpcClientServer, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.server; - } - }); - results.put(UserSettingName.InternalOABUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.offlineAddressBookUrl; - } - }); - results.put(UserSettingName.InternalUMUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.unifiedMessagingUrl; - } - }); - results.put(UserSettingName.MailboxDN, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.mailboxDN; - } - }); - results.put(UserSettingName.PublicFolderServer, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.publicFolderServer; - } - }); - results.put(UserSettingName.GroupingInformation, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.groupingInformation; - } - }); - - return results; - } - }); - - /** - * Converters to translate external (EXPR) Outlook protocol settings. - * Each entry maps to a lambda expression used to - * get the matching property from the OutlookProtocol instance. - */ - private static LazyMember>> - externalProtocolSettings = - new LazyMember>>( - new ILazyMember>>() { - public Map> createInstance() { - - Map> results = - new HashMap>(); - - results.put(UserSettingName.ExternalEcpDeliveryReportUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.convertEcpFragmentToUrl(arg.ecpUrlRet); - } - }); - results.put(UserSettingName.ExternalEcpEmailSubscriptionsUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.convertEcpFragmentToUrl(arg.ecpUrlAggr); - } - }); - results.put(UserSettingName.ExternalEcpPublishingUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.convertEcpFragmentToUrl(arg.ecpUrlPublish); - } - }); - results.put(UserSettingName.ExternalEcpRetentionPolicyTagsUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.convertEcpFragmentToUrl(arg.ecpUrlRet); - } - }); - results.put(UserSettingName.ExternalEcpTextMessagingUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.convertEcpFragmentToUrl(arg.ecpUrlSms); - } - }); - results.put(UserSettingName.ExternalEcpUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.ecpUrl; - } - }); - results.put(UserSettingName.ExternalEcpVoicemailUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.convertEcpFragmentToUrl(arg.ecpUrlUm); - } - }); - results.put(UserSettingName.ExternalEwsUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.exchangeWebServicesUrl == null ? - arg.availabilityServiceUrl : arg.exchangeWebServicesUrl; - } - }); - results.put(UserSettingName.ExternalMailboxServer, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.server; - } - }); - results.put( - UserSettingName.ExternalMailboxServerAuthenticationMethods, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.authPackage; - } - }); - results.put( - UserSettingName.ExternalMailboxServerRequiresSSL, - new IFunc() { - public Object func(OutlookProtocol arg) { - return String.valueOf(arg.sslEnabled); - } - }); - results.put(UserSettingName.ExternalOABUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.offlineAddressBookUrl; - } - }); - results.put(UserSettingName.ExternalUMUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.unifiedMessagingUrl; - } - }); - results.put(UserSettingName.ExchangeRpcUrl, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.exchangeRpcUrl; - } - }); - return results; - } - }); - - - /** - * Merged converter dictionary for translating - * internal (EXCH) Outlook protocol settings. - * Each entry maps to a lambda expression used to - * get the matching property from the OutlookProtocol instance. - */ - private static LazyMember>> - internalProtocolConverterDictionary = - new LazyMember>>( - new ILazyMember>>() { - public Map> createInstance() { - - Map> results = - new HashMap>(); - for (Entry> kv : commonProtocolSettings - .getMember().entrySet()) { - results.put(kv.getKey(), kv.getValue()); - } - for (Entry> kv : internalProtocolSettings - .getMember().entrySet()) { - results.put(kv.getKey(), kv.getValue()); - } - return results; - } - }); - - - /** - * Merged converter dictionary for translating - * external (EXPR) Outlook protocol settings. - * Each entry maps to a lambda expression used to - * get the matching property from the OutlookProtocol instance. - */ - private static LazyMember>> - externalProtocolConverterDictionary = - new LazyMember>>( - new ILazyMember>>() { - public Map> createInstance() { - - Map> results = - new HashMap>(); - for (Entry> kv : commonProtocolSettings - .getMember().entrySet()) { - results.put(kv.getKey(), kv.getValue()); - } - for (Entry> kv : externalProtocolSettings - .getMember().entrySet()) { - results.put(kv.getKey(), kv.getValue()); - } - return results; - } - }); - - - /** - * Converters to translate Web (WEB) Outlook protocol settings. - * Each entry maps to a lambda expression used to - * get the matching property from the OutlookProtocol instance. - */ - private static LazyMember>> - webProtocolConverterDictionary = - new LazyMember>>( - new ILazyMember>>() { - public Map> createInstance() { - - Map> results = - new HashMap>(); - - results.put(UserSettingName.InternalWebClientUrls, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.internalOutlookWebAccessUrls; - } - }); - results.put(UserSettingName.ExternalWebClientUrls, - new IFunc() { - public Object func(OutlookProtocol arg) { - return arg.externalOutlookWebAccessUrls; - } - }); - return results; - } - }); - - /** - * Each entry maps to a lambda expression used to - * get the matching property from the OutlookProtocol instance. - */ - private static LazyMember> - availableUserSettings = - new LazyMember>( - new ILazyMember>() { - public List createInstance() { - - List results = - new ArrayList(); - - results.addAll(commonProtocolSettings. - getMember().keySet()); - results.addAll(internalProtocolSettings. - getMember().keySet()); - results.addAll(externalProtocolSettings. - getMember().keySet()); - results.addAll(webProtocolConverterDictionary. - getMember().keySet()); - return results; - } - }); - - - /** - * Map Outlook protocol name to type. - */ - private static LazyMember> - protocolNameToTypeMap = - new LazyMember>( - new ILazyMember>() { - @Override - public Map createInstance() { - Map results = - new HashMap(); - results.put(OutlookProtocol.EXCH, OutlookProtocolType.Rpc); - results.put(OutlookProtocol.EXPR, OutlookProtocolType.RpcOverHttp); - results.put(OutlookProtocol.WEB, OutlookProtocolType.Web); - return results; - - } - }); - - - /** - * The constant activeDirectoryServer. - */ - private String activeDirectoryServer; - /** - * The constant authPackage. - */ - private String authPackage; - /** - * The constant availabilityServiceUrl. - */ - private String availabilityServiceUrl; - /** - * The constant ecpUrl. - */ - private String ecpUrl; - /** - * The constant ecpUrlAggr. - */ - private String ecpUrlAggr; - /** - * The constant ecpUrlMt. - */ - private String ecpUrlMt; - /** - * The constant ecpUrlPublish. - */ - private String ecpUrlPublish; - /** - * The constant ecpUrlRet. - */ - private String ecpUrlRet; - /** - * The constant ecpUrlSms. - */ - private String ecpUrlSms; - /** - * The constant ecpUrlUm. - */ - private String ecpUrlUm; - /** - * The constant exchangeWebServicesUrl. - */ - private String exchangeWebServicesUrl; - /** - * The constant mailboxDN. - */ - private String mailboxDN; - /** - * The constant offlineAddressBookUrl. - */ - private String offlineAddressBookUrl; - /** - * The constant exchangeRpcUrl. - */ - private String exchangeRpcUrl; - /** - * The constant publicFolderServer. - */ - private String publicFolderServer; - /** - * The constant server. - */ - private String server; - /** - * The constant serverDN. - */ - private String serverDN; - /** - * The constant unifiedMessagingUrl. - */ - private String unifiedMessagingUrl; - /** - * The constant sharingEnabled. - */ - private boolean sharingEnabled; - /** - * The constant sslEnabled. - */ - private boolean sslEnabled; - /** - * The constant externalOutlookWebAccessUrls. - */ - private WebClientUrlCollection externalOutlookWebAccessUrls; - /** - * The constant internalOutlookWebAccessUrls. - */ - private WebClientUrlCollection internalOutlookWebAccessUrls; - /** - * The constant groupingInformation. - */ - private String groupingInformation; - - - /** - * Initializes a new instance of the OutlookProtocol class. - */ - protected OutlookProtocol() { - this.internalOutlookWebAccessUrls = new WebClientUrlCollection(); - this.externalOutlookWebAccessUrls = new WebClientUrlCollection(); - } - - - /** - * Parses the XML using the specified reader and creates an Outlook - * protocol. - * - * @param reader The reader. - * @throws Exception the exception - */ - protected void loadFromXml(EwsXmlReader reader) - throws Exception { - do { - reader.read(); - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals(XmlElementNames.Type)) { - this.setProtocolType(OutlookProtocol. - protocolNameToType(reader.readElementValue())); - } else if (reader.getLocalName().equals(XmlElementNames.AuthPackage)) { - this.authPackage = reader.readElementValue(); - } else if (reader.getLocalName().equals(XmlElementNames.Server)) { - this.server = reader.readElementValue(); - } else if (reader.getLocalName().equals(XmlElementNames.ServerDN)) { - this.serverDN = reader.readElementValue(); - } else if (reader.getLocalName().equals(XmlElementNames.ServerVersion)) { - reader.readElementValue(); - } else if (reader.getLocalName().equals(XmlElementNames.AD)) { - this.activeDirectoryServer = reader.readElementValue(); - } else if (reader.getLocalName().equals(XmlElementNames.MdbDN)) { - this.mailboxDN = reader.readElementValue(); - } else if (reader.getLocalName().equals(XmlElementNames.EWSUrl)) { - this.exchangeWebServicesUrl = reader.readElementValue(); - } else if (reader.getLocalName().equals(XmlElementNames.ASUrl)) { - this.availabilityServiceUrl = reader.readElementValue(); - } else if (reader.getLocalName().equals(XmlElementNames.OOFUrl)) { - reader.readElementValue(); - } else if (reader.getLocalName().equals(XmlElementNames.UMUrl)) { - this.unifiedMessagingUrl = reader.readElementValue(); - } else if (reader.getLocalName().equals(XmlElementNames.OABUrl)) { - this.offlineAddressBookUrl = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.PublicFolderServer)) { - this.publicFolderServer = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.Internal)) { - OutlookProtocol.loadWebClientUrlsFromXml(reader, - this.internalOutlookWebAccessUrls, reader.getLocalName()); - } else if (reader.getLocalName().equals( - XmlElementNames.External)) { - OutlookProtocol.loadWebClientUrlsFromXml(reader, - this.externalOutlookWebAccessUrls, reader.getLocalName()); - } else if (reader.getLocalName().equals( - XmlElementNames.Ssl)) { - String sslStr = reader.readElementValue(); - this.sslEnabled = sslStr.equalsIgnoreCase("On"); - } else if (reader.getLocalName().equals( - XmlElementNames.SharingUrl)) { - this.sharingEnabled = reader. - readElementValue().length() > 0; - } else if (reader.getLocalName().equals( - XmlElementNames.EcpUrl)) { - this.ecpUrl = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.EcpUrl_um)) { - this.ecpUrlUm = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.EcpUrl_aggr)) { - this.ecpUrlAggr = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.EcpUrl_sms)) { - this.ecpUrlSms = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.EcpUrl_mt)) { - this.ecpUrlMt = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.EcpUrl_ret)) { - this.ecpUrlRet = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.EcpUrl_publish)) { - this.ecpUrlPublish = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.ExchangeRpcUrl)) { - this.exchangeRpcUrl = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.GroupingInformation)) { - this.groupingInformation = reader.readElementValue(); - } else { - reader.skipCurrentElement(); - } - } - } while (!reader.isEndElement(XmlNamespace.NotSpecified, - XmlElementNames.Protocol)); - } - - /** - * Convert protocol name to protocol type. - * - * @param protocolName Name of the protocol. - * @return OutlookProtocolType - */ - private static OutlookProtocolType protocolNameToType(String - protocolName) { - OutlookProtocolType protocolType = null; - if (!(protocolNameToTypeMap.getMember().containsKey(protocolName))) { - protocolType = OutlookProtocolType.Unknown; - } else { - protocolType = protocolNameToTypeMap.getMember().get(protocolName); - } - return protocolType; - - } - - /** - * Loads web client urls from XML. - * - * @param reader The reader. - * @param webClientUrls The web client urls. - * @param elementName Name of the element. - * @throws Exception - */ - private static void loadWebClientUrlsFromXml(EwsXmlReader reader, - WebClientUrlCollection webClientUrls, String elementName) throws Exception { - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals(XmlElementNames.OWAUrl)) { - String authMethod = reader.readAttributeValue( - XmlAttributeNames.AuthenticationMethod); - String owaUrl = reader.readElementValue(); - WebClientUrl webClientUrl = - new WebClientUrl(authMethod, owaUrl); - webClientUrls.getUrls().add(webClientUrl); - } else { - reader.skipCurrentElement(); - } - } - } - while (!reader.isEndElement(XmlNamespace.NotSpecified, elementName)); - } - - - /** - * Convert ECP fragment to full ECP URL. - * - * @param fragment The fragment. - * @return Full URL string (or null if either portion is empty. - */ - private String convertEcpFragmentToUrl(String fragment) { - return ((this.ecpUrl == null || this.ecpUrl.isEmpty()) || - (fragment == null || fragment.isEmpty())) ? null : (this.ecpUrl + fragment); - } - - /** - * Convert OutlookProtocol to GetUserSettings response. - * - * @param requestedSettings The requested settings. - * @param response The response. - */ - protected void convertToUserSettings( - List requestedSettings, - GetUserSettingsResponse response) { - if (this.getConverterDictionary() != null) { - // In English: collect converters that are contained in the requested settings. - Map> converterQuery = - new HashMap>(); - Map> t = - this.getConverterDictionary(); - for (Entry> map : t.entrySet()) { - if (requestedSettings.contains(map.getKey())) { - converterQuery.put(map.getKey(), map.getValue()); - } - } - - for (Entry> kv : converterQuery.entrySet()) { - Object value = kv.getValue().func(this); - if (value != null) { - response.getSettings().put(kv.getKey(), value); - } - } - } - } - - private OutlookProtocolType protocolType; - - /** - * Gets the type of the protocol. - * - * @return The type of the protocol. - */ - protected OutlookProtocolType getProtocolType() { - return this.protocolType; - } - - /** - * Sets the type of the protocol. - */ - protected void setProtocolType(OutlookProtocolType protocolType) { - this.protocolType = protocolType; - } - - /** - * Gets the converter dictionary for protocol type. - * - * @return The converter dictionary. - */ - private Map> - getConverterDictionary() { - switch (this.getProtocolType()) { - case Rpc: - return internalProtocolConverterDictionary.getMember(); - case RpcOverHttp: - return externalProtocolConverterDictionary.getMember(); - case Web: - return webProtocolConverterDictionary.getMember(); - default: - return null; - } - } - - - /** - * Gets the available user settings. - * - * @return availableUserSettings - */ - protected static List getAvailableUserSettings() { - return availableUserSettings.getMember(); - } -} - diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/outlook/OutlookUser.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/outlook/OutlookUser.java deleted file mode 100644 index fa45917c3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/configuration/outlook/OutlookUser.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.configuration.outlook; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.autodiscover.IFunc; -import microsoft.exchange.webservices.data.autodiscover.response.GetUserSettingsResponse; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.ILazyMember; -import microsoft.exchange.webservices.data.core.LazyMember; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.autodiscover.enumeration.UserSettingName; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * Represents the user Outlook configuration settings apply to. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -final class OutlookUser { - - /** - * Converters to translate Outlook user settings. - * Each entry maps to a lambda expression used to - * get the matching property from the OutlookUser instance. - */ - private static LazyMember>> - converterDictionary = - new LazyMember>>( - new ILazyMember>>() { - public Map> createInstance() { - Map> results = - new HashMap>(); - results.put(UserSettingName.UserDisplayName, - new IFunc() { - public String func(OutlookUser arg) { - return arg.displayName; - } - }); - results.put(UserSettingName.UserDN, - new IFunc() { - public String func(OutlookUser arg) { - return arg.legacyDN; - } - }); - results.put(UserSettingName.UserDeploymentId, - new IFunc() { - public String func(OutlookUser arg) { - return arg.deploymentId; - } - }); - return results; - } - }); - - /** - * The display name. - */ - private String displayName; - - /** - * The legacy dn. - */ - private String legacyDN; - - /** - * The deployment id. - */ - private String deploymentId; - - /** - * Initializes a new instance of the OutlookUser class. - */ - protected OutlookUser() { - } - - /** - * Load from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - protected void loadFromXml(EwsXmlReader reader) throws Exception { - - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals(XmlElementNames.DisplayName)) { - this.displayName = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.LegacyDN)) { - this.legacyDN = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.DeploymentId)) { - this.deploymentId = reader.readElementValue(); - } else { - reader.skipCurrentElement(); - - } - } - } while (!reader.isEndElement(XmlNamespace.NotSpecified, - XmlElementNames.User)); - } - - /** - * Convert OutlookUser to GetUserSettings response. - * - * @param requestedSettings The requested settings. - * @param response The response. - */ - protected void convertToUserSettings( - List requestedSettings, - GetUserSettingsResponse response) { - // In English: collect converters that are - //contained in the requested settings. - Map> - converterQuery = new HashMap>(); - for (Entry> map : converterDictionary.getMember() - .entrySet()) { - if (requestedSettings.contains(map.getKey())) { - converterQuery.put(map.getKey(), map.getValue()); - } - } - - for (Entry> kv : converterQuery.entrySet()) { - String value = kv.getValue().func(this); - if (!(value == null || value.isEmpty())) { - response.getSettings().put(kv.getKey(), value); - } - } - } - - /** - * Gets the available user settings. - * - * @return The available user settings. - */ - protected static Iterable getAvailableUserSettings() { - return converterDictionary.getMember().keySet(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/AutodiscoverEndpoints.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/AutodiscoverEndpoints.java deleted file mode 100644 index 26311ad2c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/AutodiscoverEndpoints.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.enumeration; - -/** - * Defines the types of Autodiscover endpoints that are available. - */ -public enum AutodiscoverEndpoints { - - /** - * No endpoints available. - */ - None(0), - - /** - * The "legacy" Autodiscover endpoint. - */ - Legacy(1), - - /** - * The SOAP endpoint. - */ - Soap(2), - - /** - * The WS-Security endpoint. - */ - WsSecurity(4), - - /** - * The WS-Security/SymmetricKey endpoint. - */ - WSSecuritySymmetricKey(8), - - /** - * The WS-Security/X509Cert endpoint. - */ - WSSecurityX509Cert(16); - - /** - * The autodiscover end points. - */ - private final int autodiscoverEndPoints; - - /** - * Instantiates a new autodiscover endpoints. - * - * @param autodiscoverEndPoints the autodiscover end points - */ - AutodiscoverEndpoints(int autodiscoverEndPoints) { - this.autodiscoverEndPoints = autodiscoverEndPoints; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/AutodiscoverErrorCode.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/AutodiscoverErrorCode.java deleted file mode 100644 index 119f1c2ca..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/AutodiscoverErrorCode.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.enumeration; - -/** - * Defines the error codes that can be returned by the Autodiscover service. - */ -public enum AutodiscoverErrorCode { - - // There was no Error. - /** - * The No error. - */ - NoError, - - // The caller must follow the e-mail address redirection that was returned - // by Autodiscover. - /** - * The Redirect address. - */ - RedirectAddress, - - // The caller must follow the URL redirection that was returned by - // Autodiscover. - /** - * The Redirect url. - */ - RedirectUrl, - - // The user that was passed in the request is invalid. - /** - * The Invalid user. - */ - InvalidUser, - - // The request is invalid. - /** - * The Invalid request. - */ - InvalidRequest, - - // A specified setting is invalid. - /** - * The Invalid setting. - */ - InvalidSetting, - - // A specified setting is not available. - /** - * The Setting is not available. - */ - SettingIsNotAvailable, - - // The server is too busy to process the request. - /** - * The Server busy. - */ - ServerBusy, - - // The requested domain is not valid. - /** - * The Invalid domain. - */ - InvalidDomain, - - // The organization is not federated. - /** - * The Not federated. - */ - NotFederated, - - // Internal server error. - /** - * The Internal server error. - */ - InternalServerError, -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/UserSettingName.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/UserSettingName.java deleted file mode 100644 index 3822464d1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/enumeration/UserSettingName.java +++ /dev/null @@ -1,360 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.enumeration; - -/** - * The Enum UserSettingName. - */ -public enum UserSettingName { - - // The display name of the user. - /** - * The User display name. - */ - UserDisplayName, - - // The legacy distinguished name of the user. - /** - * The User dn. - */ - UserDN, - - // The deployment Id of the user. - /** - * The User deployment id. - */ - UserDeploymentId, - - // The fully qualified domain name of the mailbox server. - /** - * The Internal mailbox server. - */ - InternalMailboxServer, - - // The fully qualified domain name of the RPC client server. - /** - * The Internal rpc client server. - */ - InternalRpcClientServer, - - // The legacy distinguished name of the mailbox server. - /** - * The Internal mailbox server dn. - */ - InternalMailboxServerDN, - - // The internal URL of the Exchange Control Panel. - /** - * The Internal ecp url. - */ - InternalEcpUrl, - - // The internal URL of the Exchange Control Panel for VoiceMail - // Customization. - /** - * The Internal ecp voicemail url. - */ - InternalEcpVoicemailUrl, - - // The internal URL of the Exchange Control Panel for Email Subscriptions. - /** - * The Internal ecp email subscriptions url. - */ - InternalEcpEmailSubscriptionsUrl, - - // The internal URL of the Exchange Control Panel for Text Messaging. - /** - * The Internal ecp text messaging url. - */ - InternalEcpTextMessagingUrl, - - // The internal URL of the Exchange Control Panel for Delivery Reports. - /** - * The Internal ecp delivery report url. - */ - InternalEcpDeliveryReportUrl, - - /// The internal URL of the Exchange Control Panel for RetentionPolicy Tags. - /** - * The Internal ecp retention policy tags url. - */ - InternalEcpRetentionPolicyTagsUrl, - - /// The internal URL of the Exchange Control Panel for Publishing. - /** - * The Internal ecp publishing url. - */ - InternalEcpPublishingUrl, - - // The internal URL of the Exchange Web Services. - /** - * The Internal ews url. - */ - InternalEwsUrl, - - // The internal URL of the Offline Address Book. - /** - * The Internal oab url. - */ - InternalOABUrl, - - // The internal URL of the Unified Messaging services. - /** - * The Internal um url. - */ - InternalUMUrl, - - // The internal URLs of the Exchange web client. - /** - * The Internal web client urls. - */ - InternalWebClientUrls, - - // The distinguished name of the mailbox database of the user's mailbox. - /** - * The Mailbox dn. - */ - MailboxDN, - - // The name of the Public Folders server. - /** - * The Public folder server. - */ - PublicFolderServer, - - // The name of the Active Directory server. - /** - * The Active directory server. - */ - ActiveDirectoryServer, - - // The name of the RPC over HTTP server. - /** - * The External mailbox server. - */ - ExternalMailboxServer, - - // Indicates whether the RPC over HTTP server requires SSL. - /** - * The External mailbox server requires ssl. - */ - ExternalMailboxServerRequiresSSL, - - // The authentication methods supported by the RPC over HTTP server. - /** - * The External mailbox server authentication methods. - */ - ExternalMailboxServerAuthenticationMethods, - - // The URL fragment of the Exchange Control Panel for VoiceMail - // Customization. - /** - * The Ecp voicemail url fragment. - */ - EcpVoicemailUrlFragment, - - // The URL fragment of the Exchange Control Panel for Email Subscriptions. - /** - * The Ecp email subscriptions url fragment. - */ - EcpEmailSubscriptionsUrlFragment, - - // The URL fragment of the Exchange Control Panel for Text Messaging. - /** - * The Ecp text messaging url fragment. - */ - EcpTextMessagingUrlFragment, - - // The URL fragment of the Exchange Control Panel for Delivery Reports. - /** - * The Ecp delivery report url fragment. - */ - EcpDeliveryReportUrlFragment, - - /// The URL fragment of the Exchange Control Panel for RetentionPolicy Tags. - /** - * The Ecp retention policy tags url fragment. - */ - EcpRetentionPolicyTagsUrlFragment, - - /// The URL fragment of the Exchange Control Panel for Publishing. - /** - * The Ecp publishing url fragment. - */ - EcpPublishingUrlFragment, - - // The external URL of the Exchange Control Panel. - /** - * The External ecp url. - */ - ExternalEcpUrl, - - // The external URL of the Exchange Control Panel for VoiceMail - // Customization. - /** - * The External ecp voicemail url. - */ - ExternalEcpVoicemailUrl, - - // The external URL of the Exchange Control Panel for Email Subscriptions. - /** - * The External ecp email subscriptions url. - */ - ExternalEcpEmailSubscriptionsUrl, - - // The external URL of the Exchange Control Panel for Text Messaging. - /** - * The External ecp text messaging url. - */ - ExternalEcpTextMessagingUrl, - - // The external URL of the Exchange Control Panel for Delivery Reports. - /** - * The External ecp delivery report url. - */ - ExternalEcpDeliveryReportUrl, - - /// The external URL of the Exchange Control Panel for RetentionPolicy Tags. - /** - * The External ecp retention policy tags url. - */ - ExternalEcpRetentionPolicyTagsUrl, - - /// The external URL of the Exchange Control Panel for Publishing. - /** - * The External ecp publishing url. - */ - ExternalEcpPublishingUrl, - - // The external URL of the Exchange Web Services. - /** - * The External ews url. - */ - ExternalEwsUrl, - - // The external URL of the Offline Address Book. - /** - * The External oab url. - */ - ExternalOABUrl, - - // The external URL of the Unified Messaging services. - /** - * The External um url. - */ - ExternalUMUrl, - - // The external URLs of the Exchange web client. - /** - * The External web client urls. - */ - ExternalWebClientUrls, - - // Indicates that cross-organization sharing is enabled. - /** - * The Cross organization sharing enabled. - */ - CrossOrganizationSharingEnabled, - - // Collection of alternate mailboxes. - /** - * The Alternate mailboxes. - */ - AlternateMailboxes, - - // The version of the Client Access Server serving the request (e.g. - // 14.XX.YYY.ZZZ) - /** - * The Cas version. - */ - CasVersion, - - // Comma-separated list of schema versions supported by Exchange Web - // Services. The schema version values - // will be the same as the values of the ExchangeServerVersion enumeration. - /** - * The Ews supported schema. - */ - EwsSupportedSchemas, - - // The internal connection settings list for pop protocol - /** - * The Internal pop3 connections. - */ - InternalPop3Connections, - - // The external connection settings list for pop protocol - /** - * The External pop3 connections. - */ - ExternalPop3Connections, - - // The internal connection settings list for imap4 protocol - /** - * The Internal imap4 connections. - */ - InternalImap4Connections, - - // The external connection settings list for imap4 protocol - /** - * The External imap4 connections. - */ - ExternalImap4Connections, - - // The internal connection settings list for smtp protocol - /** - * The Internal smtp connections. - */ - InternalSmtpConnections, - - // The external connection settings list for smtp protocol - /** - * The External smtp connections. - */ - ExternalSmtpConnections, - - /// If set, then clients can call the server via XTC - /** - * The Exchange Rpc Url. - */ - ExchangeRpcUrl, - - /// The version of the Exchange Web Services - ///server ExternalEwsUrl is pointing to. - /** - * The External Ews Version. - */ - ExternalEwsVersion, - - /** - * Mobile Mailbox policy settings. - */ - - MobileMailboxPolicy, - - /** - * The grouping hint for certain clients. - */ - GroupingInformation, -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/AutodiscoverLocalException.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/AutodiscoverLocalException.java deleted file mode 100644 index 8e5476b04..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/AutodiscoverLocalException.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.exception; - -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -/** - * Represents an exception that is thrown when the Autodiscover service could - * not be contacted. - */ -public class AutodiscoverLocalException extends ServiceLocalException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Initializes a new instance of the class. - */ - public AutodiscoverLocalException() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param message the message - */ - public AutodiscoverLocalException(String message) { - super(message); - } - - /** - * Initializes a new instance of the class. - * - * @param message the message - * @param innerException the inner exception - */ - public AutodiscoverLocalException(String message, - Exception innerException) { - super(message, innerException); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/AutodiscoverRemoteException.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/AutodiscoverRemoteException.java deleted file mode 100644 index 562137bc4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/AutodiscoverRemoteException.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.exception; - -import microsoft.exchange.webservices.data.autodiscover.exception.error.AutodiscoverError; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRemoteException; - -/** - * Represents an exception that is thrown when the Autodiscover service returns - * an error. - */ -public class AutodiscoverRemoteException extends ServiceRemoteException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * The error. - */ - private AutodiscoverError error; - - /** - * Initializes a new instance of the class. - * - * @param error the error - */ - public AutodiscoverRemoteException(AutodiscoverError error) { - super(); - this.error = error; - } - - /** - * Initializes a new instance of the class. - * - * @param message the message - * @param error the error - */ - public AutodiscoverRemoteException(String message, AutodiscoverError error) { - super(message); - this.error = error; - } - - /** - * Initializes a new instance of the class. - * - * @param message the message - * @param error the error - * @param innerException the inner exception - */ - public AutodiscoverRemoteException(String message, AutodiscoverError error, - Exception innerException) { - super(message, innerException); - this.error = error; - } - - /** - * Gets the error. - * - * @return the error - */ - public AutodiscoverError getError() { - return this.error; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/AutodiscoverResponseException.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/AutodiscoverResponseException.java deleted file mode 100644 index 71262f2ff..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/AutodiscoverResponseException.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.exception; - -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverErrorCode; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRemoteException; - -/** - * Represents an exception from an autodiscover error response. - */ -public class AutodiscoverResponseException extends ServiceRemoteException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Error code when Autodiscover service operation failed remotely. - */ - private AutodiscoverErrorCode errorCode; - - /** - * Initializes a new instance of the class. - * - * @param errorCode the error code - * @param message the message - */ - public AutodiscoverResponseException(AutodiscoverErrorCode errorCode, String message) { - super(message); - this.errorCode = errorCode; - } - - /** - * Gets the ErrorCode for the exception. - * - * @return the error code - */ - public AutodiscoverErrorCode getErrorCode() { - return this.errorCode; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/MaximumRedirectionHopsExceededException.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/MaximumRedirectionHopsExceededException.java deleted file mode 100644 index 8de52b3e3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/MaximumRedirectionHopsExceededException.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.exception; - -import microsoft.exchange.webservices.data.autodiscover.exception.AutodiscoverLocalException; - -/** - * - * The Class MaximumRedirectionHopsExceededException. - * - * @see microsoft.exchange.webservices.data.autodiscover.AutodiscoverService - */ -public class MaximumRedirectionHopsExceededException extends AutodiscoverLocalException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Initializes a new instance of the class. - */ - public MaximumRedirectionHopsExceededException() { - } - - /** - * Initializes a new instance of the class. - * - * @param message the message - */ - public MaximumRedirectionHopsExceededException(String message) { - super(message); - } - - /** - * Initializes a new instance of the class. - * - * @param message the message - * @param innerException the inner exception - */ - public MaximumRedirectionHopsExceededException(String message, Exception innerException) { - super(message, innerException); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/error/AutodiscoverError.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/error/AutodiscoverError.java deleted file mode 100644 index efdc18b49..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/error/AutodiscoverError.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.exception.error; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -/** - * Defines the AutodiscoverError class. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class AutodiscoverError { - - /** - * The time. - */ - private String time; - - /** - * The id. - */ - private String id; - - /** - * The error code. - */ - private int errorCode; - - /** - * The message. - */ - private String message; - - /** - * The debug data. - */ - private String debugData; - - /** - * Initializes a new instance of the AutodiscoverError class. - */ - private AutodiscoverError() { - } - - /** - * Parses the XML through the specified reader and creates an Autodiscover - * error. - * - * @param reader the reader - * @return AutodiscoverError - * @throws Exception the exception - */ - public static AutodiscoverError parse(EwsXmlReader reader) - throws Exception { - AutodiscoverError error = new AutodiscoverError(); - error.time = reader.readAttributeValue(XmlAttributeNames.Time); - error.id = reader.readAttributeValue(XmlAttributeNames.Id); - - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.ErrorCode)) { - error.errorCode = reader.readElementValue(Integer.class); - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.Message)) { - error.message = reader.readElementValue(); - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.DebugData)) { - error.debugData = reader.readElementValue(); - } else { - reader.skipCurrentElement(); - } - } - } while (!reader.isEndElement(XmlNamespace.NotSpecified, - XmlElementNames.Error)); - - return error; - } - - /** - * Gets the time when the error was returned. - * - * @return the time - */ - public String getTime() { - return time; - } - - /** - * Gets a hash of the name of the computer that is running Microsoft - * Exchange Server that has the Client Access server role installed. - * - * @return the id - */ - public String getId() { - return id; - } - - /** - * Gets the error code. - * - * @return the error code - */ - public int getErrorCode() { - return errorCode; - } - - /** - * Gets the error message. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Gets the debug data. - * - * @return the debug data - */ - public String getDebugData() { - return debugData; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/error/DomainSettingError.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/error/DomainSettingError.java deleted file mode 100644 index a19ff6f7d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/error/DomainSettingError.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.exception.error; - -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverErrorCode; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -/** - * Represents an error from a GetDomainSettings request. - */ -public final class DomainSettingError { - - /** - * The error code. - */ - private AutodiscoverErrorCode errorCode; - - /** - * The error message. - */ - private String errorMessage; - - /** - * The setting name. - */ - private String settingName; - - /** - * Initializes a new instance of the {@link DomainSettingError} class. - */ - public DomainSettingError() { - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - public void loadFromXml(EwsXmlReader reader) throws Exception { - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals(XmlElementNames.ErrorCode)) { - this.errorCode = reader - .readElementValue(AutodiscoverErrorCode.class); - } else if (reader.getLocalName().equals( - XmlElementNames.ErrorMessage)) { - this.errorMessage = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.SettingName)) { - this.settingName = reader.readElementValue(); - } - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.DomainSettingError)); - } - - /** - * Gets the error code. - * - * @return The error code. - */ - - public AutodiscoverErrorCode getErrorCode() { - return this.errorCode; - } - - /** - * Gets the error message. - * - * @return The error message. - */ - - public String getErrorMessage() { - return this.errorMessage; - } - - /** - * Gets the name of the setting. - * - * @return The name of the setting. - */ - public String getSettingName() { - return this.settingName; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/error/UserSettingError.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/error/UserSettingError.java deleted file mode 100644 index 12400489a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/exception/error/UserSettingError.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.exception.error; - -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverErrorCode; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -/** - * Represents an error from a GetUserSettings request. - */ -public final class UserSettingError { - - /** - * The error code. - */ - private AutodiscoverErrorCode errorCode; - - /** - * The error message. - */ - private String errorMessage; - - /** - * The setting name. - */ - private String settingName; - - /** - * Initializes a new instance of the "UserSettingError" class. - */ - public UserSettingError() { - } - - /** - * Initializes a new instance of the "UserSettingError" class. - * - * @param errorCode The error code - * @param errorMessage The error message - * @param settingName Name of the setting - */ - protected UserSettingError(AutodiscoverErrorCode errorCode, - String errorMessage, String settingName) { - this.errorCode = errorCode; - this.errorMessage = errorMessage; - this.settingName = settingName; - } - - - /** - * Loads from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - public void loadFromXml(EwsXmlReader reader) throws Exception { - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals(XmlElementNames.ErrorCode)) { - this.setErrorCode(reader - .readElementValue(AutodiscoverErrorCode.class)); - } else if (reader.getLocalName().equals( - XmlElementNames.ErrorMessage)) { - this.setErrorMessage(reader.readElementValue()); - } else if (reader.getLocalName().equals( - XmlElementNames.SettingName)) { - this.setSettingName(reader.readElementValue()); - } - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.UserSettingError)); - } - - /** - * Gets the error code. - * - * @return The error code. - */ - public AutodiscoverErrorCode getErrorCode() { - return errorCode; - } - - public void setErrorCode(AutodiscoverErrorCode errorCode) { - this.errorCode = errorCode; - } - - /** - * Gets the error message. - * - * @return The error message. - */ - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - - /** - * Gets the name of the setting. - * - * @return The name of the setting. - */ - public String getSettingName() { - return settingName; - } - - public void setSettingName(String settingName) { - this.settingName = settingName; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/request/ApplyConversationActionRequest.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/request/ApplyConversationActionRequest.java deleted file mode 100644 index faeba8144..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/request/ApplyConversationActionRequest.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.request.MultiResponseServiceRequest; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.ConversationAction; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a request to a Apply Conversation Action operation - */ -public final class ApplyConversationActionRequest extends MultiResponseServiceRequest { - - private List conversationActions = - new ArrayList(); - - public List getConversationActions() { - return this.conversationActions; - } - - /** - * Initializes a new instance of the ApplyConversationActionRequest class - * - * @param service The service - * @param errorHandlingMode Indicates how errors should be handled - * @throws Exception on error - */ - public ApplyConversationActionRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) throws Exception { - super(service, errorHandlingMode); - } - - /** - * Creates the service response. - * - * @param service The service. - * @param responseIndex Index of the response. - * @return Service response. - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new ServiceResponse(); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.conversationActions.size(); - } - - /** - * Validate request. - * - * @throws Exception on validation error - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParamCollection( - conversationActions.iterator(), "conversationActions" - ); - - for (int iAction = 0; iAction < this.getConversationActions().size(); iAction++) { - this.getConversationActions().get(iAction).validate(); - } - } - - - /** - * Writes XML elements. - * - * @param writer The writer. - * @throws Exception on validation error - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) throws Exception { - writer.writeStartElement( - XmlNamespace.Messages, - XmlElementNames.ConversationActions); - for (int iAction = 0; iAction < this.getConversationActions().size(); iAction++) { - this.getConversationActions().get(iAction). - writeElementsToXml(writer); - } - writer.writeEndElement(); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.ApplyConversationAction; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.ApplyConversationActionResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.ApplyConversationActionResponseMessage; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010_SP1; - } -} - diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/request/AutodiscoverRequest.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/request/AutodiscoverRequest.java deleted file mode 100644 index b96a964b8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/request/AutodiscoverRequest.java +++ /dev/null @@ -1,751 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.request; - -import microsoft.exchange.webservices.data.EWSConstants; -import microsoft.exchange.webservices.data.autodiscover.AutodiscoverService; -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverErrorCode; -import microsoft.exchange.webservices.data.autodiscover.exception.AutodiscoverResponseException; -import microsoft.exchange.webservices.data.autodiscover.response.AutodiscoverResponse; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.ExchangeServerInfo; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.request.HttpWebRequest; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.TraceFlags; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.http.EWSHttpException; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRemoteException; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.SoapFaultDetails; -import microsoft.exchange.webservices.data.security.XmlNodeType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.xml.stream.XMLStreamException; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.zip.GZIPInputStream; -import java.util.zip.InflaterInputStream; - -/** - * Represents the base class for all requested made to the Autodiscover service. - */ -public abstract class AutodiscoverRequest { - - private static final Log LOG = LogFactory.getLog(AutodiscoverRequest.class); - - /** - * The service. - */ - private AutodiscoverService service; - - /** - * The url. - */ - private URI url; - - /** - * Initializes a new instance of the AutodiscoverResponse class. - * - * @param service Autodiscover service associated with this request. - * @param url URL of Autodiscover service. - */ - protected AutodiscoverRequest(AutodiscoverService service, URI url) { - this.service = service; - this.url = url; - } - - /** - * Determines whether response is a redirection. - * - * @param request the request - * @return True if redirection response. - * @throws EWSHttpException the EWS http exception - */ - public static boolean isRedirectionResponse(HttpWebRequest request) - throws EWSHttpException { - return ((request.getResponseCode() == 301) - || (request.getResponseCode() == 302) - || (request.getResponseCode() == 307) || (request - .getResponseCode() == 303)); - } - - /** - * Validates the request. - * - * @throws Exception the exception - */ - protected void validate() throws Exception { - this.getService().validate(); - } - - /** - * Executes this instance. - * - * @return the autodiscover response - * @throws Exception the exception - */ - protected AutodiscoverResponse internalExecute() throws Exception { - this.validate(); - HttpWebRequest request = null; - try { - request = this.service.prepareHttpWebRequestForUrl(this.url); - this.service.traceHttpRequestHeaders( - TraceFlags.AutodiscoverRequestHttpHeaders, request); - - boolean needSignature = this.getService().getCredentials() != null - && this.getService().getCredentials().isNeedSignature(); - boolean needTrace = this.getService().isTraceEnabledFor( - TraceFlags.AutodiscoverRequest); - - OutputStream urlOutStream = request.getOutputStream(); - // OutputStreamWriter out = new OutputStreamWriter(request - // .getOutputStream()); - - ByteArrayOutputStream memoryStream = new ByteArrayOutputStream(); - EwsServiceXmlWriter writer = new EwsServiceXmlWriter(this - .getService(), memoryStream); - writer.setRequireWSSecurityUtilityNamespace(needSignature); - this.writeSoapRequest(this.url, writer); - - if (needSignature) { - this.service.getCredentials().sign(memoryStream); - } - - if (needTrace) { - memoryStream.flush(); - this.service.traceXml(TraceFlags.AutodiscoverRequest, - memoryStream); - } - memoryStream.writeTo(urlOutStream); - urlOutStream.flush(); - urlOutStream.close(); - memoryStream.close(); - // out.write(memoryStream.toString()); - // out.close(); - request.executeRequest(); - request.getResponseCode(); - if (AutodiscoverRequest.isRedirectionResponse(request)) { - AutodiscoverResponse response = this - .createRedirectionResponse(request); - if (response != null) { - return response; - } else { - throw new ServiceRemoteException("The service returned an invalid redirection response."); - } - } - - memoryStream = new ByteArrayOutputStream(); - InputStream serviceResponseStream = request.getInputStream(); - - while (true) { - int data = serviceResponseStream.read(); - if (-1 == data) { - break; - } else { - memoryStream.write(data); - } - } - memoryStream.flush(); - serviceResponseStream.close(); - - if (this.service.isTraceEnabled()) { - this.service.traceResponse(request, memoryStream); - } - ByteArrayInputStream memoryStreamIn = new ByteArrayInputStream( - memoryStream.toByteArray()); - EwsXmlReader ewsXmlReader = new EwsXmlReader(memoryStreamIn); - - // WCF may not generate an XML declaration. - ewsXmlReader.read(); - if (ewsXmlReader.getNodeType().getNodeType() == XmlNodeType.START_DOCUMENT) { - ewsXmlReader.readStartElement(XmlNamespace.Soap, - XmlElementNames.SOAPEnvelopeElementName); - } else if ((ewsXmlReader.getNodeType().getNodeType() != XmlNodeType.START_ELEMENT) - || (!ewsXmlReader.getLocalName().equals( - XmlElementNames.SOAPEnvelopeElementName)) - || (!ewsXmlReader.getNamespaceUri().equals( - EwsUtilities.getNamespaceUri(XmlNamespace.Soap)))) { - throw new ServiceXmlDeserializationException("The Autodiscover service response was invalid."); - } - - this.readSoapHeaders(ewsXmlReader); - - AutodiscoverResponse response = this.readSoapBody(ewsXmlReader); - - ewsXmlReader.readEndElement(XmlNamespace.Soap, - XmlElementNames.SOAPEnvelopeElementName); - - if (response.getErrorCode() == AutodiscoverErrorCode.NoError) { - return response; - } else { - throw new AutodiscoverResponseException( - response.getErrorCode(), response.getErrorMessage()); - } - - } catch (XMLStreamException ex) { - this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format("XML parsing error: %s", ex.getMessage())); - - // Wrap exception - throw new ServiceRequestException(String.format("The request failed. %s", ex.getMessage()), ex); - } catch (IOException ex) { - this.service.traceMessage(TraceFlags.AutodiscoverConfiguration, - String.format("I/O error: %s", ex.getMessage())); - - // Wrap exception - throw new ServiceRequestException(String.format("The request failed. %s", ex.getMessage()), ex); - } catch (Exception ex) { - // HttpWebRequest httpWebResponse = (HttpWebRequest)ex; - - if (null != request && request.getResponseCode() == 7) { - if (AutodiscoverRequest.isRedirectionResponse(request)) { - this.service - .processHttpResponseHeaders( - TraceFlags.AutodiscoverResponseHttpHeaders, - request); - - AutodiscoverResponse response = this - .createRedirectionResponse(request); - if (response != null) { - return response; - } - } else { - this.processWebException(ex, request); - } - } - - // Wrap exception if the above code block didn't throw - throw new ServiceRequestException(String.format("The request failed. %s", ex.getMessage()), ex); - } finally { - try { - if (request != null) { - request.close(); - } - } catch (Exception e) { - // do nothing - } - } - } - - /** - * Processes the web exception. - * - * @param exception WebException - * @param req HttpWebRequest - */ - private void processWebException(Exception exception, HttpWebRequest req) { - if (null != req) { - try { - if (500 == req.getResponseCode()) { - if (this.service - .isTraceEnabledFor( - TraceFlags.AutodiscoverRequest)) { - ByteArrayOutputStream memoryStream = - new ByteArrayOutputStream(); - InputStream serviceResponseStream = AutodiscoverRequest - .getResponseStream(req); - while (true) { - int data = serviceResponseStream.read(); - if (-1 == data) { - break; - } else { - memoryStream.write(data); - } - } - memoryStream.flush(); - serviceResponseStream.close(); - this.service.traceResponse(req, memoryStream); - ByteArrayInputStream memoryStreamIn = - new ByteArrayInputStream( - memoryStream.toByteArray()); - EwsXmlReader reader = new EwsXmlReader(memoryStreamIn); - this.readSoapFault(reader); - memoryStream.close(); - } else { - InputStream serviceResponseStream = AutodiscoverRequest - .getResponseStream(req); - EwsXmlReader reader = new EwsXmlReader( - serviceResponseStream); - SoapFaultDetails soapFaultDetails = this.readSoapFault(reader); - serviceResponseStream.close(); - - if (soapFaultDetails != null) { - throw new ServiceResponseException( - new ServiceResponse(soapFaultDetails)); - } - } - } else { - this.service.processHttpErrorResponse(req, exception); - } - } catch (Exception e) { - LOG.error(e); - } - } - } - - /** - * Create a redirection response. - * - * @param httpWebResponse the HTTP web response - * @return AutodiscoverResponse autodiscoverResponse object - * @throws XMLStreamException the XML stream exception - * @throws IOException signals that an I/O exception has occurred - * @throws EWSHttpException the EWS http exception - */ - private AutodiscoverResponse createRedirectionResponse( - HttpWebRequest httpWebResponse) throws XMLStreamException, - IOException, EWSHttpException { - String location = httpWebResponse.getResponseHeaderField("Location"); - if (!(location == null || location.isEmpty())) { - try { - URI redirectionUri = new URI(location); - String scheme = redirectionUri.getScheme(); - - if (scheme.equalsIgnoreCase(EWSConstants.HTTP_SCHEME) - || scheme.equalsIgnoreCase(EWSConstants.HTTPS_SCHEME)) { - AutodiscoverResponse response = this.createServiceResponse(); - response.setErrorCode(AutodiscoverErrorCode.RedirectUrl); - response.setRedirectionUrl(redirectionUri); - return response; - } - - this.service - .traceMessage( - TraceFlags.AutodiscoverConfiguration, - String - .format( - "Invalid redirection" + - " URL '%s' " + - "returned by Autodiscover " + - "service.", - redirectionUri.toString())); - - } catch (URISyntaxException ex) { - this.service - .traceMessage( - TraceFlags.AutodiscoverConfiguration, - String - .format( - "Invalid redirection " + - "location '%s' " + - "returned by Autodiscover " + - "service.", - location)); - } - } else { - this.service - .traceMessage( - TraceFlags.AutodiscoverConfiguration, - "Redirection response returned by Autodiscover " + - "service without redirection location."); - } - - return null; - } - - /** - * Reads the SOAP fault. - * - * @param reader The reader. - * @return SOAP fault details. - */ - private SoapFaultDetails readSoapFault(EwsXmlReader reader) { - SoapFaultDetails soapFaultDetails = null; - - try { - - reader.read(); - if (reader.getNodeType().getNodeType() == XmlNodeType.START_DOCUMENT) { - reader.read(); - } - if (!reader.isStartElement() - || (!reader.getLocalName().equals( - XmlElementNames.SOAPEnvelopeElementName))) { - return null; - } - - // Get the namespace URI from the envelope element and use it for - // the rest of the parsing. - // If it's not 1.1 or 1.2, we can't continue. - XmlNamespace soapNamespace = EwsUtilities - .getNamespaceFromUri(reader.getNamespaceUri()); - if (soapNamespace == XmlNamespace.NotSpecified) { - return null; - } - - reader.read(); - - // Skip SOAP header. - if (reader.isStartElement(soapNamespace, - XmlElementNames.SOAPHeaderElementName)) { - do { - reader.read(); - } while (!reader.isEndElement(soapNamespace, - XmlElementNames.SOAPHeaderElementName)); - - // Queue up the next read - reader.read(); - } - - // Parse the fault element contained within the SOAP body. - if (reader.isStartElement(soapNamespace, - XmlElementNames.SOAPBodyElementName)) { - do { - reader.read(); - - // Parse Fault element - if (reader.isStartElement(soapNamespace, - XmlElementNames.SOAPFaultElementName)) { - soapFaultDetails = SoapFaultDetails.parse(reader, - soapNamespace); - } - } while (!reader.isEndElement(soapNamespace, - XmlElementNames.SOAPBodyElementName)); - } - - reader.readEndElement(soapNamespace, - XmlElementNames.SOAPEnvelopeElementName); - } catch (Exception e) { - // If response doesn't contain a valid SOAP fault, just ignore - // exception and - // return null for SOAP fault details. - LOG.error(e); - } - - return soapFaultDetails; - } - - /** - * Writes the autodiscover SOAP request. - * - * @param requestUrl request URL - * @param writer writer object - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected void writeSoapRequest(URI requestUrl, - EwsServiceXmlWriter writer) throws XMLStreamException, ServiceXmlSerializationException { - - if (writer.isRequireWSSecurityUtilityNamespace()) { - writer.writeAttributeValue("xmlns", - EwsUtilities.WSSecurityUtilityNamespacePrefix, - EwsUtilities.WSSecurityUtilityNamespace); - } - writer.writeStartDocument(); - writer.writeStartElement(XmlNamespace.Soap, - XmlElementNames.SOAPEnvelopeElementName); - writer.writeAttributeValue("xmlns", EwsUtilities - .getNamespacePrefix(XmlNamespace.Soap), EwsUtilities - .getNamespaceUri(XmlNamespace.Soap)); - writer.writeAttributeValue("xmlns", - EwsUtilities.AutodiscoverSoapNamespacePrefix, - EwsUtilities.AutodiscoverSoapNamespace); - writer.writeAttributeValue("xmlns", - EwsUtilities.WSAddressingNamespacePrefix, - EwsUtilities.WSAddressingNamespace); - writer.writeAttributeValue("xmlns", - EwsUtilities.EwsXmlSchemaInstanceNamespacePrefix, - EwsUtilities.EwsXmlSchemaInstanceNamespace); - - writer.writeStartElement(XmlNamespace.Soap, - XmlElementNames.SOAPHeaderElementName); - - if (this.service.getCredentials() != null) { - this.service.getCredentials().emitExtraSoapHeaderNamespaceAliases( - writer.getInternalWriter()); - } - - writer.writeElementValue(XmlNamespace.Autodiscover, - XmlElementNames.RequestedServerVersion, this.service - .getRequestedServerVersion().toString()); - - writer.writeElementValue(XmlNamespace.WSAddressing, - XmlElementNames.Action, this.getWsAddressingActionName()); - - writer.writeElementValue(XmlNamespace.WSAddressing, XmlElementNames.To, - requestUrl.toString()); - - this.writeExtraCustomSoapHeadersToXml(writer); - - if (this.service.getCredentials() != null) { - this.service.getCredentials().serializeWSSecurityHeaders( - writer.getInternalWriter()); - } - - this.service.doOnSerializeCustomSoapHeaders(writer.getInternalWriter()); - - writer.writeEndElement(); // soap:Header - - writer.writeStartElement(XmlNamespace.Soap, - XmlElementNames.SOAPBodyElementName); - - this.writeBodyToXml(writer); - - writer.writeEndElement(); // soap:Body - writer.writeEndElement(); // soap:Envelope - writer.flush(); - writer.dispose(); - } - - /** - * Write extra headers. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws XMLStreamException the XML stream exception - */ - protected void writeExtraCustomSoapHeadersToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - // do nothing here. - // currently used only by GetUserSettingRequest to emit the BinarySecret header. - } - - - /** - * Writes XML body. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws XMLStreamException the XML stream exception - */ - protected void writeBodyToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - writer.writeStartElement(XmlNamespace.Autodiscover, this - .getRequestXmlElementName()); - - this.writeAttributesToXml(writer); - this.writeElementsToXml(writer); - - writer.writeEndElement(); // m:this.GetXmlElementName() - } - - /** - * Gets the response stream (may be wrapped with GZip/Deflate stream to - * decompress content). - * - * @param request the request - * @return ResponseStream - * @throws EWSHttpException the EWS http exception - * @throws IOException signals that an I/O exception has occurred. - */ - protected static InputStream getResponseStream(HttpWebRequest request) - throws EWSHttpException, IOException { - String contentEncoding = ""; - - if (null != request.getContentEncoding()) { - contentEncoding = request.getContentEncoding().toLowerCase(); - } - - InputStream responseStream; - - if (contentEncoding.contains("gzip")) { - responseStream = new GZIPInputStream(request.getInputStream()); - } else if (contentEncoding.contains("deflate")) { - responseStream = new InflaterInputStream(request.getInputStream()); - } else { - responseStream = request.getInputStream(); - } - return responseStream; - } - - /** - * Read SOAP header. - * - * @param reader EwsXmlReader. - * @throws Exception the exception - */ - protected void readSoapHeaders(EwsXmlReader reader) throws Exception { - reader.readStartElement(XmlNamespace.Soap, - XmlElementNames.SOAPHeaderElementName); - do { - reader.read(); - - this.readSoapHeader(reader); - } while (!reader.isEndElement(XmlNamespace.Soap, - XmlElementNames.SOAPHeaderElementName)); - } - - /** - * Reads a single SOAP header. - * - * @param reader EwsXmlReader - * @throws Exception on error - */ - protected void readSoapHeader(EwsXmlReader reader) throws Exception { - // Is this the ServerVersionInfo? - if (reader.isStartElement(XmlNamespace.Autodiscover, - XmlElementNames.ServerVersionInfo)) { - this.service.setServerInfo(this.readServerVersionInfo(reader)); - } - } - - /** - * Read ServerVersionInfo SOAP header. - * - * @param reader EwsXmlReader. - * @return ExchangeServerInfo ExchangeServerInfo object - * @throws Exception the exception - */ - private ExchangeServerInfo readServerVersionInfo(EwsXmlReader reader) - throws Exception { - ExchangeServerInfo serverInfo = new ExchangeServerInfo(); - do { - reader.read(); - - if (reader.isStartElement()) { - if (reader.getLocalName().equals(XmlElementNames.MajorVersion)) { - serverInfo.setMajorVersion(reader - .readElementValue(Integer.class)); - } else if (reader.getLocalName().equals( - XmlElementNames.MinorVersion)) { - serverInfo.setMinorVersion(reader - .readElementValue(Integer.class)); - } else if (reader.getLocalName().equals( - XmlElementNames.MajorBuildNumber)) { - serverInfo.setMajorBuildNumber(reader - .readElementValue(Integer.class)); - } else if (reader.getLocalName().equals( - XmlElementNames.MinorBuildNumber)) { - serverInfo.setMinorBuildNumber(reader - .readElementValue(Integer.class)); - } else if (reader.getLocalName() - .equals(XmlElementNames.Version)) { - serverInfo.setVersionString(reader.readElementValue()); - } - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.ServerVersionInfo)); - - return serverInfo; - } - - /** - * Read SOAP body. - * - * @param reader EwsXmlReader. - * @return AutodiscoverResponse AutodiscoverResponse object - * @throws Exception the exception - */ - protected AutodiscoverResponse readSoapBody(EwsXmlReader reader) throws Exception { - reader.readStartElement(XmlNamespace.Soap, - XmlElementNames.SOAPBodyElementName); - AutodiscoverResponse responses = this.loadFromXml(reader); - reader.readEndElement(XmlNamespace.Soap, - XmlElementNames.SOAPBodyElementName); - return responses; - } - - /** - * Loads response from XML. - * - * @param reader The reader. - * @return AutodiscoverResponse object - * @throws Exception the exception - */ - protected AutodiscoverResponse loadFromXml(EwsXmlReader reader) throws Exception { - String elementName = this.getResponseXmlElementName(); - reader.readStartElement(XmlNamespace.Autodiscover, elementName); - AutodiscoverResponse response = this.createServiceResponse(); - response.loadFromXml(reader, elementName); - return response; - } - - /** - * Gets the name of the request XML element. - * - * @return RequestXmlElementName gets XmlElementName. - */ - protected abstract String getRequestXmlElementName(); - - /** - * Gets the name of the response XML element. - * - * @return ResponseXmlElementName gets XmlElementName. - */ - protected abstract String getResponseXmlElementName(); - - /** - * Gets the WS-Addressing action name. - * - * @return WsAddressingActionName gets WsAddressingActionName. - */ - protected abstract String getWsAddressingActionName(); - - /** - * Creates the service response. - * - * @return AutodiscoverResponse AutodiscoverResponse object. - */ - protected abstract AutodiscoverResponse createServiceResponse(); - - /** - * Writes attribute to request XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected abstract void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException; - - /** - * Writes elements to request XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected abstract void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException; - - /** - * Gets the Service. - * - * @return AutodiscoverService AutodiscoverService object. - */ - protected AutodiscoverService getService() { - return this.service; - } - - /** - * Gets the URL. - * - * @return url URL Object. - */ - protected URI getUrl() { - return this.url; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/request/GetDomainSettingsRequest.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/request/GetDomainSettingsRequest.java deleted file mode 100644 index 328c5ea0a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/request/GetDomainSettingsRequest.java +++ /dev/null @@ -1,285 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.request; - -import microsoft.exchange.webservices.data.autodiscover.AutodiscoverService; -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverErrorCode; -import microsoft.exchange.webservices.data.autodiscover.response.AutodiscoverResponse; -import microsoft.exchange.webservices.data.autodiscover.response.GetDomainSettingsResponseCollection; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.autodiscover.enumeration.DomainSettingName; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -import java.net.URI; -import java.util.List; - -/** - * Represents a GetDomainSettings request. - */ -public class GetDomainSettingsRequest extends AutodiscoverRequest { - - /** - * Action Uri of Autodiscover.GetDomainSettings method. - */ - private static final String GetDomainSettingsActionUri = - EwsUtilities.AutodiscoverSoapNamespace + - "/Autodiscover/GetDomainSettings"; - - /** - * The domains. - */ - private List domains; - - /** - * The settings. - */ - private List settings; - - private ExchangeVersion requestedVersion; - - /** - * Initializes a new instance of the {@link GetDomainSettingsRequest} class. - * - * @param service the service - * @param url the url - */ - public GetDomainSettingsRequest(AutodiscoverService service, URI url) { - super(service, url); - } - - /** - * Validates the request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - - EwsUtilities.validateParam(this.getDomains(), "domains"); - EwsUtilities.validateParam(this.getSettings(), "settings"); - - if (this.getSettings().size() == 0) { - throw new ServiceValidationException("At least one setting must be requested."); - } - - if (domains.size() == 0) { - throw new ServiceValidationException("At least one domain name must be requested."); - } - - for (String domain : this.getDomains()) { - if (domain == null || domain.isEmpty()) { - throw new ServiceValidationException("The domain name must be specified."); - } - } - } - - /** - * Executes this instance. - * - * @return the gets the domain settings response collection - * @throws Exception the exception - */ - public GetDomainSettingsResponseCollection execute() throws Exception { - GetDomainSettingsResponseCollection responses = - (GetDomainSettingsResponseCollection) this - .internalExecute(); - if (responses.getErrorCode() == AutodiscoverErrorCode.NoError) { - this.PostProcessResponses(responses); - } - return responses; - } - - /** - * Post-process response to GetDomainSettings. - * - * @param responses The GetDomainSettings response. - */ - private void PostProcessResponses( - GetDomainSettingsResponseCollection responses) { - // Note:The response collection may not include all of the requested - // domains if the request has been throttled. - for (int index = 0; index < responses.getCount(); index++) { - responses.getResponses().get(index).setDomain( - this.getDomains().get(index)); - } - } - - /** - * Gets the name of the request XML element. - * - * @return Request XML element name. - */ - @Override - protected String getRequestXmlElementName() { - return XmlElementNames.GetDomainSettingsRequestMessage; - } - - /** - * Gets the name of the response XML element. - * - * @return Response XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetDomainSettingsResponseMessage; - } - - /** - * Gets the WS-Addressing action name. - * - * @return WS-Addressing action name. - */ - @Override - protected String getWsAddressingActionName() { - return GetDomainSettingsActionUri; - } - - /** - * Creates the service response. - * - * @return AutodiscoverResponse - */ - @Override - protected AutodiscoverResponse createServiceResponse() { - return new GetDomainSettingsResponseCollection(); - } - - /** - * Writes the attribute to XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue("xmlns", - EwsUtilities.AutodiscoverSoapNamespacePrefix, - EwsUtilities.AutodiscoverSoapNamespace); - } - - /** - * Writes request to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeStartElement(XmlNamespace.Autodiscover, - XmlElementNames.Request); - - writer.writeStartElement(XmlNamespace.Autodiscover, - XmlElementNames.Domains); - - for (String domain : this.getDomains()) { - if (!(domain == null || domain.isEmpty())) { - writer.writeElementValue(XmlNamespace.Autodiscover, - XmlElementNames.Domain, domain); - } - } - writer.writeEndElement(); // Domains - - writer.writeStartElement(XmlNamespace.Autodiscover, - XmlElementNames.RequestedSettings); - for (DomainSettingName setting : settings) { - writer.writeElementValue(XmlNamespace.Autodiscover, - XmlElementNames.Setting, setting); - } - - writer.writeEndElement(); // RequestedSettings - - if (this.requestedVersion != null) { - writer.writeElementValue(XmlNamespace.Autodiscover, - XmlElementNames.RequestedVersion, this.requestedVersion); - } - - writer.writeEndElement(); // Request - } - - /** - * Gets the domains. - * - * @return the domains - */ - protected List getDomains() { - return domains; - } - - /** - * Sets the domains. - * - * @param value the new domains - */ - public void setDomains(List value) { - domains = value; - } - - /** - * Gets or sets the settings. - * - * @return the settings - */ - protected List getSettings() { - return settings; - } - - /** - * Sets the settings. - * - * @param value the new settings - */ - public void setSettings(List value) { - settings = value; - } - - /** - * Gets or sets the requestedVersion. - * - * @return the requestedVersion - */ - protected ExchangeVersion getRequestedVersion() { - return requestedVersion; - } - - /** - * Sets the requestedVersion. - * - * @param value the new requestedVersion - */ - public void setRequestedVersion(ExchangeVersion value) { - requestedVersion = value; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/request/GetUserSettingsRequest.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/request/GetUserSettingsRequest.java deleted file mode 100644 index d78e27120..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/request/GetUserSettingsRequest.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.request; - -import microsoft.exchange.webservices.data.autodiscover.AutodiscoverService; -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverErrorCode; -import microsoft.exchange.webservices.data.autodiscover.response.AutodiscoverResponse; -import microsoft.exchange.webservices.data.autodiscover.response.GetUserSettingsResponseCollection; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.ExchangeServiceBase; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.autodiscover.enumeration.UserSettingName; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -import java.net.URI; -import java.util.List; - -/** - * Represents a GetUserSettings request. - */ -public class GetUserSettingsRequest extends AutodiscoverRequest { - - /** - * Action Uri of Autodiscover.GetUserSettings method. - */ - private static final String GetUserSettingsActionUri = EwsUtilities. - AutodiscoverSoapNamespace + - "/Autodiscover/GetUserSettings"; - - private List smtpAddresses; - private List settings; - - - // Expect this request to return the partner token. - - private boolean expectPartnerToken = false; - private String partnerTokenReference; - private String partnerToken; - - /** - * Initializes a new instance of the {@link GetUserSettingsRequest} class. - * - * @param service the service - * @param url the url - * @throws ServiceValidationException on validation error - */ - public GetUserSettingsRequest(AutodiscoverService service, URI url) throws ServiceValidationException { - this(service, url, false); - } - - /** - * Initializes a new instance of the {@link GetUserSettingsRequest} class. - * - * @param service autodiscover service associated with this request - * @param url URL of Autodiscover service - * @param expectPartnerToken expect partner token or not - * @throws ServiceValidationException on validation error - */ - public GetUserSettingsRequest(AutodiscoverService service, URI url, boolean expectPartnerToken) - throws ServiceValidationException { - super(service, url); - this.expectPartnerToken = expectPartnerToken; - - // make an explicit https check. - if (expectPartnerToken && !url.getScheme().equalsIgnoreCase("https")) { - throw new ServiceValidationException("Https is required."); - } - } - - /** - * Validates the request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - - EwsUtilities.validateParam(this.getSmtpAddresses(), "smtpAddresses"); - EwsUtilities.validateParam(this.getSettings(), "settings"); - - if (this.getSettings().size() == 0) { - throw new ServiceValidationException("At least one setting must be requested."); - } - - if (this.getSmtpAddresses().size() == 0) { - throw new ServiceValidationException("At least one SMTP address must be requested."); - } - - for (String smtpAddress : this.getSmtpAddresses()) { - if (smtpAddress == null || smtpAddress.isEmpty()) { - throw new ServiceValidationException("A valid SMTP address must be specified."); - } - } - } - - /** - * Executes this instance. - * - * @return the gets the user settings response collection - * @throws Exception the exception - */ - public GetUserSettingsResponseCollection execute() throws Exception { - GetUserSettingsResponseCollection responses = - (GetUserSettingsResponseCollection) this - .internalExecute(); - if (responses.getErrorCode() == AutodiscoverErrorCode.NoError) { - this.postProcessResponses(responses); - } - return responses; - } - - /** - * Post-process response to GetUserSettings. - * - * @param responses The GetUserSettings response. - */ - private void postProcessResponses( - GetUserSettingsResponseCollection responses) { - // Note:The response collection may not include all of the requested - // users if the request has been throttled. - for (int index = 0; index < responses.getCount(); index++) { - responses.getResponses().get(index).setSmtpAddress( - this.getSmtpAddresses().get(index)); - } - } - - /** - * Gets the name of the request XML element. - * - * @return Request XML element name. - */ - @Override - protected String getRequestXmlElementName() { - return XmlElementNames.GetUserSettingsRequestMessage; - } - - /** - * Gets the name of the response XML element. - * - * @return Response XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetUserSettingsResponseMessage; - } - - /** - * Gets the WS-Addressing action name. - * - * @return WS-Addressing action name. - */ - @Override - protected String getWsAddressingActionName() { - return GetUserSettingsActionUri; - } - - /** - * Creates the service response. - * - * @return AutodiscoverResponse - */ - @Override - protected AutodiscoverResponse createServiceResponse() { - return new GetUserSettingsResponseCollection(); - } - - /** - * Writes the attribute to XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue("xmlns", - EwsUtilities.AutodiscoverSoapNamespacePrefix, - EwsUtilities.AutodiscoverSoapNamespace); - } - - /** - * @param writer XML writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override public void writeExtraCustomSoapHeadersToXml(EwsServiceXmlWriter writer) throws XMLStreamException, - ServiceXmlSerializationException { - if (this.expectPartnerToken) { - writer - .writeElementValue(XmlNamespace.Autodiscover, - XmlElementNames.BinarySecret, - new String(org.apache.commons.codec.binary.Base64. - encodeBase64(ExchangeServiceBase.getSessionKey()))); - } - } - - /** - * Writes request to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeStartElement(XmlNamespace.Autodiscover, - XmlElementNames.Request); - - writer.writeStartElement(XmlNamespace.Autodiscover, - XmlElementNames.Users); - - for (String smtpAddress : this.getSmtpAddresses()) { - writer.writeStartElement(XmlNamespace.Autodiscover, - XmlElementNames.User); - - if (!(smtpAddress == null || smtpAddress.isEmpty())) { - writer.writeElementValue(XmlNamespace.Autodiscover, - XmlElementNames.Mailbox, smtpAddress); - } - writer.writeEndElement(); // User - } - writer.writeEndElement(); // Users - - writer.writeStartElement(XmlNamespace.Autodiscover, - XmlElementNames.RequestedSettings); - for (UserSettingName setting : this.getSettings()) { - writer.writeElementValue(XmlNamespace.Autodiscover, - XmlElementNames.Setting, setting); - } - - writer.writeEndElement(); // RequestedSettings - - writer.writeEndElement(); // Request - } - - /** - * Read the partner token soap header. - * - * @param reader EWS XML reader - * @throws Exception on error - */ - @Override - protected void readSoapHeader(EwsXmlReader reader) throws Exception { - super.readSoapHeader(reader); - - if (this.expectPartnerToken) { - if (reader.isStartElement(XmlNamespace.Autodiscover, - XmlElementNames.PartnerToken)) { - this.partnerToken = reader.readInnerXml(); - } - - if (reader.isStartElement(XmlNamespace.Autodiscover, - XmlElementNames.PartnerTokenReference)) { - partnerTokenReference = reader.readInnerXml(); - } - } - } - - /** - * Gets the SMTP addresses. - * @return the SMTP addresses - */ - protected List getSmtpAddresses() { - return smtpAddresses; - } - - /** - * Sets the smtp addresses. - * @param value the new smtp addresses - */ - public void setSmtpAddresses(List value) { - this.smtpAddresses = value; - } - - /** - * Gets the settings. - * @return the settings - */ - protected List getSettings() { - return settings; - } - - /** - * Sets the settings. - * - * @param value the new settings - */ - public void setSettings(List value) { - this.settings = value; - - } - - /** - * Gets the partner token. - * @return partner token - */ - protected String getPartnerToken() { - return partnerToken; - } - - private void setPartnerToken(String value) { - partnerToken = value; - } - - /** - * Gets the partner token reference. - * @return partner token reference - */ - protected String getPartnerTokenReference() { - return partnerTokenReference; - - } - - private void setPartnerTokenReference(String tokenReference) { - partnerTokenReference = tokenReference; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/AutodiscoverResponse.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/AutodiscoverResponse.java deleted file mode 100644 index e6c0e3e35..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/AutodiscoverResponse.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.response; - -import microsoft.exchange.webservices.data.autodiscover.enumeration.AutodiscoverErrorCode; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; - -import java.net.URI; - -/** - * Represents the base class for all response returned by the Autodiscover - * service. - */ -public abstract class AutodiscoverResponse { - - /** - * The error code. - */ - private AutodiscoverErrorCode errorCode; - - /** - * The error message. - */ - private String errorMessage; - - /** - * The redirection url. - */ - private URI redirectionUrl; - - /** - * Initializes a new instance of the AutodiscoverResponse class. - */ - public AutodiscoverResponse() { - this.errorCode = AutodiscoverErrorCode.NoError; - } - - /** - * Initializes a new instance of the AutodiscoverResponse class. - * - * @param reader the reader - * @param endElementName the end element name - * @throws Exception the exception - */ - public void loadFromXml(EwsXmlReader reader, String endElementName) - throws Exception { - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ErrorCode)) { - this.errorCode = reader - .readElementValue(AutodiscoverErrorCode.class); - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.ErrorMessage)) { - this.errorMessage = reader.readElementValue(); - } - } - - /** - * Gets the error code that was returned by the service. - * - * @return the error code - */ - public AutodiscoverErrorCode getErrorCode() { - return errorCode; - } - - /** - * Sets the error code. - * - * @param errorCode the new error code - */ - public void setErrorCode(AutodiscoverErrorCode errorCode) { - this.errorCode = errorCode; - } - - /** - * Gets the error message that was returned by the service. - * - * @return the error message - */ - public String getErrorMessage() { - return errorMessage; - } - - /** - * Sets the error message. - * - * @param errorMessage the new error message - */ - public void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - /** - * Gets the redirection URL. - * - * @return the redirection url - */ - public URI getRedirectionUrl() { - return redirectionUrl; - } - - /** - * Sets the redirection url. - * - * @param redirectionUrl the new redirection url - */ - public void setRedirectionUrl(URI redirectionUrl) { - this.redirectionUrl = redirectionUrl; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/GetDomainSettingsResponse.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/GetDomainSettingsResponse.java deleted file mode 100644 index a251597f1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/GetDomainSettingsResponse.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.response; - -import microsoft.exchange.webservices.data.autodiscover.exception.error.DomainSettingError; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.autodiscover.enumeration.DomainSettingName; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -/** - * Represents the response to a GetDomainSettings call for an individual domain. - */ -public final class GetDomainSettingsResponse extends AutodiscoverResponse { - - private static final Log LOG = LogFactory.getLog(GetDomainSettingsResponse.class); - - /** - * The domain. - */ - private String domain; - - /** - * The redirect target. - */ - private String redirectTarget; - - /** - * The settings. - */ - private Map settings; - - /** - * The domain setting errors. - */ - private Collection domainSettingErrors; - - /** - * Initializes a new instance of the {@link GetDomainSettingsResponse} class. - */ - public GetDomainSettingsResponse() { - super(); - this.domain = ""; - this.settings = new HashMap(); - this.domainSettingErrors = new ArrayList(); - } - - /** - * Gets the domain this response applies to. - * - * @return the domain - */ - public String getDomain() { - return this.domain; - } - - /** - * Sets the domain. - * - * @param value the new domain - */ - public void setDomain(String value) { - this.domain = value; - } - - /** - * Gets the redirectionTarget (URL or email address). - * - * @return the redirect target - */ - public String getRedirectTarget() { - return this.redirectTarget; - } - - /** - * Gets the requested settings for the domain. - * - * @return the settings - */ - public Map getSettings() { - return this.settings; - } - - /** - * Gets error information for settings that could not be returned. - * - * @return the domain setting errors - */ - public Collection getDomainSettingErrors() { - return this.domainSettingErrors; - } - - /** - * Loads response from XML. - * - * @param reader The reader. - * @param endElementName End element name. - * @throws Exception the exception - */ - @Override public void loadFromXml(EwsXmlReader reader, String endElementName) - throws Exception { - do { - reader.read(); - - if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName() - .equals(XmlElementNames.RedirectTarget)) { - this.redirectTarget = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.DomainSettingErrors)) { - this.loadDomainSettingErrorsFromXml(reader); - } else if (reader.getLocalName().equals( - XmlElementNames.DomainSettings)) { - try { - this.loadDomainSettingsFromXml(reader); - } catch (Exception e) { - LOG.error(e); - } - } else { - super.loadFromXml(reader, endElementName); - break; - } - } - } while (!reader - .isEndElement(XmlNamespace.Autodiscover, endElementName)); - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - protected void loadDomainSettingsFromXml(EwsXmlReader reader) - throws Exception { - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if ((reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) && - (reader.getLocalName() - .equals(XmlElementNames.DomainSetting))) { - String settingClass = reader.readAttributeValue( - XmlNamespace.XmlSchemaInstance, - XmlAttributeNames.Type); - - if (settingClass - .equals(XmlElementNames.DomainStringSetting)) { - - this.readSettingFromXml(reader); - } else { - EwsUtilities - .ewsAssert(false, "GetDomainSettingsResponse." + "LoadDomainSettingsFromXml", - String.format("%s,%s", "Invalid setting " + "class '%s' returned", settingClass)); - break; - } - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.DomainSettings)); - } else { - reader.read(); - } - } - - /** - * Reads domain setting from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - private void readSettingFromXml(EwsXmlReader reader) throws Exception { - DomainSettingName name = null; - Object value = null; - - do { - reader.read(); - - if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals( - XmlElementNames.DomainStringSetting)) { - name = reader.readElementValue(DomainSettingName.class); - } else if (reader.getLocalName().equals(XmlElementNames.Value)) { - value = reader.readElementValue(); - } - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.DomainSetting)); - - EwsUtilities.ewsAssert(name != null, "GetDomainSettingsResponse.ReadSettingFromXml", - "Missing name element in domain setting"); - - this.settings.put(name, value); - } - - /** - * Loads the domain setting errors. - * - * @param reader The reader. - * @throws Exception the exception - */ - private void loadDomainSettingErrorsFromXml(EwsXmlReader reader) - throws Exception { - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if ((reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) && - (reader.getLocalName() - .equals(XmlElementNames.DomainSettingError))) { - DomainSettingError error = new DomainSettingError(); - error.loadFromXml(reader); - domainSettingErrors.add(error); - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.DomainSettingErrors)); - } else { - reader.read(); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/GetDomainSettingsResponseCollection.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/GetDomainSettingsResponseCollection.java deleted file mode 100644 index e56d952d2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/GetDomainSettingsResponseCollection.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.response; - -import microsoft.exchange.webservices.data.autodiscover.AutodiscoverResponseCollection; -import microsoft.exchange.webservices.data.core.XmlElementNames; - -/** - * Represents a collection of response to GetDomainSettings. - */ -public final class GetDomainSettingsResponseCollection extends - AutodiscoverResponseCollection { - - /** - * Initializes a new instance of the AutodiscoverResponseCollection class. - */ - public GetDomainSettingsResponseCollection() { - } - - /** - * Create a response instance. - * - * @return GetDomainSettingsResponse. - */ - @Override - protected GetDomainSettingsResponse createResponseInstance() { - return new GetDomainSettingsResponse(); - } - - /** - * Gets the name of the response collection XML element. - * - * @return Response collection XMl element name. - */ - @Override - protected String getResponseCollectionXmlElementName() { - return XmlElementNames.DomainResponses; - } - - /** - * Gets the name of the response instance XML element. - * - * @return Response instance XMl element name. - */ - @Override - protected String getResponseInstanceXmlElementName() { - return XmlElementNames.DomainResponse; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/GetUserSettingsResponse.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/GetUserSettingsResponse.java deleted file mode 100644 index da57430f0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/GetUserSettingsResponse.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.response; - -import microsoft.exchange.webservices.data.autodiscover.AlternateMailboxCollection; -import microsoft.exchange.webservices.data.autodiscover.ProtocolConnectionCollection; -import microsoft.exchange.webservices.data.autodiscover.WebClientUrlCollection; -import microsoft.exchange.webservices.data.autodiscover.exception.error.UserSettingError; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.autodiscover.enumeration.UserSettingName; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -/** - * Represents the response to a GetUsersSettings call for an individual user. - */ -public final class GetUserSettingsResponse extends AutodiscoverResponse { - - /** - * The smtp address. - */ - private String smtpAddress; - - /** - * The redirect target. - */ - private String redirectTarget; - - /** - * The settings. - */ - private Map settings; - - /** - * The user setting errors. - */ - private Collection userSettingErrors; - - /** - * Initializes a new instance of the {@link GetUserSettingsResponse} class. - */ - public GetUserSettingsResponse() { - super(); - this.setSmtpAddress(null); - this.setSettings(new HashMap()); - this.setUserSettingErrors(new ArrayList()); - } - - /** - * Tries the get the user setting value. - * - * @param cls Type of user setting. - * @param setting The setting. - * @param value The setting value. - * @return True if setting was available. - */ - public boolean tryGetSettingValue(Class cls, - UserSettingName setting, OutParam value) { - Object objValue; - if (this.getSettings().containsKey(setting)) { - objValue = this.getSettings().get(setting); - value.setParam((T) objValue); - return true; - } else { - value.setParam(null); - return false; - } - } - - /** - * Gets the SMTP address this response applies to. - * - * @return the smtp address - */ - public String getSmtpAddress() { - return this.smtpAddress; - } - - /** - * Sets the smtp address. - * - * @param value the new smtp address - */ - public void setSmtpAddress(String value) { - this.smtpAddress = value; - } - - /** - * Gets the redirectionTarget (URL or email address). - * - * @return the redirect target - */ - public String getRedirectTarget() { - return this.redirectTarget; - } - - /** - * Sets the redirectionTarget (URL or email address). - * @param value redirect target value - */ - public void setRedirectTarget(String value) { - this.redirectTarget = value; - } - - /** - * Gets the requested settings for the user. - * - * @return the settings - */ - public Map getSettings() { - return this.settings; - } - - /** - * Sets the requested settings for the user. - * @param settings settings map - */ - public void setSettings(Map settings) { - this.settings = settings; - } - - /** - * Gets error information for settings that could not be returned. - * - * @return the user setting errors - */ - public Collection getUserSettingErrors() { - return this.userSettingErrors; - } - - /** - * Sets the requested settings for the user. - * @param value user setting errors - */ - protected void setUserSettingErrors(Collection value) { - this.userSettingErrors = value; - } - - /** - * Loads response from XML. - * - * @param reader The reader. - * @param endElementName End element name. - * @throws Exception the exception - */ - @Override public void loadFromXml(EwsXmlReader reader, String endElementName) - throws Exception { - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName() - .equals(XmlElementNames.RedirectTarget)) { - - this.setRedirectTarget(reader.readElementValue()); - } else if (reader.getLocalName().equals( - XmlElementNames.UserSettingErrors)) { - this.loadUserSettingErrorsFromXml(reader); - } else if (reader.getLocalName().equals( - XmlElementNames.UserSettings)) { - this.loadUserSettingsFromXml(reader); - } else { - super.loadFromXml(reader, endElementName); - } - } - } while (!reader - .isEndElement(XmlNamespace.Autodiscover, endElementName)); - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - protected void loadUserSettingsFromXml(EwsXmlReader reader) - throws Exception { - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && - (reader.getLocalName() - .equals(XmlElementNames.UserSetting))) { - String settingClass = reader.readAttributeValue( - XmlNamespace.XmlSchemaInstance, - XmlAttributeNames.Type); - - if (settingClass.equals(XmlElementNames.StringSetting)) { - this.readSettingFromXml(reader); - } else if (settingClass.equals(XmlElementNames.WebClientUrlCollectionSetting)) { - this.readSettingFromXml(reader); - } else if (settingClass.equals(XmlElementNames.AlternateMailboxCollectionSetting)) { - this.readSettingFromXml(reader); - } else if (settingClass.equals(XmlElementNames.ProtocolConnectionCollectionSetting)) { - this.readSettingFromXml(reader); - } else { - EwsUtilities.ewsAssert(false, "GetUserSettingsResponse." + "LoadUserSettingsFromXml", String - .format("%s,%s", "Invalid setting class '%s' returned", settingClass)); - break; - } - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.UserSettings)); - } else { - reader.read(); - } - } - - /** - * Reads user setting from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - private void readSettingFromXml(EwsXmlReader reader) throws Exception { - UserSettingName name = null; - Object value = null; - - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals(XmlElementNames.Name)) { - name = reader.readElementValue(UserSettingName.class); - } else if (reader.getLocalName().equals(XmlElementNames.Value)) { - value = reader.readElementValue(); - } else if (reader.getLocalName().equals( - XmlElementNames.WebClientUrls)) { - - value = WebClientUrlCollection.loadFromXml(reader); - } else if (reader.getLocalName().equals( - XmlElementNames.ProtocolConnections)) { - value = ProtocolConnectionCollection.loadFromXml(reader); - } else if (reader.getLocalName().equals( - XmlElementNames.AlternateMailboxes)) { - value = AlternateMailboxCollection.loadFromXml(reader); - } - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.UserSetting)); - - EwsUtilities.ewsAssert(name != null, "GetUserSettingsResponse.ReadSettingFromXml", - "Missing name element in user setting"); - - this.getSettings().put(name, value); - } - - /** - * Loads the user setting errors. - * - * @param reader The reader. - * @throws Exception the exception - */ - private void loadUserSettingErrorsFromXml(EwsXmlReader reader) - throws Exception { - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && - (reader.getLocalName() - .equals(XmlElementNames.UserSettingError))) { - UserSettingError error = new UserSettingError(); - error.loadFromXml(reader); - this.getUserSettingErrors().add(error); - } - } while (!reader.isEndElement(XmlNamespace.Autodiscover, - XmlElementNames.UserSettingErrors)); - } else { - reader.read(); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/GetUserSettingsResponseCollection.java b/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/GetUserSettingsResponseCollection.java deleted file mode 100644 index 5233db578..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/autodiscover/response/GetUserSettingsResponseCollection.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.response; - -import microsoft.exchange.webservices.data.autodiscover.AutodiscoverResponseCollection; -import microsoft.exchange.webservices.data.core.XmlElementNames; - -/** - * Represents a collection of response to GetUserSettings. - */ -public final class GetUserSettingsResponseCollection extends - AutodiscoverResponseCollection { - - /** - * Initializes a new instance of the AutodiscoverResponseCollection class. - */ - public GetUserSettingsResponseCollection() { - } - - /** - * Create a response instance. - * - * @return GetUserSettingsResponse. - */ - @Override - protected GetUserSettingsResponse createResponseInstance() { - return new GetUserSettingsResponse(); - } - - /** - * Gets the name of the response collection XML element. - * - * @return Response collection XMl element name. - */ - @Override - protected String getResponseCollectionXmlElementName() { - return XmlElementNames.UserResponses; - } - - /** - * Gets the name of the response instance XML element. - * - * @return Response instance XMl element name. - */ - @Override - protected String getResponseInstanceXmlElementName() { - return XmlElementNames.UserResponse; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/CookieProcessingTargetAuthenticationStrategy.java b/src/main/java/microsoft/exchange/webservices/data/core/CookieProcessingTargetAuthenticationStrategy.java deleted file mode 100644 index 6a1e1b81b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/CookieProcessingTargetAuthenticationStrategy.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import org.apache.http.Header; -import org.apache.http.HttpException; -import org.apache.http.HttpHost; -import org.apache.http.HttpRequest; -import org.apache.http.HttpResponse; -import org.apache.http.auth.MalformedChallengeException; -import org.apache.http.client.protocol.HttpClientContext; -import org.apache.http.client.protocol.RequestAddCookies; -import org.apache.http.client.protocol.ResponseProcessCookies; -import org.apache.http.impl.client.TargetAuthenticationStrategy; -import org.apache.http.protocol.HttpContext; - -import java.io.IOException; -import java.util.Map; - -/** - * TargetAuthenticationStrategy that also processes the cookies in HTTP 401 response. While not fully - * according to the RFC's, this is often necessary to ensure good load balancing behaviour (e.g., TMG server - * requires it for authentication, where it sends a HTTP 401 with a new Cookie after 5 minutes of inactivity) - */ -public class CookieProcessingTargetAuthenticationStrategy extends TargetAuthenticationStrategy { - ResponseProcessCookies responseProcessCookies = new ResponseProcessCookies(); - RequestAddCookies requestAddCookies = new RequestAddCookies(); - - @Override - public Map getChallenges(HttpHost authhost, HttpResponse response, HttpContext context) - throws MalformedChallengeException { - try { - // Get the request from the context - HttpClientContext clientContext = HttpClientContext.adapt(context); - HttpRequest request = clientContext.getRequest(); - - // Save new cookies in the context - responseProcessCookies.process(response, context); - - // Remove existing cookies and set the new cookies in the request - request.removeHeaders("Cookie"); - requestAddCookies.process(request, context); - } catch (HttpException e) { - throw new RuntimeException(e); // Looking at the source of responseProcessCookies this never happens - } catch (IOException e) { - throw new RuntimeException(e); // Looking at the source of responseProcessCookies this never happens - } - - return super.getChallenges(authhost, response, context); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/EwsSSLProtocolSocketFactory.java b/src/main/java/microsoft/exchange/webservices/data/core/EwsSSLProtocolSocketFactory.java deleted file mode 100644 index d4d2fefec..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/EwsSSLProtocolSocketFactory.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import org.apache.http.conn.ssl.DefaultHostnameVerifier; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.ssl.SSLContexts; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; - -import java.security.GeneralSecurityException; - -/** - *

- * EwsSSLProtocolSocketFactory can be used to create SSL {@link java.net.Socket}s - * that accept self-signed certificates. - *

- *

- * This socket factory SHOULD NOT be used for productive systems - * due to security reasons, unless it is a conscious decision and - * you are perfectly aware of security implications of accepting - * self-signed certificates - *

- * Example of using custom protocol socket factory for a specific host: - *
- *     Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
- *
- *     URI uri = new URI("https://localhost/", true);
- *     // use relative url only
- *     GetMethod httpget = new GetMethod(uri.getPathQuery());
- *     HostConfiguration hc = new HostConfiguration();
- *     hc.setHost(uri.getHost(), uri.getPort(), easyhttps);
- *     HttpClient client = new HttpClient();
- *     client.executeMethod(hc, httpget);
- *     
- *

- *

- * Example of using custom protocol socket factory per default instead of the standard one: - *

- *     Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
- *     Protocol.registerProtocol("https", easyhttps);
- *
- *     HttpClient client = new HttpClient();
- *     GetMethod httpget = new GetMethod("https://localhost/");
- *     client.executeMethod(httpget);
- *     
- *

- * - *

- * DISCLAIMER: HttpClient developers DO NOT actively support this component. - * The component is provided as a reference material, which may be inappropriate - * for use without additional customization. - *

- */ - -public class EwsSSLProtocolSocketFactory extends SSLConnectionSocketFactory { - - /** - * Default hostname verifier. - */ - private static final HostnameVerifier DEFAULT_HOSTNAME_VERIFIER = new DefaultHostnameVerifier(); - - - /** - * The SSL Context. - */ - private final SSLContext sslcontext; - - - /** - * Constructor for EasySSLProtocolSocketFactory. - * - * @param context SSL context - * @param hostnameVerifier hostname verifier - */ - public EwsSSLProtocolSocketFactory( - SSLContext context, HostnameVerifier hostnameVerifier - ) { - super(context, hostnameVerifier); - this.sslcontext = context; - } - - - /** - * Create and configure SSL protocol socket factory using default hostname verifier. - * {@link EwsSSLProtocolSocketFactory#DEFAULT_HOSTNAME_VERIFIER} - * - * @param trustManager trust manager - * @return socket factory for SSL protocol - * @throws GeneralSecurityException on security error - */ - public static EwsSSLProtocolSocketFactory build(TrustManager trustManager) - throws GeneralSecurityException { - return build(trustManager, DEFAULT_HOSTNAME_VERIFIER); - } - - /** - * Create and configure SSL protocol socket factory using trust manager and hostname verifier. - * - * @param trustManager trust manager - * @param hostnameVerifier hostname verifier - * @return socket factory for SSL protocol - * @throws GeneralSecurityException on security error - */ - public static EwsSSLProtocolSocketFactory build( - TrustManager trustManager, HostnameVerifier hostnameVerifier - ) throws GeneralSecurityException { - SSLContext sslContext = createSslContext(trustManager); - return new EwsSSLProtocolSocketFactory(sslContext, hostnameVerifier); - } - - /** - * Create SSL context and initialize it using specific trust manager. - * - * @param trustManager trust manager - * @return initialized SSL context - * @throws GeneralSecurityException on security error - */ - public static SSLContext createSslContext(TrustManager trustManager) - throws GeneralSecurityException { - EwsX509TrustManager x509TrustManager = new EwsX509TrustManager(null, trustManager); - SSLContext sslContext = SSLContexts.createDefault(); - sslContext.init( - null, - new TrustManager[] { x509TrustManager }, - null - ); - return sslContext; - } - - - /** - * @return SSL context - */ - public SSLContext getContext() { - return sslcontext; - } - - public boolean equals(Object obj) { - return ((obj != null) && obj.getClass().equals(EwsSSLProtocolSocketFactory.class)); - } - - public int hashCode() { - return EwsSSLProtocolSocketFactory.class.hashCode(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/EwsServiceMultiResponseXmlReader.java b/src/main/java/microsoft/exchange/webservices/data/core/EwsServiceMultiResponseXmlReader.java deleted file mode 100644 index aa9b25ab1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/EwsServiceMultiResponseXmlReader.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; - -/** - * Represents an xml reader used by the ExchangeService to parse multi-response streams, - * such as GetStreamingEvents. - *

- * Necessary because the basic EwsServiceXmlReader does not - * use normalization (see E14:60369), and in order to turn normalization off, it is - * necessary to use an XmlTextReader, which does not allow the ConformanceLevel.Auto that - * a multi-response stream requires. - * If ever there comes a time we need to deal with multi-response streams with user-generated - * content, we will need to tackle that parsing problem separately. - *

- */ -public class EwsServiceMultiResponseXmlReader extends EwsServiceXmlReader { - - /** - * Initializes a new instance of the - * EwsServiceMultiResponseXmlReader class. - * - * @param stream The stream. - * @param service The service. - * @throws Exception - */ - private EwsServiceMultiResponseXmlReader(InputStream stream, - ExchangeService service) throws Exception { - super(stream, service); - } - - /** - * Creates a new instance of the EwsServiceMultiResponseXmlReader class. - * - * @param stream the stream - * @param service the service - * @return an instance of EwsServiceMultiResponseXmlReader wrapped around the input stream - * @throws Exception on error - */ - public static EwsServiceMultiResponseXmlReader create(InputStream stream, ExchangeService service) throws Exception { - return new EwsServiceMultiResponseXmlReader(stream, service); - } - - /** - * Creates the XML reader. - * - * @param stream The stream - * @return an XML reader to use - * @throws XMLStreamException the XML stream exception - */ - private static XMLEventReader createXmlReader(InputStream stream) - throws XMLStreamException { - - // E14:240522 The ProhibitDtd property is used to indicate whether XmlReader should process DTDs or not. By default, - // it will do so. EWS doesn't use DTD references so we want to turn this off. Also, the XmlResolver property is - // set to an instance of XmlUrlResolver by default. We don't want XmlTextReader to try to resolve this DTD reference - // so we disable the XmlResolver as well. - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - InputStreamReader isr = new InputStreamReader(stream); - BufferedReader in = new BufferedReader(isr); - return inputFactory.createXMLEventReader(in); - } - - - /** - * Initializes the XML reader. - * - * @param stream The stream. An XML reader to use. - * @throws Exception on error - */ - @Override - protected XMLEventReader initializeXmlReader(InputStream stream) - throws Exception { - return createXmlReader(stream); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/EwsServiceXmlReader.java b/src/main/java/microsoft/exchange/webservices/data/core/EwsServiceXmlReader.java deleted file mode 100644 index e174f807a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/EwsServiceXmlReader.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.core.response.IGetObjectInstanceDelegate; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.util.DateTimeUtils; - -import java.io.InputStream; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.TimeZone; - -/** - * XML reader. - */ -public class EwsServiceXmlReader extends EwsXmlReader { - - /** - * The service. - */ - private ExchangeService service; - - /** - * Initializes a new instance of the EwsXmlReader class. - * - * @param stream the stream - * @param service the service - * @throws Exception on error - */ - public EwsServiceXmlReader(InputStream stream, ExchangeService service) - throws Exception { - super(stream); - this.service = service; - } - - /** - * Reads the element value as date time. - * - * @return Element value - * @throws Exception the exception - */ - public Date readElementValueAsDateTime() throws Exception { - return DateTimeUtils.convertDateTimeStringToDate(readElementValue()); - } - - /** - * Reads the element value as unspecified date. - * - * @return element value - * @throws Exception on error - */ - public Date readElementValueAsUnspecifiedDate() throws Exception { - return DateTimeUtils.convertDateStringToDate(readElementValue()); - } - - /** - * Reads the element value as date time, assuming it is unbiased (e.g. - * 2009/01/01T08:00) and scoped to service's time zone. - * - * @return Date - * @throws Exception the exception - */ - public Date readElementValueAsUnbiasedDateTimeScopedToServiceTimeZone() - throws Exception { - // Convert the element's value to a DateTime with no adjustment. - String date = this.readElementValue(); - - try { - DateFormat formatter = - new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); - formatter.setTimeZone(TimeZone.getTimeZone("UTC")); - return formatter.parse(date); - } catch (Exception e) { - DateFormat formatter = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss.SSS"); - formatter.setTimeZone(TimeZone.getTimeZone("UTC")); - return formatter.parse(date); - } - } - - /** - * Reads the element value as date time. - * - * @param xmlNamespace the xml namespace - * @param localName the local name - * @return the date - * @throws Exception the exception - */ - public Date readElementValueAsDateTime(XmlNamespace xmlNamespace, String localName) throws Exception { - return DateTimeUtils.convertDateTimeStringToDate(readElementValue(xmlNamespace, localName)); - } - - /** - * Reads the service objects collection from XML. - * - * @param the generic type - * @param collectionXmlElementName the collection xml element name - * @param getObjectInstanceDelegate the get object instance delegate - * @param clearPropertyBag the clear property bag - * @param requestedPropertySet the requested property set - * @param summaryPropertiesOnly the summary property only - * @return the list - * @throws Exception the exception - */ - public List - readServiceObjectsCollectionFromXml( - String collectionXmlElementName, - IGetObjectInstanceDelegate - getObjectInstanceDelegate, - boolean clearPropertyBag, PropertySet requestedPropertySet, - boolean summaryPropertiesOnly) throws Exception { - - List serviceObjects = new ArrayList(); - TServiceObject serviceObject; - - this.readStartElement(XmlNamespace.Messages, collectionXmlElementName); - - if (!this.isEmptyElement()) { - do { - this.read(); - - if (this.isStartElement()) { - serviceObject = (TServiceObject) getObjectInstanceDelegate - .getObjectInstanceDelegate(this.getService(), this - .getLocalName()); - if (serviceObject == null) { - this.skipCurrentElement(); - } else { - if (!(this.getLocalName()).equals(serviceObject - .getXmlElementName())) { - - throw new ServiceLocalException(String - .format( - "The type of the " + "object in " + - "the store (%s)" + - " does not match that" + - " of the " + - "local object (%s).", - this.getLocalName(), serviceObject - .getXmlElementName())); - } - serviceObject.loadFromXml(this, clearPropertyBag, - requestedPropertySet, summaryPropertiesOnly); - - serviceObjects.add(serviceObject); - } - } - } while (!this.isEndElement(XmlNamespace.Messages, - collectionXmlElementName)); - } else { - // For empty elements read End Element tag - // i.e. position cursor on End Element - this.read(); - } - - return serviceObjects; - - } - - /** - * Gets the service. - * - * @return the service - */ - public ExchangeService getService() { - return service; - } - - /** - * Sets the service. - * - * @param service the new service - */ - public void setService(ExchangeService service) { - this.service = service; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/EwsServiceXmlWriter.java b/src/main/java/microsoft/exchange/webservices/data/core/EwsServiceXmlWriter.java deleted file mode 100644 index 4aeab0ba0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/EwsServiceXmlWriter.java +++ /dev/null @@ -1,592 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.complex.ISearchStringProvider; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.CDATASection; -import org.w3c.dom.Comment; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.EntityReference; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.ProcessingInstruction; -import org.w3c.dom.Text; - -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Date; - -/** - * Stax based XML Writer implementation. - */ -public class EwsServiceXmlWriter implements IDisposable { - - private static final Log LOG = LogFactory.getLog(EwsServiceXmlWriter.class); - - /** - * The is disposed. - */ - private boolean isDisposed; - - /** - * The service. - */ - private ExchangeServiceBase service; - - /** - * The xml writer. - */ - private XMLStreamWriter xmlWriter; - - /** - * The is time zone header emitted. - */ - private boolean isTimeZoneHeaderEmitted; - - /** - * The Buffer size. - */ - private static final int BufferSize = 4096; - - /** - * The requireWSSecurityUtilityNamespace * - */ - - protected boolean requireWSSecurityUtilityNamespace; - - /** - * Initializes a new instance. - * - * @param service the service - * @param stream the stream - * @throws XMLStreamException the XML stream exception - */ - public EwsServiceXmlWriter(ExchangeServiceBase service, OutputStream stream) throws XMLStreamException { - this.service = service; - XMLOutputFactory xmlof = XMLOutputFactory.newInstance(); - xmlWriter = xmlof.createXMLStreamWriter(stream, "utf-8"); - - } - - /** - * Try to convert object to a string. - * - * @param value The value. - * @param str the str - * @return True if object was converted, false otherwise. A null object will - * be "successfully" converted to a null string. - */ - protected boolean tryConvertObjectToString(Object value, - OutParam str) { - boolean converted = true; - str.setParam(null); - if (value != null) { - if (value.getClass().isEnum()) { - str.setParam(EwsUtilities.serializeEnum(value)); - } else if (value.getClass().equals(Boolean.class)) { - str.setParam(EwsUtilities.boolToXSBool((Boolean) value)); - } else if (value instanceof Date) { - str - .setParam(this.service - .convertDateTimeToUniversalDateTimeString( - (Date) value)); - } else if (value.getClass().isPrimitive()) { - str.setParam(value.toString()); - } else if (value instanceof String) { - str.setParam(value.toString()); - } else if (value instanceof ISearchStringProvider) { - ISearchStringProvider searchStringProvider = - (ISearchStringProvider) value; - str.setParam(searchStringProvider.getSearchString()); - } else if (value instanceof Number) { - str.setParam(value.toString()); - } else { - converted = false; - } - } - return converted; - } - - /** - * Performs application-defined tasks associated with freeing, releasing, or - * resetting unmanaged resources. - */ - @Override - public void dispose() { - if (!this.isDisposed) { - try { - this.xmlWriter.close(); - } catch (XMLStreamException e) { - LOG.error(e); - } - this.isDisposed = true; - } - } - - /** - * Flushes this instance. - * - * @throws XMLStreamException the XML stream exception - */ - public void flush() throws XMLStreamException { - this.xmlWriter.flush(); - } - - /** - * Writes the start element. - * - * @param xmlNamespace the XML namespace - * @param localName the local name of the element - * @throws XMLStreamException the XML stream exception - */ - public void writeStartElement(XmlNamespace xmlNamespace, String localName) - throws XMLStreamException { - String strPrefix = EwsUtilities.getNamespacePrefix(xmlNamespace); - String strNameSpace = EwsUtilities.getNamespaceUri(xmlNamespace); - this.xmlWriter.writeStartElement(strPrefix, localName, strNameSpace); - } - - /** - * Writes the end element. - * - * @throws XMLStreamException the XML stream exception - */ - public void writeEndElement() throws XMLStreamException { - this.xmlWriter.writeEndElement(); - } - - /** - * Writes the attribute value. - * - * @param localName the local name of the attribute - * @param value the value - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeAttributeValue(String localName, Object value) - throws ServiceXmlSerializationException { - this.writeAttributeValue(localName, - false /* alwaysWriteEmptyString */, value); - } - - /** - * Writes the attribute value. Optionally emits empty string values. - * - * @param localName the local name of the attribute. - * @param alwaysWriteEmptyString always emit the empty string as the value. - * @param value the value - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeAttributeValue(String localName, - boolean alwaysWriteEmptyString, - Object value) throws ServiceXmlSerializationException { - OutParam stringOut = new OutParam(); - String stringValue = null; - if (this.tryConvertObjectToString(value, stringOut)) { - stringValue = stringOut.getParam(); - if ((null != stringValue) && (alwaysWriteEmptyString || (stringValue.length() != 0))) { - this.writeAttributeString(localName, stringValue); - } - } else { - throw new ServiceXmlSerializationException(String.format( - "Values of type '%s' can't be used for the '%s' attribute.", value.getClass() - .getName(), localName)); - } - } - - /** - * Writes the attribute value. - * - * @param namespacePrefix the namespace prefix - * @param localName the local name of the attribute - * @param value the value - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeAttributeValue(String namespacePrefix, String localName, - Object value) throws ServiceXmlSerializationException { - OutParam stringOut = new OutParam(); - String stringValue = null; - if (this.tryConvertObjectToString(value, stringOut)) { - stringValue = stringOut.getParam(); - if (null != stringValue && !stringValue.isEmpty()) { - this.writeAttributeString(namespacePrefix, localName, - stringValue); - } - } else { - throw new ServiceXmlSerializationException(String.format( - "Values of type '%s' can't be used for the '%s' attribute.", value.getClass() - .getName(), localName)); - } - } - - /** - * Writes the attribute value. - * - * @param localName The local name of the attribute. - * @param stringValue The string value. - * @throws ServiceXmlSerializationException Thrown if string value isn't valid for XML - */ - protected void writeAttributeString(String localName, String stringValue) - throws ServiceXmlSerializationException { - try { - this.xmlWriter.writeAttribute(localName, stringValue); - } catch (XMLStreamException e) { - // Bug E14:65046: XmlTextWriter will throw ArgumentException - //if string includes invalid characters. - throw new ServiceXmlSerializationException(String.format( - "The invalid value '%s' was specified for the '%s' attribute.", stringValue, localName), e); - } - } - - /** - * Writes the attribute value. - * - * @param namespacePrefix The namespace prefix. - * @param localName The local name of the attribute. - * @param stringValue The string value. - * @throws ServiceXmlSerializationException Thrown if string value isn't valid for XML. - */ - protected void writeAttributeString(String namespacePrefix, - String localName, String stringValue) - throws ServiceXmlSerializationException { - try { - this.xmlWriter.writeAttribute(namespacePrefix, "", localName, - stringValue); - } catch (XMLStreamException e) { - // Bug E14:65046: XmlTextWriter will throw ArgumentException - //if string includes invalid characters. - throw new ServiceXmlSerializationException(String.format( - "The invalid value '%s' was specified for the '%s' attribute.", stringValue, localName), e); - } - } - - /** - * Writes string value. - * - * @param value The value. - * @param name Element name (used for error handling) - * @throws ServiceXmlSerializationException Thrown if string value isn't valid for XML. - */ - public void writeValue(String value, String name) - throws ServiceXmlSerializationException { - try { - this.xmlWriter.writeCharacters(value); - } catch (XMLStreamException e) { - // Bug E14:65046: XmlTextWriter will throw ArgumentException - //if string includes invalid characters. - throw new ServiceXmlSerializationException(String.format( - "The invalid value '%s' was specified for the '%s' element.", value, name), e); - } - } - - /** - * Writes the element value. - * - * @param xmlNamespace the XML namespace - * @param localName the local name of the element - * @param displayName the name that should appear in the exception message when the value can not be serialized - * @param value the value - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeElementValue(XmlNamespace xmlNamespace, String localName, String displayName, Object value) - throws XMLStreamException, ServiceXmlSerializationException { - String stringValue = null; - OutParam strOut = new OutParam(); - - if (this.tryConvertObjectToString(value, strOut)) { - stringValue = strOut.getParam(); - if (null != stringValue) { - // allow an empty string to create an empty element (like ). - this.writeStartElement(xmlNamespace, localName); - this.writeValue(stringValue, displayName); - this.writeEndElement(); - } - } else { - throw new ServiceXmlSerializationException(String.format( - "Values of type '%s' can't be used for the '%s' element.", value.getClass() - .getName(), localName)); - } - } - - public void writeNode(Node xmlNode) throws XMLStreamException { - if (xmlNode != null) { - writeNode(xmlNode, this.xmlWriter); - } - } - - /** - * @param xmlNode XML node - * @param xmlStreamWriter XML stream writer - * @throws XMLStreamException the XML stream exception - */ - public static void writeNode(Node xmlNode, XMLStreamWriter xmlStreamWriter) - throws XMLStreamException { - if (xmlNode instanceof Element) { - addElement((Element) xmlNode, xmlStreamWriter); - } else if (xmlNode instanceof Text) { - xmlStreamWriter.writeCharacters(xmlNode.getNodeValue()); - } else if (xmlNode instanceof CDATASection) { - xmlStreamWriter.writeCData(((CDATASection) xmlNode).getData()); - } else if (xmlNode instanceof Comment) { - xmlStreamWriter.writeComment(((Comment) xmlNode).getData()); - } else if (xmlNode instanceof EntityReference) { - xmlStreamWriter.writeEntityRef(xmlNode.getNodeValue()); - } else if (xmlNode instanceof ProcessingInstruction) { - ProcessingInstruction procInst = (ProcessingInstruction) xmlNode; - xmlStreamWriter.writeProcessingInstruction(procInst.getTarget(), - procInst.getData()); - } else if (xmlNode instanceof Document) { - writeToDocument((Document) xmlNode, xmlStreamWriter); - } - } - - /** - * @param document XML document - * @param xmlStreamWriter XML stream writer - * @throws XMLStreamException the XML stream exception - */ - public static void writeToDocument(Document document, - XMLStreamWriter xmlStreamWriter) throws XMLStreamException { - - xmlStreamWriter.writeStartDocument(); - Element rootElement = document.getDocumentElement(); - addElement(rootElement, xmlStreamWriter); - xmlStreamWriter.writeEndDocument(); - } - - /** - * @param element DOM element - * @param writer XML stream writer - * @throws XMLStreamException the XML stream exception - */ - public static void addElement(Element element, XMLStreamWriter writer) - throws XMLStreamException { - String nameSpace = element.getNamespaceURI(); - String prefix = element.getPrefix(); - String localName = element.getLocalName(); - if (prefix == null) { - prefix = ""; - } - if (localName == null) { - localName = element.getNodeName(); - - if (localName == null) { - throw new IllegalStateException( - "Element's local name cannot be null!"); - } - } - - String decUri = writer.getNamespaceContext().getNamespaceURI(prefix); - boolean declareNamespace = decUri == null || !decUri.equals(nameSpace); - - if (nameSpace == null || nameSpace.length() == 0) { - writer.writeStartElement(localName); - } else { - writer.writeStartElement(prefix, localName, nameSpace); - } - - NamedNodeMap attrs = element.getAttributes(); - for (int i = 0; i < attrs.getLength(); i++) { - Node attr = attrs.item(i); - - String name = attr.getNodeName(); - String attrPrefix = ""; - int prefixIndex = name.indexOf(':'); - if (prefixIndex != -1) { - attrPrefix = name.substring(0, prefixIndex); - name = name.substring(prefixIndex + 1); - } - - if ("xmlns".equals(attrPrefix)) { - writer.writeNamespace(name, attr.getNodeValue()); - if (name.equals(prefix) - && attr.getNodeValue().equals(nameSpace)) { - declareNamespace = false; - } - } else { - if ("xmlns".equals(name) && "".equals(attrPrefix)) { - writer.writeNamespace("", attr.getNodeValue()); - if (attr.getNodeValue().equals(nameSpace)) { - declareNamespace = false; - } - } else { - writer.writeAttribute(attrPrefix, attr.getNamespaceURI(), - name, attr.getNodeValue()); - } - } - } - - if (declareNamespace) { - if (nameSpace == null) { - writer.writeNamespace(prefix, ""); - } else { - writer.writeNamespace(prefix, nameSpace); - } - } - - NodeList nodes = element.getChildNodes(); - for (int i = 0; i < nodes.getLength(); i++) { - Node n = nodes.item(i); - writeNode(n, writer); - } - - - writer.writeEndElement(); - - } - - - - /** - * Writes the element value. - * - * @param xmlNamespace the XML namespace - * @param localName the local name of the element - * @param value the value - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeElementValue(XmlNamespace xmlNamespace, String localName, - Object value) throws XMLStreamException, - ServiceXmlSerializationException { - this.writeElementValue(xmlNamespace, localName, localName, value); - } - - /** - * Writes the base64-encoded element value. - * - * @param buffer the buffer - * @throws XMLStreamException the XML stream exception - */ - public void writeBase64ElementValue(byte[] buffer) - throws XMLStreamException { - - String strValue = Base64.encodeBase64String(buffer); - this.xmlWriter.writeCharacters(strValue);//Base64.encode(buffer)); - } - - /** - * Writes the base64-encoded element value. - * - * @param stream the stream - * @throws IOException signals that an I/O exception has occurred - * @throws XMLStreamException the XML stream exception - */ - public void writeBase64ElementValue(InputStream stream) throws IOException, - XMLStreamException { - - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - byte[] buf = new byte[BufferSize]; - try { - for (int readNum; (readNum = stream.read(buf)) != -1; ) { - bos.write(buf, 0, readNum); - } - } catch (IOException ex) { - LOG.error(ex); - } finally { - bos.close(); - } - byte[] bytes = bos.toByteArray(); - String strValue = Base64.encodeBase64String(bytes); - this.xmlWriter.writeCharacters(strValue); - - } - - /** - * Gets the internal XML writer. - * - * @return the internal writer - */ - public XMLStreamWriter getInternalWriter() { - return xmlWriter; - } - - /** - * Gets the service. - * - * @return The service. - */ - public ExchangeServiceBase getService() { - return service; - } - - /** - * Gets a value indicating whether the SOAP message need WSSecurity Utility namespace. - */ - public boolean isRequireWSSecurityUtilityNamespace() { - return requireWSSecurityUtilityNamespace; - } - - /** - * Sets a value indicating whether the SOAP message need WSSecurity Utility namespace. - */ - public void setRequireWSSecurityUtilityNamespace(boolean requireWSSecurityUtilityNamespace) { - this.requireWSSecurityUtilityNamespace = requireWSSecurityUtilityNamespace; - } - - /** - * Gets a value indicating whether the time zone SOAP header was emitted - * through this writer. - * - * @return true if the time zone SOAP header was emitted; otherwise false. - */ - public boolean isTimeZoneHeaderEmitted() { - return isTimeZoneHeaderEmitted; - } - - /** - * Sets a value indicating whether the time zone SOAP header was emitted - * through this writer. - * - * @param isTimeZoneHeaderEmitted true if the time zone SOAP header was emitted; otherwise - * false. - */ - public void setTimeZoneHeaderEmitted(boolean isTimeZoneHeaderEmitted) { - this.isTimeZoneHeaderEmitted = isTimeZoneHeaderEmitted; - } - - /** - * Write start document. - * - * @throws XMLStreamException the XML stream exception - */ - public void writeStartDocument() throws XMLStreamException { - this.xmlWriter.writeStartDocument("utf-8", "1.0"); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/EwsUtilities.java b/src/main/java/microsoft/exchange/webservices/data/core/EwsUtilities.java deleted file mode 100644 index c822d9bf1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/EwsUtilities.java +++ /dev/null @@ -1,1348 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.ISelfValidate; -import microsoft.exchange.webservices.data.attribute.EwsEnum; -import microsoft.exchange.webservices.data.attribute.RequiredServerVersion; -import microsoft.exchange.webservices.data.core.request.HttpWebRequest; -import microsoft.exchange.webservices.data.core.service.ICreateServiceObjectWithAttachmentParam; -import microsoft.exchange.webservices.data.core.service.ICreateServiceObjectWithServiceParam; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.ServiceObjectInfo; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.notification.EventType; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.FileAsMapping; -import microsoft.exchange.webservices.data.core.enumeration.search.ItemTraversal; -import microsoft.exchange.webservices.data.core.enumeration.property.MailboxType; -import microsoft.exchange.webservices.data.core.enumeration.service.MeetingRequestsDeliveryScope; -import microsoft.exchange.webservices.data.core.enumeration.property.RuleProperty; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentNullException; -import microsoft.exchange.webservices.data.core.exception.http.EWSHttpException; -import microsoft.exchange.webservices.data.core.exception.misc.FormatException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.misc.TimeSpan; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.joda.time.Period; -import org.joda.time.format.ISOPeriodFormat; - -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.lang.reflect.Field; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.net.URISyntaxException; -import java.text.DateFormat; -import java.text.DecimalFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.TimeZone; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * EWS utilities. - */ -public final class EwsUtilities { - - private static final Log LOG = LogFactory.getLog(EwsUtilities.class); - - /** - * The Constant XSFalse. - */ - public static final String XSFalse = "false"; - - /** - * The Constant XSTrue. - */ - public static final String XSTrue = "true"; - - /** - * The Constant EwsTypesNamespacePrefix. - */ - public static final String EwsTypesNamespacePrefix = "t"; - - /** - * The Constant EwsMessagesNamespacePrefix. - */ - public static final String EwsMessagesNamespacePrefix = "m"; - - /** - * The Constant EwsErrorsNamespacePrefix. - */ - public static final String EwsErrorsNamespacePrefix = "e"; - - /** - * The Constant EwsSoapNamespacePrefix. - */ - public static final String EwsSoapNamespacePrefix = "soap"; - - /** - * The Constant EwsXmlSchemaInstanceNamespacePrefix. - */ - public static final String EwsXmlSchemaInstanceNamespacePrefix = "xsi"; - - /** - * The Constant PassportSoapFaultNamespacePrefix. - */ - public static final String PassportSoapFaultNamespacePrefix = "psf"; - - /** - * The Constant WSTrustFebruary2005NamespacePrefix. - */ - public static final String WSTrustFebruary2005NamespacePrefix = "wst"; - - /** - * The Constant WSAddressingNamespacePrefix. - */ - public static final String WSAddressingNamespacePrefix = "wsa"; - - /** - * The Constant AutodiscoverSoapNamespacePrefix. - */ - public static final String AutodiscoverSoapNamespacePrefix = "a"; - - /** - * The Constant WSSecurityUtilityNamespacePrefix. - */ - public static final String WSSecurityUtilityNamespacePrefix = "wsu"; - - /** - * The Constant WSSecuritySecExtNamespacePrefix. - */ - public static final String WSSecuritySecExtNamespacePrefix = "wsse"; - - /** - * The Constant EwsTypesNamespace. - */ - public static final String EwsTypesNamespace = - "http://schemas.microsoft.com/exchange/services/2006/types"; - - /** - * The Constant EwsMessagesNamespace. - */ - public static final String EwsMessagesNamespace = - "http://schemas.microsoft.com/exchange/services/2006/messages"; - - /** - * The Constant EwsErrorsNamespace. - */ - public static final String EwsErrorsNamespace = - "http://schemas.microsoft.com/exchange/services/2006/errors"; - - /** - * The Constant EwsSoapNamespace. - */ - public static final String EwsSoapNamespace = - "http://schemas.xmlsoap.org/soap/envelope/"; - - /** - * The Constant EwsSoap12Namespace. - */ - public static final String EwsSoap12Namespace = - "http://www.w3.org/2003/05/soap-envelope"; - - /** - * The Constant EwsXmlSchemaInstanceNamespace. - */ - public static final String EwsXmlSchemaInstanceNamespace = - "http://www.w3.org/2001/XMLSchema-instance"; - - /** - * The Constant PassportSoapFaultNamespace. - */ - public static final String PassportSoapFaultNamespace = - "http://schemas.microsoft.com/Passport/SoapServices/SOAPFault"; - - /** - * The Constant WSTrustFebruary2005Namespace. - */ - public static final String WSTrustFebruary2005Namespace = - "http://schemas.xmlsoap.org/ws/2005/02/trust"; - - /** - * The Constant WSAddressingNamespace. - */ - public static final String WSAddressingNamespace = - "http://www.w3.org/2005/08/addressing"; - // "http://schemas.xmlsoap.org/ws/2004/08/addressing"; - - /** - * The Constant AutodiscoverSoapNamespace. - */ - public static final String AutodiscoverSoapNamespace = - "http://schemas.microsoft.com/exchange/2010/Autodiscover"; - - public static final String WSSecurityUtilityNamespace = - "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"; - public static final String WSSecuritySecExtNamespace = - "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; - - /** - * The service object info. - */ - private static final LazyMember SERVICE_OBJECT_INFO = - new LazyMember( - new ILazyMember() { - public ServiceObjectInfo createInstance() { - return new ServiceObjectInfo(); - } - } - ); - - private static final String XML_SCHEMA_DATE_FORMAT = "yyyy-MM-dd'Z'"; - private static final String XML_SCHEMA_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; - - private static final Pattern PATTERN_TIME_SPAN = Pattern.compile("-P"); - private static final Pattern PATTERN_YEAR = Pattern.compile("(\\d+)Y"); - private static final Pattern PATTERN_MONTH = Pattern.compile("(\\d+)M"); - private static final Pattern PATTERN_DAY = Pattern.compile("(\\d+)D"); - private static final Pattern PATTERN_HOUR = Pattern.compile("(\\d+)H"); - private static final Pattern PATTERN_MINUTES = Pattern.compile("(\\d+)M"); - private static final Pattern PATTERN_SECONDS = Pattern.compile("(\\d+)\\."); // Need to escape dot, otherwise it matches any char - private static final Pattern PATTERN_MILLISECONDS = Pattern.compile("(\\d+)S"); - - - private EwsUtilities() { - throw new UnsupportedOperationException(); - } - - - /** - * Gets the builds the version. - * - * @return the builds the version - */ - public static String getBuildVersion() { - return "0.0.0.0"; - } - - /** - * The enum version dictionaries. - */ - private static final LazyMember, Map>> - ENUM_VERSION_DICTIONARIES = - new LazyMember, Map>>( - new ILazyMember, Map>>() { - @Override - public Map, Map> - createInstance() { - Map, Map> enumDicts = - new HashMap, Map>(); - enumDicts.put(WellKnownFolderName.class, - buildEnumDict(WellKnownFolderName.class)); - enumDicts.put(ItemTraversal.class, - buildEnumDict(ItemTraversal.class)); - enumDicts.put(FileAsMapping.class, - buildEnumDict(FileAsMapping.class)); - enumDicts.put(EventType.class, - buildEnumDict(EventType.class)); - enumDicts.put(MeetingRequestsDeliveryScope.class, - buildEnumDict(MeetingRequestsDeliveryScope. - class)); - return enumDicts; - } - }); - /** - * Dictionary of enum type to schema-name-to-enum-value maps. - */ - private static final LazyMember, Map>> - SCHEMA_TO_ENUM_DICTIONARIES = - new LazyMember, Map>>( - new ILazyMember, Map>>() { - @Override - public Map, Map> createInstance() { - Map, Map> enumDicts = - new HashMap, Map>(); - enumDicts.put(EventType.class, - buildSchemaToEnumDict(EventType.class)); - enumDicts.put(MailboxType.class, - buildSchemaToEnumDict(MailboxType.class)); - enumDicts.put(FileAsMapping.class, - buildSchemaToEnumDict(FileAsMapping.class)); - enumDicts.put(RuleProperty.class, - buildSchemaToEnumDict(RuleProperty.class)); - return enumDicts; - - } - }); - - /** - * Dictionary of enum type to enum-value-to-schema-name maps. - */ - public static final LazyMember, Map>> - ENUM_TO_SCHEMA_DICTIONARIES = - new LazyMember, Map>>( - new ILazyMember, Map>>() { - @Override - public Map, Map> createInstance() { - Map, Map> enumDicts = - new HashMap, Map>(); - enumDicts.put(EventType.class, - buildEnumToSchemaDict(EventType.class)); - enumDicts.put(MailboxType.class, - buildEnumToSchemaDict(MailboxType.class)); - enumDicts.put(FileAsMapping.class, - buildEnumToSchemaDict(FileAsMapping.class)); - enumDicts.put(RuleProperty.class, - buildEnumToSchemaDict(RuleProperty.class)); - return enumDicts; - } - }); - - /** - * Regular expression for legal domain names. - */ - public static final String DomainRegex = "^[-a-zA-Z0-9_.]+$"; - - /** - * Asserts that the specified condition if true. - * - * @param condition Assertion. - * @param caller The caller. - * @param message The message to use if assertion fails. - */ - public static void ewsAssert( - final boolean condition, final String caller, final String message - ) { - if (!condition) { - throw new RuntimeException(String.format("[%s] %s", caller, message)); - } - } - - /** - * Gets the namespace prefix from an XmlNamespace enum value. - * - * @param xmlNamespace The XML namespace - * @return Namespace prefix string. - */ - public static String getNamespacePrefix(XmlNamespace xmlNamespace) { - return xmlNamespace.getNameSpacePrefix(); - } - - /** - * Gets the namespace URI from an XmlNamespace enum value. - * - * @param xmlNamespace The XML namespace. - * @return Uri as string - */ - public static String getNamespaceUri(XmlNamespace xmlNamespace) { - return xmlNamespace.getNameSpaceUri(); - } - - /** - * Gets the namespace from uri. - * - * @param namespaceUri the namespace uri - * @return the namespace from uri - */ - public static XmlNamespace getNamespaceFromUri(String namespaceUri) { - if (EwsErrorsNamespace.equals(namespaceUri)) { - return XmlNamespace.Errors; - } else if (EwsTypesNamespace.equals(namespaceUri)) { - return XmlNamespace.Types; - } else if (EwsMessagesNamespace.equals(namespaceUri)) { - return XmlNamespace.Messages; - } else if (EwsSoapNamespace.equals(namespaceUri)) { - return XmlNamespace.Soap; - } else if (EwsSoap12Namespace.equals(namespaceUri)) { - return XmlNamespace.Soap12; - } else if (EwsXmlSchemaInstanceNamespace.equals(namespaceUri)) { - return XmlNamespace.XmlSchemaInstance; - } else if (PassportSoapFaultNamespace.equals(namespaceUri)) { - return XmlNamespace.PassportSoapFault; - } else if (WSTrustFebruary2005Namespace.equals(namespaceUri)) { - return XmlNamespace.WSTrustFebruary2005; - } else if (WSAddressingNamespace.equals(namespaceUri)) { - return XmlNamespace.WSAddressing; - } else { - return XmlNamespace.NotSpecified; - } - } - - /** - * Creates the ews object from xml element name. - * - * @param the generic type - * @param itemClass the item class - * @param service the service - * @param xmlElementName the xml element name - * @return the t service object - * @throws Exception the exception - */ - @SuppressWarnings("unchecked") - public static - TServiceObject createEwsObjectFromXmlElementName( - Class itemClass, ExchangeService service, String xmlElementName) - throws Exception { - final ServiceObjectInfo member = EwsUtilities.SERVICE_OBJECT_INFO.getMember(); - final Map> map = member.getXmlElementNameToServiceObjectClassMap(); - - final Class ic = map.get(xmlElementName); - if (ic != null) { - final Map, ICreateServiceObjectWithServiceParam> - serviceParam = member.getServiceObjectConstructorsWithServiceParam(); - final ICreateServiceObjectWithServiceParam creationDelegate = - serviceParam.get(ic); - - if (creationDelegate != null) { - return (TServiceObject) creationDelegate - .createServiceObjectWithServiceParam(service); - } else { - throw new IllegalArgumentException("No appropriate constructor could be found for this item class."); - } - } - - return (TServiceObject) itemClass.newInstance(); - } - - /** - * Creates the item from item class. - * - * @param itemAttachment the item attachment - * @param itemClass the item class - * @param isNew the is new - * @return the item - * @throws Exception the exception - */ - public static Item createItemFromItemClass( - ItemAttachment itemAttachment, Class itemClass, boolean isNew) - throws Exception { - final ServiceObjectInfo member = EwsUtilities.SERVICE_OBJECT_INFO.getMember(); - final Map, ICreateServiceObjectWithAttachmentParam> - dataMap = member.getServiceObjectConstructorsWithAttachmentParam(); - final ICreateServiceObjectWithAttachmentParam creationDelegate = - dataMap.get(itemClass); - - if (creationDelegate != null) { - return (Item) creationDelegate - .createServiceObjectWithAttachmentParam(itemAttachment, isNew); - } - throw new IllegalArgumentException("No appropriate constructor could be found for this item class."); - } - - /** - * Creates the item from xml element name. - * - * @param itemAttachment the item attachment - * @param xmlElementName the xml element name - * @return the item - * @throws Exception the exception - */ - public static Item createItemFromXmlElementName( - ItemAttachment itemAttachment, String xmlElementName) - throws Exception { - final ServiceObjectInfo member = EwsUtilities.SERVICE_OBJECT_INFO.getMember(); - final Map> map = - member.getXmlElementNameToServiceObjectClassMap(); - - final Class itemClass = map.get(xmlElementName); - if (itemClass != null) { - return createItemFromItemClass(itemAttachment, itemClass, false); - } - return null; - } - - public static Class getItemTypeFromXmlElementName(String xmlElementName) { - final ServiceObjectInfo member = EwsUtilities.SERVICE_OBJECT_INFO.getMember(); - final Map> map = member.getXmlElementNameToServiceObjectClassMap(); - return map.get(xmlElementName); - } - - /** - * Finds the first item of type TItem (not a descendant type) in the - * specified collection. - * - * @param TItem is the type of the item to find. - * @param cls the cls - * @param items the item - * @return A TItem instance or null if no instance of TItem could be found. - */ - @SuppressWarnings("unchecked") - public static TItem findFirstItemOfType( - Class cls, Iterable items - ) { - for (Item item : items) { - // We're looking for an exact class match here. - final Class itemClass = item.getClass(); - if (itemClass.equals(cls)) { - return (TItem) item; - } - } - - return null; - } - - /** - * Write trace start element. - * - * @param writer the writer to write the start element to - * @param traceTag the trace tag - * @param includeVersion if true, include build version attribute - * @throws XMLStreamException the XML stream exception - */ - private static void writeTraceStartElement( - XMLStreamWriter writer, - String traceTag, - boolean includeVersion) throws XMLStreamException { - writer.writeStartElement("Trace"); - writer.writeAttribute("Tag", traceTag); - writer.writeAttribute("Tid", Thread.currentThread().getId() + ""); - Date d = new Date(); - DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'Z'"); - df.setTimeZone(TimeZone.getTimeZone("UTC")); - String formattedString = df.format(d); - writer.writeAttribute("Time", formattedString); - - if (includeVersion) { - writer.writeAttribute("Version", EwsUtilities.getBuildVersion()); - } - } - - /** - * . - * - * @param entryKind the entry kind - * @param logEntry the log entry - * @return the string - * @throws XMLStreamException the XML stream exception - * @throws IOException signals that an I/O exception has occurred. - */ - public static String formatLogMessage(String entryKind, String logEntry) - throws XMLStreamException, IOException { - String lineSeparator = System.getProperty("line.separator"); - ByteArrayOutputStream outStream = new ByteArrayOutputStream(); - XMLOutputFactory factory = XMLOutputFactory.newInstance(); - XMLStreamWriter writer = factory.createXMLStreamWriter(outStream); - EwsUtilities.writeTraceStartElement(writer, entryKind, false); - writer.writeCharacters(lineSeparator); - writer.writeCharacters(logEntry); - writer.writeCharacters(lineSeparator); - writer.writeEndElement(); - writer.writeCharacters(lineSeparator); - writer.flush(); - writer.close(); - outStream.flush(); - String formattedLogMessage = outStream.toString(); - formattedLogMessage = formattedLogMessage.replaceAll("'", "'"); - formattedLogMessage = formattedLogMessage.replaceAll(""", "\""); - formattedLogMessage = formattedLogMessage.replaceAll(">", ">"); - formattedLogMessage = formattedLogMessage.replaceAll("<", "<"); - formattedLogMessage = formattedLogMessage.replaceAll("&", "&"); - outStream.close(); - return formattedLogMessage; - } - - /** - * Format http response headers. - * - * @param response the response - * @return the string - * @throws EWSHttpException the EWS http exception - */ - public static String formatHttpResponseHeaders(HttpWebRequest response) - throws EWSHttpException { - final int code = response.getResponseCode(); - final String contentType = response.getResponseContentType(); - final Map headers = response.getResponseHeaders(); - - return code + " " + contentType + "\n" - + EwsUtilities.formatHttpHeaders(headers) + "\n"; - } - - /** - * Format request HTTP headers. - * - * @param request The HTTP request. - */ - public static String formatHttpRequestHeaders(HttpWebRequest request) - throws URISyntaxException, EWSHttpException { - final String method = request.getRequestMethod().toUpperCase(); - final String path = request.getUrl().toURI().getPath(); - final Map property = request.getRequestProperty(); - final String headers = EwsUtilities.formatHttpHeaders(property); - - return String.format("%s %s HTTP/%s\n", method, path, "1.1") + headers + "\n"; - } - - /** - * Formats HTTP headers. - * - * @param headers The headers. - * @return Headers as a string - */ - private static String formatHttpHeaders(Map headers) { - StringBuilder sb = new StringBuilder(); - for (Map.Entry header : headers.entrySet()) { - sb.append(String.format("%s : %s\n", header.getKey(), header.getValue())); - } - return sb.toString(); - } - - /** - * Format XML content in a MemoryStream for message. - * - * @param traceTypeStr Kind of the entry. - * @param stream The memory stream. - * @return XML log entry as a string. - */ - public static String formatLogMessageWithXmlContent(String traceTypeStr, - ByteArrayOutputStream stream) { - try { - return formatLogMessage(traceTypeStr, stream.toString()); - } catch (Exception e) { - return stream.toString(); - } - } - - /** - * Convert bool to XML Schema bool. - * - * @param value Bool value. - * @return String representing bool value in XML Schema. - */ - public static String boolToXSBool(Boolean value) { - return value ? EwsUtilities.XSTrue : EwsUtilities.XSFalse; - } - - /** - * Parses an enum value list. - * - * @param the generic type - * @param c the c - * @param list the list - * @param value the value - * @param separators the separators - */ - public static > void parseEnumValueList(Class c, - List list, String value, char... separators) { - EwsUtilities.ewsAssert(c.isEnum(), "EwsUtilities.ParseEnumValueList", "T is not an enum type."); - - StringBuilder regexp = new StringBuilder(); - regexp.append("["); - for (char s : separators) { - regexp.append("["); - regexp.append(Pattern.quote(s + "")); - regexp.append("]"); - } - regexp.append("]"); - - String[] enumValues = value.split(regexp.toString()); - - for (String enumValue : enumValues) { - for (T o : c.getEnumConstants()) { - if (o.toString().equals(enumValue)) { - list.add(o); - } - } - } - } - - /** - * Converts an enum to a string, using the mapping dictionaries if - * appropriate. - * - * @param value The enum value to be serialized - * @return String representation of enum to be used in the protocol - */ - public static String serializeEnum(Object value) { - String strValue = value.toString(); - final Map, Map> member = - ENUM_TO_SCHEMA_DICTIONARIES.getMember(); - - final Map enumToStringDict = member.get(value.getClass()); - if (enumToStringDict != null) { - final Enum e = (Enum) value; - final String enumStr = enumToStringDict.get(e.name()); - if (enumStr != null) { - strValue = enumStr; - } - } - return strValue; - } - - /** - * Parses the. - * - * @param the generic type - * @param cls the cls - * @param value the value - * @return the t - * @throws java.text.ParseException the parse exception - */ - @SuppressWarnings("unchecked") - public static T parse(Class cls, String value) throws ParseException { - if (cls.isEnum()) { - final Map, Map> member = SCHEMA_TO_ENUM_DICTIONARIES.getMember(); - - String val = value; - final Map stringToEnumDict = member.get(cls); - if (stringToEnumDict != null) { - final String strEnumName = stringToEnumDict.get(value); - if (strEnumName != null) { - val = strEnumName; - } - } - for (T o : cls.getEnumConstants()) { - if (o.toString().equals(val)) { - return o; - } - } - return null; - }else if (Number.class.isAssignableFrom(cls)){ - if (Double.class.isAssignableFrom(cls)){ - return (T) ((Double) Double.parseDouble(value)); - }else if (Integer.class.isAssignableFrom(cls)) { - return (T) ((Integer) Integer.parseInt(value)); - }else if (Long.class.isAssignableFrom(cls)){ - return (T) ((Long) Long.parseLong(value)); - }else if (Float.class.isAssignableFrom(cls)){ - return (T) ((Float) Float.parseFloat(value)); - }else if (Byte.class.isAssignableFrom(cls)){ - return (T) ((Byte) Byte.parseByte(value)); - }else if (Short.class.isAssignableFrom(cls)){ - return (T) ((Short) Short.parseShort(value)); - }else if (BigInteger.class.isAssignableFrom(cls)){ - return (T) (new BigInteger(value)); - }else if (BigDecimal.class.isAssignableFrom(cls)){ - return (T) (new BigDecimal(value)); - } - } else if (Date.class.isAssignableFrom(cls)) { - DateFormat df = createDateFormat(XML_SCHEMA_DATE_TIME_FORMAT); - return (T) df.parse(value); - } else if (Boolean.class.isAssignableFrom(cls)) { - return (T) ((Boolean) Boolean.parseBoolean(value)); - } else if (String.class.isAssignableFrom(cls)) { - return (T) value; - } - return null; - } - - - - /** - * Builds the schema to enum mapping dictionary. - * - * @param Type of the enum. - * @param c Class - * @return The mapping from enum to schema name - */ - private static > Map - buildSchemaToEnumDict(Class c) { - Map dict = new HashMap(); - - Field[] fields = c.getDeclaredFields(); - for (Field f : fields) { - if (f.isEnumConstant() && f.isAnnotationPresent(EwsEnum.class)) { - EwsEnum ewsEnum = f.getAnnotation(EwsEnum.class); - String fieldName = f.getName(); - String schemaName = ewsEnum.schemaName(); - if (!schemaName.isEmpty()) { - dict.put(schemaName, fieldName); - } - } - } - return dict; - } - - /** - * Validate param collection. - * - * @param eventTypes the event types - * @param paramName the param name - * @throws Exception the exception - */ - public static void validateParamCollection(EventType[] eventTypes, - String paramName) throws Exception { - validateParam(eventTypes, paramName); - int count = 0; - - for (EventType event : eventTypes) { - try { - validateParam(event, String.format("collection[%d] , ", count)); - } catch (Exception e) { - throw new IllegalArgumentException(String.format( - "The element at position %d is invalid", count), e); - } - count++; - } - - if (count == 0) { - throw new IllegalArgumentException( - String.format("The collection \"%s\" is empty.", paramName) - ); - } - } - - /** - * Convert DateTime to XML Schema date. - * - * @param date the date - * @return String representation of DateTime. - */ - public static String dateTimeToXSDate(Date date) { - return formatDate(date, XML_SCHEMA_DATE_FORMAT); - } - - /** - * Dates the DateTime into an XML schema date time. - * - * @param date the date - * @return String representation of DateTime. - */ - public static String dateTimeToXSDateTime(Date date) { - return formatDate(date, XML_SCHEMA_DATE_TIME_FORMAT); - } - - /** - * 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 - * - * @param timeOffset structure to convert - * @return xs:duration formatted string - */ - public static String getTimeSpanToXSDuration(TimeSpan timeOffset) { - // Optional '-' offset - String offsetStr = (timeOffset.getTotalSeconds() < 0) ? "-" : ""; - long days = Math.abs(timeOffset.getDays()); - long hours = Math.abs(timeOffset.getHours()); - long minutes = Math.abs(timeOffset.getMinutes()); - long seconds = Math.abs(timeOffset.getSeconds()); - long milliseconds = Math.abs(timeOffset.getMilliseconds()); - - // The TimeSpan structure does not have a Year or Month - // property, therefore we wouldn't be able to return an xs:duration - // string from a TimeSpan that included the nY or nM components. - return offsetStr + "P" + days + "DT" + hours + "H" + minutes + "M" - + seconds + "." + milliseconds + "S"; - } - - /** - * 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. - * - * @param xsDuration xs:duration string to convert - * @return System.TimeSpan structure - */ - public static TimeSpan getXSDurationToTimeSpan(String xsDuration) { - // TODO: Need to check whether this should be the equivalent or not - Matcher m = PATTERN_TIME_SPAN.matcher(xsDuration); - boolean negative = false; - if (m.find()) { - negative = true; - } - - // Removing leading '-' - if (negative) { - xsDuration = xsDuration.replace("-P", "P"); - } - - Period period = Period.parse(xsDuration, ISOPeriodFormat.standard()); - - long retval = period.toStandardDuration().getMillis(); - - if (negative) { - retval = -retval; - } - - return new TimeSpan(retval); - - } - - /** - * Time span to xs time. - * - * @param timeSpan the time span - * @return the string - */ - public static String timeSpanToXSTime(TimeSpan timeSpan) { - DecimalFormat myFormatter = new DecimalFormat("00"); - return String.format("%s:%s:%s", myFormatter.format(timeSpan.getHours()), myFormatter.format(timeSpan - .getMinutes()), myFormatter.format(timeSpan.getSeconds())); - } - - /** - * Gets the domain name from an email address. - * - * @param emailAddress The email address. - * @return Domain name. - * @throws FormatException the format exception - */ - public static String domainFromEmailAddress(String emailAddress) - throws FormatException { - String[] emailAddressParts = emailAddress.split("@"); - - if (emailAddressParts.length != 2 - || (emailAddressParts[1] == null || emailAddressParts[1] - .isEmpty())) { - throw new FormatException("The e-mail address is formed incorrectly."); - } - - return emailAddressParts[1]; - } - - public static int getDim(Object array) { - int dim = 0; - Class c = array.getClass(); - while (c.isArray()) { - c = c.getComponentType(); - dim++; - } - return (dim); - } - - /** - * Validates parameter (and allows null value). - * - * @param param The param. - * @param paramName Name of the param. - * @throws Exception the exception - */ - public static void validateParamAllowNull(Object param, String paramName) - throws Exception { - if (param instanceof ISelfValidate) { - ISelfValidate selfValidate = (ISelfValidate) param; - try { - selfValidate.validate(); - } catch (ServiceValidationException e) { - throw new Exception(String.format("%s %s", "Validation failed.", paramName), e); - } - } - - if (param instanceof ServiceObject) { - ServiceObject ewsObject = (ServiceObject) param; - if (ewsObject.isNew()) { - throw new Exception(String.format("%s %s", "This service object doesn't have an ID.", paramName)); - } - } - } - - /** - * Validates parameter (null value not allowed). - * - * @param param The param. - * @param paramName Name of the param. - * @throws Exception the exception - */ - public static void validateParam(Object param, String paramName) throws Exception { - boolean isValid; - - if (param instanceof String) { - String strParam = (String) param; - isValid = !strParam.isEmpty(); - } else { - isValid = param != null; - } - - if (!isValid) { - throw new Exception(String.format("Argument %s not valid", - paramName)); - } - validateParamAllowNull(param, paramName); - } - - /** - * Validates parameter collection. - * - * @param the generic type - * @param collection The collection. - * @param paramName Name of the param. - * @throws Exception the exception - */ - public static void validateParamCollection(Iterator collection, String paramName) throws Exception { - validateParam(collection, paramName); - int count = 0; - - while (collection.hasNext()) { - T obj = collection.next(); - try { - validateParam(obj, String.format("collection[%d],", count)); - } catch (Exception e) { - throw new IllegalArgumentException(String.format( - "The element at position %d is invalid", count), e); - } - count++; - } - - if (count == 0) { - throw new IllegalArgumentException( - String.format("The collection \"%s\" is empty.", paramName) - ); - } - } - - /** - * Validates string parameter to be non-empty string (null value allowed). - * - * @param param The string parameter. - * @param paramName Name of the parameter. - * @throws ArgumentException - * @throws ServiceLocalException - */ - public static void validateNonBlankStringParamAllowNull(String param, - String paramName) throws ArgumentException, ServiceLocalException { - if (param != null) { - // Non-empty string has at least one character - //which is *not* a whitespace character - if (param.length() == countMatchingChars(param, - new IPredicate() { - @Override - public boolean predicate(Character obj) { - return Character.isWhitespace(obj); - } - })) { - throw new ArgumentException("The string argument contains only white space characters.", paramName); - } - } - } - - - /** - * Validates string parameter to be - * non-empty string (null value not allowed). - * - * @param param The string parameter. - * @param paramName Name of the parameter. - * @throws ArgumentNullException - * @throws ArgumentException - * @throws ServiceLocalException - */ - public static void validateNonBlankStringParam(String param, - String paramName) throws ArgumentNullException, ArgumentException, ServiceLocalException { - if (param == null) { - throw new ArgumentNullException(paramName); - } - - validateNonBlankStringParamAllowNull(param, paramName); - } - - /** - * Validate enum version value. - * - * @param enumValue the enum value - * @param requestVersion the request version - * @throws ServiceVersionException the service version exception - */ - public static void validateEnumVersionValue(Enum enumValue, - ExchangeVersion requestVersion) throws ServiceVersionException { - final Map, Map> member = - ENUM_VERSION_DICTIONARIES.getMember(); - final Map enumVersionDict = - member.get(enumValue.getClass()); - - final ExchangeVersion enumVersion = enumVersionDict.get(enumValue.toString()); - if (enumVersion != null) { - final int i = requestVersion.compareTo(enumVersion); - if (i < 0) { - throw new ServiceVersionException( - String.format( - "Enumeration value %s in enumeration type %s is only valid for Exchange version %s or later.", - enumValue.toString(), - enumValue.getClass().getName(), - enumVersion - ) - ); - } - } - } - - /** - * Validates service object version against the request version. - * - * @param serviceObject The service object. - * @param requestVersion The request version. - * @throws ServiceVersionException Raised if this service object type requires a later version - * of Exchange. - */ - public static void validateServiceObjectVersion( - ServiceObject serviceObject, ExchangeVersion requestVersion) - throws ServiceVersionException { - ExchangeVersion minimumRequiredServerVersion = serviceObject - .getMinimumRequiredServerVersion(); - - if (requestVersion.ordinal() < minimumRequiredServerVersion.ordinal()) { - String msg = String.format( - "The object type %s is only valid for Exchange Server version %s or later versions.", - serviceObject.getClass().getName(), minimumRequiredServerVersion.toString()); - throw new ServiceVersionException(msg); - } - } - - /** - * Validates property version against the request version. - * - * @param service The Exchange service. - * @param minimumServerVersion The minimum server version - * @param propertyName The property name - * @throws ServiceVersionException The service version exception - */ - public static void validatePropertyVersion( - ExchangeService service, - ExchangeVersion minimumServerVersion, - String propertyName) throws ServiceVersionException { - if (service.getRequestedServerVersion().ordinal() < - minimumServerVersion.ordinal()) { - throw new ServiceVersionException( - String.format("The property %s is valid only for Exchange %s or later versions.", - propertyName, - minimumServerVersion)); - } - } - - /** - * Validate method version. - * - * @param service the service - * @param minimumServerVersion the minimum server version - * @param methodName the method name - * @throws ServiceVersionException the service version exception - */ - public static void validateMethodVersion(ExchangeService service, - ExchangeVersion minimumServerVersion, String methodName) - throws ServiceVersionException { - if (service.getRequestedServerVersion().ordinal() < - minimumServerVersion.ordinal()) - - { - throw new ServiceVersionException(String.format( - "Method %s is only valid for Exchange Server version %s or later.", methodName, - minimumServerVersion)); - } - } - - /** - * Validates class version against the request version. - * - * @param service the service - * @param minimumServerVersion The minimum server version that supports the method. - * @param className Name of the class. - * @throws ServiceVersionException - */ - public static void validateClassVersion( - ExchangeService service, - ExchangeVersion minimumServerVersion, - String className) throws ServiceVersionException { - if (service.getRequestedServerVersion().ordinal() < - minimumServerVersion.ordinal()) { - throw new ServiceVersionException( - String.format("Class %s is only valid for Exchange version %s or later.", - className, - minimumServerVersion)); - } - } - - /** - * Validates domain name (null value allowed) - * - * @param domainName Domain name. - * @param paramName Parameter name. - * @throws ArgumentException - */ - public static void validateDomainNameAllowNull(String domainName, String paramName) throws - ArgumentException { - if (domainName != null) { - Pattern domainNamePattern = Pattern.compile(DomainRegex); - Matcher domainNameMatcher = domainNamePattern.matcher(domainName); - if (!domainNameMatcher.find()) { - throw new ArgumentException(String.format("'%s' is not a valid domain name.", domainName), paramName); - } - } - } - - /** - * Builds the enum dict. - * - * @param the element type - * @param c the c - * @return the map - */ - private static > Map - buildEnumDict(Class c) { - Map dict = - new HashMap(); - Field[] fields = c.getDeclaredFields(); - for (Field f : fields) { - if (f.isEnumConstant() - && f.isAnnotationPresent(RequiredServerVersion.class)) { - RequiredServerVersion ewsEnum = f - .getAnnotation(RequiredServerVersion.class); - String fieldName = f.getName(); - ExchangeVersion exchangeVersion = ewsEnum.version(); - dict.put(fieldName, exchangeVersion); - } - } - return dict; - } - - /** - * Builds the enum to schema mapping dictionary. - * - * @param c class type - * @return The mapping from enum to schema name - */ - private static Map buildEnumToSchemaDict(Class c) { - Map dict = new HashMap(); - Field[] fields = c.getFields(); - for (Field f : fields) { - if (f.isEnumConstant() && f.isAnnotationPresent(EwsEnum.class)) { - EwsEnum ewsEnum = f.getAnnotation(EwsEnum.class); - String fieldName = f.getName(); - String schemaName = ewsEnum.schemaName(); - if (!schemaName.isEmpty()) { - dict.put(fieldName, schemaName); - } - } - } - return dict; - } - - /** - * Gets the enumerated object count. - * - * @param the generic type - * @param objects The objects. - * @return Count of objects in iterator. - */ - public static int getEnumeratedObjectCount(Iterator objects) { - int count = 0; - while (objects != null && objects.hasNext()) { - objects.next(); - count++; - } - return count; - } - - /** - * Gets the enumerated object at. - * - * @param the generic type - * @param objects the objects - * @param index the index - * @return the enumerated object at - */ - public static Object getEnumeratedObjectAt(Iterable objects, int index) { - int count = 0; - for (Object obj : objects) { - if (count == index) { - return obj; - } - count++; - } - throw new IndexOutOfBoundsException("The IEnumerable doesn't contain that many objects."); - } - - - /** - * Count characters in string that match a condition. - * - * @param str The string. - * @param charPredicate Predicate to evaluate for each character in the string. - * @return Count of characters that match condition expressed by predicate. - * @throws ServiceLocalException - */ - public static int countMatchingChars( - String str, IPredicate charPredicate - ) throws ServiceLocalException { - int count = 0; - for (int i = 0; i < str.length(); i++) { - if (charPredicate.predicate(str.charAt(i))) { - count++; - } - } - return count; - } - - /** - * Determines whether every element in the collection - * matches the conditions defined by the specified predicate. - * - * @param Entry type. - * @param collection The collection. - * @param predicate Predicate that defines the conditions to check against the elements. - * @return True if every element in the collection matches - * the conditions defined by the specified predicate; otherwise, false. - * @throws ServiceLocalException - */ - public static boolean trueForAll(Iterable collection, - IPredicate predicate) throws ServiceLocalException { - for (T entry : collection) { - if (!predicate.predicate(entry)) { - return false; - } - } - - return true; - } - - /** - * Call an action for each member of a collection. - * - * @param Collection element type. - * @param collection The collection. - * @param action The action to apply. - */ - public static void forEach(Iterable collection, IAction action) { - for (T entry : collection) { - action.action(entry); - } - } - - - private static String formatDate(Date date, String format) { - final DateFormat utcFormatter = createDateFormat(format); - return utcFormatter.format(date); - } - - private static DateFormat createDateFormat(String format) { - final DateFormat utcFormatter = new SimpleDateFormat(format); - utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); - return utcFormatter; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/EwsX509TrustManager.java b/src/main/java/microsoft/exchange/webservices/data/core/EwsX509TrustManager.java deleted file mode 100644 index 00a78657e..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/EwsX509TrustManager.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -/** - * EwsX509TrustManager is used for SSL handshake. - * - */ -import javax.net.ssl.TrustManager; -import javax.net.ssl.TrustManagerFactory; -import javax.net.ssl.X509TrustManager; - -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; - -class EwsX509TrustManager implements X509TrustManager { - /** - * The Standard TrustManager. - */ - private X509TrustManager standardTrustManager = null; - - /** - * Constructor for EasyX509TrustManager. - */ - public EwsX509TrustManager(KeyStore keystore, TrustManager trustManager) - throws NoSuchAlgorithmException, KeyStoreException { - super(); - if (trustManager == null) { - TrustManagerFactory factory = - TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); - factory.init(keystore); - TrustManager[] trustmanagers = factory.getTrustManagers(); - if (trustmanagers.length == 0) { - throw new NoSuchAlgorithmException("no trust manager found"); - } - this.standardTrustManager = (X509TrustManager) trustmanagers[0]; - } else { - standardTrustManager = (X509TrustManager) trustManager; - } - } - - /** - * @see javax.net.ssl.X509TrustManager#checkClientTrusted(java.security.cert.X509Certificate[], String authType) - */ - public void checkClientTrusted(X509Certificate[] certificates, String authType) - throws CertificateException { - standardTrustManager.checkClientTrusted(certificates, authType); - } - - /** - * @see javax.net.ssl.X509TrustManager#checkServerTrusted(java.security.cert.X509Certificate[], String authType) - */ - public void checkServerTrusted(X509Certificate[] certificates, String authType) - throws CertificateException { - - if ((certificates != null) && (certificates.length == 1)) { - certificates[0].checkValidity(); - } else { - standardTrustManager.checkServerTrusted(certificates, authType); - } - } - - /** - * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers() - */ - public X509Certificate[] getAcceptedIssuers() { - return this.standardTrustManager.getAcceptedIssuers(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/EwsXmlReader.java b/src/main/java/microsoft/exchange/webservices/data/core/EwsXmlReader.java deleted file mode 100644 index ba1b1cc9d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/EwsXmlReader.java +++ /dev/null @@ -1,1144 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.security.XmlNodeType; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.Attribute; -import javax.xml.stream.events.Characters; -import javax.xml.stream.events.EndElement; -import javax.xml.stream.events.StartElement; -import javax.xml.stream.events.XMLEvent; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; - -/** - * Defines the EwsXmlReader class. - */ -public class EwsXmlReader { - - private static final Log LOG = LogFactory.getLog(EwsXmlReader.class); - - /** - * The Read write buffer size. - */ - private static final int ReadWriteBufferSize = 4096; - - /** - * The xml reader. - */ - private XMLEventReader xmlReader = null; - - /** - * The present event. - */ - private XMLEvent presentEvent; - - /** - * The prev event. - */ - private XMLEvent prevEvent; - - /** - * Initializes a new instance of the EwsXmlReader class. - * - * @param stream the stream - * @throws Exception on error - */ - public EwsXmlReader(InputStream stream) throws Exception { - this.xmlReader = initializeXmlReader(stream); - } - - /** - * Initializes the XML reader. - * - * @param stream the stream - * @return An XML reader to use. - * @throws Exception on error - */ - protected XMLEventReader initializeXmlReader(InputStream stream) throws Exception { - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false); - - return inputFactory.createXMLEventReader(stream); - } - - - /** - * Formats the name of the element. - * - * @param namespacePrefix The namespace prefix - * @param localElementName Element name - * @return the string - */ - private static String formatElementName(String namespacePrefix, - String localElementName) { - - return isNullOrEmpty(namespacePrefix) ? localElementName : - namespacePrefix + ":" + localElementName; - } - - /** - * Read XML element. - * - * @param xmlNamespace The XML namespace - * @param localName Name of the local - * @param nodeType Type of the node - * @throws Exception the exception - */ - private void internalReadElement(XmlNamespace xmlNamespace, - String localName, XmlNodeType nodeType) throws Exception { - - if (xmlNamespace == XmlNamespace.NotSpecified) { - this.internalReadElement("", localName, nodeType); - } else { - this.read(nodeType); - - if ((!this.getLocalName().equals(localName)) || - (!this.getNamespaceUri().equals(EwsUtilities - .getNamespaceUri(xmlNamespace)))) { - throw new ServiceXmlDeserializationException( - String - .format( - "An element node '%s:%s' of the type %s was expected, but node '%s' of type %s was found.", - EwsUtilities - .getNamespacePrefix( - xmlNamespace), - localName, nodeType.toString(), this - .getName(), this.getNodeType() - .toString())); - } - } - } - - /** - * Read XML element. - * - * @param namespacePrefix The namespace prefix - * @param localName Name of the local - * @param nodeType Type of the node - * @throws Exception the exception - */ - private void internalReadElement(String namespacePrefix, String localName, - XmlNodeType nodeType) throws Exception { - read(nodeType); - - if ((!this.getLocalName().equals(localName)) || - (!this.getNamespacePrefix().equals(namespacePrefix))) { - throw new ServiceXmlDeserializationException(String.format( - "An element node '%s:%s' of the type %s was expected, but node '%s' of type %s was found.", namespacePrefix, localName, - nodeType.toString(), this.getName(), this.getNodeType() - .toString())); - } - } - - /** - * Reads the specified node type. - * - * @throws ServiceXmlDeserializationException the service xml deserialization exception - * @throws XMLStreamException the XML stream exception - */ - public void read() throws ServiceXmlDeserializationException, - XMLStreamException { - read(false); - } - - /** - * Reads the specified node type. - * - * @param keepWhiteSpace Do not remove whitespace characters if true - * @throws ServiceXmlDeserializationException the service xml deserialization exception - * @throws XMLStreamException the XML stream exception - */ - private void read(boolean keepWhiteSpace) throws ServiceXmlDeserializationException, - XMLStreamException { - // The caller to EwsXmlReader.Read expects - // that there's another node to - // read. Throw an exception if not true. - while (true) { - if (!xmlReader.hasNext()) { - throw new ServiceXmlDeserializationException("Unexpected end of XML document."); - } else { - XMLEvent event = xmlReader.nextEvent(); - if (event.getEventType() == XMLStreamConstants.CHARACTERS) { - Characters characters = (Characters) event; - if (!keepWhiteSpace) - if (characters.isIgnorableWhiteSpace() - || characters.isWhiteSpace()) { - continue; - } - } - this.prevEvent = this.presentEvent; - this.presentEvent = event; - break; - } - } - } - - /** - * Reads the specified node type. - * - * @param nodeType Type of the node. - * @throws Exception the exception - */ - public void read(XmlNodeType nodeType) throws Exception { - this.read(); - if (!this.getNodeType().equals(nodeType)) { - throw new ServiceXmlDeserializationException(String - .format("The expected XML node type was %s, but the actual type is %s.", nodeType, this - .getNodeType())); - } - } - - /** - * Read attribute value from QName. - * - * @param qName QName of the attribute - * @return Attribute Value - * @throws Exception thrown if attribute value can not be read - */ - private String readAttributeValue(QName qName) throws Exception { - if (this.presentEvent.isStartElement()) { - StartElement startElement = this.presentEvent.asStartElement(); - Attribute attr = startElement.getAttributeByName(qName); - if (null != attr) { - return attr.getValue(); - } else { - return null; - } - } else { - String errMsg = String.format("Could not fetch attribute %s", qName - .toString()); - throw new Exception(errMsg); - } - } - - /** - * Reads the attribute value. - * - * @param xmlNamespace The XML namespace. - * @param attributeName Name of the attribute - * @return Attribute Value - * @throws Exception the exception - */ - public String readAttributeValue(XmlNamespace xmlNamespace, - String attributeName) throws Exception { - if (xmlNamespace == XmlNamespace.NotSpecified) { - return this.readAttributeValue(attributeName); - } else { - QName qName = new QName(EwsUtilities.getNamespaceUri(xmlNamespace), - attributeName); - return readAttributeValue(qName); - } - } - - /** - * Reads the attribute value. - * - * @param attributeName Name of the attribute - * @return Attribute value. - * @throws Exception the exception - */ - public String readAttributeValue(String attributeName) throws Exception { - QName qName = new QName(attributeName); - return readAttributeValue(qName); - } - - /** - * Reads the attribute value. - * - * @param the generic type - * @param cls the cls - * @param attributeName the attribute name - * @return T - * @throws Exception the exception - */ - public T readAttributeValue(Class cls, String attributeName) - throws Exception { - return EwsUtilities.parse(cls, this.readAttributeValue(attributeName)); - } - - /** - * Reads a nullable attribute value. - * - * @param the generic type - * @param cls the cls - * @param attributeName the attribute name - * @return T - * @throws Exception the exception - */ - public T readNullableAttributeValue(Class cls, String attributeName) - throws Exception { - String attributeValue = this.readAttributeValue(attributeName); - if (attributeValue == null) { - return null; - } else { - return EwsUtilities.parse(cls, attributeValue); - } - } - - /** - * Reads the element value. - * - * @param namespacePrefix the namespace prefix - * @param localName the local name - * @return String - * @throws Exception the exception - */ - public String readElementValue(String namespacePrefix, String localName) - throws Exception { - if (!this.isStartElement(namespacePrefix, localName)) { - this.readStartElement(namespacePrefix, localName); - } - - String value = null; - - if (!this.isEmptyElement()) { - value = this.readValue(); - } - return value; - } - - /** - * Reads the element value. - * - * @param xmlNamespace the xml namespace - * @param localName the local name - * @return String - * @throws Exception the exception - */ - public String readElementValue(XmlNamespace xmlNamespace, String localName) - throws Exception { - - if (!this.isStartElement(xmlNamespace, localName)) { - this.readStartElement(xmlNamespace, localName); - } - - String value = null; - - if (!this.isEmptyElement()) { - value = this.readValue(); - } else { - this.read(); - } - - return value; - } - - /** - * Read element value. - * - * @return String - * @throws Exception the exception - */ - public String readElementValue() throws Exception { - this.ensureCurrentNodeIsStartElement(); - - return this.readElementValue(this.getNamespacePrefix(), this - .getLocalName()); - } - - /** - * Reads the element value. - * - * @param the generic type - * @param cls the cls - * @param xmlNamespace the xml namespace - * @param localName the local name - * @return T - * @throws Exception the exception - */ - public T readElementValue(Class cls, XmlNamespace xmlNamespace, - String localName) throws Exception { - if (!this.isStartElement(xmlNamespace, localName)) { - this.readStartElement(xmlNamespace, localName); - } - - T value = null; - - if (!this.isEmptyElement()) { - value = this.readValue(cls); - } - - return value; - } - - /** - * Read element value. - * - * @param the generic type - * @param cls the cls - * @return T - * @throws Exception the exception - */ - public T readElementValue(Class cls) throws Exception { - this.ensureCurrentNodeIsStartElement(); - - T value = null; - - if (!this.isEmptyElement()) { - value = this.readValue(cls); - } - - return value; - } - - /** - * Reads the value. Should return content element or text node as string - * Present event must be START ELEMENT. After executing this function - * Present event will be set on END ELEMENT - * - * @return String - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlDeserializationException the service xml deserialization exception - */ - public String readValue() throws XMLStreamException, - ServiceXmlDeserializationException { - return readValue(false); - } - - /** - * Reads the value. Should return content element or text node as string - * Present event must be START ELEMENT. After executing this function - * Present event will be set on END ELEMENT - * - * @param keepWhiteSpace Do not remove whitespace characters if true - * @return String - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlDeserializationException the service xml deserialization exception - */ - public String readValue(boolean keepWhiteSpace) throws XMLStreamException, - ServiceXmlDeserializationException { - if (this.presentEvent.isStartElement()) { - // Go to next event and check for Characters event - this.read(keepWhiteSpace); - if (this.presentEvent.isCharacters()) { - final StringBuilder elementValue = new StringBuilder(); - do { - if (this.getNodeType().nodeType == XmlNodeType.CHARACTERS) { - Characters characters = (Characters) this.presentEvent; - if (keepWhiteSpace || (!characters.isIgnorableWhiteSpace() - && !characters.isWhiteSpace())) { - final String charactersData = characters.getData(); - if (charactersData != null && !charactersData.isEmpty()) { - elementValue.append(charactersData); - } - } - } - this.read(); - } while (!this.presentEvent.isEndElement()); - // Characters chars = this.presentEvent.asCharacters(); - // String elementValue = chars.getData(); - // Advance to next event post Characters (ideally it will be End - // Element) - // this.read(); - return elementValue.toString(); - } else if (this.presentEvent.isEndElement()) { - return ""; - } else { - throw new ServiceXmlDeserializationException( - getReadValueErrMsg("Could not find " + XmlNodeType.getString(XmlNodeType.CHARACTERS))); - } - } else if (this.presentEvent.getEventType() == XmlNodeType.CHARACTERS - && this.presentEvent.isCharacters()) { - /* - * if(this.presentEvent.asCharacters().getData().equals("<")) { - */ - final String charData = this.presentEvent.asCharacters().getData(); - final StringBuilder data = new StringBuilder(charData == null ? "" : charData); - do { - this.read(keepWhiteSpace); - if (this.getNodeType().nodeType == XmlNodeType.CHARACTERS) { - Characters characters = (Characters) this.presentEvent; - if (keepWhiteSpace || (!characters.isIgnorableWhiteSpace() - && !characters.isWhiteSpace())) { - final String charactersData = characters.getData(); - if (charactersData != null && !charactersData.isEmpty()) { - data.append(charactersData); - } - } - } - } while (!this.presentEvent.isEndElement()); - return data.toString();// this.presentEvent. = new XMLEvent(); - /* - * } else { Characters chars = this.presentEvent.asCharacters(); - * String elementValue = chars.getData(); // Advance to next event - * post Characters (ideally it will be End // Element) this.read(); - * return elementValue; } - */ - } else { - throw new ServiceXmlDeserializationException( - getReadValueErrMsg("Expected is " + XmlNodeType.getString(XmlNodeType.START_ELEMENT)) - ); - } - - } - - /** - * Tries to read value. - * - * @param value the value - * @return boolean - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlDeserializationException the service xml deserialization exception - */ - public boolean tryReadValue(OutParam value) - throws XMLStreamException, ServiceXmlDeserializationException { - if (!this.isEmptyElement()) { - this.read(); - - if (this.presentEvent.isCharacters()) { - value.setParam(this.readValue()); - return true; - } else { - return false; - } - } else { - return false; - } - } - - /** - * Reads the value. - * - * @param the generic type - * @param cls the cls - * @return T - * @throws Exception the exception - */ - public T readValue(Class cls) throws Exception { - return EwsUtilities.parse(cls, this.readValue()); - } - - /** - * Reads the base64 element value. - * - * @return byte[] - * @throws ServiceXmlDeserializationException the service xml deserialization exception - * @throws XMLStreamException the XML stream exception - * @throws IOException signals that an I/O exception has occurred - */ - public byte[] readBase64ElementValue() - throws ServiceXmlDeserializationException, XMLStreamException, - IOException { - this.ensureCurrentNodeIsStartElement(); - - byte[] buffer = null; - - ByteArrayOutputStream byteArrayStream = new ByteArrayOutputStream(); - - buffer = Base64.decodeBase64(this.xmlReader.getElementText().toString()); - byteArrayStream.write(buffer); - - return byteArrayStream.toByteArray(); - - } - - /** - * Reads the base64 element value. - * - * @param outputStream the output stream - * @throws Exception the exception - */ - public void readBase64ElementValue(OutputStream outputStream) - throws Exception { - this.ensureCurrentNodeIsStartElement(); - - byte[] buffer = null; - buffer = Base64.decodeBase64(this.xmlReader.getElementText().toString()); - outputStream.write(buffer); - outputStream.flush(); - } - - /** - * Reads the start element. - * - * @param namespacePrefix the namespace prefix - * @param localName the local name - * @throws Exception the exception - */ - public void readStartElement(String namespacePrefix, String localName) - throws Exception { - this.internalReadElement(namespacePrefix, localName, new XmlNodeType( - XmlNodeType.START_ELEMENT)); - } - - /** - * Reads the start element. - * - * @param xmlNamespace the xml namespace - * @param localName the local name - * @throws Exception the exception - */ - public void readStartElement(XmlNamespace xmlNamespace, String localName) - throws Exception { - this.internalReadElement(xmlNamespace, localName, new XmlNodeType( - XmlNodeType.START_ELEMENT)); - } - - /** - * Reads the end element. - * - * @param namespacePrefix the namespace prefix - * @param elementName the element name - * @throws Exception the exception - */ - public void readEndElement(String namespacePrefix, String elementName) - throws Exception { - this.internalReadElement(namespacePrefix, elementName, new XmlNodeType( - XmlNodeType.END_ELEMENT)); - } - - /** - * Reads the end element. - * - * @param xmlNamespace the xml namespace - * @param localName the local name - * @throws Exception the exception - */ - public void readEndElement(XmlNamespace xmlNamespace, String localName) - throws Exception { - - this.internalReadElement(xmlNamespace, localName, new XmlNodeType( - XmlNodeType.END_ELEMENT)); - - } - - /** - * Reads the end element if necessary. - * - * @param xmlNamespace the xml namespace - * @param localName the local name - * @throws Exception the exception - */ - public void readEndElementIfNecessary(XmlNamespace xmlNamespace, - String localName) throws Exception { - - if (!(this.isStartElement(xmlNamespace, localName) && this - .isEmptyElement())) { - if (!this.isEndElement(xmlNamespace, localName)) { - this.readEndElement(xmlNamespace, localName); - } - } - } - - /** - * Determines whether current element is a start element. - * - * @return boolean - */ - public boolean isStartElement() { - return this.presentEvent.isStartElement(); - } - - /** - * Determines whether current element is a start element. - * - * @param namespacePrefix the namespace prefix - * @param localName the local name - * @return boolean - */ - public boolean isStartElement(String namespacePrefix, String localName) { - boolean isStart = false; - if (this.presentEvent.isStartElement()) { - StartElement startElement = this.presentEvent.asStartElement(); - QName qName = startElement.getName(); - isStart = qName.getLocalPart().equals(localName) - && qName.getPrefix().equals(namespacePrefix); - } - return isStart; - } - - /** - * Determines whether current element is a start element. - * - * @param xmlNamespace the xml namespace - * @param localName the local name - * @return true for matching start element; false otherwise. - */ - public boolean isStartElement(XmlNamespace xmlNamespace, String localName) { - return this.isStartElement() - && StringUtils.equals(getLocalName(), localName) - && ( - StringUtils.equals(getNamespacePrefix(), EwsUtilities.getNamespacePrefix(xmlNamespace)) || - StringUtils.equals(getNamespaceUri(), EwsUtilities.getNamespaceUri(xmlNamespace))); - } - - /** - * Determines whether current element is a end element. - * - * @param namespacePrefix the namespace prefix - * @param localName the local name - * @return boolean - */ - public boolean isEndElement(String namespacePrefix, String localName) { - boolean isEndElement = false; - if (this.presentEvent.isEndElement()) { - EndElement endElement = this.presentEvent.asEndElement(); - QName qName = endElement.getName(); - isEndElement = qName.getLocalPart().equals(localName) - && qName.getPrefix().equals(namespacePrefix); - - } - return isEndElement; - } - - /** - * Determines whether current element is a end element. - * - * @param xmlNamespace the xml namespace - * @param localName the local name - * @return boolean - */ - public boolean isEndElement(XmlNamespace xmlNamespace, String localName) { - - boolean isEndElement = false; - /* - * if(localName.equals("Body")) { return true; } else - */ - if (this.presentEvent.isEndElement()) { - EndElement endElement = this.presentEvent.asEndElement(); - QName qName = endElement.getName(); - isEndElement = qName.getLocalPart().equals(localName) - && (qName.getPrefix().equals( - EwsUtilities.getNamespacePrefix(xmlNamespace)) || - qName.getNamespaceURI().equals( - EwsUtilities.getNamespaceUri( - xmlNamespace))); - - } - return isEndElement; - } - - /** - * Skips the element. - * - * @param namespacePrefix the namespace prefix - * @param localName the local name - * @throws Exception the exception - */ - public void skipElement(String namespacePrefix, String localName) - throws Exception { - if (!this.isEndElement(namespacePrefix, localName)) { - if (!this.isStartElement(namespacePrefix, localName)) { - this.readStartElement(namespacePrefix, localName); - } - - if (!this.isEmptyElement()) { - do { - this.read(); - } while (!this.isEndElement(namespacePrefix, localName)); - } - } - } - - /** - * Skips the element. - * - * @param xmlNamespace the xml namespace - * @param localName the local name - * @throws Exception the exception - */ - public void skipElement(XmlNamespace xmlNamespace, String localName) - throws Exception { - if (!this.isEndElement(xmlNamespace, localName)) { - if (!this.isStartElement(xmlNamespace, localName)) { - this.readStartElement(xmlNamespace, localName); - } - - if (!this.isEmptyElement()) { - do { - this.read(); - } while (!this.isEndElement(xmlNamespace, localName)); - } - } - } - - /** - * Skips the current element. - * - * @throws Exception the exception - */ - public void skipCurrentElement() throws Exception { - this.skipElement(this.getNamespacePrefix(), this.getLocalName()); - } - - /** - * Ensures the current node is start element. - * - * @param xmlNamespace the xml namespace - * @param localName the local name - * @throws ServiceXmlDeserializationException the service xml deserialization exception - */ - public void ensureCurrentNodeIsStartElement(XmlNamespace xmlNamespace, - String localName) throws ServiceXmlDeserializationException { - - if (!this.isStartElement(xmlNamespace, localName)) { - throw new ServiceXmlDeserializationException( - String - .format("The element '%s' in namespace '%s' wasn't found at the current position.", - localName, xmlNamespace)); - } - } - - /** - * Ensures the current node is start element. - * - * @throws ServiceXmlDeserializationException the service xml deserialization exception - */ - public void ensureCurrentNodeIsStartElement() - throws ServiceXmlDeserializationException { - XmlNodeType presentNodeType = new XmlNodeType(this.presentEvent - .getEventType()); - if (!this.presentEvent.isStartElement()) { - throw new ServiceXmlDeserializationException(String.format( - "The start element was expected, but node '%s' of type %s was found.", - this.presentEvent.toString(), presentNodeType.toString())); - } - } - - /** - * Ensures the current node is start element. - * - * @param xmlNamespace the xml namespace - * @param localName the local name - * @throws Exception the exception - */ - public void ensureCurrentNodeIsEndElement(XmlNamespace xmlNamespace, - String localName) throws Exception { - if (!this.isEndElement(xmlNamespace, localName)) { - if (!(this.isStartElement(xmlNamespace, localName) && this - .isEmptyElement())) { - throw new ServiceXmlDeserializationException( - String - .format("The element '%s' in namespace '%s' wasn't found at the current position.", - xmlNamespace, localName)); - } - } - } - - /** - * Outer XML as string. - * - * @return String - * @throws ServiceXmlDeserializationException the service xml deserialization exception - * @throws XMLStreamException the XML stream exception - */ - public String readOuterXml() throws ServiceXmlDeserializationException, - XMLStreamException { - if (!this.isStartElement()) { - throw new ServiceXmlDeserializationException("The current position is not the start of an element."); - } - - XMLEvent startEvent = this.presentEvent; - XMLEvent event; - StringBuilder str = new StringBuilder(); - str.append(startEvent); - do { - event = this.xmlReader.nextEvent(); - str.append(event); - } while (!checkEndElement(startEvent, event)); - - return str.toString(); - } - - /** - * Reads the Inner XML at the given location. - * - * @return String - * @throws ServiceXmlDeserializationException the service xml deserialization exception - * @throws XMLStreamException the XML stream exception - */ - public String readInnerXml() throws ServiceXmlDeserializationException, - XMLStreamException { - if (!this.isStartElement()) { - throw new ServiceXmlDeserializationException("The current position is not the start of an element."); - } - - XMLEvent startEvent = this.presentEvent; - StringBuilder str = new StringBuilder(); - do { - XMLEvent event = this.xmlReader.nextEvent(); - if (checkEndElement(startEvent, event)) { - break; - } - str.append(event); - } while (true); - - return str.toString(); - } - - /** - * Check end element. - * - * @param startEvent the start event - * @param endEvent the end event - * @return true, if successful - */ - public static boolean checkEndElement(XMLEvent startEvent, XMLEvent endEvent) { - boolean isEndElement = false; - if (endEvent.isEndElement()) { - QName qEName = endEvent.asEndElement().getName(); - QName qSName = startEvent.asStartElement().getName(); - isEndElement = qEName.getLocalPart().equals(qSName.getLocalPart()) - && (qEName.getPrefix().equals(qSName.getPrefix()) || qEName - .getNamespaceURI().equals(qSName. - getNamespaceURI())); - - } - return isEndElement; - } - - /** - * Gets the XML reader for node. - * - * @return null - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlDeserializationException the service xml deserialization exception - * @throws FileNotFoundException the file not found exception - */ - public XMLEventReader getXmlReaderForNode() - throws FileNotFoundException, ServiceXmlDeserializationException, XMLStreamException { - return readSubtree(); - } - - public XMLEventReader readSubtree() - throws XMLStreamException, FileNotFoundException, ServiceXmlDeserializationException { - - if (!this.isStartElement()) { - throw new ServiceXmlDeserializationException("The current position is not the start of an element."); - } - - XMLEventReader eventReader = null; - InputStream in = null; - XMLEvent startEvent = this.presentEvent; - XMLEvent event = startEvent; - StringBuilder str = new StringBuilder(); - str.append(startEvent); - do { - event = this.xmlReader.nextEvent(); - str.append(event); - } while (!checkEndElement(startEvent, event)); - - try { - - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - - try { - in = new ByteArrayInputStream(str.toString().getBytes("UTF-8")); - } catch (UnsupportedEncodingException e) { - LOG.error(e); - } - eventReader = inputFactory.createXMLEventReader(in); - - } catch (Exception e) { - LOG.error(e); - } - return eventReader; - } - - /** - * Reads to the next descendant element with the specified local name and - * namespace. - * - * @param xmlNamespace The namespace of the element you with to move to. - * @param localName The local name of the element you wish to move to. - * @throws XMLStreamException the XML stream exception - */ - public void readToDescendant(XmlNamespace xmlNamespace, String localName) throws XMLStreamException { - readToDescendant(localName, EwsUtilities.getNamespaceUri(xmlNamespace)); - } - - public boolean readToDescendant(String localName, String namespaceURI) throws XMLStreamException { - - if (!this.isStartElement()) { - return false; - } - XMLEvent startEvent = this.presentEvent; - XMLEvent event = this.presentEvent; - do { - if (event.isStartElement()) { - QName qEName = event.asStartElement().getName(); - if (qEName.getLocalPart().equals(localName) && - qEName.getNamespaceURI().equals(namespaceURI)) { - return true; - } - } - event = this.xmlReader.nextEvent(); - } while (!checkEndElement(startEvent, event)); - - return false; - } - - - - /** - * Gets a value indicating whether this instance has attribute. - * - * @return boolean - */ - public boolean hasAttributes() { - - if (this.presentEvent.isStartElement()) { - StartElement startElement = this.presentEvent.asStartElement(); - return startElement.getAttributes().hasNext(); - } else { - return false; - } - } - - /** - * Gets a value indicating whether current element is empty. - * - * @return boolean - * @throws XMLStreamException the XML stream exception - */ - public boolean isEmptyElement() throws XMLStreamException { - boolean isPresentStartElement = this.presentEvent.isStartElement(); - boolean isNextEndElement = this.xmlReader.peek().isEndElement(); - return isPresentStartElement && isNextEndElement; - } - - /** - * Gets the local name of the current element. - * - * @return String - */ - public String getLocalName() { - - String localName = null; - - if (this.presentEvent.isStartElement()) { - localName = this.presentEvent.asStartElement().getName() - .getLocalPart(); - } else { - - localName = this.presentEvent.asEndElement().getName() - .getLocalPart(); - } - return localName; - } - - /** - * Gets the namespace prefix. - * - * @return String - */ - protected String getNamespacePrefix() { - if (this.presentEvent.isStartElement()) { - return this.presentEvent.asStartElement().getName().getPrefix(); - } - if (this.presentEvent.isEndElement()) { - return this.presentEvent.asEndElement().getName().getPrefix(); - } - return null; - } - - /** - * Gets the namespace URI. - * - * @return String - */ - public String getNamespaceUri() { - - String nameSpaceUri = null; - if (this.presentEvent.isStartElement()) { - nameSpaceUri = this.presentEvent.asStartElement().getName() - .getNamespaceURI(); - } else { - - nameSpaceUri = this.presentEvent.asEndElement().getName() - .getNamespaceURI(); - } - return nameSpaceUri; - } - - /** - * Gets the type of the node. - * - * @return XmlNodeType - * @throws XMLStreamException the XML stream exception - */ - public XmlNodeType getNodeType() throws XMLStreamException { - XMLEvent event = this.presentEvent; - return new XmlNodeType(event.getEventType()); - } - - /** - * Gets the name of the current element. - * - * @return Object - */ - protected Object getName() { - String name = null; - if (this.presentEvent.isStartElement()) { - name = this.presentEvent.asStartElement().getName().toString(); - } else { - - name = this.presentEvent.asEndElement().getName().toString(); - } - return name; - } - - /** - * Checks is the string is null or empty. - * - * @param namespacePrefix the namespace prefix - * @return true, if is null or empty - */ - private static boolean isNullOrEmpty(String namespacePrefix) { - return (namespacePrefix == null || namespacePrefix.isEmpty()); - - } - - /** - * Gets the error message which happened during {@link #readValue()}. - * - * @param details details message - * @return error message with details - */ - private String getReadValueErrMsg(final String details) { - final int eventType = this.presentEvent.getEventType(); - return "Could not read value from " + XmlNodeType.getString(eventType) + "." + details; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/ExchangeServerInfo.java b/src/main/java/microsoft/exchange/webservices/data/core/ExchangeServerInfo.java deleted file mode 100644 index 10219a7dd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/ExchangeServerInfo.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -/** - * Represents Exchange server information. - */ -public final class ExchangeServerInfo { - - /** - * The major version. - */ - private int majorVersion; - - /** - * The minor version. - */ - private int minorVersion; - - /** - * The major build number. - */ - private int majorBuildNumber; - - /** - * The minor build number. - */ - private int minorBuildNumber; - - /** - * The version string. - */ - private String versionString; - - /* - * Default constructor - */ - - /** - * Instantiates a new exchange server info. - */ - public ExchangeServerInfo() { - - } - - /** - * Parse current element to extract server information. - * - * @param reader EwsServiceXmlReader - * @return ExchangeServerInfo - * @throws Exception the exception - */ - public static ExchangeServerInfo parse(EwsServiceXmlReader reader) - throws Exception { - EwsUtilities.ewsAssert(reader.hasAttributes(), "ExchangeServerVersion.Parse", - "Current element doesn't have attribute"); - - ExchangeServerInfo info = new ExchangeServerInfo(); - info.majorVersion = reader.readAttributeValue(Integer.class, - "MajorVersion"); - info.minorVersion = reader.readAttributeValue(Integer.class, - "MinorVersion"); - info.majorBuildNumber = reader.readAttributeValue(Integer.class, - "MajorBuildNumber"); - info.minorBuildNumber = reader.readAttributeValue(Integer.class, - "MinorBuildNumber"); - info.versionString = reader.readAttributeValue("Version"); - return info; - } - - /** - * Gets the Major Exchange server version number. - * - * @return the major version - */ - public int getMajorVersion() { - return this.majorVersion; - } - - /** - * Sets the major version. - * - * @param majorVersion the new major version - */ - public void setMajorVersion(int majorVersion) { - this.majorVersion = majorVersion; - } - - /** - * Gets the Minor Exchange server version number. - * - * @return the minor version - */ - public int getMinorVersion() { - return minorVersion; - } - - /** - * Sets the minor version. - * - * @param minorVersion the new minor version - */ - public void setMinorVersion(int minorVersion) { - this.minorVersion = minorVersion; - } - - /** - * Gets the Major Exchange server build number. - * - * @return the major build number - */ - public int getMajorBuildNumber() { - return majorBuildNumber; - } - - /** - * Sets the major build number. - * - * @param majorBuildNumber the new major build number - */ - public void setMajorBuildNumber(int majorBuildNumber) { - this.majorBuildNumber = majorBuildNumber; - } - - /** - * Gets the Minor Exchange server build number. - * - * @return the minor build number - */ - public int getMinorBuildNumber() { - return minorBuildNumber; - } - - /** - * Sets the minor build number. - * - * @param minorBuildNumber the new minor build number - */ - public void setMinorBuildNumber(int minorBuildNumber) { - this.minorBuildNumber = minorBuildNumber; - } - - /** - * Gets the Exchange server version string (e.g. "Exchange2010") - * - * @return the version string - */ - // / The version is a string rather than an enum since its possible for the - // client to - // / be connected to a later server for which there would be no appropriate - // enum value. - public String getVersionString() { - return versionString; - } - - /** - * Sets the version string. - * - * @param versionString the new version string - */ - public void setVersionString(String versionString) { - this.versionString = versionString; - } - - /** - * Override ToString method. - * - * @return the string - */ - @Override - public String toString() { - return String - .format("%d,%2d,%4d,%3d", this.majorVersion, this.minorVersion, - this.majorBuildNumber, this.minorBuildNumber); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/ExchangeService.java b/src/main/java/microsoft/exchange/webservices/data/core/ExchangeService.java deleted file mode 100644 index 529637769..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/ExchangeService.java +++ /dev/null @@ -1,3996 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.EnumSet; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.TimeZone; - -import microsoft.exchange.webservices.data.autodiscover.AutodiscoverService; -import microsoft.exchange.webservices.data.autodiscover.IAutodiscoverRedirectionUrl; -import microsoft.exchange.webservices.data.autodiscover.enumeration.UserSettingName; -import microsoft.exchange.webservices.data.autodiscover.exception.AutodiscoverLocalException; -import microsoft.exchange.webservices.data.autodiscover.request.ApplyConversationActionRequest; -import microsoft.exchange.webservices.data.autodiscover.response.GetUserSettingsResponse; -import microsoft.exchange.webservices.data.core.enumeration.availability.AvailabilityData; -import microsoft.exchange.webservices.data.core.enumeration.misc.ConversationActionType; -import microsoft.exchange.webservices.data.core.enumeration.misc.DateTimePrecision; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.IdFormat; -import microsoft.exchange.webservices.data.core.enumeration.misc.TraceFlags; -import microsoft.exchange.webservices.data.core.enumeration.misc.UserConfigurationProperties; -import microsoft.exchange.webservices.data.core.enumeration.notification.EventType; -import microsoft.exchange.webservices.data.core.enumeration.property.BodyType; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.core.enumeration.search.ResolveNameSearchLocation; -import microsoft.exchange.webservices.data.core.enumeration.service.ConflictResolutionMode; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.enumeration.service.MeetingRequestsDeliveryScope; -import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition; -import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode; -import microsoft.exchange.webservices.data.core.enumeration.service.SendInvitationsMode; -import microsoft.exchange.webservices.data.core.enumeration.service.SendInvitationsOrCancellationsMode; -import microsoft.exchange.webservices.data.core.enumeration.service.SyncFolderItemsScope; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentOutOfRangeException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.remote.AccountIsLockedException; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRemoteException; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException; -import microsoft.exchange.webservices.data.core.request.AddDelegateRequest; -import microsoft.exchange.webservices.data.core.request.ConvertIdRequest; -import microsoft.exchange.webservices.data.core.request.CopyFolderRequest; -import microsoft.exchange.webservices.data.core.request.CopyItemRequest; -import microsoft.exchange.webservices.data.core.request.CreateAttachmentRequest; -import microsoft.exchange.webservices.data.core.request.CreateFolderRequest; -import microsoft.exchange.webservices.data.core.request.CreateItemRequest; -import microsoft.exchange.webservices.data.core.request.CreateResponseObjectRequest; -import microsoft.exchange.webservices.data.core.request.CreateUserConfigurationRequest; -import microsoft.exchange.webservices.data.core.request.DeleteAttachmentRequest; -import microsoft.exchange.webservices.data.core.request.DeleteFolderRequest; -import microsoft.exchange.webservices.data.core.request.DeleteItemRequest; -import microsoft.exchange.webservices.data.core.request.DeleteUserConfigurationRequest; -import microsoft.exchange.webservices.data.core.request.EmptyFolderRequest; -import microsoft.exchange.webservices.data.core.request.ExecuteDiagnosticMethodRequest; -import microsoft.exchange.webservices.data.core.request.ExpandGroupRequest; -import microsoft.exchange.webservices.data.core.request.FindConversationRequest; -import microsoft.exchange.webservices.data.core.request.FindFolderRequest; -import microsoft.exchange.webservices.data.core.request.FindItemRequest; -import microsoft.exchange.webservices.data.core.request.GetAttachmentRequest; -import microsoft.exchange.webservices.data.core.request.GetDelegateRequest; -import microsoft.exchange.webservices.data.core.request.GetEventsRequest; -import microsoft.exchange.webservices.data.core.request.GetFolderRequest; -import microsoft.exchange.webservices.data.core.request.GetFolderRequestForLoad; -import microsoft.exchange.webservices.data.core.request.GetInboxRulesRequest; -import microsoft.exchange.webservices.data.core.request.GetItemRequest; -import microsoft.exchange.webservices.data.core.request.GetItemRequestForLoad; -import microsoft.exchange.webservices.data.core.request.GetPasswordExpirationDateRequest; -import microsoft.exchange.webservices.data.core.request.GetRoomListsRequest; -import microsoft.exchange.webservices.data.core.request.GetRoomsRequest; -import microsoft.exchange.webservices.data.core.request.GetServerTimeZonesRequest; -import microsoft.exchange.webservices.data.core.request.GetUserAvailabilityRequest; -import microsoft.exchange.webservices.data.core.request.GetUserConfigurationRequest; -import microsoft.exchange.webservices.data.core.request.GetUserOofSettingsRequest; -import microsoft.exchange.webservices.data.core.request.HttpWebRequest; -import microsoft.exchange.webservices.data.core.request.MoveFolderRequest; -import microsoft.exchange.webservices.data.core.request.MoveItemRequest; -import microsoft.exchange.webservices.data.core.request.RemoveDelegateRequest; -import microsoft.exchange.webservices.data.core.request.ResolveNamesRequest; -import microsoft.exchange.webservices.data.core.request.SendItemRequest; -import microsoft.exchange.webservices.data.core.request.SetUserOofSettingsRequest; -import microsoft.exchange.webservices.data.core.request.SubscribeToPullNotificationsRequest; -import microsoft.exchange.webservices.data.core.request.SubscribeToPushNotificationsRequest; -import microsoft.exchange.webservices.data.core.request.SubscribeToStreamingNotificationsRequest; -import microsoft.exchange.webservices.data.core.request.SyncFolderHierarchyRequest; -import microsoft.exchange.webservices.data.core.request.SyncFolderItemsRequest; -import microsoft.exchange.webservices.data.core.request.UnsubscribeRequest; -import microsoft.exchange.webservices.data.core.request.UpdateDelegateRequest; -import microsoft.exchange.webservices.data.core.request.UpdateFolderRequest; -import microsoft.exchange.webservices.data.core.request.UpdateInboxRulesRequest; -import microsoft.exchange.webservices.data.core.request.UpdateItemRequest; -import microsoft.exchange.webservices.data.core.request.UpdateUserConfigurationRequest; -import microsoft.exchange.webservices.data.core.response.ConvertIdResponse; -import microsoft.exchange.webservices.data.core.response.CreateAttachmentResponse; -import microsoft.exchange.webservices.data.core.response.CreateResponseObjectResponse; -import microsoft.exchange.webservices.data.core.response.DelegateManagementResponse; -import microsoft.exchange.webservices.data.core.response.DelegateUserResponse; -import microsoft.exchange.webservices.data.core.response.DeleteAttachmentResponse; -import microsoft.exchange.webservices.data.core.response.FindFolderResponse; -import microsoft.exchange.webservices.data.core.response.FindItemResponse; -import microsoft.exchange.webservices.data.core.response.GetAttachmentResponse; -import microsoft.exchange.webservices.data.core.response.GetDelegateResponse; -import microsoft.exchange.webservices.data.core.response.GetFolderResponse; -import microsoft.exchange.webservices.data.core.response.GetItemResponse; -import microsoft.exchange.webservices.data.core.response.GetServerTimeZonesResponse; -import microsoft.exchange.webservices.data.core.response.MoveCopyFolderResponse; -import microsoft.exchange.webservices.data.core.response.MoveCopyItemResponse; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.response.ServiceResponseCollection; -import microsoft.exchange.webservices.data.core.response.UpdateItemResponse; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.service.item.Appointment; -import microsoft.exchange.webservices.data.core.service.item.Conversation; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.messaging.UnifiedMessaging; -import microsoft.exchange.webservices.data.misc.AsyncCallback; -import microsoft.exchange.webservices.data.misc.AsyncRequestResult; -import microsoft.exchange.webservices.data.misc.ConversationAction; -import microsoft.exchange.webservices.data.misc.DelegateInformation; -import microsoft.exchange.webservices.data.misc.ExpandGroupResults; -import microsoft.exchange.webservices.data.misc.FolderIdWrapper; -import microsoft.exchange.webservices.data.misc.IAsyncResult; -import microsoft.exchange.webservices.data.misc.ImpersonatedUserId; -import microsoft.exchange.webservices.data.misc.NameResolutionCollection; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.misc.UserConfiguration; -import microsoft.exchange.webservices.data.misc.availability.AttendeeInfo; -import microsoft.exchange.webservices.data.misc.availability.AvailabilityOptions; -import microsoft.exchange.webservices.data.misc.availability.GetUserAvailabilityResults; -import microsoft.exchange.webservices.data.misc.availability.TimeWindow; -import microsoft.exchange.webservices.data.misc.id.AlternateIdBase; -import microsoft.exchange.webservices.data.notification.GetEventsResults; -import microsoft.exchange.webservices.data.notification.PullSubscription; -import microsoft.exchange.webservices.data.notification.PushSubscription; -import microsoft.exchange.webservices.data.notification.StreamingSubscription; -import microsoft.exchange.webservices.data.property.complex.Attachment; -import microsoft.exchange.webservices.data.property.complex.ConversationId; -import microsoft.exchange.webservices.data.property.complex.DelegateUser; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; -import microsoft.exchange.webservices.data.property.complex.EmailAddressCollection; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.Mailbox; -import microsoft.exchange.webservices.data.property.complex.RuleCollection; -import microsoft.exchange.webservices.data.property.complex.RuleOperation; -import microsoft.exchange.webservices.data.property.complex.StringList; -import microsoft.exchange.webservices.data.property.complex.UserId; -import microsoft.exchange.webservices.data.property.complex.availability.OofSettings; -import microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinitionBase; -import microsoft.exchange.webservices.data.search.CalendarView; -import microsoft.exchange.webservices.data.search.ConversationIndexedItemView; -import microsoft.exchange.webservices.data.search.FindFoldersResults; -import microsoft.exchange.webservices.data.search.FindItemsResults; -import microsoft.exchange.webservices.data.search.FolderView; -import microsoft.exchange.webservices.data.search.GroupedFindItemsResults; -import microsoft.exchange.webservices.data.search.Grouping; -import microsoft.exchange.webservices.data.search.ItemView; -import microsoft.exchange.webservices.data.search.ViewBase; -import microsoft.exchange.webservices.data.search.filter.SearchFilter; -import microsoft.exchange.webservices.data.sync.ChangeCollection; -import microsoft.exchange.webservices.data.sync.FolderChange; -import microsoft.exchange.webservices.data.sync.ItemChange; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -/** - * Represents a binding to the Exchange Web Services. - */ -public class ExchangeService extends ExchangeServiceBase implements IAutodiscoverRedirectionUrl { - - private static final Log LOG = LogFactory.getLog(ExchangeService.class); - - /** - * The url. - */ - private URI url; - - /** - * The preferred culture. - */ - private Locale preferredCulture; - - /** - * The DateTimePrecision - */ - private DateTimePrecision dateTimePrecision = DateTimePrecision.Default; - - /** - * The impersonated user id. - */ - private ImpersonatedUserId impersonatedUserId; - // private Iterator Iterator; - /** - * The file attachment content handler. - */ - private IFileAttachmentContentHandler fileAttachmentContentHandler; - - /** - * The unified messaging. - */ - private UnifiedMessaging unifiedMessaging; - - private boolean enableScpLookup = true; - - /** - * When false, used to indicate that we should use "Exchange2007" as the server version String rather than - * Exchange2007_SP1 (@see #getExchange2007CompatibilityMode). - * - */ - private boolean exchange2007CompatibilityMode = false; - - /** - * Create response object. - * - * @param responseObject the response object - * @param parentFolderId the parent folder id - * @param messageDisposition the message disposition - * @return The list of item created or modified as a result of the - * "creation" of the response object. - * @throws Exception the exception - */ - public List internalCreateResponseObject(ServiceObject responseObject, FolderId parentFolderId, - MessageDisposition messageDisposition) throws Exception { - CreateResponseObjectRequest request = new CreateResponseObjectRequest( - this, ServiceErrorHandling.ThrowOnError); - Collection serviceList = new ArrayList(); - serviceList.add(responseObject); - request.setParentFolderId(parentFolderId); - request.setItems(serviceList); - request.setMessageDisposition(messageDisposition); - - ServiceResponseCollection responses = request - .execute(); - - return responses.getResponseAtIndex(0).getItems(); - } - - /** - * Creates a folder. Calling this method results in a call to EWS. - * - * @param folder The folder. - * @param parentFolderId The parent folder Id - * @throws Exception the exception - */ - public void createFolder(Folder folder, FolderId parentFolderId) - throws Exception { - CreateFolderRequest request = new CreateFolderRequest(this, - ServiceErrorHandling.ThrowOnError); - List folArry = new ArrayList(); - folArry.add(folder); - request.setFolders(folArry); - request.setParentFolderId(parentFolderId); - - request.execute(); - } - - /** - * Updates a folder. - * - * @param folder The folder. - * @throws Exception the exception - */ - public void updateFolder(Folder folder) throws Exception { - UpdateFolderRequest request = new UpdateFolderRequest(this, - ServiceErrorHandling.ThrowOnError); - - request.getFolders().add(folder); - - request.execute(); - } - - /** - * Copies a folder. Calling this method results in a call to EWS. - * - * @param folderId The folderId. - * @param destinationFolderId The destination folder id. - * @return the folder - * @throws Exception the exception - */ - public Folder copyFolder(FolderId folderId, FolderId destinationFolderId) - throws Exception { - CopyFolderRequest request = new CopyFolderRequest(this, - ServiceErrorHandling.ThrowOnError); - - request.setDestinationFolderId(destinationFolderId); - request.getFolderIds().add(folderId); - - ServiceResponseCollection responses = request - .execute(); - - return responses.getResponseAtIndex(0).getFolder(); - } - - /** - * Move a folder. - * - * @param folderId The folderId. - * @param destinationFolderId The destination folder id. - * @return the folder - * @throws Exception the exception - */ - public Folder moveFolder(FolderId folderId, FolderId destinationFolderId) - throws Exception { - MoveFolderRequest request = new MoveFolderRequest(this, - ServiceErrorHandling.ThrowOnError); - - request.setDestinationFolderId(destinationFolderId); - request.getFolderIds().add(folderId); - - ServiceResponseCollection responses = request - .execute(); - - return responses.getResponseAtIndex(0).getFolder(); - } - - /** - * Finds folder. - * - * @param parentFolderIds The parent folder ids. - * @param searchFilter The search filter. Available search filter classes include - * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection - * @param view The view controlling the number of folder returned. - * @param errorHandlingMode Indicates the type of error handling should be done. - * @return Collection of service response. - * @throws Exception the exception - */ - private ServiceResponseCollection internalFindFolders( - Iterable parentFolderIds, SearchFilter searchFilter, - FolderView view, ServiceErrorHandling errorHandlingMode) - throws Exception { - FindFolderRequest request = new FindFolderRequest(this, - errorHandlingMode); - - request.getParentFolderIds().addRangeFolderId(parentFolderIds); - request.setSearchFilter(searchFilter); - request.setView(view); - - return request.execute(); - - } - - /** - * Obtains a list of folder by searching the sub-folder of the specified - * folder. - * - * @param parentFolderId The Id of the folder in which to search for folder. - * @param searchFilter The search filter. Available search filter classes include - * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection - * @param view The view controlling the number of folder returned. - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindFoldersResults findFolders(FolderId parentFolderId, - SearchFilter searchFilter, FolderView view) throws Exception { - EwsUtilities.validateParam(parentFolderId, "parentFolderId"); - EwsUtilities.validateParam(view, "view"); - EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); - - List folderIdArray = new ArrayList(); - folderIdArray.add(parentFolderId); - ServiceResponseCollection responses = this - .internalFindFolders(folderIdArray, searchFilter, view, - ServiceErrorHandling.ThrowOnError); - - return responses.getResponseAtIndex(0).getResults(); - } - - /** - * Obtains a list of folder by searching the sub-folder of the specified - * folder. - * - * @param parentFolderId The Id of the folder in which to search for folder. - * @param view The view controlling the number of folder returned. - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindFoldersResults findFolders(FolderId parentFolderId, - FolderView view) throws Exception { - EwsUtilities.validateParam(parentFolderId, "parentFolderId"); - EwsUtilities.validateParam(view, "view"); - - List folderIdArray = new ArrayList(); - folderIdArray.add(parentFolderId); - - ServiceResponseCollection responses = this - .internalFindFolders(folderIdArray, null, /* searchFilter */ - view, ServiceErrorHandling.ThrowOnError); - - return responses.getResponseAtIndex(0).getResults(); - } - - /** - * Obtains a list of folder by searching the sub-folder of the specified - * folder. - * - * @param parentFolderName The name of the folder in which to search for folder. - * @param searchFilter The search filter. Available search filter classes include - * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection - * @param view The view controlling the number of folder returned. - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindFoldersResults findFolders(WellKnownFolderName parentFolderName, - SearchFilter searchFilter, FolderView view) throws Exception { - return this.findFolders(new FolderId(parentFolderName), searchFilter, - view); - } - - /** - * Obtains a list of folder by searching the sub-folder of the specified - * folder. - * - * @param parentFolderName the parent folder name - * @param view the view - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindFoldersResults findFolders(WellKnownFolderName parentFolderName, - FolderView view) throws Exception { - return this.findFolders(new FolderId(parentFolderName), view); - } - - /** - * Load specified property for a folder. - * - * @param folder The folder - * @param propertySet The property set - * @throws Exception the exception - */ - public void loadPropertiesForFolder(Folder folder, PropertySet propertySet) throws Exception { - EwsUtilities.validateParam(folder, "folder"); - EwsUtilities.validateParam(propertySet, "propertySet"); - - GetFolderRequestForLoad request = new GetFolderRequestForLoad(this, - ServiceErrorHandling.ThrowOnError); - - request.getFolderIds().add(folder); - request.setPropertySet(propertySet); - - request.execute(); - } - - /** - * Binds to a folder. - * - * - * @param folderId the folder id - * @param propertySet the property set - * @return Folder - * @throws Exception the exception - */ - public Folder bindToFolder(FolderId folderId, PropertySet propertySet) - throws Exception { - EwsUtilities.validateParam(folderId, "folderId"); - EwsUtilities.validateParam(propertySet, "propertySet"); - - GetFolderRequest request = new GetFolderRequest(this, - ServiceErrorHandling.ThrowOnError); - - request.getFolderIds().add(folderId); - request.setPropertySet(propertySet); - - ServiceResponseCollection responses = request - .execute(); - - return responses.getResponseAtIndex(0).getFolder(); - - } - - /** - * Binds to folder. - * - * @param The type of the folder. - * @param cls Folder class - * @param folderId The folder id. - * @param propertySet The property set. - * @return Folder - * @throws Exception the exception - */ - public TFolder bindToFolder(Class cls, FolderId folderId, - PropertySet propertySet) throws Exception { - Folder result = this.bindToFolder(folderId, propertySet); - - if (cls.isAssignableFrom(result.getClass())) { - return (TFolder) result; - } else { - throw new ServiceLocalException(String.format( - "The folder type returned by the service (%s) isn't compatible with the requested folder type (%s).", - result.getClass().getName(), cls.getName())); - } - } - - /** - * Deletes a folder. Calling this method results in a call to EWS. - * - * @param folderId The folder id - * @param deleteMode The delete mode - * @throws Exception the exception - */ - public void deleteFolder(FolderId folderId, DeleteMode deleteMode) - throws Exception { - EwsUtilities.validateParam(folderId, "folderId"); - - DeleteFolderRequest request = new DeleteFolderRequest(this, - ServiceErrorHandling.ThrowOnError); - - request.getFolderIds().add(folderId); - request.setDeleteMode(deleteMode); - - request.execute(); - } - - /** - * Empties a folder. Calling this method results in a call to EWS. - * - * @param folderId The folder id - * @param deleteMode The delete mode - * @param deleteSubFolders if set to "true" empty folder should also delete sub folder. - * @throws Exception the exception - */ - public void emptyFolder(FolderId folderId, DeleteMode deleteMode, boolean deleteSubFolders) throws Exception { - EwsUtilities.validateParam(folderId, "folderId"); - - EmptyFolderRequest request = new EmptyFolderRequest(this, - ServiceErrorHandling.ThrowOnError); - - request.getFolderIds().add(folderId); - request.setDeleteMode(deleteMode); - request.setDeleteSubFolders(deleteSubFolders); - request.execute(); - } - - /** - * Creates multiple item in a single EWS call. Supported item classes are - * EmailMessage, Appointment, Contact, PostItem, Task and Item. CreateItems - * does not support item that have unsaved attachments. - * - * @param items the item - * @param parentFolderId the parent folder id - * @param messageDisposition the message disposition - * @param sendInvitationsMode the send invitations mode - * @param errorHandling the error handling - * @return A ServiceResponseCollection providing creation results for each - * of the specified item. - * @throws Exception the exception - */ - private ServiceResponseCollection internalCreateItems( - Collection items, FolderId parentFolderId, - MessageDisposition messageDisposition, - SendInvitationsMode sendInvitationsMode, - ServiceErrorHandling errorHandling) throws Exception { - CreateItemRequest request = new CreateItemRequest(this, errorHandling); - request.setParentFolderId(parentFolderId); - request.setItems(items); - request.setMessageDisposition(messageDisposition); - request.setSendInvitationsMode(sendInvitationsMode); - return request.execute(); - } - - /** - * Creates multiple item in a single EWS call. Supported item classes are - * EmailMessage, Appointment, Contact, PostItem, Task and Item. CreateItems - * does not support item that have unsaved attachments. - * - * @param items the item - * @param parentFolderId the parent folder id - * @param messageDisposition the message disposition - * @param sendInvitationsMode the send invitations mode - * @return A ServiceResponseCollection providing creation results for each - * of the specified item. - * @throws Exception the exception - */ - public ServiceResponseCollection createItems( - Collection items, FolderId parentFolderId, - MessageDisposition messageDisposition, - SendInvitationsMode sendInvitationsMode) throws Exception { - // All item have to be new. - if (!EwsUtilities.trueForAll(items, new IPredicate() { - @Override - public boolean predicate(Item obj) throws ServiceLocalException { - return obj.isNew(); - } - })) { - throw new ServiceValidationException( - "This operation can't be performed because at least one item already has an ID."); - } - - // E14:298274 Make sure that all item do *not* have unprocessed - // attachments. - if (!EwsUtilities.trueForAll(items, new IPredicate() { - @Override - public boolean predicate(Item obj) throws ServiceLocalException { - return !obj.hasUnprocessedAttachmentChanges(); - } - })) { - throw new ServiceValidationException("This operation doesn't support item that have attachments."); - } - return this.internalCreateItems(items, parentFolderId, - messageDisposition, sendInvitationsMode, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Creates an item. Calling this method results in a call to EWS. - * - * @param item the item - * @param parentFolderId the parent folder id - * @param messageDisposition the message disposition - * @param sendInvitationsMode the send invitations mode - * @throws Exception the exception - */ - public void createItem(Item item, FolderId parentFolderId, MessageDisposition messageDisposition, - SendInvitationsMode sendInvitationsMode) throws Exception { - ArrayList items = new ArrayList(); - items.add(item); - internalCreateItems(items, parentFolderId, messageDisposition, sendInvitationsMode, - ServiceErrorHandling.ThrowOnError); - } - - /** - * Updates multiple item in a single EWS call. UpdateItems does not - * support item that have unsaved attachments. - * - * @param items the item - * @param savedItemsDestinationFolderId the saved item destination folder id - * @param conflictResolution the conflict resolution - * @param messageDisposition the message disposition - * @param sendInvitationsOrCancellationsMode the send invitations or cancellations mode - * @param errorHandling the error handling - * @return A ServiceResponseCollection providing update results for each of - * the specified item. - * @throws Exception the exception - */ - private ServiceResponseCollection internalUpdateItems( - Iterable items, - FolderId savedItemsDestinationFolderId, - ConflictResolutionMode conflictResolution, - MessageDisposition messageDisposition, - SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode, - ServiceErrorHandling errorHandling) throws Exception { - UpdateItemRequest request = new UpdateItemRequest(this, errorHandling); - - request.getItems().addAll((Collection) items); - request.setSavedItemsDestinationFolder(savedItemsDestinationFolderId); - request.setMessageDisposition(messageDisposition); - request.setConflictResolutionMode(conflictResolution); - request - .setSendInvitationsOrCancellationsMode(sendInvitationsOrCancellationsMode); - - return request.execute(); - } - - /** - * Updates multiple item in a single EWS call. UpdateItems does not - * support item that have unsaved attachments. - * - * @param items the item - * @param savedItemsDestinationFolderId the saved item destination folder id - * @param conflictResolution the conflict resolution - * @param messageDisposition the message disposition - * @param sendInvitationsOrCancellationsMode the send invitations or cancellations mode - * @return A ServiceResponseCollection providing update results for each of - * the specified item. - * @throws Exception the exception - */ - public ServiceResponseCollection updateItems( - Iterable items, - FolderId savedItemsDestinationFolderId, - ConflictResolutionMode conflictResolution, - MessageDisposition messageDisposition, - SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode) - throws Exception { - - // All item have to exist on the server (!new) and modified (dirty) - if (!EwsUtilities.trueForAll(items, new IPredicate() { - @Override - public boolean predicate(Item obj) throws ServiceLocalException { - return (!obj.isNew() && obj.isDirty()); - } - })) { - throw new ServiceValidationException( - "This operation can't be performed because one or more item are new or unmodified."); - } - - // E14:298274 Make sure that all item do *not* have unprocessed - // attachments. - if (!EwsUtilities.trueForAll(items, new IPredicate() { - @Override - public boolean predicate(Item obj) throws ServiceLocalException { - return !obj.hasUnprocessedAttachmentChanges(); - } - })) { - throw new ServiceValidationException( - "This operation can't be performed because attachments have been added or deleted for one or more item."); - } - - return this.internalUpdateItems(items, savedItemsDestinationFolderId, conflictResolution, - messageDisposition, sendInvitationsOrCancellationsMode, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Updates an item. - * - * @param item the item - * @param savedItemsDestinationFolderId the saved item destination folder id - * @param conflictResolution the conflict resolution - * @param messageDisposition the message disposition - * @param sendInvitationsOrCancellationsMode the send invitations or cancellations mode - * @return A ServiceResponseCollection providing deletion results for each - * of the specified item Ids. - * @throws Exception the exception - */ - public Item updateItem(Item item, FolderId savedItemsDestinationFolderId, - ConflictResolutionMode conflictResolution, MessageDisposition messageDisposition, - SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode) - throws Exception { - List itemIdArray = new ArrayList(); - itemIdArray.add(item); - - ServiceResponseCollection responses = this - .internalUpdateItems(itemIdArray, - savedItemsDestinationFolderId, conflictResolution, - messageDisposition, sendInvitationsOrCancellationsMode, - ServiceErrorHandling.ThrowOnError); - - return responses.getResponseAtIndex(0).getReturnedItem(); - } - - /** - * Send item. - * - * @param item the item - * @param savedCopyDestinationFolderId the saved copy destination folder id - * @throws Exception the exception - */ - public void sendItem(Item item, FolderId savedCopyDestinationFolderId) - throws Exception { - SendItemRequest request = new SendItemRequest(this, - ServiceErrorHandling.ThrowOnError); - - List itemIdArray = new ArrayList(); - itemIdArray.add(item); - - request.setItems(itemIdArray); - request.setSavedCopyDestinationFolderId(savedCopyDestinationFolderId); - - request.execute(); - } - - /** - * Copies multiple item in a single call to EWS. - * - * @param itemIds the item ids - * @param destinationFolderId the destination folder id - * @param returnNewItemIds Flag indicating whether service should return new ItemIds or - * not. - * @param errorHandling the error handling - * @return A ServiceResponseCollection providing copy results for each of - * the specified item Ids. - * @throws Exception the exception - */ - private ServiceResponseCollection internalCopyItems( - Iterable itemIds, FolderId destinationFolderId, - Boolean returnNewItemIds, ServiceErrorHandling errorHandling) - throws Exception { - CopyItemRequest request = new CopyItemRequest(this, errorHandling); - request.getItemIds().addRange(itemIds); - request.setDestinationFolderId(destinationFolderId); - request.setReturnNewItemIds(returnNewItemIds); - return request.execute(); - - } - - /** - * Copies multiple item in a single call to EWS. - * - * @param itemIds the item ids - * @param destinationFolderId the destination folder id - * @return A ServiceResponseCollection providing copy results for each of - * the specified item Ids. - * @throws Exception the exception - */ - public ServiceResponseCollection copyItems( - Iterable itemIds, FolderId destinationFolderId) - throws Exception { - return this.internalCopyItems(itemIds, destinationFolderId, null, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Copies multiple item in a single call to EWS. - * - * @param itemIds The Ids of the item to copy. - * @param destinationFolderId The Id of the folder to copy the item to. - * @param returnNewItemIds Flag indicating whether service should return new ItemIds or - * not. - * @return A ServiceResponseCollection providing copy results for each of - * the specified item Ids. - * @throws Exception on error - */ - public ServiceResponseCollection copyItems( - Iterable itemIds, FolderId destinationFolderId, - boolean returnNewItemIds) throws Exception { - EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010_SP1, "CopyItems"); - - return this.internalCopyItems(itemIds, destinationFolderId, returnNewItemIds, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Copies an item. Calling this method results in a call to EWS. - * - * @param itemId The Id of the item to copy. - * @param destinationFolderId The folder in which to save sent messages, meeting invitations - * or cancellations. If null, the message, meeting invitation or - * cancellation is saved in the Sent Items folder - * @return The copy of the item. - * @throws Exception the exception - */ - public Item copyItem(ItemId itemId, FolderId destinationFolderId) - throws Exception { - List itemIdArray = new ArrayList(); - itemIdArray.add(itemId); - - return this.internalCopyItems(itemIdArray, destinationFolderId, null, - ServiceErrorHandling.ThrowOnError).getResponseAtIndex(0) - .getItem(); - } - - /** - * Moves multiple item in a single call to EWS. - * - * @param itemIds the item ids - * @param destinationFolderId the destination folder id - * @param returnNewItemIds Flag indicating whether service should return new ItemIds or - * not. - * @param errorHandling the error handling - * @return A ServiceResponseCollection providing copy results for each of - * the specified item Ids. - * @throws Exception the exception - */ - private ServiceResponseCollection internalMoveItems( - Iterable itemIds, FolderId destinationFolderId, - Boolean returnNewItemIds, ServiceErrorHandling errorHandling) - throws Exception { - MoveItemRequest request = new MoveItemRequest(this, errorHandling); - - request.getItemIds().addRange(itemIds); - request.setDestinationFolderId(destinationFolderId); - request.setReturnNewItemIds(returnNewItemIds); - return request.execute(); - } - - /** - * Moves multiple item in a single call to EWS. - * - * @param itemIds the item ids - * @param destinationFolderId the destination folder id - * @return A ServiceResponseCollection providing copy results for each of - * the specified item Ids. - * @throws Exception the exception - */ - public ServiceResponseCollection moveItems( - Iterable itemIds, FolderId destinationFolderId) - throws Exception { - return this.internalMoveItems(itemIds, destinationFolderId, null, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Moves multiple item in a single call to EWS. - * - * @param itemIds The Ids of the item to move. - * @param destinationFolderId The Id of the folder to move the item to. - * @param returnNewItemIds Flag indicating whether service should return new ItemIds or - * not. - * @return A ServiceResponseCollection providing copy results for each of - * the specified item Ids. - * @throws Exception on error - */ - public ServiceResponseCollection moveItems( - Iterable itemIds, FolderId destinationFolderId, - boolean returnNewItemIds) throws Exception { - EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010_SP1, "MoveItems"); - - return this.internalMoveItems(itemIds, destinationFolderId, returnNewItemIds, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Copies multiple item in a single call to EWS. - * - * @param itemId the item id - * @param destinationFolderId the destination folder id - * @return A ServiceResponseCollection providing copy results for each of - * the specified item Ids. - * @throws Exception the exception - */ - public Item moveItem(ItemId itemId, FolderId destinationFolderId) - throws Exception { - List itemIdArray = new ArrayList(); - itemIdArray.add(itemId); - - return this.internalMoveItems(itemIdArray, destinationFolderId, null, - ServiceErrorHandling.ThrowOnError).getResponseAtIndex(0) - .getItem(); - } - - /** - * Finds item. - * - * @param The type of item - * @param parentFolderIds The parent folder ids. - * @param searchFilter The search filter. Available search filter classes include - * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection - * @param queryString the query string - * @param view The view controlling the number of folder returned. - * @param groupBy The group by. - * @param errorHandlingMode Indicates the type of error handling should be done. - * @return Service response collection. - * @throws Exception the exception - */ - public ServiceResponseCollection> findItems( - Iterable parentFolderIds, SearchFilter searchFilter, String queryString, ViewBase view, - Grouping groupBy, ServiceErrorHandling errorHandlingMode) throws Exception { - EwsUtilities.validateParamCollection(parentFolderIds.iterator(), - "parentFolderIds"); - EwsUtilities.validateParam(view, "view"); - EwsUtilities.validateParamAllowNull(groupBy, "groupBy"); - EwsUtilities.validateParamAllowNull(queryString, "queryString"); - EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); - - FindItemRequest request = new FindItemRequest(this, - errorHandlingMode); - - request.getParentFolderIds().addRangeFolderId(parentFolderIds); - request.setSearchFilter(searchFilter); - request.setQueryString(queryString); - request.setView(view); - request.setGroupBy(groupBy); - - return request.execute(); - } - - /** - * Obtains a list of item by searching the contents of a specific folder. - * Calling this method results in a call to EWS. - * - * @param parentFolderId the parent folder id - * @param queryString the query string - * @param view the view - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindItemsResults findItems(FolderId parentFolderId, - String queryString, ItemView view) throws Exception { - EwsUtilities.validateParamAllowNull(queryString, "queryString"); - - List folderIdArray = new ArrayList(); - folderIdArray.add(parentFolderId); - - ServiceResponseCollection> responses = this - .findItems(folderIdArray, null, /* searchFilter */ - queryString, view, null, /* groupBy */ - ServiceErrorHandling.ThrowOnError); - - return responses.getResponseAtIndex(0).getResults(); - } - - /** - * Obtains a list of item by searching the contents of a specific folder. - * Calling this method results in a call to EWS. - * - * @param parentFolderId the parent folder id - * @param searchFilter the search filter - * @param view the view - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindItemsResults findItems(FolderId parentFolderId, - SearchFilter searchFilter, ItemView view) throws Exception { - EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); - List folderIdArray = new ArrayList(); - folderIdArray.add(parentFolderId); - ServiceResponseCollection> responses = this - .findItems(folderIdArray, searchFilter, null, /* queryString */ - view, null, /* groupBy */ - ServiceErrorHandling.ThrowOnError); - - return responses.getResponseAtIndex(0).getResults(); - } - - /** - * Obtains a list of item by searching the contents of a specific folder. - * Calling this method results in a call to EWS. - * - * @param parentFolderId the parent folder id - * @param view the view - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindItemsResults findItems(FolderId parentFolderId, - ItemView view) throws Exception { - List folderIdArray = new ArrayList(); - folderIdArray.add(parentFolderId); - ServiceResponseCollection> responses = this - .findItems(folderIdArray, null, /* searchFilter */ - null, /* queryString */ - view, null, /* groupBy */ - ServiceErrorHandling.ThrowOnError); - - return responses.getResponseAtIndex(0).getResults(); - } - - /** - * Obtains a list of item by searching the contents of a specific folder. - * Calling this method results in a call to EWS. - * - * @param parentFolderName the parent folder name - * @param queryString the query string - * @param view the view - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindItemsResults findItems( - WellKnownFolderName parentFolderName, String queryString, - ItemView view) throws Exception { - return this - .findItems(new FolderId(parentFolderName), queryString, view); - } - - /** - * Obtains a list of item by searching the contents of a specific folder. - * Calling this method results in a call to EWS. - * - * @param parentFolderName the parent folder name - * @param searchFilter the search filter - * @param view the view - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindItemsResults findItems( - WellKnownFolderName parentFolderName, SearchFilter searchFilter, - ItemView view) throws Exception { - return this.findItems(new FolderId(parentFolderName), searchFilter, - view); - } - - /** - * Obtains a list of item by searching the contents of a specific folder. - * Calling this method results in a call to EWS. - * - * @param parentFolderName the parent folder name - * @param view the view - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindItemsResults findItems( - WellKnownFolderName parentFolderName, ItemView view) - throws Exception { - return this.findItems(new FolderId(parentFolderName), (SearchFilter) null, view); - } - - /** - * Obtains a grouped list of item by searching the contents of a specific - * folder. Calling this method results in a call to EWS. - * - * @param parentFolderId the parent folder id - * @param queryString the query string - * @param view the view - * @param groupBy the group by - * @return A list of item containing the contents of the specified folder. - * @throws Exception the exception - */ - public GroupedFindItemsResults findItems(FolderId parentFolderId, - String queryString, ItemView view, Grouping groupBy) - throws Exception { - EwsUtilities.validateParam(groupBy, "groupBy"); - EwsUtilities.validateParamAllowNull(queryString, "queryString"); - - List folderIdArray = new ArrayList(); - folderIdArray.add(parentFolderId); - - ServiceResponseCollection> responses = this - .findItems(folderIdArray, null, /* searchFilter */ - queryString, view, groupBy, ServiceErrorHandling.ThrowOnError); - - return responses.getResponseAtIndex(0).getGroupedFindResults(); - } - - /** - * Obtains a grouped list of item by searching the contents of a specific - * folder. Calling this method results in a call to EWS. - * - * @param parentFolderId the parent folder id - * @param searchFilter the search filter - * @param view the view - * @param groupBy the group by - * @return A list of item containing the contents of the specified folder. - * @throws Exception the exception - */ - public GroupedFindItemsResults findItems(FolderId parentFolderId, - SearchFilter searchFilter, ItemView view, Grouping groupBy) - throws Exception { - EwsUtilities.validateParam(groupBy, "groupBy"); - EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); - - List folderIdArray = new ArrayList(); - folderIdArray.add(parentFolderId); - - ServiceResponseCollection> responses = this - .findItems(folderIdArray, searchFilter, null, /* queryString */ - view, groupBy, ServiceErrorHandling.ThrowOnError); - - return responses.getResponseAtIndex(0).getGroupedFindResults(); - } - - /** - * Obtains a grouped list of item by searching the contents of a specific - * folder. Calling this method results in a call to EWS. - * - * @param parentFolderId the parent folder id - * @param view the view - * @param groupBy the group by - * @return A list of item containing the contents of the specified folder. - * @throws Exception the exception - */ - public GroupedFindItemsResults findItems(FolderId parentFolderId, - ItemView view, Grouping groupBy) throws Exception { - EwsUtilities.validateParam(groupBy, "groupBy"); - - List folderIdArray = new ArrayList(); - folderIdArray.add(parentFolderId); - - ServiceResponseCollection> responses = this - .findItems(folderIdArray, null, /* searchFilter */ - null, /* queryString */ - view, groupBy, ServiceErrorHandling.ThrowOnError); - - return responses.getResponseAtIndex(0).getGroupedFindResults(); - } - - /** - * Obtains a grouped list of item by searching the contents of a specific - * folder. Calling this method results in a call to EWS. - * - * @param the generic type - * @param cls the cls - * @param parentFolderId the parent folder id - * @param searchFilter the search filter - * @param view the view - * @param groupBy the group by - * @return A list of item containing the contents of the specified folder. - * @throws Exception the exception - */ - protected ServiceResponseCollection> findItems( - Class cls, FolderId parentFolderId, - SearchFilter searchFilter, ViewBase view, Grouping groupBy) - throws Exception { - List folderIdArray = new ArrayList(); - folderIdArray.add(parentFolderId); - - return this.findItems(folderIdArray, searchFilter, null, /* queryString */ - view, groupBy, ServiceErrorHandling.ThrowOnError); - } - - /** - * Obtains a grouped list of item by searching the contents of a specific - * folder. Calling this method results in a call to EWS. - * - * @param parentFolderName the parent folder name - * @param queryString the query string - * @param view the view - * @param groupBy the group by - * @return A collection of grouped item containing the contents of the - * specified. - * @throws Exception the exception - */ - public GroupedFindItemsResults findItems( - WellKnownFolderName parentFolderName, String queryString, - ItemView view, Grouping groupBy) throws Exception { - EwsUtilities.validateParam(groupBy, "groupBy"); - return this.findItems(new FolderId(parentFolderName), queryString, - view, groupBy); - } - - /** - * Obtains a grouped list of item by searching the contents of a specific - * folder. Calling this method results in a call to EWS. - * - * @param parentFolderName the parent folder name - * @param searchFilter the search filter - * @param view the view - * @param groupBy the group by - * @return A collection of grouped item containing the contents of the - * specified. - * @throws Exception the exception - */ - public GroupedFindItemsResults findItems( - WellKnownFolderName parentFolderName, SearchFilter searchFilter, - ItemView view, Grouping groupBy) throws Exception { - return this.findItems(new FolderId(parentFolderName), searchFilter, view, groupBy); - } - - /** - * Obtains a list of appointments by searching the contents of a specific - * folder. Calling this method results in a call to EWS. - * - * @param parentFolderId the parent folder id - * @param calendarView the calendar view - * @return A collection of appointments representing the contents of the - * specified folder. - * @throws Exception the exception - */ - public FindItemsResults findAppointments( - FolderId parentFolderId, CalendarView calendarView) - throws Exception { - List folderIdArray = new ArrayList(); - folderIdArray.add(parentFolderId); - - ServiceResponseCollection> response = this - .findItems(folderIdArray, null, /* searchFilter */ - null /* queryString */, calendarView, null, /* groupBy */ - ServiceErrorHandling.ThrowOnError); - - return response.getResponseAtIndex(0).getResults(); - } - - /** - * Obtains a list of appointments by searching the contents of a specific - * folder. Calling this method results in a call to EWS. - * - * @param parentFolderName the parent folder name - * @param calendarView the calendar view - * @return A collection of appointments representing the contents of the - * specified folder. - * @throws Exception the exception - */ - public FindItemsResults findAppointments( - WellKnownFolderName parentFolderName, CalendarView calendarView) - throws Exception { - return this.findAppointments(new FolderId(parentFolderName), calendarView); - } - - /** - * Loads the property of multiple item in a single call to EWS. - * - * @param items the item - * @param propertySet the property set - * @return A ServiceResponseCollection providing results for each of the - * specified item. - * @throws Exception the exception - */ - public ServiceResponseCollection loadPropertiesForItems( - Iterable items, PropertySet propertySet) throws Exception { - EwsUtilities.validateParamCollection(items.iterator(), "item"); - EwsUtilities.validateParam(propertySet, "propertySet"); - - return this.internalLoadPropertiesForItems(items, propertySet, ServiceErrorHandling.ReturnErrors); - } - - /** - * Loads the property of multiple item in a single call to EWS. - * - * @param items the item - * @param propertySet the property set - * @param errorHandling the error handling - * @return A ServiceResponseCollection providing results for each of the - * specified item. - * @throws Exception the exception - */ - public ServiceResponseCollection internalLoadPropertiesForItems(Iterable items, - PropertySet propertySet, ServiceErrorHandling errorHandling) throws Exception { - GetItemRequestForLoad request = new GetItemRequestForLoad(this, - errorHandling); - // return null; - - request.getItemIds().addRangeItem(items); - request.setPropertySet(propertySet); - - return request.execute(); - } - - /** - * Binds to multiple item in a single call to EWS. - * - * @param itemIds the item ids - * @param propertySet the property set - * @param errorHandling the error handling - * @return A ServiceResponseCollection providing results for each of the - * specified item Ids. - * @throws Exception the exception - */ - private ServiceResponseCollection internalBindToItems( - Iterable itemIds, PropertySet propertySet, - ServiceErrorHandling errorHandling) throws Exception { - GetItemRequest request = new GetItemRequest(this, errorHandling); - request.getItemIds().addRange(itemIds); - request.setPropertySet(propertySet); - return request.execute(); - } - - /** - * Binds to multiple item in a single call to EWS. - * - * @param itemIds the item ids - * @param propertySet the property set - * @return A ServiceResponseCollection providing results for each of the - * specified item Ids. - * @throws Exception the exception - */ - public ServiceResponseCollection bindToItems( - Iterable itemIds, PropertySet propertySet) throws Exception { - EwsUtilities.validateParamCollection(itemIds.iterator(), "itemIds"); - EwsUtilities.validateParam(propertySet, "propertySet"); - - return this.internalBindToItems(itemIds, propertySet, ServiceErrorHandling.ReturnErrors); - } - - /** - * Binds to multiple item in a single call to EWS. - * - * @param itemId the item id - * @param propertySet the property set - * @return A ServiceResponseCollection providing results for each of the - * specified item Ids. - * @throws Exception the exception - */ - public Item bindToItem(ItemId itemId, PropertySet propertySet) - throws Exception { - EwsUtilities.validateParam(itemId, "itemId"); - EwsUtilities.validateParam(propertySet, "propertySet"); - List itmLst = new ArrayList(); - itmLst.add(itemId); - ServiceResponseCollection responses = this - .internalBindToItems(itmLst, propertySet, ServiceErrorHandling.ThrowOnError); - - return responses.getResponseAtIndex(0).getItem(); - } - - /** - * Bind to item. - * - * @param The type of the item. - * @param c the c - * @param itemId the item id - * @param propertySet the property set - * @return the t item - * @throws Exception the exception - */ - public TItem bindToItem(Class c, ItemId itemId, PropertySet propertySet) throws Exception { - Item result = this.bindToItem(itemId, propertySet); - if (c.isAssignableFrom(result.getClass())) { - return (TItem) result; - } else { - throw new ServiceLocalException(String.format( - "The item type returned by the service (%s) isn't compatible with the requested item type (%s).", result.getClass().getName(), - c.getName())); - } - } - - /** - * Deletes multiple item in a single call to EWS. - * - * @param itemIds the item ids - * @param deleteMode the delete mode - * @param sendCancellationsMode the send cancellations mode - * @param affectedTaskOccurrences the affected task occurrences - * @param errorHandling the error handling - * @return A ServiceResponseCollection providing deletion results for each - * of the specified item Ids. - * @throws Exception the exception - */ - private ServiceResponseCollection internalDeleteItems( - Iterable itemIds, DeleteMode deleteMode, - SendCancellationsMode sendCancellationsMode, - AffectedTaskOccurrence affectedTaskOccurrences, - ServiceErrorHandling errorHandling) throws Exception { - DeleteItemRequest request = new DeleteItemRequest(this, errorHandling); - - request.getItemIds().addRange(itemIds); - request.setDeleteMode(deleteMode); - request.setSendCancellationsMode(sendCancellationsMode); - request.setAffectedTaskOccurrences(affectedTaskOccurrences); - - return request.execute(); - } - - /** - * Deletes multiple item in a single call to EWS. - * - * @param itemIds the item ids - * @param deleteMode the delete mode - * @param sendCancellationsMode the send cancellations mode - * @param affectedTaskOccurrences the affected task occurrences - * @return A ServiceResponseCollection providing deletion results for each - * of the specified item Ids. - * @throws Exception the exception - */ - public ServiceResponseCollection deleteItems( - Iterable itemIds, DeleteMode deleteMode, - SendCancellationsMode sendCancellationsMode, - AffectedTaskOccurrence affectedTaskOccurrences) throws Exception { - EwsUtilities.validateParamCollection(itemIds.iterator(), "itemIds"); - - return this.internalDeleteItems(itemIds, deleteMode, - sendCancellationsMode, affectedTaskOccurrences, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Deletes an item. Calling this method results in a call to EWS. - * - * @param itemId the item id - * @param deleteMode the delete mode - * @param sendCancellationsMode the send cancellations mode - * @param affectedTaskOccurrences the affected task occurrences - * @throws Exception the exception - */ - public void deleteItem(ItemId itemId, DeleteMode deleteMode, SendCancellationsMode sendCancellationsMode, - AffectedTaskOccurrence affectedTaskOccurrences) throws Exception { - List itemIdArray = new ArrayList(); - itemIdArray.add(itemId); - - EwsUtilities.validateParam(itemId, "itemId"); - this.internalDeleteItems(itemIdArray, deleteMode, - sendCancellationsMode, affectedTaskOccurrences, - ServiceErrorHandling.ThrowOnError); - } - - /** - * Gets an attachment. - * - * @param attachments the attachments - * @param bodyType the body type - * @param additionalProperties the additional property - * @param errorHandling the error handling - * @throws Exception the exception - */ - private ServiceResponseCollection internalGetAttachments( - Iterable attachments, BodyType bodyType, - Iterable additionalProperties, ServiceErrorHandling errorHandling) - throws Exception { - GetAttachmentRequest request = new GetAttachmentRequest(this, errorHandling); - - Iterator it = attachments.iterator(); - while (it.hasNext()) { - request.getAttachments().add(it.next()); - } - request.setBodyType(bodyType); - - if (additionalProperties != null) { - List propsArray = new ArrayList(); - for (PropertyDefinitionBase propertyDefinitionBase : additionalProperties) { - propsArray.add(propertyDefinitionBase); - } - request.getAdditionalProperties().addAll(propsArray); - } - - return request.execute(); - } - - /** - * Gets attachments. - * - * @param attachments the attachments - * @param bodyType the body type - * @param additionalProperties the additional property - * @return service response collection - * @throws Exception on error - */ - protected ServiceResponseCollection getAttachments( - Attachment[] attachments, BodyType bodyType, - Iterable additionalProperties) - throws Exception { - return this.internalGetAttachments(Arrays.asList(attachments), bodyType, - additionalProperties, ServiceErrorHandling.ReturnErrors); - } - - /** - * Gets the attachment. - * - * @param attachment the attachment - * @param bodyType the body type - * @param additionalProperties the additional property - * @throws Exception the exception - */ - public void getAttachment(Attachment attachment, BodyType bodyType, - Iterable additionalProperties) - throws Exception { - - List attachmentArray = new ArrayList(); - attachmentArray.add(attachment); - - this.internalGetAttachments(attachmentArray, bodyType, additionalProperties, - ServiceErrorHandling.ThrowOnError); - - } - - /** - * Creates attachments. - * - * @param parentItemId the parent item id - * @param attachments the attachments - * @return Service response collection. - * @throws ServiceResponseException the service response exception - * @throws Exception the exception - */ - public ServiceResponseCollection createAttachments(String parentItemId, - Iterable attachments) - throws ServiceResponseException, Exception { - CreateAttachmentRequest request = new CreateAttachmentRequest(this, - ServiceErrorHandling.ReturnErrors); - - request.setParentItemId(parentItemId); - /* - * if (null != attachments) { while (attachments.hasNext()) { - * request.getAttachments().add(attachments.next()); } } - */ - request.getAttachments().addAll( - (Collection) attachments); - - return request.execute(); - } - - /** - * Deletes attachments. - * - * @param attachments the attachments - * @return the service response collection - * @throws ServiceResponseException the service response exception - * @throws Exception the exception - */ - public ServiceResponseCollection deleteAttachments( - Iterable attachments) throws ServiceResponseException, - Exception { - DeleteAttachmentRequest request = new DeleteAttachmentRequest(this, - ServiceErrorHandling.ReturnErrors); - - request.getAttachments().addAll( - (Collection) attachments); - - return request.execute(); - } - - /** - * Finds contacts in the user's Contacts folder and the Global Address - * List (in that order) that have names that match the one passed as a - * parameter. Calling this method results in a call to EWS. - * - * @param nameToResolve the name to resolve - * @return A collection of name resolutions whose names match the one passed - * as a parameter. - * @throws Exception the exception - */ - public NameResolutionCollection resolveName(String nameToResolve) - throws Exception { - return this.resolveName(nameToResolve, ResolveNameSearchLocation.ContactsThenDirectory, false); - } - - /** - * Finds contacts in the user's Contacts folder and the Global Address - * List (in that order) that have names that match the one passed as a - * parameter. Calling this method results in a call to EWS. - * - * @param nameToResolve the name to resolve - * @param parentFolderIds the parent folder ids - * @param searchScope the search scope - * @param returnContactDetails the return contact details - * @return A collection of name resolutions whose names match the one passed - * as a parameter. - * @throws Exception the exception - */ - public NameResolutionCollection resolveName(String nameToResolve, - Iterable parentFolderIds, - ResolveNameSearchLocation searchScope, boolean returnContactDetails) - throws Exception { - return resolveName(nameToResolve, parentFolderIds, searchScope, returnContactDetails, null); - - } - - /** - * Finds contacts in the Global Address List and/or in specific contact - * folder that have names that match the one passed as a parameter. Calling - * this method results in a call to EWS. - * - * @param nameToResolve The name to resolve. - * @param parentFolderIds The Ids of the contact folder in which to look for matching - * contacts. - * @param searchScope The scope of the search. - * @param returnContactDetails Indicates whether full contact information should be returned - * for each of the found contacts. - * @param contactDataPropertySet The property set for the contact details - * @return a collection of name resolutions whose names match the one passed as a parameter - * @throws Exception on error - */ - public NameResolutionCollection resolveName(String nameToResolve, - Iterable parentFolderIds, - ResolveNameSearchLocation searchScope, - boolean returnContactDetails, PropertySet contactDataPropertySet) - throws Exception { - if (contactDataPropertySet != null) { - EwsUtilities.validateMethodVersion(this, - ExchangeVersion.Exchange2010_SP1, "ResolveName"); - } - - EwsUtilities.validateParam(nameToResolve, "nameToResolve"); - - if (parentFolderIds != null) { - EwsUtilities.validateParamCollection(parentFolderIds.iterator(), - "parentFolderIds"); - } - ResolveNamesRequest request = new ResolveNamesRequest(this); - - request.setNameToResolve(nameToResolve); - request.setReturnFullContactData(returnContactDetails); - request.getParentFolderIds().addRangeFolderId(parentFolderIds); - request.setSearchLocation(searchScope); - request.setContactDataPropertySet(contactDataPropertySet); - - return request.execute().getResponseAtIndex(0).getResolutions(); - } - - /** - * Finds contacts in the Global Address List that have names that match the - * one passed as a parameter. Calling this method results in a call to EWS. - * - * @param nameToResolve The name to resolve. - * @param searchScope The scope of the search. - * @param returnContactDetails Indicates whether full contact information should be returned - * for each of the found contacts. - * @param contactDataPropertySet The property set for the contact details - * @return A collection of name resolutions whose names match the one - * passed as a parameter. - * @throws Exception on error - */ - public NameResolutionCollection resolveName(String nameToResolve, - ResolveNameSearchLocation searchScope, - boolean returnContactDetails, PropertySet contactDataPropertySet) - throws Exception { - return this.resolveName(nameToResolve, null, searchScope, - returnContactDetails, contactDataPropertySet); - } - - /** - * Finds contacts in the user's Contacts folder and the Global Address - * List (in that order) that have names that match the one passed as a - * parameter. Calling this method results in a call to EWS. - * - * @param nameToResolve the name to resolve - * @param searchScope the search scope - * @param returnContactDetails the return contact details - * @return A collection of name resolutions whose names match the one passed - * as a parameter. - * @throws Exception the exception - */ - public NameResolutionCollection resolveName(String nameToResolve, - ResolveNameSearchLocation searchScope, boolean returnContactDetails) - throws Exception { - return this.resolveName(nameToResolve, null, searchScope, returnContactDetails); - } - - /** - * Expands a group by retrieving a list of its members. Calling this - * method results in a call to EWS. - * - * @param emailAddress the email address - * @return URL of the Exchange Web Services. - * @throws Exception the exception - */ - public ExpandGroupResults expandGroup(EmailAddress emailAddress) - throws Exception { - EwsUtilities.validateParam(emailAddress, "emailAddress"); - ExpandGroupRequest request = new ExpandGroupRequest(this); - request.setEmailAddress(emailAddress); - return request.execute().getResponseAtIndex(0).getMembers(); - } - - /** - * Expands a group by retrieving a list of its members. Calling this - * method results in a call to EWS. - * - * @param groupId the group id - * @return An ExpandGroupResults containing the members of the group. - * @throws Exception the exception - */ - public ExpandGroupResults expandGroup(ItemId groupId) throws Exception { - EwsUtilities.validateParam(groupId, "groupId"); - EmailAddress emailAddress = new EmailAddress(); - emailAddress.setId(groupId); - return this.expandGroup(emailAddress); - } - - /** - * Expands a group by retrieving a list of its members. Calling this - * method results in a call to EWS. - * - * @param smtpAddress the smtp address - * @return An ExpandGroupResults containing the members of the group. - * @throws Exception the exception - */ - public ExpandGroupResults expandGroup(String smtpAddress) throws Exception { - EwsUtilities.validateParam(smtpAddress, "smtpAddress"); - return this.expandGroup(new EmailAddress(smtpAddress)); - } - - /** - * Expands a group by retrieving a list of its members. Calling this - * method results in a call to EWS. - * - * @param address the address - * @param routingType the routing type - * @return An ExpandGroupResults containing the members of the group. - * @throws Exception the exception - */ - public ExpandGroupResults expandGroup(String address, String routingType) - throws Exception { - EwsUtilities.validateParam(address, "address"); - EwsUtilities.validateParam(routingType, "routingType"); - - EmailAddress emailAddress = new EmailAddress(address); - emailAddress.setRoutingType(routingType); - return this.expandGroup(emailAddress); - } - - /** - * Get the password expiration date - * - * @param mailboxSmtpAddress The e-mail address of the user. - * @return The password expiration date - * @throws Exception on error - */ - public Date getPasswordExpirationDate(String mailboxSmtpAddress) throws Exception { - GetPasswordExpirationDateRequest request = new GetPasswordExpirationDateRequest(this); - request.setMailboxSmtpAddress(mailboxSmtpAddress); - - return request.execute().getPasswordExpirationDate(); - } - - /** - * Subscribes to pull notification. Calling this method results in a call - * to EWS. - * - * @param folderIds The Ids of the folder to subscribe to - * @param timeout The timeout, in minutes, after which the subscription expires. - * Timeout must be between 1 and 1440. - * @param watermark An optional watermark representing a previously opened - * subscription. - * @param eventTypes The event types to subscribe to. - * @return A PullSubscription representing the new subscription. - * @throws Exception on error - */ - public PullSubscription subscribeToPullNotifications( - Iterable folderIds, int timeout, String watermark, - EventType... eventTypes) throws Exception { - EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds"); - - return this.buildSubscribeToPullNotificationsRequest(folderIds, - timeout, watermark, eventTypes).execute().getResponseAtIndex(0) - .getSubscription(); - } - - /** - * Begins an asynchronous request to subscribes to pull notification. - * Calling this method results in a call to EWS. - * - * @param callback The AsyncCallback delegate. - * @param state An object that contains state information for this request. - * @param folderIds The Ids of the folder to subscribe to. - * @param timeout The timeout, in minutes, after which the subscription expires. - * Timeout must be between 1 and 1440. - * @param watermark An optional watermark representing a previously opened - * subscription. - * @param eventTypes The event types to subscribe to. - * @return An IAsyncResult that references the asynchronous request. - * @throws Exception - */ - public AsyncRequestResult beginSubscribeToPullNotifications( - AsyncCallback callback, Object state, Iterable folderIds, - int timeout, String watermark, EventType... eventTypes) - throws Exception { - EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds"); - - return this.buildSubscribeToPullNotificationsRequest(folderIds, timeout, watermark, - eventTypes).beginExecute(callback); - } - - /** - * Subscribes to pull notification on all folder in the authenticated - * user's mailbox. Calling this method results in a call to EWS. - * - * @param timeout the timeout - * @param watermark the watermark - * @param eventTypes the event types - * @return A PullSubscription representing the new subscription. - * @throws Exception the exception - */ - public PullSubscription subscribeToPullNotificationsOnAllFolders( - int timeout, String watermark, EventType... eventTypes) - throws Exception { - EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010, - "SubscribeToPullNotificationsOnAllFolders"); - - return this.buildSubscribeToPullNotificationsRequest(null, timeout, - watermark, eventTypes).execute().getResponseAtIndex(0) - .getSubscription(); - } - - /** - * Begins an asynchronous request to subscribe to pull notification on all - * folder in the authenticated user's mailbox. Calling this method results - * in a call to EWS. - * - * @param callback The AsyncCallback delegate. - * @param state An object that contains state information for this request. - * @param timeout The timeout, in minutes, after which the subscription expires. - * Timeout must be between 1 and 1440. - * @param watermark An optional watermark representing a previously opened - * subscription. - * @param eventTypes The event types to subscribe to. - * @return An IAsyncResult that references the asynchronous request. - * @throws Exception - */ - public IAsyncResult beginSubscribeToPullNotificationsOnAllFolders(AsyncCallback callback, Object state, - int timeout, - String watermark, EventType... eventTypes) throws Exception { - EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010, - "BeginSubscribeToPullNotificationsOnAllFolders"); - - return this.buildSubscribeToPullNotificationsRequest(null, timeout, watermark, eventTypes).beginExecute( - null); - } - - /** - * Ends an asynchronous request to subscribe to pull notification in the - * authenticated user's mailbox. - * - * @param asyncResult An IAsyncResult that references the asynchronous request. - * @return A PullSubscription representing the new subscription. - * @throws Exception - */ - public PullSubscription endSubscribeToPullNotifications( - IAsyncResult asyncResult) throws Exception { - SubscribeToPullNotificationsRequest request = AsyncRequestResult - .extractServiceRequest(this, asyncResult); - - return request.endExecute(asyncResult).getResponseAtIndex(0) - .getSubscription(); - } - - /** - * Builds a request to subscribe to pull notification in the - * authenticated user's mailbox. - * - * @param folderIds The Ids of the folder to subscribe to. - * @param timeout The timeout, in minutes, after which the subscription expires. - * Timeout must be between 1 and 1440 - * @param watermark An optional watermark representing a previously opened - * subscription - * @param eventTypes The event types to subscribe to - * @return A request to subscribe to pull notification in the authenticated - * user's mailbox - * @throws Exception the exception - */ - private SubscribeToPullNotificationsRequest buildSubscribeToPullNotificationsRequest( - Iterable folderIds, int timeout, String watermark, - EventType... eventTypes) throws Exception { - if (timeout < 1 || timeout > 1440) { - throw new IllegalArgumentException("timeout", new Throwable( - "Timeout must be a value between 1 and 1440.")); - } - - EwsUtilities.validateParamCollection(eventTypes, "eventTypes"); - - SubscribeToPullNotificationsRequest request = new SubscribeToPullNotificationsRequest( - this); - - if (folderIds != null) { - request.getFolderIds().addRangeFolderId(folderIds); - } - - request.setTimeOut(timeout); - - for (EventType event : eventTypes) { - request.getEventTypes().add(event); - } - - request.setWatermark(watermark); - - return request; - } - - /** - * Unsubscribes from a pull subscription. Calling this method results in a - * call to EWS. - * - * @param subscriptionId the subscription id - * @throws Exception the exception - */ - public void unsubscribe(String subscriptionId) throws Exception { - - this.buildUnsubscribeRequest(subscriptionId).execute(); - } - - /** - * Begins an asynchronous request to unsubscribe from a subscription. - * Calling this method results in a call to EWS. - * - * @param callback The AsyncCallback delegate. - * @param state An object that contains state information for this request. - * @param subscriptionId The Id of the pull subscription to unsubscribe from. - * @return An IAsyncResult that references the asynchronous request. - * @throws Exception - */ - public IAsyncResult beginUnsubscribe(AsyncCallback callback, Object state, String subscriptionId) - throws Exception { - return this.buildUnsubscribeRequest(subscriptionId).beginExecute(callback); - } - - /** - * Ends an asynchronous request to unsubscribe from a subscription. - * - * @param asyncResult An IAsyncResult that references the asynchronous request. - * @throws Exception - */ - public void endUnsubscribe(IAsyncResult asyncResult) throws Exception { - UnsubscribeRequest request = AsyncRequestResult.extractServiceRequest(this, asyncResult); - - request.endExecute(asyncResult); - } - - /** - * Buids a request to unsubscribe from a subscription. - * - * @param subscriptionId The id of the subscription for which to get the events - * @return A request to unsubscripbe from a subscription - * @throws Exception - */ - private UnsubscribeRequest buildUnsubscribeRequest(String subscriptionId) - throws Exception { - EwsUtilities.validateParam(subscriptionId, "subscriptionId"); - - UnsubscribeRequest request = new UnsubscribeRequest(this); - - request.setSubscriptionId(subscriptionId); - - return request; - } - - /** - * Retrieves the latests events associated with a pull subscription. - * Calling this method results in a call to EWS. - * - * @param subscriptionId the subscription id - * @param waterMark the water mark - * @return A GetEventsResults containing a list of events associated with - * the subscription. - * @throws Exception the exception - */ - public GetEventsResults getEvents(String subscriptionId, String waterMark) - throws Exception { - - return this.buildGetEventsRequest(subscriptionId, waterMark).execute() - .getResponseAtIndex(0).getResults(); - } - - /** - * Begins an asynchronous request to retrieve the latest events associated - * with a pull subscription. Calling this method results in a call to EWS. - * - * @param callback The AsyncCallback delegate. - * @param state An object that contains state information for this request. - * @param subscriptionId The id of the pull subscription for which to get the events - * @param watermark The watermark representing the point in time where to start - * receiving events - * @return An IAsynResult that references the asynchronous request - * @throws Exception - */ - public IAsyncResult beginGetEvents(AsyncCallback callback, Object state, String subscriptionId, - String watermark) throws Exception { - return this.buildGetEventsRequest(subscriptionId, watermark) - .beginExecute(callback); - } - - /** - * Ends an asynchronous request to retrieve the latest events associated - * with a pull subscription. - * - * @param asyncResult An IAsyncResult that references the asynchronous request. - * @return A GetEventsResults containing a list of events associated with - * the subscription. - * @throws Exception - */ - public GetEventsResults endGetEvents(IAsyncResult asyncResult) throws Exception { - GetEventsRequest request = AsyncRequestResult.extractServiceRequest(this, asyncResult); - - return request.endExecute(asyncResult).getResponseAtIndex(0).getResults(); - } - - /** - * Builds a request to retrieve the letest events associated with a pull - * subscription - * - * @param subscriptionId The Id of the pull subscription for which to get the events - * @param watermark The watermark representing the point in time where to start - * receiving events - * @return An request to retrieve the latest events associated with a pull - * subscription - * @throws Exception - */ - private GetEventsRequest buildGetEventsRequest(String subscriptionId, - String watermark) throws Exception { - EwsUtilities.validateParam(subscriptionId, "subscriptionId"); - EwsUtilities.validateParam(watermark, "watermark"); - - GetEventsRequest request = new GetEventsRequest(this); - - request.setSubscriptionId(subscriptionId); - request.setWatermark(watermark); - - return request; - } - - /** - * Subscribes to push notification. Calling this method results in a call - * to EWS. - * - * @param folderIds the folder ids - * @param url the url - * @param frequency the frequency - * @param watermark the watermark - * @param eventTypes the event types - * @return A PushSubscription representing the new subscription. - * @throws Exception the exception - */ - public PushSubscription subscribeToPushNotifications( - Iterable folderIds, URI url, int frequency, - String watermark, EventType... eventTypes) throws Exception { - EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds"); - - return this.buildSubscribeToPushNotificationsRequest(folderIds, url, - frequency, watermark, eventTypes).execute().getResponseAtIndex(0).getSubscription(); - } - - /** - * Begins an asynchronous request to subscribe to push notification. - * Calling this method results in a call to EWS. - * - * @param callback The asynccallback delegate - * @param state An object that contains state information for this request - * @param folderIds The ids of the folder to subscribe - * @param url the url of web service endpoint the exchange server should - * @param frequency the frequency,in minutes at which the exchange server should - * contact the web Service endpoint. Frequency must be between 1 - * and 1440. - * @param watermark An optional watermark representing a previously opened - * subscription - * @param eventTypes The event types to subscribe to. - * @return An IAsyncResult that references the asynchronous request. - * @throws Exception - */ - public IAsyncResult beginSubscribeToPushNotifications( - AsyncCallback callback, Object state, Iterable folderIds, - URI url, int frequency, String watermark, EventType... eventTypes) - throws Exception { - EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds"); - - return this.buildSubscribeToPushNotificationsRequest(folderIds, url, frequency, watermark, - eventTypes).beginExecute(callback); - } - - /** - * Subscribes to push notification on all folder in the authenticated - * user's mailbox. Calling this method results in a call to EWS. - * - * @param url the url - * @param frequency the frequency - * @param watermark the watermark - * @param eventTypes the event types - * @return A PushSubscription representing the new subscription. - * @throws Exception the exception - */ - public PushSubscription subscribeToPushNotificationsOnAllFolders(URI url, - int frequency, String watermark, EventType... eventTypes) - throws Exception { - EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010, - "SubscribeToPushNotificationsOnAllFolders"); - - return this.buildSubscribeToPushNotificationsRequest(null, url, - frequency, watermark, eventTypes).execute().getResponseAtIndex(0).getSubscription(); - } - - /** - * Begins an asynchronous request to subscribe to push notification on all - * folder in the authenticated user's mailbox. Calling this method results - * in a call to EWS. - * - * @param callback The asynccallback delegate - * @param state An object that contains state inforamtion for this request - * @param url the url - * @param frequency the frequency,in minutes at which the exchange server should - * contact the web Service endpoint. Frequency must be between 1 - * and 1440. - * @param watermark An optional watermark representing a previously opened - * subscription - * @param eventTypes The event types to subscribe to. - * @return An IAsyncResult that references the asynchronous request. - * @throws Exception - */ - public IAsyncResult beginSubscribeToPushNotificationsOnAllFolders( - AsyncCallback callback, Object state, URI url, int frequency, - String watermark, EventType... eventTypes) throws Exception { - EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010, - "BeginSubscribeToPushNotificationsOnAllFolders"); - - return this.buildSubscribeToPushNotificationsRequest(null, url, frequency, watermark, - eventTypes).beginExecute(callback); - } - - - /** - * Ends an asynchronous request to subscribe to push notification in the - * authenticated user's mailbox. - * - * @param asyncResult An IAsyncResult that references the asynchronous request. - * @return A PushSubscription representing the new subscription - * @throws Exception - */ - public PushSubscription endSubscribeToPushNotifications( - IAsyncResult asyncResult) throws Exception { - SubscribeToPushNotificationsRequest request = AsyncRequestResult - .extractServiceRequest(this, asyncResult); - - return request.endExecute(asyncResult).getResponseAtIndex(0) - .getSubscription(); - } - - /** - * Builds an request to request to subscribe to push notification in the - * authenticated user's mailbox. - * - * @param folderIds the folder ids - * @param url the url - * @param frequency the frequency - * @param watermark the watermark - * @param eventTypes the event types - * @return A request to request to subscribe to push notification in the - * authenticated user's mailbox. - * @throws Exception the exception - */ - private SubscribeToPushNotificationsRequest buildSubscribeToPushNotificationsRequest( - Iterable folderIds, URI url, int frequency, - String watermark, EventType[] eventTypes) throws Exception { - EwsUtilities.validateParam(url, "url"); - if (frequency < 1 || frequency > 1440) { - throw new ArgumentOutOfRangeException("frequency", "The frequency must be a value between 1 and 1440."); - } - - EwsUtilities.validateParamCollection(eventTypes, "eventTypes"); - SubscribeToPushNotificationsRequest request = new SubscribeToPushNotificationsRequest(this); - - if (folderIds != null) { - request.getFolderIds().addRangeFolderId(folderIds); - } - - request.setUrl(url); - request.setFrequency(frequency); - - for (EventType event : eventTypes) { - request.getEventTypes().add(event); - } - - request.setWatermark(watermark); - - return request; - } - - /** - * Subscribes to streaming notification. Calling this method results in a - * call to EWS. - * - * @param folderIds The Ids of the folder to subscribe to. - * @param eventTypes The event types to subscribe to. - * @return A StreamingSubscription representing the new subscription - * @throws Exception - */ - public StreamingSubscription subscribeToStreamingNotifications( - Iterable folderIds, EventType... eventTypes) - throws Exception { - EwsUtilities.validateMethodVersion(this, - ExchangeVersion.Exchange2010_SP1, - "SubscribeToStreamingNotifications"); - - EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds"); - - return this.buildSubscribeToStreamingNotificationsRequest(folderIds, - eventTypes).execute().getResponseAtIndex(0).getSubscription(); - } - - /** - * Subscribes to streaming notification on all folder in the authenticated - * user's mailbox. Calling this method results in a call to EWS. - * - * @param eventTypes The event types to subscribe to. - * @return A StreamingSubscription representing the new subscription. - * @throws Exception - */ - public StreamingSubscription subscribeToStreamingNotificationsOnAllFolders( - EventType... eventTypes) throws Exception { - EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010_SP1, - "SubscribeToStreamingNotificationsOnAllFolders"); - - return this.buildSubscribeToStreamingNotificationsRequest(null, - eventTypes).execute().getResponseAtIndex(0).getSubscription(); - } - - /** - * Begins an asynchronous request to subscribe to streaming notification. - * Calling this method results in a call to EWS. - * - * @param callback The AsyncCallback delegate - * @param state An object that contains state information for this request. - * @param folderIds The Ids of the folder to subscribe to. - * @param eventTypes The event types to subscribe to. - * @return An IAsyncResult that references the asynchronous request - * @throws Exception - */ - public IAsyncResult beginSubscribeToStreamingNotifications(AsyncCallback callback, Object state, - Iterable folderIds, - EventType... eventTypes) throws Exception { - EwsUtilities.validateMethodVersion(this, - ExchangeVersion.Exchange2010_SP1, - "BeginSubscribeToStreamingNotifications"); - - EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds"); - - return this.buildSubscribeToStreamingNotificationsRequest(folderIds, - eventTypes).beginExecute(callback); - } - - /** - * Begins an asynchronous request to subscribe to streaming notification on - * all folder in the authenticated user's mailbox. Calling this method - * results in a call to EWS. - * - * @param callback The AsyncCallback delegate - * @param state An object that contains state information for this request. - * @return An IAsyncResult that references the asynchronous request. - * @throws Exception - */ - public IAsyncResult beginSubscribeToStreamingNotificationsOnAllFolders(AsyncCallback callback, Object state, - EventType... eventTypes) throws Exception { - EwsUtilities.validateMethodVersion(this, - ExchangeVersion.Exchange2010_SP1, - "BeginSubscribeToStreamingNotificationsOnAllFolders"); - - return this.buildSubscribeToStreamingNotificationsRequest(null, - eventTypes).beginExecute(callback); - } - - /** - * Ends an asynchronous request to subscribe to push notification in the - * authenticated user's mailbox. - * - * @param asyncResult An IAsyncResult that references the asynchronous request. - * @return A streamingSubscription representing the new subscription - * @throws Exception - * @throws IndexOutOfBoundsException - */ - public StreamingSubscription endSubscribeToStreamingNotifications(IAsyncResult asyncResult) - throws IndexOutOfBoundsException, Exception { - EwsUtilities.validateMethodVersion( - this, - ExchangeVersion.Exchange2010_SP1, - "EndSubscribeToStreamingNotifications"); - - SubscribeToStreamingNotificationsRequest request = - AsyncRequestResult.extractServiceRequest(this, asyncResult); - // SubscribeToStreamingNotificationsRequest request = AsyncRequestResult.extractServiceRequest(this, asyncResult); - return request.endExecute(asyncResult).getResponseAtIndex(0).getSubscription(); - } - - /** - * Builds request to subscribe to streaming notification in the - * authenticated user's mailbox. - * - * @param folderIds The Ids of the folder to subscribe to. - * @param eventTypes The event types to subscribe to. - * @return A request to subscribe to streaming notification in the - * authenticated user's mailbox - * @throws Exception - */ - private SubscribeToStreamingNotificationsRequest buildSubscribeToStreamingNotificationsRequest( - Iterable folderIds, EventType[] eventTypes) throws Exception { - EwsUtilities.validateParamCollection(eventTypes, "eventTypes"); - - SubscribeToStreamingNotificationsRequest request = new SubscribeToStreamingNotificationsRequest( - this); - - if (folderIds != null) { - request.getFolderIds().addRangeFolderId(folderIds); - } - - for (EventType event : eventTypes) { - request.getEventTypes().add(event); - } - - return request; - } - - - - /** - * Synchronizes the item of a specific folder. Calling this method - * results in a call to EWS. - * - * @param syncFolderId The Id of the folder containing the item to synchronize with. - * @param propertySet The set of property to retrieve for synchronized item. - * @param ignoredItemIds The optional list of item Ids that should be ignored. - * @param maxChangesReturned The maximum number of changes that should be returned. - * @param syncScope The sync scope identifying item to include in the - * ChangeCollection. - * @param syncState The optional sync state representing the point in time when to - * start the synchronization. - * @return A ChangeCollection containing a list of changes that occurred in - * the specified folder. - * @throws Exception the exception - */ - public ChangeCollection syncFolderItems(FolderId syncFolderId, - PropertySet propertySet, Iterable ignoredItemIds, - int maxChangesReturned, SyncFolderItemsScope syncScope, - String syncState) throws Exception { - return this.buildSyncFolderItemsRequest(syncFolderId, propertySet, - ignoredItemIds, maxChangesReturned, syncScope, syncState) - .execute().getResponseAtIndex(0).getChanges(); - } - - /** - * Begins an asynchronous request to synchronize the item of a specific - * folder. Calling this method results in a call to EWS. - * - * @param callback The AsyncCallback delegate - * @param state An object that contains state information for this request - * @param syncFolderId The Id of the folder containing the item to synchronize with - * @param propertySet The set of property to retrieve for synchronized item. - * @param ignoredItemIds The optional list of item Ids that should be ignored. - * @param maxChangesReturned The maximum number of changes that should be returned. - * @param syncScope The sync scope identifying item to include in the - * ChangeCollection - * @param syncState The optional sync state representing the point in time when to - * start the synchronization - * @return An IAsyncResult that references the asynchronous request. - * @throws Exception - */ - public IAsyncResult beginSyncFolderItems(AsyncCallback callback, Object state, FolderId syncFolderId, - PropertySet propertySet, - Iterable ignoredItemIds, int maxChangesReturned, - SyncFolderItemsScope syncScope, String syncState) throws Exception { - return this.buildSyncFolderItemsRequest(syncFolderId, propertySet, - ignoredItemIds, maxChangesReturned, syncScope, syncState) - .beginExecute(callback); - } - - /** - * Ends an asynchronous request to synchronize the item of a specific - * folder. - * - * @param asyncResult An IAsyncResult that references the asynchronous request. - * @return A ChangeCollection containing a list of changes that occurred in - * the specified folder. - * @throws Exception - */ - public ChangeCollection endSyncFolderItems(IAsyncResult asyncResult) throws Exception { - SyncFolderItemsRequest request = AsyncRequestResult.extractServiceRequest(this, asyncResult); - - return request.endExecute(asyncResult).getResponseAtIndex(0).getChanges(); - } - - /** - * Builds a request to synchronize the item of a specific folder. - * - * @param syncFolderId The Id of the folder containing the item to synchronize with - * @param propertySet The set of property to retrieve for synchronized item. - * @param ignoredItemIds The optional list of item Ids that should be ignored - * @param maxChangesReturned The maximum number of changes that should be returned. - * @param syncScope The sync scope identifying item to include in the - * ChangeCollection. - * @param syncState The optional sync state representing the point in time when to - * start the synchronization. - * @return A request to synchronize the item of a specific folder. - * @throws Exception - */ - private SyncFolderItemsRequest buildSyncFolderItemsRequest( - FolderId syncFolderId, PropertySet propertySet, - Iterable ignoredItemIds, int maxChangesReturned, - SyncFolderItemsScope syncScope, String syncState) throws Exception { - EwsUtilities.validateParam(syncFolderId, "syncFolderId"); - EwsUtilities.validateParam(propertySet, "propertySet"); - - SyncFolderItemsRequest request = new SyncFolderItemsRequest(this); - - request.setSyncFolderId(syncFolderId); - request.setPropertySet(propertySet); - if (ignoredItemIds != null) { - request.getIgnoredItemIds().addRange(ignoredItemIds); - } - request.setMaxChangesReturned(maxChangesReturned); - request.setSyncScope(syncScope); - request.setSyncState(syncState); - - return request; - } - - /** - * Synchronizes the sub-folder of a specific folder. Calling this method - * results in a call to EWS. - * - * @param syncFolderId the sync folder id - * @param propertySet the property set - * @param syncState the sync state - * @return A ChangeCollection containing a list of changes that occurred in - * the specified folder. - * @throws Exception the exception - */ - public ChangeCollection syncFolderHierarchy( - FolderId syncFolderId, PropertySet propertySet, String syncState) - throws Exception { - return this.buildSyncFolderHierarchyRequest(syncFolderId, propertySet, - syncState).execute().getResponseAtIndex(0).getChanges(); - } - - /** - * Begins an asynchronous request to synchronize the sub-folder of a - * specific folder. Calling this method results in a call to EWS. - * - * @param callback The AsyncCallback delegate - * @param state An object that contains state information for this request. - * @param syncFolderId The Id of the folder containing the item to synchronize with. - * A null value indicates the root folder of the mailbox. - * @param propertySet The set of property to retrieve for synchronized item. - * @param syncState The optional sync state representing the point in time when to - * start the synchronization. - * @return An IAsyncResult that references the asynchronous request - * @throws Exception - */ - public IAsyncResult beginSyncFolderHierarchy(AsyncCallback callback, Object state, FolderId syncFolderId, - PropertySet propertySet, - String syncState) throws Exception { - return this.buildSyncFolderHierarchyRequest(syncFolderId, propertySet, - syncState).beginExecute(callback); - } - - /** - * Synchronizes the entire folder hierarchy of the mailbox this Service is - * connected to. Calling this method results in a call to EWS. - * - * @param propertySet The set of property to retrieve for synchronized item. - * @param syncState The optional sync state representing the point in time when to - * start the synchronization. - * @return A ChangeCollection containing a list of changes that occurred in - * the specified folder. - * @throws Exception - */ - public ChangeCollection syncFolderHierarchy( - PropertySet propertySet, String syncState) - throws Exception { - return this.syncFolderHierarchy(null, propertySet, syncState); - } - - /* - * Begins an asynchronous request to synchronize the entire folder hierarchy - * of the mailbox this Service is connected to. Calling this method results - * in a call to EWS - * - * @param callback - * The AsyncCallback delegate - * @param state - * An object that contains state information for this request. - * @param propertySet - * The set of property to retrieve for synchronized item. - * @param syncState - * The optional sync state representing the point in time when to - * start the synchronization. - * @return An IAsyncResult that references the asynchronous request - * @throws Exception - public IAsyncResult beginSyncFolderHierarchy(FolderId syncFolderId, PropertySet propertySet, String syncState) throws Exception { - return this.beginSyncFolderHierarchy(null,null, null, - propertySet, syncState); - }*/ - - /** - * Ends an asynchronous request to synchronize the specified folder - * hierarchy of the mailbox this Service is connected to. - * - * @param asyncResult An IAsyncResult that references the asynchronous request. - * @return A ChangeCollection containing a list of changes that occurred in - * the specified folder. - * @throws Exception - */ - public ChangeCollection endSyncFolderHierarchy(IAsyncResult asyncResult) throws Exception { - SyncFolderHierarchyRequest request = AsyncRequestResult.extractServiceRequest(this, asyncResult); - - return request.endExecute(asyncResult).getResponseAtIndex(0).getChanges(); - } - - /** - * Builds a request to synchronize the specified folder hierarchy of the - * mailbox this Service is connected to. - * - * @param syncFolderId The Id of the folder containing the item to synchronize with. - * A null value indicates the root folder of the mailbox. - * @param propertySet The set of property to retrieve for synchronized item. - * @param syncState The optional sync state representing the point in time when to - * start the synchronization. - * @return A request to synchronize the specified folder hierarchy of the - * mailbox this Service is connected to - * @throws Exception - */ - private SyncFolderHierarchyRequest buildSyncFolderHierarchyRequest( - FolderId syncFolderId, PropertySet propertySet, String syncState) - throws Exception { - EwsUtilities.validateParamAllowNull(syncFolderId, "syncFolderId"); // Null - // syncFolderId - // is - // allowed - EwsUtilities.validateParam(propertySet, "propertySet"); - - SyncFolderHierarchyRequest request = new SyncFolderHierarchyRequest(this); - - request.setPropertySet(propertySet); - request.setSyncFolderId(syncFolderId); - request.setSyncState(syncState); - - return request; - } - - // Availability operations - - /** - * Gets Out of Office (OOF) settings for a specific user. Calling this - * method results in a call to EWS. - * - * @param smtpAddress the smtp address - * @return An OofSettings instance containing OOF information for the - * specified user. - * @throws Exception the exception - */ - public OofSettings getUserOofSettings(String smtpAddress) throws Exception { - EwsUtilities.validateParam(smtpAddress, "smtpAddress"); - GetUserOofSettingsRequest request = new GetUserOofSettingsRequest(this); - request.setSmtpAddress(smtpAddress); - - return request.execute().getOofSettings(); - } - - /** - * Sets Out of Office (OOF) settings for a specific user. Calling this - * method results in a call to EWS. - * - * @param smtpAddress the smtp address - * @param oofSettings the oof settings - * @throws Exception the exception - */ - public void setUserOofSettings(String smtpAddress, OofSettings oofSettings) - throws Exception { - EwsUtilities.validateParam(smtpAddress, "smtpAddress"); - EwsUtilities.validateParam(oofSettings, "oofSettings"); - - SetUserOofSettingsRequest request = new SetUserOofSettingsRequest(this); - - request.setSmtpAddress(smtpAddress); - request.setOofSettings(oofSettings); - - request.execute(); - } - - /** - * Gets detailed information about the availability of a set of users, - * rooms, and resources within a specified time window. - * - * @param attendees the attendees - * @param timeWindow the time window - * @param requestedData the requested data - * @param options the options - * @return The availability information for each user appears in a unique - * FreeBusyResponse object. The order of users in the request - * determines the order of availability data for each user in the - * response. - * @throws Exception the exception - */ - public GetUserAvailabilityResults getUserAvailability( - Iterable attendees, TimeWindow timeWindow, - AvailabilityData requestedData, AvailabilityOptions options) - throws Exception { - EwsUtilities.validateParamCollection(attendees.iterator(), "attendees"); - EwsUtilities.validateParam(timeWindow, "timeWindow"); - EwsUtilities.validateParam(options, "options"); - - GetUserAvailabilityRequest request = new GetUserAvailabilityRequest(this); - - request.setAttendees(attendees); - request.setTimeWindow(timeWindow); - request.setRequestedData(requestedData); - request.setOptions(options); - - return request.execute(); - } - - /** - * Gets detailed information about the availability of a set of users, - * rooms, and resources within a specified time window. - * - * @param attendees the attendees - * @param timeWindow the time window - * @param requestedData the requested data - * @return The availability information for each user appears in a unique - * FreeBusyResponse object. The order of users in the request - * determines the order of availability data for each user in the - * response. - * @throws Exception the exception - */ - public GetUserAvailabilityResults getUserAvailability( - Iterable attendees, TimeWindow timeWindow, - AvailabilityData requestedData) throws Exception { - return this.getUserAvailability(attendees, timeWindow, requestedData, - new AvailabilityOptions()); - } - - /** - * Retrieves a collection of all room lists in the organization. - * - * @return An EmailAddressCollection containing all the room lists in the - * organization - * @throws Exception the exception - */ - public EmailAddressCollection getRoomLists() throws Exception { - GetRoomListsRequest request = new GetRoomListsRequest(this); - return request.execute().getRoomLists(); - } - - /** - * Retrieves a collection of all room lists in the specified room list in - * the organization. - * - * @param emailAddress the email address - * @return A collection of EmailAddress objects representing all the rooms - * within the specifed room list. - * @throws Exception the exception - */ - public Collection getRooms(EmailAddress emailAddress) - throws Exception { - EwsUtilities.validateParam(emailAddress, "emailAddress"); - GetRoomsRequest request = new GetRoomsRequest(this); - request.setRoomList(emailAddress); - - return request.execute().getRooms(); - } - - // region Conversation - - /** - * Retrieves a collection of all Conversations in the specified Folder. - * - * @param view The view controlling the number of conversations returned. - * @param filter The search filter. Only search filter class supported - * SearchFilter.IsEqualTo - * @param folderId The Id of the folder in which to search for conversations. - * @throws Exception - */ - private Collection findConversation( - ConversationIndexedItemView view, SearchFilter.IsEqualTo filter, - FolderId folderId) throws Exception { - EwsUtilities.validateParam(view, "view"); - EwsUtilities.validateParamAllowNull(filter, "filter"); - EwsUtilities.validateParam(folderId, "folderId"); - EwsUtilities.validateMethodVersion(this, - ExchangeVersion.Exchange2010_SP1, "FindConversation"); - - FindConversationRequest request = new FindConversationRequest(this); - request.setIndexedItemView(view); - request.setConversationViewFilter(filter); - request.setFolderId(new FolderIdWrapper(folderId)); - - return request.execute().getConversations(); - } - - /** - * Retrieves a collection of all Conversations in the specified Folder. - * - * @param view The view controlling the number of conversations returned. - * @param folderId The Id of the folder in which to search for conversations. - * @throws Exception - */ - public Collection findConversation( - ConversationIndexedItemView view, FolderId folderId) - throws Exception { - return this.findConversation(view, null, folderId); - } - - /** - * Applies ConversationAction on the specified conversation. - * - * @param actionType ConversationAction - * @param conversationIds The conversation ids. - * @param processRightAway True to process at once . This is blocking and false to let - * the Assitant process it in the back ground - * @param categories Catgories that need to be stamped can be null or empty - * @param enableAlwaysDelete True moves every current and future messages in the - * conversation to deleted item folder. False stops the alwasy - * delete action. This is applicable only if the action is - * AlwaysDelete - * @param destinationFolderId Applicable if the action is AlwaysMove. This moves every - * current message and future message in the conversation to the - * specified folder. Can be null if tis is then it stops the - * always move action - * @param errorHandlingMode The error handling mode. - * @throws Exception - */ - private ServiceResponseCollection applyConversationAction( - ConversationActionType actionType, - Iterable conversationIds, boolean processRightAway, - StringList categories, boolean enableAlwaysDelete, - FolderId destinationFolderId, ServiceErrorHandling errorHandlingMode) - throws Exception { - EwsUtilities.ewsAssert(actionType == ConversationActionType.AlwaysCategorize - || actionType == ConversationActionType.AlwaysMove - || actionType == ConversationActionType.AlwaysDelete, "ApplyConversationAction", - "Invalic actionType"); - - EwsUtilities.validateParam(conversationIds, "conversationId"); - EwsUtilities.validateMethodVersion(this, - ExchangeVersion.Exchange2010_SP1, "ApplyConversationAction"); - - ApplyConversationActionRequest request = new ApplyConversationActionRequest( - this, errorHandlingMode); - ConversationAction action = new ConversationAction(); - - for (ConversationId conversationId : conversationIds) { - action.setAction(actionType); - action.setConversationId(conversationId); - action.setProcessRightAway(processRightAway); - action.setCategories(categories); - action.setEnableAlwaysDelete(enableAlwaysDelete); - action - .setDestinationFolderId(destinationFolderId != null ? new FolderIdWrapper( - destinationFolderId) - : null); - request.getConversationActions().add(action); - } - - return request.execute(); - } - - /** - * Applies one time conversation action on item in specified folder inside - * the conversation. - * - * @param actionType The action - * @param idTimePairs The id time pairs. - * @param contextFolderId The context folder id. - * @param destinationFolderId The destination folder id. - * @param deleteType Type of the delete. - * @param isRead The is read. - * @param errorHandlingMode The error handling mode. - * @throws Exception - */ - private ServiceResponseCollection applyConversationOneTimeAction( - ConversationActionType actionType, - Iterable> idTimePairs, - FolderId contextFolderId, FolderId destinationFolderId, - DeleteMode deleteType, Boolean isRead, - ServiceErrorHandling errorHandlingMode) throws Exception { - EwsUtilities.ewsAssert( - actionType == ConversationActionType.Move || actionType == ConversationActionType.Delete - || actionType == ConversationActionType.SetReadState || actionType == ConversationActionType.Copy, - "ApplyConversationOneTimeAction", "Invalid actionType"); - - EwsUtilities.validateParamCollection(idTimePairs.iterator(), - "idTimePairs"); - EwsUtilities.validateMethodVersion(this, - ExchangeVersion.Exchange2010_SP1, "ApplyConversationAction"); - - ApplyConversationActionRequest request = new ApplyConversationActionRequest( - this, errorHandlingMode); - - for (HashMap idTimePair : idTimePairs) { - ConversationAction action = new ConversationAction(); - - action.setAction(actionType); - action.setConversationId(idTimePair.keySet().iterator().next()); - action - .setContextFolderId(contextFolderId != null ? new FolderIdWrapper( - contextFolderId) - : null); - action - .setDestinationFolderId(destinationFolderId != null ? new FolderIdWrapper( - destinationFolderId) - : null); - action.setConversationLastSyncTime(idTimePair.values().iterator() - .next()); - action.setIsRead(isRead); - action.setDeleteType(deleteType); - - request.getConversationActions().add(action); - } - - return request.execute(); - } - - /** - * Sets up a conversation so that any item received within that conversation - * is always categorized. Calling this method results in a call to EWS. - * - * @param conversationId The id of the conversation. - * @param categories The categories that should be stamped on item in the - * conversation. - * @param processSynchronously Indicates whether the method should return only once enabling - * this rule and stamping existing item in the conversation is - * completely done. If processSynchronously is false, the method - * returns immediately. - * @throws Exception - */ - public ServiceResponseCollection enableAlwaysCategorizeItemsInConversations( - Iterable conversationId, - Iterable categories, boolean processSynchronously) - throws Exception { - EwsUtilities.validateParamCollection(categories.iterator(), - "categories"); - return this.applyConversationAction( - ConversationActionType.AlwaysCategorize, conversationId, - processSynchronously, new StringList(categories), false, null, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Sets up a conversation so that any item received within that conversation - * is no longer categorized. Calling this method results in a call to EWS. - * - * @param conversationId The id of the conversation. - * @param processSynchronously Indicates whether the method should return only once enabling - * this rule and stamping existing item in the conversation is - * completely done. If processSynchronously is false, the method - * returns immediately. - * @throws Exception - */ - public ServiceResponseCollection disableAlwaysCategorizeItemsInConversations( - Iterable conversationId, - boolean processSynchronously) throws Exception { - return this.applyConversationAction( - ConversationActionType.AlwaysCategorize, conversationId, - processSynchronously, null, false, null, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Sets up a conversation so that any item received within that conversation - * is always moved to Deleted Items folder. Calling this method results in a - * call to EWS. - * - * @param conversationId The id of the conversation. - * @param processSynchronously Indicates whether the method should return only once enabling - * this rule and stamping existing item in the conversation is - * completely done. If processSynchronously is false, the method - * returns immediately. - * @throws Exception - */ - public ServiceResponseCollection enableAlwaysDeleteItemsInConversations( - Iterable conversationId, - boolean processSynchronously) throws Exception { - return this.applyConversationAction( - ConversationActionType.AlwaysDelete, conversationId, - processSynchronously, null, true, null, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Sets up a conversation so that any item received within that conversation - * is no longer moved to Deleted Items folder. Calling this method results - * in a call to EWS. - * - * @param conversationId The id of the conversation. - * @param processSynchronously Indicates whether the method should return only once enabling - * this rule and stamping existing item in the conversation is - * completely done. If processSynchronously is false, the method - * returns immediately. - * @throws Exception - */ - public ServiceResponseCollection disableAlwaysDeleteItemsInConversations( - Iterable conversationId, - boolean processSynchronously) throws Exception { - return this.applyConversationAction( - ConversationActionType.AlwaysDelete, conversationId, - processSynchronously, null, false, null, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Sets up a conversation so that any item received within that conversation - * is always moved to a specific folder. Calling this method results in a - * call to EWS. - * - * @param conversationId The Id of the folder to which conversation item should be - * moved. - * @param destinationFolderId The Id of the destination folder. - * @param processSynchronously Indicates whether the method should return only once enabling - * this rule and stamping existing item in the conversation is - * completely done. If processSynchronously is false, the method - * returns immediately. - * @throws Exception - */ - public ServiceResponseCollection enableAlwaysMoveItemsInConversations( - Iterable conversationId, - FolderId destinationFolderId, boolean processSynchronously) - throws Exception { - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - return this.applyConversationAction(ConversationActionType.AlwaysMove, - conversationId, processSynchronously, null, false, - destinationFolderId, ServiceErrorHandling.ReturnErrors); - } - - /** - * Sets up a conversation so that any item received within that conversation - * is no longer moved to a specific folder. Calling this method results in a - * call to EWS. - * - * @param conversationIds The conversation ids. - * @param processSynchronously Indicates whether the method should return only once disabling - * this rule is completely done. If processSynchronously is - * false, the method returns immediately. - * @throws Exception - */ - public ServiceResponseCollection disableAlwaysMoveItemsInConversations( - Iterable conversationIds, - boolean processSynchronously) throws Exception { - return this.applyConversationAction(ConversationActionType.AlwaysMove, - conversationIds, processSynchronously, null, false, null, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Moves the item in the specified conversation to the specified - * destination folder. Calling this method results in a call to EWS. - * - * @param idLastSyncTimePairs The pairs of Id of conversation whose item should be moved - * and the dateTime conversation was last synced (Items received - * after that dateTime will not be moved). - * @param contextFolderId The Id of the folder that contains the conversation. - * @param destinationFolderId The Id of the destination folder. - * @throws Exception - */ - public ServiceResponseCollection moveItemsInConversations( - Iterable> idLastSyncTimePairs, - FolderId contextFolderId, FolderId destinationFolderId) - throws Exception { - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - return this.applyConversationOneTimeAction(ConversationActionType.Move, - idLastSyncTimePairs, contextFolderId, destinationFolderId, - null, null, ServiceErrorHandling.ReturnErrors); - } - - /** - * Copies the item in the specified conversation to the specified - * destination folder. Calling this method results in a call to EWS. - * - * @param idLastSyncTimePairs The pairs of Id of conversation whose item should be copied - * and the dateTime conversation was last synced (Items received - * after that dateTime will not be copied). - * @param contextFolderId The context folder id. - * @param destinationFolderId The destination folder id. - * @throws Exception - */ - public ServiceResponseCollection copyItemsInConversations( - Iterable> idLastSyncTimePairs, - FolderId contextFolderId, FolderId destinationFolderId) - throws Exception { - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - return this.applyConversationOneTimeAction(ConversationActionType.Copy, - idLastSyncTimePairs, contextFolderId, destinationFolderId, - null, null, ServiceErrorHandling.ReturnErrors); - } - - /** - * Deletes the item in the specified conversation. Calling this method - * results in a call to EWS. - * - * @param idLastSyncTimePairs The pairs of Id of conversation whose item should be deleted - * and the date and time conversation was last synced (Items - * received after that date will not be deleted). conversation - * was last synced (Items received after that dateTime will not - * be copied). - * @param contextFolderId The Id of the folder that contains the conversation. - * @param deleteMode The deletion mode - * @throws Exception - */ - public ServiceResponseCollection deleteItemsInConversations( - Iterable> idLastSyncTimePairs, - FolderId contextFolderId, DeleteMode deleteMode) throws Exception { - return this.applyConversationOneTimeAction( - ConversationActionType.Delete, idLastSyncTimePairs, - contextFolderId, null, deleteMode, null, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Sets the read state for item in conversation. Calling this mehtod would - * result in call to EWS. - * - * @param idLastSyncTimePairs The pairs of Id of conversation whose item should read state - * set and the date and time conversation was last synced (Items - * received after that date will not have their read state set). - * was last synced (Items received after that date will not be - * deleted). conversation was last synced (Items received after - * that dateTime will not be copied). - * @param contextFolderId The Id of the folder that contains the conversation. - * @param isRead if set to true, conversation item are marked as read; - * otherwise they are marked as unread. - * @throws Exception - */ - public ServiceResponseCollection setReadStateForItemsInConversations( - Iterable> idLastSyncTimePairs, - FolderId contextFolderId, boolean isRead) throws Exception { - return this.applyConversationOneTimeAction( - ConversationActionType.SetReadState, idLastSyncTimePairs, - contextFolderId, null, null, isRead, - ServiceErrorHandling.ReturnErrors); - } - - // Id conversion operations - - /** - * Converts multiple Ids from one format to another in a single call to - * EWS. - * - * @param ids the ids - * @param destinationFormat the destination format - * @param errorHandling the error handling - * @return A ServiceResponseCollection providing conversion results for each - * specified Ids. - * @throws Exception the exception - */ - private ServiceResponseCollection internalConvertIds( - Iterable ids, IdFormat destinationFormat, - ServiceErrorHandling errorHandling) throws Exception { - EwsUtilities.validateParamCollection(ids.iterator(), "ids"); - - ConvertIdRequest request = new ConvertIdRequest(this, errorHandling); - - request.getIds().addAll((Collection) ids); - request.setDestinationFormat(destinationFormat); - - return request.execute(); - } - - /** - * Converts multiple Ids from one format to another in a single call to - * EWS. - * - * @param ids the ids - * @param destinationFormat the destination format - * @return A ServiceResponseCollection providing conversion results for each - * specified Ids. - * @throws Exception the exception - */ - public ServiceResponseCollection convertIds( - Iterable ids, IdFormat destinationFormat) - throws Exception { - EwsUtilities.validateParamCollection(ids.iterator(), "ids"); - - return this.internalConvertIds(ids, destinationFormat, - ServiceErrorHandling.ReturnErrors); - } - - /** - * Converts Id from one format to another in a single call to EWS. - * - * @param id the id - * @param destinationFormat the destination format - * @return The converted Id. - * @throws Exception the exception - */ - public AlternateIdBase convertId(AlternateIdBase id, - IdFormat destinationFormat) throws Exception { - EwsUtilities.validateParam(id, "id"); - - List alternateIdBaseArray = new ArrayList(); - alternateIdBaseArray.add(id); - - ServiceResponseCollection responses = this - .internalConvertIds(alternateIdBaseArray, destinationFormat, - ServiceErrorHandling.ThrowOnError); - - return responses.getResponseAtIndex(0).getConvertedId(); - } - - /** - * Adds delegates to a specific mailbox. Calling this method results in a - * call to EWS. - * - * @param mailbox the mailbox - * @param meetingRequestsDeliveryScope the meeting request delivery scope - * @param delegateUsers the delegate users - * @return A collection of DelegateUserResponse objects providing the - * results of the operation. - * @throws Exception the exception - */ - public Collection addDelegates(Mailbox mailbox, - MeetingRequestsDeliveryScope meetingRequestsDeliveryScope, - DelegateUser... delegateUsers) throws Exception { - return addDelegates(mailbox, meetingRequestsDeliveryScope, - Arrays.asList(delegateUsers)); - } - - /** - * Adds delegates to a specific mailbox. Calling this method results in a - * call to EWS. - * - * @param mailbox the mailbox - * @param meetingRequestsDeliveryScope the meeting request delivery scope - * @param delegateUsers the delegate users - * @return A collection of DelegateUserResponse objects providing the - * results of the operation. - * @throws Exception the exception - */ - public Collection addDelegates(Mailbox mailbox, - MeetingRequestsDeliveryScope meetingRequestsDeliveryScope, - Iterable delegateUsers) throws Exception { - EwsUtilities.validateParam(mailbox, "mailbox"); - EwsUtilities.validateParamCollection(delegateUsers.iterator(), - "delegateUsers"); - - AddDelegateRequest request = new AddDelegateRequest(this); - request.setMailbox(mailbox); - - for (DelegateUser user : delegateUsers) { - request.getDelegateUsers().add(user); - } - - request.setMeetingRequestsDeliveryScope(meetingRequestsDeliveryScope); - - DelegateManagementResponse response = request.execute(); - return response.getDelegateUserResponses(); - } - - /** - * Updates delegates on a specific mailbox. Calling this method results in - * a call to EWS. - * - * @param mailbox the mailbox - * @param meetingRequestsDeliveryScope the meeting request delivery scope - * @param delegateUsers the delegate users - * @return A collection of DelegateUserResponse objects providing the - * results of the operation. - * @throws Exception the exception - */ - public Collection updateDelegates(Mailbox mailbox, - MeetingRequestsDeliveryScope meetingRequestsDeliveryScope, - DelegateUser... delegateUsers) throws Exception { - return this.updateDelegates(mailbox, meetingRequestsDeliveryScope, - Arrays.asList(delegateUsers)); - } - - /** - * Updates delegates on a specific mailbox. Calling this method results in - * a call to EWS. - * - * @param mailbox the mailbox - * @param meetingRequestsDeliveryScope the meeting request delivery scope - * @param delegateUsers the delegate users - * @return A collection of DelegateUserResponse objects providing the - * results of the operation. - * @throws Exception the exception - */ - public Collection updateDelegates(Mailbox mailbox, - MeetingRequestsDeliveryScope meetingRequestsDeliveryScope, - Iterable delegateUsers) throws Exception { - EwsUtilities.validateParam(mailbox, "mailbox"); - EwsUtilities.validateParamCollection(delegateUsers.iterator(), - "delegateUsers"); - - UpdateDelegateRequest request = new UpdateDelegateRequest(this); - - request.setMailbox(mailbox); - - ArrayList delUser = new ArrayList(); - for (DelegateUser user : delegateUsers) { - delUser.add(user); - } - request.getDelegateUsers().addAll(delUser); - request.setMeetingRequestsDeliveryScope(meetingRequestsDeliveryScope); - - DelegateManagementResponse response = request.execute(); - return response.getDelegateUserResponses(); - } - - /** - * Removes delegates on a specific mailbox. Calling this method results in - * a call to EWS. - * - * @param mailbox the mailbox - * @param userIds the user ids - * @return A collection of DelegateUserResponse objects providing the - * results of the operation. - * @throws Exception the exception - */ - public Collection removeDelegates(Mailbox mailbox, - UserId... userIds) throws Exception { - return removeDelegates(mailbox, Arrays.asList(userIds)); - } - - /** - * Removes delegates on a specific mailbox. Calling this method results in - * a call to EWS. - * - * @param mailbox the mailbox - * @param userIds the user ids - * @return A collection of DelegateUserResponse objects providing the - * results of the operation. - * @throws Exception the exception - */ - public Collection removeDelegates(Mailbox mailbox, - Iterable userIds) throws Exception { - EwsUtilities.validateParam(mailbox, "mailbox"); - EwsUtilities.validateParamCollection(userIds.iterator(), "userIds"); - - RemoveDelegateRequest request = new RemoveDelegateRequest(this); - request.setMailbox(mailbox); - - ArrayList delUser = new ArrayList(); - for (UserId user : userIds) { - delUser.add(user); - } - request.getUserIds().addAll(delUser); - - DelegateManagementResponse response = request.execute(); - return response.getDelegateUserResponses(); - } - - /** - * Retrieves the delegates of a specific mailbox. Calling this method - * results in a call to EWS. - * - * @param mailbox the mailbox - * @param includePermissions the include permissions - * @param userIds the user ids - * @return A GetDelegateResponse providing the results of the operation. - * @throws Exception the exception - */ - public DelegateInformation getDelegates(Mailbox mailbox, - boolean includePermissions, UserId... userIds) throws Exception { - return this.getDelegates(mailbox, includePermissions, Arrays.asList(userIds)); - } - - /** - * Retrieves the delegates of a specific mailbox. Calling this method - * results in a call to EWS. - * - * @param mailbox the mailbox - * @param includePermissions the include permissions - * @param userIds the user ids - * @return A GetDelegateResponse providing the results of the operation. - * @throws Exception the exception - */ - public DelegateInformation getDelegates(Mailbox mailbox, - boolean includePermissions, Iterable userIds) - throws Exception { - EwsUtilities.validateParam(mailbox, "mailbox"); - - GetDelegateRequest request = new GetDelegateRequest(this); - - request.setMailbox(mailbox); - - ArrayList delUser = new ArrayList(); - for (UserId user : userIds) { - delUser.add(user); - } - request.getUserIds().addAll(delUser); - request.setIncludePermissions(includePermissions); - - GetDelegateResponse response = request.execute(); - DelegateInformation delegateInformation = new DelegateInformation( - (List) response - .getDelegateUserResponses(), response - .getMeetingRequestsDeliveryScope()); - - return delegateInformation; - } - - /** - * Creates the user configuration. - * - * @param userConfiguration the user configuration - * @throws Exception the exception - */ - public void createUserConfiguration(UserConfiguration userConfiguration) - throws Exception { - EwsUtilities.validateParam(userConfiguration, "userConfiguration"); - - CreateUserConfigurationRequest request = new CreateUserConfigurationRequest( - this); - - request.setUserConfiguration(userConfiguration); - - request.execute(); - } - - /** - * Creates a UserConfiguration. - * - * @param name the name - * @param parentFolderId the parent folder id - * @throws Exception the exception - */ - public void deleteUserConfiguration(String name, FolderId parentFolderId) - throws Exception { - EwsUtilities.validateParam(name, "name"); - EwsUtilities.validateParam(parentFolderId, "parentFolderId"); - - DeleteUserConfigurationRequest request = new DeleteUserConfigurationRequest( - this); - - request.setName(name); - request.setParentFolderId(parentFolderId); - request.execute(); - } - - /** - * Creates a UserConfiguration. - * - * @param name the name - * @param parentFolderId the parent folder id - * @param properties the property - * @return the user configuration - * @throws Exception the exception - */ - public UserConfiguration getUserConfiguration(String name, FolderId parentFolderId, - UserConfigurationProperties properties) - throws Exception { - EwsUtilities.validateParam(name, "name"); - EwsUtilities.validateParam(parentFolderId, "parentFolderId"); - - GetUserConfigurationRequest request = new GetUserConfigurationRequest(this); - - request.setName(name); - request.setParentFolderId(parentFolderId); - request.setProperties(EnumSet.of(properties)); - - return request.execute().getResponseAtIndex(0).getUserConfiguration(); - } - - /** - * Loads the property of the specified userConfiguration. - * - * @param userConfiguration the user configuration - * @param properties the property - * @throws Exception the exception - */ - public void loadPropertiesForUserConfiguration(UserConfiguration userConfiguration, - UserConfigurationProperties properties) throws Exception { - EwsUtilities.ewsAssert(userConfiguration != null, "ExchangeService.LoadPropertiesForUserConfiguration", - "userConfiguration is null"); - - GetUserConfigurationRequest request = new GetUserConfigurationRequest( - this); - - request.setUserConfiguration(userConfiguration); - request.setProperties(EnumSet.of(properties)); - - request.execute(); - } - - /** - * Updates a UserConfiguration. - * - * @param userConfiguration the user configuration - * @throws Exception the exception - */ - public void updateUserConfiguration(UserConfiguration userConfiguration) - throws Exception { - EwsUtilities.validateParam(userConfiguration, "userConfiguration"); - UpdateUserConfigurationRequest request = new UpdateUserConfigurationRequest(this); - - request.setUserConfiguration(userConfiguration); - - request.execute(); - } - - // region InboxRule operations - - /** - * Retrieves inbox rules of the authenticated user. - * - * @return A RuleCollection object containing the authenticated users inbox - * rules. - * @throws Exception - */ - public RuleCollection getInboxRules() throws Exception { - GetInboxRulesRequest request = new GetInboxRulesRequest(this); - return request.execute().getRules(); - } - - /** - * Retrieves the inbox rules of the specified user. - * - * @param mailboxSmtpAddress The SMTP address of the user whose inbox rules should be - * retrieved - * @return A RuleCollection object containing the inbox rules of the - * specified user. - * @throws Exception - */ - public RuleCollection getInboxRules(String mailboxSmtpAddress) - throws Exception { - EwsUtilities.validateParam(mailboxSmtpAddress, "MailboxSmtpAddress"); - - GetInboxRulesRequest request = new GetInboxRulesRequest(this); - request.setmailboxSmtpAddress(mailboxSmtpAddress); - return request.execute().getRules(); - } - - /** - * Updates the authenticated user's inbox rules by applying the specified - * operations. - * - * @param operations The operations that should be applied to the user's inbox - * rules. - * @param removeOutlookRuleBlob Indicate whether or not to remove Outlook Rule Blob. - * @throws Exception - */ - public void updateInboxRules(Iterable operations, - boolean removeOutlookRuleBlob) throws Exception { - UpdateInboxRulesRequest request = new UpdateInboxRulesRequest(this); - request.setInboxRuleOperations(operations); - request.setRemoveOutlookRuleBlob(removeOutlookRuleBlob); - request.execute(); - } - - /** - * Updates the authenticated user's inbox rules by applying the specified - * operations. - * - * @param operations The operations that should be applied to the user's inbox - * rules. - * @param removeOutlookRuleBlob Indicate whether or not to remove Outlook Rule Blob. - * @param mailboxSmtpAddress The SMTP address of the user whose inbox rules should be - * retrieved - * @throws Exception - */ - public void updateInboxRules(Iterable operations, - boolean removeOutlookRuleBlob, String mailboxSmtpAddress) - throws Exception { - UpdateInboxRulesRequest request = new UpdateInboxRulesRequest(this); - request.setInboxRuleOperations(operations); - request.setRemoveOutlookRuleBlob(removeOutlookRuleBlob); - request.setMailboxSmtpAddress(mailboxSmtpAddress); - request.execute(); - } - - /** - * Default implementation of AutodiscoverRedirectionUrlValidationCallback. - * Always returns true indicating that the URL can be used. - * - * @param redirectionUrl the redirection url - * @return Returns true. - * @throws AutodiscoverLocalException the autodiscover local exception - */ - private boolean defaultAutodiscoverRedirectionUrlValidationCallback( - String redirectionUrl) throws AutodiscoverLocalException { - throw new AutodiscoverLocalException(String.format( - "Autodiscover blocked a potentially insecure redirection to %s. To allow Autodiscover to follow the redirection, use the AutodiscoverUrl(string, AutodiscoverRedirectionUrlValidationCallback) overload.", redirectionUrl)); - } - - /** - * Initializes the Url property to the Exchange Web Services URL for the - * specified e-mail address by calling the Autodiscover service. - * - * @param emailAddress the email address - * @throws Exception the exception - */ - public void autodiscoverUrl(String emailAddress) throws Exception { - this.autodiscoverUrl(emailAddress, this); - } - - /** - * Initializes the Url property to the Exchange Web Services URL for the - * specified e-mail address by calling the Autodiscover service. - * - * @param emailAddress the email address to use. - * @param validateRedirectionUrlCallback The callback used to validate redirection URL - * @throws Exception the exception - */ - public void autodiscoverUrl(String emailAddress, - IAutodiscoverRedirectionUrl validateRedirectionUrlCallback) - throws Exception { - URI exchangeServiceUrl = null; - - if (this.getRequestedServerVersion().ordinal() > ExchangeVersion.Exchange2007_SP1 - .ordinal()) { - try { - exchangeServiceUrl = this.getAutodiscoverUrl(emailAddress, this - .getRequestedServerVersion(), - validateRedirectionUrlCallback); - this.setUrl(this - .adjustServiceUriFromCredentials(exchangeServiceUrl)); - return; - } catch (AutodiscoverLocalException ex) { - - this.traceMessage(TraceFlags.AutodiscoverResponse, String - .format("Autodiscover service call " - + "failed with error '%s'. " - + "Will try legacy service", ex.getMessage())); - - } catch (ServiceRemoteException ex) { - // E14:321785 -- Special case: if - // the caller's account is locked - // we want to return this exception, not continue. - if (ex instanceof AccountIsLockedException) { - throw new AccountIsLockedException(ex.getMessage(), - exchangeServiceUrl, ex); - } - - this.traceMessage(TraceFlags.AutodiscoverResponse, String - .format("Autodiscover service call " - + "failed with error '%s'. " - + "Will try legacy service", ex.getMessage())); - } - } - - // Try legacy Autodiscover provider - - exchangeServiceUrl = this.getAutodiscoverUrl(emailAddress, - ExchangeVersion.Exchange2007_SP1, - validateRedirectionUrlCallback); - - this.setUrl(this.adjustServiceUriFromCredentials(exchangeServiceUrl)); - } - - /** - * Autodiscover will always return the "plain" EWS endpoint URL but if the - * client is using WindowsLive credential, ExchangeService needs to use the - * WS-Security endpoint. - * - * @param uri the uri - * @return Adjusted URL. - * @throws Exception - */ - private URI adjustServiceUriFromCredentials(URI uri) - throws Exception { - return (this.getCredentials() != null) ? this.getCredentials() - .adjustUrl(uri) : uri; - } - - /** - * Gets the autodiscover url. - * - * @param emailAddress the email address - * @param requestedServerVersion the Exchange version - * @param validateRedirectionUrlCallback the validate redirection url callback - * @return the autodiscover url - * @throws Exception the exception - */ - private URI getAutodiscoverUrl(String emailAddress, - ExchangeVersion requestedServerVersion, - IAutodiscoverRedirectionUrl validateRedirectionUrlCallback) - throws Exception { - - AutodiscoverService autodiscoverService = new AutodiscoverService(this, requestedServerVersion); - autodiscoverService.setWebProxy(getWebProxy()); - autodiscoverService.setTimeout(getTimeout()); - - autodiscoverService - .setRedirectionUrlValidationCallback(validateRedirectionUrlCallback); - autodiscoverService.setEnableScpLookup(this.getEnableScpLookup()); - - GetUserSettingsResponse response = autodiscoverService.getUserSettings( - emailAddress, UserSettingName.InternalEwsUrl, - UserSettingName.ExternalEwsUrl); - - switch (response.getErrorCode()) { - case NoError: - return this.getEwsUrlFromResponse(response, autodiscoverService - .isExternal().TRUE); - - case InvalidUser: - throw new ServiceRemoteException(String.format("Invalid user: '%s'", - emailAddress)); - - case InvalidRequest: - throw new ServiceRemoteException(String.format("Invalid Autodiscover request: '%s'", response - .getErrorMessage())); - - default: - this.traceMessage(TraceFlags.AutodiscoverConfiguration, String - .format("No EWS Url returned for user %s, " - + "error code is %s", emailAddress, response - .getErrorCode())); - - throw new ServiceRemoteException(response.getErrorMessage()); - } - } - - private URI getEwsUrlFromResponse(GetUserSettingsResponse response, - boolean isExternal) throws URISyntaxException, AutodiscoverLocalException { - String uriString; - - // Bug E14:59063 -- Figure out which URL to use: Internal or External. - // Bug E14:67646 -- AutoDiscover may not return an external protocol. - // First try external, then internal. - // Bug E14:82650 -- Either protocol - // may be returned without a configured URL. - OutParam outParam = new OutParam(); - if ((isExternal && response.tryGetSettingValue(String.class, - UserSettingName.ExternalEwsUrl, outParam))) { - uriString = outParam.getParam(); - if (!(uriString == null || uriString.isEmpty())) { - return new URI(uriString); - } - } - if ((response.tryGetSettingValue(String.class, - UserSettingName.InternalEwsUrl, outParam) || response - .tryGetSettingValue(String.class, - UserSettingName.ExternalEwsUrl, outParam))) { - uriString = outParam.getParam(); - if (!(uriString == null || uriString.isEmpty())) { - return new URI(uriString); - } - } - - // If Autodiscover doesn't return an - // internal or external EWS URL, throw an exception. - throw new AutodiscoverLocalException( - "The Autodiscover service didn't return an appropriate URL that can be used for the ExchangeService Autodiscover URL."); - } - - // region Diagnostic Method -- Only used by test - - /** - * Executes the diagnostic method. - * - * @param verb The verb. - * @param parameter The parameter. - * @throws Exception - */ - protected Document executeDiagnosticMethod(String verb, Node parameter) - throws Exception { - ExecuteDiagnosticMethodRequest request = new ExecuteDiagnosticMethodRequest(this); - request.setVerb(verb); - request.setParameter(parameter); - - return request.execute().getResponseAtIndex(0).getReturnValue(); - - } - - // endregion - - // region Validation - - /** - * Validates this instance. - * - * @throws ServiceLocalException the service local exception - */ - @Override public void validate() throws ServiceLocalException { - super.validate(); - if (this.getUrl() == null) { - throw new ServiceLocalException("The Url property on the ExchangeService object must be set."); - } - } - - // region Constructors - - /** - * Initializes a new instance of the class, - * targeting the specified version of EWS and scoped to the to the system's - * current time zone. - */ - public ExchangeService() { - super(); - } - - /** - * Initializes a new instance of the class, - * targeting the specified version of EWS and scoped to the system's current - * time zone. - * - * @param requestedServerVersion the requested server version - */ - public ExchangeService(ExchangeVersion requestedServerVersion) { - super(requestedServerVersion); - } - - // Utilities - - /** - * Prepare http web request. - * - * @return the http web request - * @throws ServiceLocalException the service local exception - * @throws java.net.URISyntaxException the uRI syntax exception - */ - public HttpWebRequest prepareHttpWebRequest() - throws ServiceLocalException, URISyntaxException { - try { - this.url = this.adjustServiceUriFromCredentials(this.getUrl()); - } catch (Exception e) { - LOG.error(e); - } - return this.prepareHttpWebRequestForUrl(url, this - .getAcceptGzipEncoding(), true); - } - - /** - * Prepares a http web request from a pooling connection manager, used for subscriptions. - * - * @return A http web request - * @throws ServiceLocalException The service local exception - * @throws java.net.URISyntaxException the uRI syntax exception - */ - public HttpWebRequest prepareHttpPoolingWebRequest() - throws ServiceLocalException, URISyntaxException { - try { - this.url = this.adjustServiceUriFromCredentials(this.getUrl()); - } catch (Exception e) { - LOG.error(e); - } - return this.prepareHttpPoolingWebRequestForUrl(url, this - .getAcceptGzipEncoding(), true); - } - - /** - * Processes an HTTP error response. - * - * @param httpWebResponse The HTTP web response. - * @param webException The web exception - * @throws Exception - */ - @Override public void processHttpErrorResponse(HttpWebRequest httpWebResponse, Exception webException) throws Exception { - this.internalProcessHttpErrorResponse(httpWebResponse, webException, - TraceFlags.EwsResponseHttpHeaders, TraceFlags.EwsResponse); - } - - // Properties - - /** - * Gets the URL of the Exchange Web Services. - * - * @return URL of the Exchange Web Services. - */ - public URI getUrl() { - return url; - } - - /** - * Sets the URL of the Exchange Web Services. - * - * @param url URL of the Exchange Web Services. - */ - public void setUrl(URI url) { - this.url = url; - } - - /** - * Gets the impersonated user id. - * - * @return the impersonated user id - */ - public ImpersonatedUserId getImpersonatedUserId() { - return impersonatedUserId; - } - - /** - * Sets the impersonated user id. - * - * @param impersonatedUserId the new impersonated user id - */ - public void setImpersonatedUserId(ImpersonatedUserId impersonatedUserId) { - this.impersonatedUserId = impersonatedUserId; - } - - /** - * Gets the preferred culture. - * - * @return the preferred culture - */ - public Locale getPreferredCulture() { - return preferredCulture; - } - - /** - * Sets the preferred culture. - * - * @param preferredCulture the new preferred culture - */ - public void setPreferredCulture(Locale preferredCulture) { - this.preferredCulture = preferredCulture; - } - - /** - * Gets the DateTime precision for DateTime values returned from Exchange - * Web Services. - * - * @return the DateTimePrecision - */ - public DateTimePrecision getDateTimePrecision() { - return this.dateTimePrecision; - } - - /** - * Sets the DateTime precision for DateTime values Web Services. - * @param d date time precision - */ - public void setDateTimePrecision(DateTimePrecision d) { - this.dateTimePrecision = d; - } - - /** - * Sets the DateTime precision for DateTime values returned from Exchange - * Web Services. - * - * @param dateTimePrecision the new DateTimePrecision - */ - public void setPreferredCulture(DateTimePrecision dateTimePrecision) { - this.dateTimePrecision = dateTimePrecision; - } - - /** - * Gets the file attachment content handler. - * - * @return the file attachment content handler - */ - public IFileAttachmentContentHandler getFileAttachmentContentHandler() { - return this.fileAttachmentContentHandler; - } - - /** - * Sets the file attachment content handler. - * - * @param fileAttachmentContentHandler the new file attachment content handler - */ - public void setFileAttachmentContentHandler( - IFileAttachmentContentHandler fileAttachmentContentHandler) { - this.fileAttachmentContentHandler = fileAttachmentContentHandler; - } - - /** - * Provides access to the Unified Messaging functionalities. - * - * @return the unified messaging - */ - public UnifiedMessaging getUnifiedMessaging() { - if (this.unifiedMessaging == null) { - this.unifiedMessaging = new UnifiedMessaging(this); - } - - return this.unifiedMessaging; - } - - /** - * Gets or sets a value indicating whether the AutodiscoverUrl method should - * perform SCP (Service Connection Point) record lookup when determining the - * Autodiscover service URL. - * - * @return enable scp lookup flag. - */ - public boolean getEnableScpLookup() { - return this.enableScpLookup; - } - - - public void setEnableScpLookup(boolean value) { - this.enableScpLookup = value; - } - - /** - * Returns true whether Exchange2007 compatibility mode is enabled, false otherwise. - */ - public boolean getExchange2007CompatibilityMode() { - return this.exchange2007CompatibilityMode; - } - - /** - * Set the flag indicating if the Exchange2007 compatibility mode is enabled. - * - * - * In order to support E12 servers, the exchange2007CompatibilityMode property, - * set to true, can be used to indicate that we should use "Exchange2007" as the server version String - * rather than Exchange2007_SP1. - * - * - * @param value true if the Exchange2007 compatibility mode is enabled. - */ - public void setExchange2007CompatibilityMode(boolean value) { - this.exchange2007CompatibilityMode = value; - } - - /** - * Retrieves the definitions of the specified server-side time zones. - * - * @param timeZoneIds the time zone ids - * @return A Collection containing the definitions of the specified time - * zones. - * @throws Exception - */ - public Collection getServerTimeZones( - Iterable timeZoneIds) throws Exception { - Map timeZoneMap = new HashMap(); - - GetServerTimeZonesRequest request = new GetServerTimeZonesRequest(this); - ServiceResponseCollection responses = request.execute(); - for (GetServerTimeZonesResponse response : responses) { - for (TimeZoneDefinition tzd : response.getTimeZones()) { - timeZoneMap.put(tzd.getId(), tzd); - } - } - - Collection timeZoneList = new ArrayList(); - - for (String timeZoneId : timeZoneIds) { - timeZoneList.add(timeZoneMap.get(timeZoneId)); - } - - return timeZoneList; - } - - /** - * Retrieves the definitions of all server-side time zones. - * - * @return A Collection containing the definitions of the specified time - * zones. - * @throws Exception - */ - public Collection getServerTimeZones() throws Exception { - GetServerTimeZonesRequest request = new GetServerTimeZonesRequest(this); - Collection timeZoneList = new ArrayList(); - ServiceResponseCollection responses = request.execute(); - for (GetServerTimeZonesResponse response : responses) { - timeZoneList.addAll(response.getTimeZones()); - } - - return timeZoneList; - } - - /* - * (non-Javadoc) - * - * @seemicrosoft.exchange.webservices.AutodiscoverRedirectionUrlInterface# - * autodiscoverRedirectionUrlValidationCallback(java.lang.String) - */ - public boolean autodiscoverRedirectionUrlValidationCallback( - String redirectionUrl) throws AutodiscoverLocalException { - return defaultAutodiscoverRedirectionUrlValidationCallback(redirectionUrl); - - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/ExchangeServiceBase.java b/src/main/java/microsoft/exchange/webservices/data/core/ExchangeServiceBase.java deleted file mode 100644 index 9e383c582..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/ExchangeServiceBase.java +++ /dev/null @@ -1,896 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import java.io.ByteArrayOutputStream; -import java.io.Closeable; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.security.GeneralSecurityException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.TimeZone; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import microsoft.exchange.webservices.data.EWSConstants; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.TraceFlags; -import microsoft.exchange.webservices.data.core.exception.http.EWSHttpException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.remote.AccountIsLockedException; -import microsoft.exchange.webservices.data.core.request.HttpClientWebRequest; -import microsoft.exchange.webservices.data.core.request.HttpWebRequest; -import microsoft.exchange.webservices.data.credential.ExchangeCredentials; -import microsoft.exchange.webservices.data.misc.EwsTraceListener; -import microsoft.exchange.webservices.data.misc.ITraceListener; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.http.client.AuthenticationStrategy; -import org.apache.http.client.CookieStore; -import org.apache.http.client.protocol.HttpClientContext; -import org.apache.http.config.Registry; -import org.apache.http.config.RegistryBuilder; -import org.apache.http.conn.HttpClientConnectionManager; -import org.apache.http.conn.socket.ConnectionSocketFactory; -import org.apache.http.conn.socket.PlainConnectionSocketFactory; -import org.apache.http.impl.client.BasicCookieStore; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.conn.BasicHttpClientConnectionManager; -import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; - -/** - * Represents an abstract binding to an Exchange Service. - */ -public abstract class ExchangeServiceBase implements Closeable { - - private static final Log LOG = LogFactory.getLog(ExchangeService.class); - - /** - * The credential. - */ - private ExchangeCredentials credentials; - - /** - * The use default credential. - */ - private boolean useDefaultCredentials; - - /** - * The binary secret. - */ - private static byte[] binarySecret; - - /** - * The timeout. - */ - private int timeout = 100000; - - /** - * The trace enabled. - */ - private boolean traceEnabled; - - /** - * The trace flags. - */ - private EnumSet traceFlags = EnumSet.allOf(TraceFlags.class); - - /** - * The trace listener. - */ - private ITraceListener traceListener = new EwsTraceListener(); - - /** - * The pre authenticate. - */ - private boolean preAuthenticate; - - /** - * The user agent. - */ - private String userAgent = ExchangeServiceBase.defaultUserAgent; - - /** - * The accept gzip encoding. - */ - private boolean acceptGzipEncoding = true; - - /** - * The requested server version. - */ - private ExchangeVersion requestedServerVersion = ExchangeVersion.Exchange2010_SP2; - - /** - * The server info. - */ - private ExchangeServerInfo serverInfo; - - private Map httpHeaders = new HashMap(); - - private Map httpResponseHeaders = new HashMap(); - - private WebProxy webProxy; - - protected CloseableHttpClient httpClient; - - protected HttpClientContext httpContext; - - protected CloseableHttpClient httpPoolingClient; - - private int maximumPoolingConnections = 10; - - -// protected HttpClientWebRequest request = null; - - // protected static HttpStatusCode AccountIsLocked = (HttpStatusCode)456; - - /** - * Default UserAgent. - */ - private static String defaultUserAgent = "ExchangeServicesClient/" + EwsUtilities.getBuildVersion(); - - /** - * Initializes a new instance. - * - * This constructor performs the initialization of the HTTP connection manager, so it should be called by - * every other constructor. - */ - protected ExchangeServiceBase() { - setUseDefaultCredentials(true); - initializeHttpClient(); - initializeHttpContext(); - } - - protected ExchangeServiceBase(ExchangeVersion requestedServerVersion) { - this(); - this.requestedServerVersion = requestedServerVersion; - } - - protected ExchangeServiceBase(ExchangeServiceBase service, ExchangeVersion requestedServerVersion) { - this(requestedServerVersion); - this.useDefaultCredentials = service.getUseDefaultCredentials(); - this.credentials = service.getCredentials(); - this.traceEnabled = service.isTraceEnabled(); - this.traceListener = service.getTraceListener(); - this.traceFlags = service.getTraceFlags(); - this.timeout = service.getTimeout(); - this.preAuthenticate = service.isPreAuthenticate(); - this.userAgent = service.getUserAgent(); - this.acceptGzipEncoding = service.getAcceptGzipEncoding(); - this.httpHeaders = service.getHttpHeaders(); - } - - private void initializeHttpClient() { - Registry registry = createConnectionSocketFactoryRegistry(); - HttpClientConnectionManager httpConnectionManager = new BasicHttpClientConnectionManager(registry); - AuthenticationStrategy authStrategy = new CookieProcessingTargetAuthenticationStrategy(); - - httpClient = HttpClients.custom() - .setConnectionManager(httpConnectionManager) - .setTargetAuthenticationStrategy(authStrategy) - .build(); - } - - private void initializeHttpPoolingClient() { - Registry registry = createConnectionSocketFactoryRegistry(); - PoolingHttpClientConnectionManager httpConnectionManager = new PoolingHttpClientConnectionManager(registry); - httpConnectionManager.setMaxTotal(maximumPoolingConnections); - httpConnectionManager.setDefaultMaxPerRoute(maximumPoolingConnections); - AuthenticationStrategy authStrategy = new CookieProcessingTargetAuthenticationStrategy(); - - httpPoolingClient = HttpClients.custom() - .setConnectionManager(httpConnectionManager) - .setTargetAuthenticationStrategy(authStrategy) - .build(); - } - - /** - * Sets the maximum number of connections for the pooling connection manager which is used for - * subscriptions. - *

- * Default is 10. - *

- * - * @param maximumPoolingConnections Maximum number of pooling connections - */ - public void setMaximumPoolingConnections(int maximumPoolingConnections) { - if (maximumPoolingConnections < 1) - throw new IllegalArgumentException("maximumPoolingConnections must be 1 or greater"); - this.maximumPoolingConnections = maximumPoolingConnections; - } - - /** - * Create registry with configured {@link ConnectionSocketFactory} instances. - * Override this method to change how to work with different schemas. - * - * @return registry object - */ - protected Registry createConnectionSocketFactoryRegistry() { - try { - return RegistryBuilder.create() - .register(EWSConstants.HTTP_SCHEME, new PlainConnectionSocketFactory()) - .register(EWSConstants.HTTPS_SCHEME, EwsSSLProtocolSocketFactory.build(null)) - .build(); - } catch (GeneralSecurityException e) { - throw new RuntimeException( - "Could not initialize ConnectionSocketFactory instances for HttpClientConnectionManager", e - ); - } - } - - /** - * (Re)initializes the HttpContext object. This removes any existing state (mainly cookies). Use an own - * cookie store, instead of the httpClient's global store, so cookies get reset on reinitialization - */ - private void initializeHttpContext() { - CookieStore cookieStore = new BasicCookieStore(); - httpContext = HttpClientContext.create(); - httpContext.setCookieStore(cookieStore); - } - - @Override - public void close() { - IOUtils.closeQuietly(httpClient); - IOUtils.closeQuietly(httpPoolingClient); - } - - // Event handlers - - /** - * Calls the custom SOAP header serialisation event handlers, if defined. - * - * @param writer The XmlWriter to which to write the custom SOAP headers. - */ - public void doOnSerializeCustomSoapHeaders(XMLStreamWriter writer) { - EwsUtilities - .ewsAssert(writer != null, "ExchangeService.DoOnSerializeCustomSoapHeaders", "writer is null"); - - if (null != getOnSerializeCustomSoapHeaders() && - !getOnSerializeCustomSoapHeaders().isEmpty()) { - for (ICustomXmlSerialization customSerialization : getOnSerializeCustomSoapHeaders()) { - customSerialization.CustomXmlSerialization(writer); - } - } - } - - // Utilities - - /** - * Creates an HttpWebRequest instance and initialises it with the - * appropriate parameters, based on the configuration of this service - * object. - * - * @param url The URL that the HttpWebRequest should target. - * @param acceptGzipEncoding If true, ask server for GZip compressed content. - * @param allowAutoRedirect If true, redirection response will be automatically followed. - * @return An initialised instance of HttpWebRequest. - * @throws ServiceLocalException the service local exception - * @throws java.net.URISyntaxException the uRI syntax exception - */ - protected HttpWebRequest prepareHttpWebRequestForUrl(URI url, boolean acceptGzipEncoding, - boolean allowAutoRedirect) throws ServiceLocalException, URISyntaxException { - // Verify that the protocol is something that we can handle - String scheme = url.getScheme(); - if (!scheme.equalsIgnoreCase(EWSConstants.HTTP_SCHEME) - && !scheme.equalsIgnoreCase(EWSConstants.HTTPS_SCHEME)) { - String strErr = String.format("Protocol %s isn't supported for service request.", scheme); - throw new ServiceLocalException(strErr); - } - - HttpClientWebRequest request = new HttpClientWebRequest(httpClient, httpContext); - prepareHttpWebRequestForUrl(url, acceptGzipEncoding, allowAutoRedirect, request); - - return request; - } - - /** - * 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. - *

- * - * @param url The URL that the HttpWebRequest should target. - * @param acceptGzipEncoding If true, ask server for GZip compressed content. - * @param allowAutoRedirect If true, redirection response will be automatically followed. - * @return An initialised instance of HttpWebRequest. - * @throws ServiceLocalException the service local exception - * @throws java.net.URISyntaxException the uRI syntax exception - */ - protected HttpWebRequest prepareHttpPoolingWebRequestForUrl(URI url, boolean acceptGzipEncoding, - boolean allowAutoRedirect) throws ServiceLocalException, URISyntaxException { - // Verify that the protocol is something that we can handle - String scheme = url.getScheme(); - if (!scheme.equalsIgnoreCase(EWSConstants.HTTP_SCHEME) - && !scheme.equalsIgnoreCase(EWSConstants.HTTPS_SCHEME)) { - String strErr = String.format("Protocol %s isn't supported for service request.", scheme); - throw new ServiceLocalException(strErr); - } - - if (httpPoolingClient == null) { - initializeHttpPoolingClient(); - } - - HttpClientWebRequest request = new HttpClientWebRequest(httpPoolingClient, httpContext); - prepareHttpWebRequestForUrl(url, acceptGzipEncoding, allowAutoRedirect, request); - - return request; - } - - private void prepareHttpWebRequestForUrl(URI url, boolean acceptGzipEncoding, boolean allowAutoRedirect, - HttpClientWebRequest request) throws ServiceLocalException, URISyntaxException { - try { - request.setUrl(url.toURL()); - } catch (MalformedURLException e) { - String strErr = String.format("Incorrect format : %s", url); - throw new ServiceLocalException(strErr); - } - - request.setPreAuthenticate(preAuthenticate); - request.setTimeout(timeout); - request.setContentType("text/xml; charset=utf-8"); - request.setAccept("text/xml"); - request.setUserAgent(userAgent); - request.setAllowAutoRedirect(allowAutoRedirect); - request.setAcceptGzipEncoding(acceptGzipEncoding); - request.setHeaders(getHttpHeaders()); - request.setProxy(getWebProxy()); - prepareCredentials(request); - - request.prepareConnection(); - - httpResponseHeaders.clear(); - } - - protected void prepareCredentials(HttpWebRequest request) throws ServiceLocalException, URISyntaxException { - request.setUseDefaultCredentials(useDefaultCredentials); - if (!useDefaultCredentials) { - if (credentials == null) { - throw new ServiceLocalException("Credentials are required to make a service request."); - } - - // Make sure that credential have been authenticated if required - credentials.preAuthenticate(); - - // Apply credential to the request - credentials.prepareWebRequest(request); - } - } - - /** - * 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. - * - * @param httpWebResponse HTTP web response - * @param webException web exception - * @param responseHeadersTraceFlag trace flag for response headers - * @param responseTraceFlag trace flag for respone - * @throws Exception on error - */ - protected void internalProcessHttpErrorResponse(HttpWebRequest httpWebResponse, Exception webException, - TraceFlags responseHeadersTraceFlag, TraceFlags responseTraceFlag) throws Exception { - EwsUtilities.ewsAssert(500 != httpWebResponse.getResponseCode(), - "ExchangeServiceBase.InternalProcessHttpErrorResponse", - "InternalProcessHttpErrorResponse does not handle 500 ISE errors, the caller is supposed to handle this."); - - this.processHttpResponseHeaders(responseHeadersTraceFlag, httpWebResponse); - - // E14:321785 -- Deal with new HTTP error code indicating that account is locked. - // The "unlock" URL is returned as the status description in the response. - if (httpWebResponse.getResponseCode() == 456) { - String location = httpWebResponse.getResponseContentType(); - - URI accountUnlockUrl = null; - if (checkURIPath(location)) { - accountUnlockUrl = new URI(location); - } - - final String message = String.format("This account is locked. Visit %s to unlock it.", accountUnlockUrl); - this.traceMessage(responseTraceFlag, message); - throw new AccountIsLockedException(message, accountUnlockUrl, webException); - } - } - - /** - * @param location file path - * @return false if location is null,true if this abstract pathname is absolute - */ - public static boolean checkURIPath(String location) { - if (location == null) { - return false; - } - final File file = new File(location); - return file.isAbsolute(); - } - - /** - * @param httpWebResponse HTTP web response - * @param webException web exception - * @throws Exception on error - */ - protected abstract void processHttpErrorResponse(HttpWebRequest httpWebResponse, Exception webException) - throws Exception; - - /** - * Determines whether tracing is enabled for specified trace flag(s). - * - * @param traceFlags The trace flags. - * @return True if tracing is enabled for specified trace flag(s). - */ - public boolean isTraceEnabledFor(TraceFlags traceFlags) { - return this.isTraceEnabled() && this.traceFlags.contains(traceFlags); - } - - /** - * Logs the specified string to the TraceListener if tracing is enabled. - * - * @param traceType kind of trace entry - * @param logEntry the entry to log - * @throws XMLStreamException the XML stream exception - * @throws IOException signals that an I/O exception has occurred - */ - public void traceMessage(TraceFlags traceType, String logEntry) throws XMLStreamException, IOException { - if (this.isTraceEnabledFor(traceType)) { - String traceTypeStr = traceType.toString(); - String logMessage = EwsUtilities.formatLogMessage(traceTypeStr, logEntry); - this.traceListener.trace(traceTypeStr, logMessage); - } - } - - /** - * Logs the specified XML to the TraceListener if tracing is enabled. - * - * @param traceType Kind of trace entry. - * @param stream The stream containing XML. - */ - public void traceXml(TraceFlags traceType, ByteArrayOutputStream stream) { - if (this.isTraceEnabledFor(traceType)) { - String traceTypeStr = traceType.toString(); - String logMessage = EwsUtilities.formatLogMessageWithXmlContent(traceTypeStr, stream); - this.traceListener.trace(traceTypeStr, logMessage); - } - } - - /** - * Traces the HTTP request headers. - * - * @param traceType Kind of trace entry. - * @param request The request - * @throws EWSHttpException EWS http exception - * @throws URISyntaxException URI syntax error - * @throws IOException signals that an I/O exception has occurred - * @throws XMLStreamException the XML stream exception - */ - public void traceHttpRequestHeaders(TraceFlags traceType, HttpWebRequest request) - throws URISyntaxException, EWSHttpException, XMLStreamException, IOException { - if (this.isTraceEnabledFor(traceType)) { - String traceTypeStr = traceType.toString(); - String headersAsString = EwsUtilities.formatHttpRequestHeaders(request); - String logMessage = EwsUtilities.formatLogMessage(traceTypeStr, headersAsString); - this.traceListener.trace(traceTypeStr, logMessage); - } - } - - /** - * Traces the HTTP response headers. - * - * @param traceType kind of trace entry - * @param request the HttpRequest object - * @throws XMLStreamException the XML stream exception - * @throws IOException signals that an I/O exception has occurred - * @throws EWSHttpException the EWS http exception - */ - private void traceHttpResponseHeaders(TraceFlags traceType, HttpWebRequest request) - throws XMLStreamException, IOException, EWSHttpException { - if (this.isTraceEnabledFor(traceType)) { - String traceTypeStr = traceType.toString(); - String headersAsString = EwsUtilities.formatHttpResponseHeaders(request); - String logMessage = EwsUtilities.formatLogMessage(traceTypeStr, headersAsString); - this.traceListener.trace(traceTypeStr, logMessage); - } - } - - /** - * Converts the date time to universal date time string. - * - * @param dt the date - * @return String representation of DateTime in yyyy-MM-ddTHH:mm:ssZ format. - */ - public String convertDateTimeToUniversalDateTimeString(Date dt) { - String utcPattern = "yyyy-MM-dd'T'HH:mm:ss'Z'"; - DateFormat utcFormatter = new SimpleDateFormat(utcPattern); - utcFormatter.setTimeZone(TimeZone.getTimeZone("UTC")); - return utcFormatter.format(dt); - } - - /** - * Sets the user agent to a custom value - * - * @param userAgent User agent string to set on the service - */ - protected void setCustomUserAgent(String userAgent) { - this.userAgent = userAgent; - } - - /** - * Validates this instance. - * - * @throws ServiceLocalException the service local exception - */ - public void validate() throws ServiceLocalException { - } - - /** - * Gets a value indicating whether tracing is enabled. - * - * @return True is tracing is enabled - */ - public boolean isTraceEnabled() { - return this.traceEnabled; - } - - /** - * Sets a value indicating whether tracing is enabled. - * - * @param traceEnabled true to enable tracing - */ - public void setTraceEnabled(boolean traceEnabled) { - this.traceEnabled = traceEnabled; - if (this.traceEnabled && (this.traceListener == null)) { - this.traceListener = new EwsTraceListener(); - } - } - - /** - * Gets the trace flags. - * - * @return Set of trace flags. - */ - public EnumSet getTraceFlags() { - return traceFlags; - } - - /** - * Sets the trace flags. - * - * @param traceFlags A set of trace flags - */ - public void setTraceFlags(EnumSet traceFlags) { - this.traceFlags = traceFlags; - } - - /** - * Gets the trace listener. - * - * @return The trace listener. - */ - public ITraceListener getTraceListener() { - return traceListener; - } - - /** - * Sets the trace listener. - * - * @param traceListener the trace listener. - */ - public void setTraceListener(ITraceListener traceListener) { - this.traceListener = traceListener; - this.traceEnabled = (traceListener != null); - } - - /** - * Gets the credential used to authenticate with the Exchange Web Services. - * - * @return credential - */ - public ExchangeCredentials getCredentials() { - return this.credentials; - } - - /** - * Sets the credential used to authenticate with the Exchange Web Services. - * Setting the Credentials property automatically sets the - * UseDefaultCredentials to false. - * - * @param credentials Exchange credential. - */ - public void setCredentials(ExchangeCredentials credentials) { - this.credentials = credentials; - this.useDefaultCredentials = false; - - // Reset the httpContext, to remove any existing authentication cookies from subsequent request - initializeHttpContext(); - } - - /** - * Gets a value indicating whether the credential of the user currently - * logged into Windows should be used to authenticate with the Exchange Web - * Services. - * - * @return true if credential of the user currently logged in are used - */ - public boolean getUseDefaultCredentials() { - return this.useDefaultCredentials; - } - - /** - * 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. - * - * @param value the new use default credential - */ - public void setUseDefaultCredentials(boolean value) { - this.useDefaultCredentials = value; - if (value) { - this.credentials = null; - } - - // Reset the httpContext, to remove any existing authentication cookies from subsequent request - initializeHttpContext(); - } - - /** - * Gets the timeout used when sending HTTP request and when receiving HTTP - * response, in milliseconds. - * - * @return timeout in milliseconds - */ - public int getTimeout() { - return timeout; - } - - /** - * Sets the timeout used when sending HTTP request and when receiving HTTP - * respones, in milliseconds. Defaults to 100000. - * - * @param timeout timeout in milliseconds - */ - public void setTimeout(int timeout) { - if (timeout < 1) { - throw new IllegalArgumentException("Timeout must be greater than zero."); - } - this.timeout = timeout; - } - - /** - * Gets a value that indicates whether HTTP pre-authentication should be - * performed. - * - * @return true indicates pre-authentication is set - */ - public boolean isPreAuthenticate() { - return preAuthenticate; - } - - /** - * Sets a value that indicates whether HTTP pre-authentication should be - * performed. - * - * @param preAuthenticate true to enable pre-authentication - */ - public void setPreAuthenticate(boolean preAuthenticate) { - this.preAuthenticate = preAuthenticate; - } - - /** - * 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. - * - * @return true if compression is used - */ - public boolean getAcceptGzipEncoding() { - return 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. - * - * @param acceptGzipEncoding true to enable compression - */ - public void setAcceptGzipEncoding(boolean acceptGzipEncoding) { - this.acceptGzipEncoding = acceptGzipEncoding; - } - - /** - * Gets the requested server version. - * - * @return The requested server version. - */ - public ExchangeVersion getRequestedServerVersion() { - return this.requestedServerVersion; - } - - /** - * Gets the user agent. - * - * @return The user agent. - */ - public String getUserAgent() { - return this.userAgent; - } - - /** - * Sets the user agent. - * - * @param userAgent The user agent - */ - public void setUserAgent(String userAgent) { - this.userAgent = userAgent + " (" + ExchangeServiceBase.defaultUserAgent + ")"; - } - - /** - * Gets information associated with the server that processed the last - * request. Will be null if no request have been processed. - * - * @return the server info - */ - public ExchangeServerInfo getServerInfo() { - return serverInfo; - } - - /** - * Sets information associated with the server that processed the last - * request. - * - * @param serverInfo Server Information - */ - public void setServerInfo(ExchangeServerInfo serverInfo) { - this.serverInfo = serverInfo; - } - - /** - * Gets the web proxy that should be used when sending request to EWS. - * - * @return Proxy - * the Proxy Information - */ - public WebProxy getWebProxy() { - return this.webProxy; - } - - /** - * Sets the web proxy that should be used when sending request to EWS. - * Set this property to null to use the default web proxy. - * - * @param value the Proxy Information - */ - public void setWebProxy(WebProxy value) { - this.webProxy = value; - } - - /** - * Gets a collection of HTTP headers that will be sent with each request to - * EWS. - * - * @return httpHeaders - */ - public Map getHttpHeaders() { - return this.httpHeaders; - } - - // Events - - /** - * Provides an event that applications can implement to emit custom SOAP - * headers in request that are sent to Exchange. - */ - private List OnSerializeCustomSoapHeaders; - - /** - * Gets the on serialize custom soap headers. - * - * @return the on serialize custom soap headers - */ - public List getOnSerializeCustomSoapHeaders() { - return OnSerializeCustomSoapHeaders; - } - - /** - * Sets the on serialize custom soap headers. - * - * @param onSerializeCustomSoapHeaders the new on serialize custom soap headers - */ - public void setOnSerializeCustomSoapHeaders(List onSerializeCustomSoapHeaders) { - OnSerializeCustomSoapHeaders = onSerializeCustomSoapHeaders; - } - - /** - * Traces the HTTP response headers. - * - * @param traceType kind of trace entry - * @param request The request - * @throws EWSHttpException EWS http exception - * @throws IOException signals that an I/O exception has occurred - * @throws XMLStreamException the XML stream exception - */ - public void processHttpResponseHeaders(TraceFlags traceType, HttpWebRequest request) - throws XMLStreamException, IOException, EWSHttpException { - this.traceHttpResponseHeaders(traceType, request); - this.saveHttpResponseHeaders(request.getResponseHeaders()); - } - - /** - * Save the HTTP response headers. - * - * @param headers The response headers - */ - private void saveHttpResponseHeaders(Map headers) { - this.httpResponseHeaders.clear(); - - for (String key : headers.keySet()) { - this.httpResponseHeaders.put(key, headers.get(key)); - } - } - - /** - * Gets a collection of HTTP headers from the last response. - * @return HTTP response headers - */ - public Map getHttpResponseHeaders() { - return this.httpResponseHeaders; - } - - /** - * Gets the session key. - * @return session key - */ - public static byte[] getSessionKey() { - // this has to be computed only once. - synchronized (ExchangeServiceBase.class) { - if (ExchangeServiceBase.binarySecret == null) { - Random randomNumberGenerator = new Random(); - ExchangeServiceBase.binarySecret = new byte[256 / 8]; - randomNumberGenerator.nextBytes(binarySecret); - } - - return ExchangeServiceBase.binarySecret; - } - } - - public int getMaximumPoolingConnections() { - return maximumPoolingConnections; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/ICustomXmlUpdateSerializer.java b/src/main/java/microsoft/exchange/webservices/data/core/ICustomXmlUpdateSerializer.java deleted file mode 100644 index 92255591c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/ICustomXmlUpdateSerializer.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -/** - * Interface defined for property that produce their own update serialization. - */ -public interface ICustomXmlUpdateSerializer { - - /** - * Writes the update to XML. - * - * @param writer the writer - * @param ewsObject The ews object - * @param propertyDefinition property definition - * @return true if property generated serialization - * @throws Exception the exception - */ - boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject, PropertyDefinition propertyDefinition) throws Exception; - - /** - * Writes the deletion update to XML. - * - * @param writer The writer. - * @param ewsObject The ews object. - * @return True if property generated serialization. - * @throws Exception the exception - */ - boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject) throws Exception; -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/IGetPropertyDefinitionCallback.java b/src/main/java/microsoft/exchange/webservices/data/core/IGetPropertyDefinitionCallback.java deleted file mode 100644 index 76a9304fe..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/IGetPropertyDefinitionCallback.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -/** - * The Interface GetPropertyDefinitionCallbackInterface. - */ -interface IGetPropertyDefinitionCallback { - - /** - * Gets the property definition callback. - * - * @param version the version - * @return the property definition callback - */ - PropertyDefinition getPropertyDefinitionCallback(ExchangeVersion version); -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/IPredicate.java b/src/main/java/microsoft/exchange/webservices/data/core/IPredicate.java deleted file mode 100644 index 8dce9b5b1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/IPredicate.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -/** - * The Interface IPredicate. - * - * @param The type of the object to compare. - */ -public interface IPredicate { - - /** - * Represents the method that defines a - * set of criteria and determines whether - * the specified object meets those criteria. - * - * @param obj The object to compare against - * the criteria defined within the method represented - * by this delegate. - * @return true if obj meets the criteria - * defined within the method represented by this - * delegate; otherwise, false. - * @throws ServiceLocalException - */ - boolean predicate(T obj) throws ServiceLocalException; -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/LazyMember.java b/src/main/java/microsoft/exchange/webservices/data/core/LazyMember.java deleted file mode 100644 index 5d7d2bed0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/LazyMember.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -/** - * Wrapper class for lazy members. Does lazy initialization of member on first - * access. - * - * @param Type of the lazy member - *

- * If we find ourselves creating a whole bunch of these in our code, - * we need to rethink this. Each lazy member holds the actual member - * and a delegate. That can turn into a whole lot of overhead - *

- */ -public class LazyMember { - - /** - * The lazy member. - */ - private volatile T lazyMember; - - /** - * The lazy implementation. - */ - private final ILazyMember lazyImplementation; - - /** - * Public accessor for the lazy member. Lazy initializes the member on first - * access - * - * @return the member - */ - public T getMember() { - T result = this.lazyMember; - if (result == null) { // first check (no locking) - synchronized (this) { - result = this.lazyMember; - if (result == null) { // second check (with locking) - this.lazyMember = result = lazyImplementation.createInstance(); - } - } - } - return result; - } - - /** - * Constructor. - * - * @param lazyImplementation The initialization delegate to call for the item on first - * access - */ - public LazyMember(ILazyMember lazyImplementation) { - this.lazyImplementation = lazyImplementation; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/PropertyBag.java b/src/main/java/microsoft/exchange/webservices/data/core/PropertyBag.java deleted file mode 100644 index f65aea5bb..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/PropertyBag.java +++ /dev/null @@ -1,881 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.ISelfValidate; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.property.BasePropertySet; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceObjectPropertyException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; -import microsoft.exchange.webservices.data.property.complex.IComplexPropertyChanged; -import microsoft.exchange.webservices.data.property.complex.IComplexPropertyChangedDelegate; -import microsoft.exchange.webservices.data.property.complex.IOwnedProperty; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinitionBase; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * Represents a property bag keyed on PropertyDefinition objects. - */ -public class PropertyBag implements IComplexPropertyChanged, IComplexPropertyChangedDelegate { - - /** - * The owner. - */ - private ServiceObject owner; - - /** - * The is dirty. - */ - private boolean isDirty; - - /** - * The loading. - */ - private boolean loading; - - /** - * The only summary property requested. - */ - private boolean onlySummaryPropertiesRequested; - - /** - * The loaded property. - */ - private List loadedProperties = - new ArrayList(); - - /** - * The property. - */ - private Map properties = - new HashMap(); - - /** - * The deleted property. - */ - private Map deletedProperties = - new HashMap(); - - /** - * The modified property. - */ - private List modifiedProperties = - new ArrayList(); - - /** - * The added property. - */ - private List addedProperties = - new ArrayList(); - - /** - * The requested property set. - */ - private PropertySet requestedPropertySet; - - /** - * Initializes a new instance of PropertyBag. - * - * @param owner The owner of the bag. - */ - public PropertyBag(ServiceObject owner) { - EwsUtilities.ewsAssert(owner != null, "PropertyBag.ctor", "owner is null"); - - this.owner = owner; - } - - /** - * Gets a Map holding the bag's property. - * - * @return A Map holding the bag's property. - */ - public Map getProperties() { - return this.properties; - } - - /** - * Gets the owner of this bag. - * - * @return The owner of this bag. - */ - public ServiceObject getOwner() { - return this.owner; - } - - /** - * Indicates if a bag has pending changes. - * - * @return True if the bag has pending changes, false otherwise. - */ - public boolean getIsDirty() { - int changes = this.modifiedProperties.size() + - this.deletedProperties.size() + this.addedProperties.size(); - return changes > 0 || this.isDirty; - } - - /** - * Adds the specified property to the specified change list if it is not - * already present. - * - * @param propertyDefinition The property to add to the change list. - * @param changeList The change list to add the property to. - */ - protected static void addToChangeList( - PropertyDefinition propertyDefinition, - List changeList) { - if (!changeList.contains(propertyDefinition)) { - changeList.add(propertyDefinition); - } - } - - /** - * Checks if is property loaded. - * - * @param propertyDefinition the property definition - * @return true, if is property loaded - */ - public boolean isPropertyLoaded(PropertyDefinition propertyDefinition) { - // Is the property loaded? - if (this.loadedProperties.contains(propertyDefinition)) { - return true; - } else { - // Was the property requested? - return this.isRequestedProperty(propertyDefinition); - } - } - - /** - * Checks if is requested property. - * - * @param propertyDefinition the property definition - * @return true, if is requested property - */ - private boolean isRequestedProperty(PropertyDefinition propertyDefinition) { - // If no requested property set, then property wasn't requested. - if (this.requestedPropertySet == null) { - return false; - } - - // If base property set is all first-class property, use the - // appropriate list of - // property definitions to see if this property was requested. - // Otherwise, property had - // to be explicitly requested and needs to be listed in - // AdditionalProperties. - if (this.requestedPropertySet.getBasePropertySet() == BasePropertySet.FirstClassProperties) { - List firstClassProps = - this.onlySummaryPropertiesRequested ? this - .getOwner().getSchema().getFirstClassSummaryProperties() : - this.getOwner().getSchema().getFirstClassProperties(); - - return firstClassProps.contains(propertyDefinition) || - this.requestedPropertySet.contains(propertyDefinition); - } else { - return this.requestedPropertySet.contains(propertyDefinition); - } - } - - /** - * Determines whether the specified property has been updated. - * - * @param propertyDefinition The property definition. - * @return true if the specified property has been updated; otherwise, - * false. - */ - public boolean isPropertyUpdated(PropertyDefinition propertyDefinition) { - return this.modifiedProperties.contains(propertyDefinition) || - this.addedProperties.contains(propertyDefinition); - } - - /** - * Tries to get a property value based on a property definition. - * - * @param propertyDefinition The property definition. - * @param propertyValueOutParam The property value. - * @return True if property was retrieved. - */ - protected boolean tryGetProperty(PropertyDefinition propertyDefinition, - OutParam propertyValueOutParam) { - OutParam serviceExceptionOutParam = - new OutParam(); - propertyValueOutParam.setParam(this.getPropertyValueOrException( - propertyDefinition, serviceExceptionOutParam)); - return serviceExceptionOutParam.getParam() == null; - } - - /** - * Tries to get a property value based on a property definition. - * - * @param the types of the property - * @param propertyDefinition the property definition - * @param propertyValue the property value - * @return true if property was retrieved - * @throws ArgumentException on validation error - */ - public boolean tryGetPropertyType(Class cls, PropertyDefinition propertyDefinition, - OutParam propertyValue) throws ArgumentException { - // Verify that the type parameter and - //property definition's type are compatible. - if (!cls.isAssignableFrom(propertyDefinition.getType())) { - String errorMessage = String.format( - "Property definition type '%s' and type parameter '%s' aren't compatible.", - propertyDefinition.getType().getSimpleName(), - cls.getSimpleName()); - throw new ArgumentException(errorMessage, "propertyDefinition"); - } - - OutParam value = new OutParam(); - boolean result = this.tryGetProperty(propertyDefinition, value); - if (result) { - propertyValue.setParam((T) value.getParam()); - } else { - propertyValue.setParam(null); - } - - return result; - } - - - /** - * Gets the property value. - * - * @param propertyDefinition The property definition. - * @param serviceExceptionOutParam Exception that would be raised if there's an error retrieving - * the property. - * @return Property value. May be null. - */ - private T getPropertyValueOrException( - PropertyDefinition propertyDefinition, - OutParam serviceExceptionOutParam) { - OutParam propertyValueOutParam = new OutParam(); - propertyValueOutParam.setParam(null); - serviceExceptionOutParam.setParam(null); - - if (propertyDefinition.getVersion().ordinal() > this.getOwner() - .getService().getRequestedServerVersion().ordinal()) { - serviceExceptionOutParam.setParam(new ServiceVersionException( - String.format("The property %s is valid only for Exchange %s or later versions.", - propertyDefinition.getName(), propertyDefinition - .getVersion()))); - return null; - } - - if (this.tryGetValue(propertyDefinition, propertyValueOutParam)) { - // If the requested property is in the bag, return it. - return propertyValueOutParam.getParam(); - } else { - if (propertyDefinition - .hasFlag(PropertyDefinitionFlags.AutoInstantiateOnRead)) { - EwsUtilities - .ewsAssert(propertyDefinition instanceof ComplexPropertyDefinitionBase, - "PropertyBag.get_this[]", - "propertyDefinition is " + - "marked with AutoInstantiateOnRead " + - "but is not a descendant " + - "of ComplexPropertyDefinitionBase"); - - // The requested property is an auto-instantiate-on-read - // property - ComplexPropertyDefinitionBase complexPropertyDefinition = - (ComplexPropertyDefinitionBase) propertyDefinition; - ComplexProperty propertyValue = complexPropertyDefinition - .createPropertyInstance(getOwner()); - - // XXX: It could be dangerous to return complex value instead of - propertyValueOutParam.setParam((T) propertyValue); - if (propertyValue != null) { - this.initComplexProperty(propertyValue); - this.properties.put(propertyDefinition, propertyValue); - } - } else { - // If the property is not the Id (we need to let developers read - // the Id when it's null) and if has - // not been loaded, we throw. - if (propertyDefinition != this.getOwner() - .getIdPropertyDefinition()) { - if (!this.isPropertyLoaded(propertyDefinition)) { - serviceExceptionOutParam - .setParam(new ServiceObjectPropertyException( - "You must load or assign this property before you can read its value.", - propertyDefinition)); - return null; - } - - // Non-nullable property (int, bool, etc.) must be - // assigned or loaded; cannot return null value. - if (!propertyDefinition.isNullable()) { - String errorMessage = this - .isRequestedProperty(propertyDefinition) ? "This property was requested, but it wasn't returned by the server." - : "You must assign this property before you can read its value."; - serviceExceptionOutParam - .setParam(new ServiceObjectPropertyException( - errorMessage, propertyDefinition)); - } - } - } - return propertyValueOutParam.getParam(); - } - } - - /** - * Sets the isDirty flag to true and triggers dispatch of the change event - * to the owner of the property bag. Changed must be called whenever an - * operation that changes the state of this property bag is performed (e.g. - * adding or removing a property). - */ - public void changed() { - this.isDirty = true; - this.getOwner().changed(); - } - - /** - * Determines whether the property bag contains a specific property. - * - * @param propertyDefinition The property to check against. - * @return True if the specified property is in the bag, false otherwise. - */ - public boolean contains(PropertyDefinition propertyDefinition) { - return this.properties.containsKey(propertyDefinition); - } - - - - /** - * Tries to retrieve the value of the specified property. - * - * @param propertyDefinition the property for which to retrieve a value - * @param propertyValueOutParam if the method succeeds, contains the value of the property - * @return true if the value could be retrieved, false otherwise - */ - public boolean tryGetValue(PropertyDefinition propertyDefinition, OutParam propertyValueOutParam) { - if (this.properties.containsKey(propertyDefinition)) { - T param = (T) properties.get(propertyDefinition); - propertyValueOutParam.setParam(param); - return true; - } else { - propertyValueOutParam.setParam(null); - return false; - } - } - - /** - * Handles a change event for the specified property. - * - * @param complexProperty The property that changes. - */ - protected void propertyChanged(ComplexProperty complexProperty) { - Iterator> it = this.properties - .entrySet().iterator(); - while (it.hasNext()) { - Entry keyValuePair = it.next(); - if (keyValuePair.getValue().equals(complexProperty)) { - if (!this.deletedProperties.containsKey(keyValuePair.getKey())) { - addToChangeList(keyValuePair.getKey(), - this.modifiedProperties); - this.changed(); - } - } - } - } - - /** - * Deletes the property from the bag. - * - * @param propertyDefinition The property to delete. - */ - protected void deleteProperty(PropertyDefinition propertyDefinition) { - if (!this.deletedProperties.containsKey(propertyDefinition)) { - Object propertyValue = null; - - if (this.properties.containsKey(propertyDefinition)) { - propertyValue = this.properties.get(propertyDefinition); - } - - this.properties.remove(propertyDefinition); - this.modifiedProperties.remove(propertyDefinition); - this.deletedProperties.put(propertyDefinition, propertyValue); - - if (propertyValue instanceof ComplexProperty) { - ComplexProperty complexProperty = - (ComplexProperty) propertyValue; - complexProperty.addOnChangeEvent(this); - } - } - } - - /** - * Clears the bag. - */ - protected void clear() { - this.clearChangeLog(); - this.properties.clear(); - this.loadedProperties.clear(); - this.requestedPropertySet = null; - } - - /** - * Clears the bag's change log. - */ - public void clearChangeLog() { - this.deletedProperties.clear(); - this.modifiedProperties.clear(); - this.addedProperties.clear(); - - Iterator> it = this.properties - .entrySet().iterator(); - while (it.hasNext()) { - Entry keyValuePair = it.next(); - if (keyValuePair.getValue() instanceof ComplexProperty) { - ComplexProperty complexProperty = (ComplexProperty) keyValuePair - .getValue(); - complexProperty.clearChangeLog(); - } - } - - this.isDirty = false; - } - - /** - * Loads property from XML and inserts them in the bag. - * - * @param reader The reader from which to read the property. - * @param clear Indicates whether the bag should be cleared before property - * are loaded. - * @param requestedPropertySet The requested property set. - * @param onlySummaryPropertiesRequested Indicates whether summary or full property were requested. - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader, boolean clear, PropertySet requestedPropertySet, - boolean onlySummaryPropertiesRequested) throws Exception { - if (clear) { - this.clear(); - } - - // Put the property bag in "loading" mode. When in loading mode, no - // checking is done - // when setting property values. - this.loading = true; - - this.requestedPropertySet = requestedPropertySet; - this.onlySummaryPropertiesRequested = onlySummaryPropertiesRequested; - - try { - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - OutParam propertyDefinitionOut = - new OutParam(); - PropertyDefinition propertyDefinition; - - if (this.getOwner().schema().tryGetPropertyDefinition( - reader.getLocalName(), propertyDefinitionOut)) { - propertyDefinition = propertyDefinitionOut.getParam(); - propertyDefinition.loadPropertyValueFromXml(reader, - this); - - this.loadedProperties.add(propertyDefinition); - } else { - reader.skipCurrentElement(); - } - } - } while (!reader.isEndElement(XmlNamespace.Types, this.getOwner() - .getXmlElementName())); - - this.clearChangeLog(); - } finally { - this.loading = false; - } - } - - /** - * Writes the bag's property to XML. - * - * @param writer The writer to write the property to. - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer) throws Exception { - writer.writeStartElement(XmlNamespace.Types, this.getOwner() - .getXmlElementName()); - - Iterator it = this.getOwner().getSchema() - .iterator(); - while (it.hasNext()) { - PropertyDefinition propertyDefinition = it.next(); - // The following test should not be necessary since the property bag - // prevents - // property to be set if they don't have the CanSet flag, but it - // doesn't hurt... - if (propertyDefinition - .hasFlag(PropertyDefinitionFlags.CanSet, writer.getService().getRequestedServerVersion())) { - if (this.contains(propertyDefinition)) { - propertyDefinition.writePropertyValueToXml(writer, this, - false /* isUpdateOperation */); - } - } - } - - writer.writeEndElement(); - } - - /** - * Writes the EWS update operations corresponding to the changes that - * occurred in the bag to XML. - * - * @param writer The writer to write the updates to. - * @throws Exception the exception - */ - public void writeToXmlForUpdate(EwsServiceXmlWriter writer) - throws Exception { - writer.writeStartElement(XmlNamespace.Types, this.getOwner() - .getChangeXmlElementName()); - - this.getOwner().getId().writeToXml(writer); - - writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Updates); - - for (PropertyDefinition propertyDefinition : this.addedProperties) { - this.writeSetUpdateToXml(writer, propertyDefinition); - } - - for (PropertyDefinition propertyDefinition : this.modifiedProperties) { - this.writeSetUpdateToXml(writer, propertyDefinition); - } - - Iterator> it = this.deletedProperties - .entrySet().iterator(); - while (it.hasNext()) { - Entry property = it.next(); - this.writeDeleteUpdateToXml(writer, property.getKey(), property - .getValue()); - } - - writer.writeEndElement(); - writer.writeEndElement(); - } - - /** - * Determines whether an EWS UpdateItem/UpdateFolder call is necessary to - * save the changes that occurred in the bag. - * - * @return True if an UpdateItem/UpdateFolder call is necessary, false - * otherwise. - */ - public boolean getIsUpdateCallNecessary() { - List propertyDefinitions = - new ArrayList(); - propertyDefinitions.addAll(this.addedProperties); - propertyDefinitions.addAll(this.modifiedProperties); - propertyDefinitions.addAll(this.deletedProperties.keySet()); - for (PropertyDefinition propertyDefinition : propertyDefinitions) { - if (propertyDefinition.hasFlag(PropertyDefinitionFlags.CanUpdate)) { - return true; - } - } - return false; - } - - /** - * Initializes a ComplexProperty instance. When a property is inserted into - * the bag, it needs to be initialized in order for changes that occur on - * that property to be properly detected and dispatched. - * - * @param complexProperty The ComplexProperty instance to initialize. - */ - private void initComplexProperty(ComplexProperty complexProperty) { - if (complexProperty != null) { - complexProperty.addOnChangeEvent(this); - if (complexProperty instanceof IOwnedProperty) { - IOwnedProperty ownedProperty = (IOwnedProperty) complexProperty; - ownedProperty.setOwner(this.getOwner()); - } - } - } - - /** - * Writes an EWS SetUpdate opeartion for the specified property. - * - * @param writer The writer to write the update to. - * @param propertyDefinition The property fro which to write the update. - * @throws Exception the exception - */ - private void writeSetUpdateToXml(EwsServiceXmlWriter writer, - PropertyDefinition propertyDefinition) throws Exception { - // The following test should not be necessary since the property bag - // prevents - // property to be updated if they don't have the CanUpdate flag, but - // it - // doesn't hurt... - if (propertyDefinition.hasFlag(PropertyDefinitionFlags.CanUpdate)) { - Object propertyValue = this - .getObjectFromPropertyDefinition(propertyDefinition); - - boolean handled = false; - - if (propertyValue instanceof ICustomXmlUpdateSerializer) { - ICustomXmlUpdateSerializer updateSerializer = - (ICustomXmlUpdateSerializer) propertyValue; - handled = updateSerializer.writeSetUpdateToXml(writer, this - .getOwner(), propertyDefinition); - } - - if (!handled) { - writer.writeStartElement(XmlNamespace.Types, this.getOwner() - .getSetFieldXmlElementName()); - - propertyDefinition.writeToXml(writer); - - writer.writeStartElement(XmlNamespace.Types, this.getOwner() - .getXmlElementName()); - propertyDefinition - .writePropertyValueToXml(writer, this, - true /* isUpdateOperation */); - writer.writeEndElement(); - - writer.writeEndElement(); - } - } - } - - /** - * Writes an EWS DeleteUpdate opeartion for the specified property. - * - * @param writer The writer to write the update to. - * @param propertyDefinition The property fro which to write the update. - * @param propertyValue The current value of the property. - * @throws Exception the exception - */ - private void writeDeleteUpdateToXml(EwsServiceXmlWriter writer, - PropertyDefinition propertyDefinition, Object propertyValue) - throws Exception { - // The following test should not be necessary since the property bag - // prevents - // property to be deleted (set to null) if they don't have the - // CanDelete flag, - // but it doesn't hurt... - if (propertyDefinition.hasFlag(PropertyDefinitionFlags.CanDelete)) { - boolean handled = false; - - if (propertyValue instanceof ICustomXmlUpdateSerializer) { - ICustomXmlUpdateSerializer updateSerializer = - (ICustomXmlUpdateSerializer) propertyValue; - handled = updateSerializer.writeDeleteUpdateToXml(writer, this - .getOwner()); - } - - if (!handled) { - writer.writeStartElement(XmlNamespace.Types, this.getOwner() - .getDeleteFieldXmlElementName()); - propertyDefinition.writeToXml(writer); - writer.writeEndElement(); - } - } - } - - /** - * Validate property bag instance. - * - * @throws Exception the exception - */ - public void validate() throws Exception { - for (PropertyDefinition propertyDefinition : this.addedProperties) { - this.validatePropertyValue(propertyDefinition); - } - - for (PropertyDefinition propertyDefinition : this.modifiedProperties) { - this.validatePropertyValue(propertyDefinition); - } - } - - /** - * Validates the property value. - * - * @param propertyDefinition The property definition. - * @throws Exception the exception - */ - private void validatePropertyValue(PropertyDefinition propertyDefinition) - throws Exception { - OutParam propertyValueOut = new OutParam(); - if (this.tryGetProperty(propertyDefinition, propertyValueOut)) { - Object propertyValue = propertyValueOut.getParam(); - - if (propertyValue instanceof ISelfValidate) { - ISelfValidate validatingValue = (ISelfValidate) propertyValue; - validatingValue.validate(); - } - } - } - - /** - * Gets the value of a property. - * - * @param propertyDefinition The property to get or set. - * @return An object representing the value of the property. - * @throws ServiceLocalException ServiceVersionException will be raised if this property - * requires a later version of Exchange. - * ServiceObjectPropertyException will be raised for get if - * property hasn't been assigned or loaded, raised for set if - * property cannot be updated or deleted. - */ - public T getObjectFromPropertyDefinition(PropertyDefinition propertyDefinition) - throws ServiceLocalException { - OutParam serviceExceptionOut = - new OutParam(); - T propertyValue = getPropertyValueOrException(propertyDefinition, serviceExceptionOut); - - ServiceLocalException serviceException = serviceExceptionOut.getParam(); - if (serviceException != null) { - throw serviceException; - } - return propertyValue; - } - - /** - * Gets the value of a property. - * - * @param propertyDefinition The property to get or set. - * @param object An object representing the value of the property. - * @throws Exception the exception - */ - public void setObjectFromPropertyDefinition(PropertyDefinition propertyDefinition, Object object) - throws Exception { - if (propertyDefinition.getVersion().ordinal() > this.getOwner() - .getService().getRequestedServerVersion().ordinal()) { - throw new ServiceVersionException(String.format( - "The property %s is valid only for Exchange %s or later versions.", - propertyDefinition.getName(), propertyDefinition - .getVersion())); - } - - // If the property bag is not in the loading state, we need to verify - // whether - // the property can actually be set or updated. - if (!this.loading) { - // If the owner is new and if the property cannot be set, throw. - if (this.getOwner().isNew() - && !propertyDefinition - .hasFlag(PropertyDefinitionFlags.CanSet, this.getOwner() - .getService().getRequestedServerVersion())) { - throw new ServiceObjectPropertyException("This property is read-only and can't be set.", propertyDefinition); - } - - if (!this.getOwner().isNew()) { - // If owner is an item attachment, property cannot be updated - // (EWS doesn't support updating item attachments) - - if ((this.getOwner() instanceof Item)) { - Item ownerItem = (Item) this.getOwner(); - if (ownerItem.isAttachment()) { - throw new ServiceObjectPropertyException("Item attachments can't be updated.", - propertyDefinition); - } - } - - // If the property cannot be deleted, throw. - if (object == null - && !propertyDefinition - .hasFlag(PropertyDefinitionFlags.CanDelete)) { - throw new ServiceObjectPropertyException("This property can't be deleted.", - propertyDefinition); - } - - // If the property cannot be updated, throw. - if (!propertyDefinition - .hasFlag(PropertyDefinitionFlags.CanUpdate)) { - throw new ServiceObjectPropertyException("This property can't be updated.", - propertyDefinition); - } - } - } - - // If the value is set to null, delete the property. - if (object == null) { - this.deleteProperty(propertyDefinition); - } else { - ComplexProperty complexProperty = null; - Object currentValue = null; - - if (this.properties.containsKey(propertyDefinition)) { - currentValue = this.properties.get(propertyDefinition); - - if (currentValue instanceof ComplexProperty) { - complexProperty = (ComplexProperty) currentValue; - complexProperty.removeChangeEvent(this); - } - } - - // If the property was to be deleted, the deletion becomes an - // update. - if (this.deletedProperties.containsKey(propertyDefinition)) { - this.deletedProperties.remove(propertyDefinition); - addToChangeList(propertyDefinition, this.modifiedProperties); - } else { - // If the property value was not set, we have a newly set - // property. - if (!this.properties.containsKey(propertyDefinition)) { - addToChangeList(propertyDefinition, this.addedProperties); - } else { - // The last case is that we have a modified property. - if (!this.modifiedProperties.contains(propertyDefinition)) { - addToChangeList(propertyDefinition, - this.modifiedProperties); - } - } - } - - if (object instanceof ComplexProperty) { - this.initComplexProperty((ComplexProperty) object); - } - this.properties.put(propertyDefinition, object); - this.changed(); - } - - } - - /* - * (non-Javadoc) - * - * @seemicrosoft.exchange.webservices.ComplexPropertyChangedInterface# - * complexPropertyChanged(microsoft.exchange.webservices.ComplexProperty) - */ - @Override - public void complexPropertyChanged(ComplexProperty complexProperty) { - this.propertyChanged(complexProperty); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/PropertySet.java b/src/main/java/microsoft/exchange/webservices/data/core/PropertySet.java deleted file mode 100644 index 32ae28ee5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/PropertySet.java +++ /dev/null @@ -1,591 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.ISelfValidate; -import microsoft.exchange.webservices.data.core.request.ServiceRequestBase; -import microsoft.exchange.webservices.data.core.enumeration.property.BasePropertySet; -import microsoft.exchange.webservices.data.core.enumeration.property.BodyType; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinitionBase; - -import javax.xml.stream.XMLStreamException; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * Represents a set of item or folder property. Property sets are used to - * indicate what property of an item or folder should be loaded when binding - * to an existing item or folder or when loading an item or folder's property. - */ -public final class PropertySet implements ISelfValidate, - Iterable { - - /** - * The Constant IdOnly. - */ - public static final PropertySet IdOnly = PropertySet. - createReadonlyPropertySet(BasePropertySet.IdOnly); - - /** - * Returns a predefined property set that only includes the Id property. - * - * @return Returns a predefined property set that only includes the Id - * property. - */ - public static PropertySet getIdOnly() { - return IdOnly; - } - - /** - * The Constant FirstClassProperties. - */ - public static final PropertySet FirstClassProperties = PropertySet. - createReadonlyPropertySet(BasePropertySet.FirstClassProperties); - - /** - * Returns a predefined property set that includes the first class - * property of an item or folder. - * - * @return A predefined property set that includes the first class - * property of an item or folder. - */ - public static PropertySet getFirstClassProperties() { - return FirstClassProperties; - } - - /** - * Maps BasePropertySet values to EWS's BaseShape values. - */ - private static LazyMember> defaultPropertySetMap = - new LazyMember>(new - ILazyMember>() { - @Override - public Map createInstance() { - Map result = new - HashMap(); - result.put(BasePropertySet.IdOnly, - BasePropertySet.IdOnly - .getBaseShapeValue()); - result.put(BasePropertySet.FirstClassProperties, - BasePropertySet.FirstClassProperties - .getBaseShapeValue()); - return result; - } - }); - /** - * The base property set this property set is based upon. - */ - private BasePropertySet basePropertySet; - - /** - * The list of additional property included in this property set. - */ - private List additionalProperties = new - ArrayList(); - - /** - * The requested body type for get and find operations. If null, the - * "best body" is returned. - */ - private BodyType requestedBodyType; - - /** - * Value indicating whether or not the server should filter HTML content. - */ - private Boolean filterHtml; - - /** - * Value indicating whether or not the server - * should convert HTML code page to UTF8. - */ - private Boolean convertHtmlCodePageToUTF8; - - /** - * Value indicating whether or not this PropertySet can be modified. - */ - private boolean isReadOnly; - - /** - * Initializes a new instance of PropertySet. - * - * @param basePropertySet The base property set to base the property set upon. - * @param additionalProperties Additional property to include in the property set. Property - * definitions are available as static members from schema - * classes (for example, EmailMessageSchema.Subject, - * AppointmentSchema.Start, ContactSchema.GivenName, etc.) - */ - public PropertySet(BasePropertySet basePropertySet, - PropertyDefinitionBase... additionalProperties) { - this.basePropertySet = basePropertySet; - if (null != additionalProperties) { - this.additionalProperties.addAll(Arrays.asList(additionalProperties)); - } - } - - /** - * Initializes a new instance of PropertySet. - * - * @param basePropertySet The base property set to base the property set upon. - * @param additionalProperties Additional property to include in the property set. Property - * definitions are available as static members from schema - * classes (for example, EmailMessageSchema.Subject, - * AppointmentSchema.Start, ContactSchema.GivenName, etc.) - */ - public PropertySet(BasePropertySet basePropertySet, - Iterator additionalProperties) { - this.basePropertySet = basePropertySet; - if (null != additionalProperties) { - while (additionalProperties.hasNext()) { - this.additionalProperties.add(additionalProperties.next()); - } - } - } - - /** - * Initializes a new instance of PropertySet based upon - * BasePropertySet.IdOnly. - */ - public PropertySet() { - this.basePropertySet = BasePropertySet.IdOnly; - } - - /** - * Initializes a new instance of PropertySet. - * - * @param basePropertySet The base property set to base the property set upon. - */ - public PropertySet(BasePropertySet basePropertySet) { - this.basePropertySet = basePropertySet; - } - - /** - * Initializes a new instance of PropertySet based upon - * BasePropertySet.IdOnly. - * - * @param additionalProperties Additional property to include in the property set. Property - * definitions are available as static members from schema - * classes (for example, EmailMessageSchema.Subject, - * AppointmentSchema.Start, ContactSchema.GivenName, etc.) - */ - public PropertySet(PropertyDefinitionBase... additionalProperties) { - this(BasePropertySet.IdOnly, additionalProperties); - } - - /** - * Initializes a new instance of PropertySet based upon - * BasePropertySet.IdOnly. - * - * @param additionalProperties Additional property to include in the property set. Property - * definitions are available as static members from schema - * classes (for example, EmailMessageSchema.Subject, - * AppointmentSchema.Start, ContactSchema.GivenName, etc.) - */ - public PropertySet(Iterator additionalProperties) { - this(BasePropertySet.IdOnly, additionalProperties); - } - - /** - * Implements an implicit conversion between - * PropertySet and BasePropertySet. - * - * @param basePropertySet The BasePropertySet value to convert from. - * @return A PropertySet instance based on the specified base property set. - */ - public static PropertySet getPropertySetFromBasePropertySet(BasePropertySet - basePropertySet) { - return new PropertySet(basePropertySet); - } - - - /** - * Adds the specified property to the property set. - * - * @param property The property to add. - * @throws Exception the exception - */ - public void add(PropertyDefinitionBase property) throws Exception { - this.throwIfReadonly(); - EwsUtilities.validateParam(property, "property"); - - if (!this.additionalProperties.contains(property)) { - this.additionalProperties.add(property); - } - } - - /** - * Adds the specified property to the property set. - * - * @param properties The property to add. - * @throws Exception the exception - */ - public void addRange(Iterable properties) - throws Exception { - this.throwIfReadonly(); - Iterator property = properties.iterator(); - EwsUtilities.validateParamCollection(property, "property"); - - for (Iterator it = properties.iterator(); it - .hasNext(); ) { - this.add(it.next()); - } - } - - /** - * Remove all explicitly added property from the property set. - */ - public void clear() { - this.throwIfReadonly(); - this.additionalProperties.clear(); - } - - /** - * Creates a read-only PropertySet. - * - * @param basePropertySet The base property set. - * @return PropertySet - */ - private static PropertySet createReadonlyPropertySet( - BasePropertySet basePropertySet) { - PropertySet propertySet = new PropertySet(basePropertySet); - propertySet.isReadOnly = true; - return propertySet; - } - - /** - * Throws if readonly property set. - */ - private void throwIfReadonly() { - if (this.isReadOnly) { - throw new UnsupportedOperationException("This PropertySet is read-only and can't be modified."); - } - } - - /** - * Determines whether the specified property has been explicitly added to - * this property set using the Add or AddRange methods. - * - * @param property The property. - * @return true if this property set contains the specified property - * otherwise, false - */ - public boolean contains(PropertyDefinitionBase property) { - return this.additionalProperties.contains(property); - } - - /** - * Removes the specified property from the set. - * - * @param property The property to remove. - * @return true if the property was successfully removed, false otherwise. - */ - public boolean remove(PropertyDefinitionBase property) { - this.throwIfReadonly(); - return this.additionalProperties.remove(property); - } - - /** - * Gets the base property set, the property set is based upon. - * - * @return the base property set - */ - public BasePropertySet getBasePropertySet() { - return this.basePropertySet; - } - - /** - * Maps BasePropertySet values to EWS's BaseShape values. - * - * @return the base property set - */ - public static LazyMember> getDefaultPropertySetMap() { - return PropertySet.defaultPropertySetMap; - - } - - /** - * Sets the base property set, the property set is based upon. - * - * @param basePropertySet Base property set. - */ - public void setBasePropertySet(BasePropertySet basePropertySet) { - this.throwIfReadonly(); - this.basePropertySet = basePropertySet; - } - - /** - * Gets type of body that should be loaded on item. If RequestedBodyType - * is null, body is returned as HTML if available, plain text otherwise. - * - * @return the requested body type - */ - public BodyType getRequestedBodyType() { - return this.requestedBodyType; - } - - /** - * Sets type of body that should be loaded on item. If RequestedBodyType is - * null, body is returned as HTML if available, plain text otherwise. - * - * @param requestedBodyType Type of body that should be loaded on item. - */ - public void setRequestedBodyType(BodyType requestedBodyType) { - this.throwIfReadonly(); - this.requestedBodyType = requestedBodyType; - } - - /** - * Gets the number of explicitly added property in this set. - * - * @return the count - */ - public int getCount() { - return this.additionalProperties.size(); - } - - /** - * Gets value indicating whether or not to filter potentially unsafe HTML - * content from message bodies. - * - * @return the filter html content - */ - public Boolean getFilterHtmlContent() { - return this.filterHtml; - } - - /** - * Sets value indicating whether or not to filter potentially unsafe HTML - * content from message bodies. - * - * @param filterHtml true to filter otherwise false. - */ - public void setFilterHtmlContent(Boolean filterHtml) { - this.throwIfReadonly(); - this.filterHtml = filterHtml; - } - - - - /** - * Gets value indicating whether or not to convert - * HTML code page to UTF8 encoding. - */ - public Boolean getConvertHtmlCodePageToUTF8() { - return this.convertHtmlCodePageToUTF8; - - } - - /** - * Sets value indicating whether or not to - * convert HTML code page to UTF8 encoding. - */ - public void setConvertHtmlCodePageToUTF8(Boolean value) { - this.throwIfReadonly(); - this.convertHtmlCodePageToUTF8 = value; - - } - - - /** - * Gets the PropertyDefinitionBase at the specified index. - * - * @param index Index. - * @return the property definition base at - */ - public PropertyDefinitionBase getPropertyDefinitionBaseAt(int index) { - return this.additionalProperties.get(index); - } - - - /** - * Validate. - * - * @throws ServiceValidationException the service validation exception - */ - @Override - public void validate() throws ServiceValidationException { - this.internalValidate(); - } - - /** - * Writes additional property to XML. - * - * @param writer The writer to write to - * @param propertyDefinitions The property definitions to write - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public static void writeAdditionalPropertiesToXml(EwsServiceXmlWriter writer, - Iterator propertyDefinitions) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.AdditionalProperties); - - while (propertyDefinitions.hasNext()) { - PropertyDefinitionBase propertyDefinition = propertyDefinitions - .next(); - propertyDefinition.writeToXml(writer); - } - - writer.writeEndElement(); - } - - /** - * Validates this property set. - * - * @throws ServiceValidationException the service validation exception - */ - public void internalValidate() throws ServiceValidationException { - for (int i = 0; i < this.additionalProperties.size(); i++) { - if (this.additionalProperties.get(i) == null) { - throw new ServiceValidationException(String.format("The additional property at index %d is null.", i)); - } - } - } - - /** - * Validates this property set instance for request to ensure that: 1. - * Properties are valid for the request server version 2. If only summary - * property are legal for this request (e.g. FindItem) then only summary - * property were specified. - * - * @param request The request. - * @param summaryPropertiesOnly if set to true then only summary property are allowed. - * @throws ServiceVersionException the service version exception - * @throws ServiceValidationException the service validation exception - */ - public void validateForRequest(ServiceRequestBase request, boolean summaryPropertiesOnly) throws ServiceVersionException, - ServiceValidationException { - for (PropertyDefinitionBase propDefBase : this.additionalProperties) { - if (propDefBase instanceof PropertyDefinition) { - PropertyDefinition propertyDefinition = - (PropertyDefinition) propDefBase; - if (propertyDefinition.getVersion().ordinal() > request - .getService().getRequestedServerVersion().ordinal()) { - throw new ServiceVersionException(String.format( - "The property %s is valid only for Exchange %s or later versions.", - propertyDefinition.getName(), propertyDefinition - .getVersion())); - } - - if (summaryPropertiesOnly && - !propertyDefinition.hasFlag( - PropertyDefinitionFlags.CanFind, request. - getService().getRequestedServerVersion())) { - throw new ServiceValidationException(String.format("The property %s can't be used in %s request.", - propertyDefinition.getName(), request - .getXmlElementName())); - } - } - } - if (this.getFilterHtmlContent() != null) { - if (request.getService().getRequestedServerVersion().compareTo(ExchangeVersion.Exchange2010) < 0) { - throw new ServiceVersionException( - String.format("The property %s is valid only for Exchange %s or later versions.", - "FilterHtmlContent", - ExchangeVersion.Exchange2010)); - } - } - - if (this.getConvertHtmlCodePageToUTF8() != null) { - if (request.getService().getRequestedServerVersion().compareTo(ExchangeVersion.Exchange2010_SP1) < 0) { - throw new ServiceVersionException( - String.format("The property %s is valid only for Exchange %s or later versions.", - "ConvertHtmlCodePageToUTF8", - ExchangeVersion.Exchange2010_SP1)); - } - } - } - - /** - * Writes the property set to XML. - * - * @param writer The writer to write to - * @param serviceObjectType The type of service object the property set is emitted for - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeToXml(EwsServiceXmlWriter writer, ServiceObjectType serviceObjectType) throws XMLStreamException, ServiceXmlSerializationException { - writer - .writeStartElement( - XmlNamespace.Messages, - serviceObjectType == ServiceObjectType.Item ? - XmlElementNames.ItemShape - : XmlElementNames.FolderShape); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.BaseShape, - this.getBasePropertySet().getBaseShapeValue()); - - if (serviceObjectType == ServiceObjectType.Item) { - if (this.getRequestedBodyType() != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.BodyType, this.getRequestedBodyType()); - } - - if (this.getFilterHtmlContent() != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.FilterHtmlContent, this - .getFilterHtmlContent()); - } - if ((this.getConvertHtmlCodePageToUTF8() != null) && - writer.getService().getRequestedServerVersion(). - compareTo(ExchangeVersion.Exchange2010_SP1) >= 0) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.ConvertHtmlCodePageToUTF8, - this.getConvertHtmlCodePageToUTF8()); - } - } - - if (this.additionalProperties.size() > 0) { - writeAdditionalPropertiesToXml(writer, this.additionalProperties - .iterator()); - } - - writer.writeEndElement(); // Item/FolderShape - } - - /* - * (non-Javadoc) - * - * @see java.lang.Iterable#iterator() - */ - @Override - public Iterator iterator() { - return this.additionalProperties.iterator(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/SimplePropertyBag.java b/src/main/java/microsoft/exchange/webservices/data/core/SimplePropertyBag.java deleted file mode 100644 index b6f4d2f2a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/SimplePropertyBag.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.complex.IPropertyBagChangedDelegate; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * Represents a simple property bag. - * - * @param The type of key - */ -public class SimplePropertyBag implements Iterable> { - - /** - * The item. - */ - private Map items = new HashMap(); - - /** - * The removed item. - */ - private List removedItems = new ArrayList(); - - /** - * The added item. - */ - private List addedItems = new ArrayList(); - - /** - * The modified item. - */ - private List modifiedItems = new ArrayList(); - - /** - * Add item to change list. - * - * @param key the key - * @param changeList the change list - */ - private void internalAddItemToChangeList(TKey key, List changeList) { - if (!changeList.contains(key)) { - changeList.add(key); - } - } - - /** - * Triggers dispatch of the change event. - */ - private void changed() { - if (!onChange.isEmpty()) { - for (IPropertyBagChangedDelegate change : onChange) { - change.propertyBagChanged(this); - } - } - } - - /** - * Remove item. - * - * @param key the key - */ - private void internalRemoveItem(TKey key) { - OutParam value = new OutParam(); - if (this.tryGetValue(key, value)) { - this.items.remove(key); - this.removedItems.add(key); - this.changed(); - } - } - - - /** - * Gets the added item. The added item. - * - * @return the added item - */ - public Iterable getAddedItems() { - return this.addedItems; - } - - /** - * Gets the removed item. The removed item. - * - * @return the removed item - */ - public Iterable getRemovedItems() { - return this.removedItems; - } - - /** - * Gets the modified item. The modified item. - * - * @return the modified item - */ - public Iterable getModifiedItems() { - return this.modifiedItems; - } - - /** - * Initializes a new instance of the class. - */ - public SimplePropertyBag() { - } - - /** - * Clears the change log. - */ - public void clearChangeLog() { - this.removedItems.clear(); - this.addedItems.clear(); - this.modifiedItems.clear(); - } - - /** - * Determines whether the specified key is in the property bag. - * - * @param key the key - * @return true, if successful if the specified key exists; otherwise, . - */ - public boolean containsKey(TKey key) { - return this.items.containsKey(key); - } - - /** - * Tries to get value. - * - * @param key the key - * @param value the value - * @return True if value exists in property bag. - */ - public boolean tryGetValue(TKey key, OutParam value) { - if (this.items.containsKey(key)) { - value.setParam(this.items.get(key)); - return true; - } else { - value.setParam(null); - return false; - } - } - - /** - * Gets the simple property bag. - * - * @param key the key - * @return the simple property bag - */ - public Object getSimplePropertyBag(TKey key) { - OutParam value = new OutParam(); - if (this.tryGetValue(key, value)) { - return value.getParam(); - } else { - return null; - } - } - - /** - * Sets the simple property bag. - * - * @param key the key - * @param value the value - */ - public void setSimplePropertyBag(TKey key, Object value) { - if (value == null) { - this.internalRemoveItem(key); - } else { - // If the item was to be deleted, the deletion becomes an update. - if (this.removedItems.remove(key)) { - internalAddItemToChangeList(key, this.modifiedItems); - } else { - // If the property value was not set, we have a newly set - // property. - if (!this.containsKey(key)) { - internalAddItemToChangeList(key, this.addedItems); - } else { - // The last case is that we have a modified property. - if (!this.modifiedItems.contains(key)) { - internalAddItemToChangeList(key, this.modifiedItems); - } - } - } - - this.items.put(key, value); - this.changed(); - } - } - - /** - * Occurs when Changed. - */ - private List> onChange = - new ArrayList>(); - - /** - * Set event to happen when property changed. - * - * @param change change event - */ - public void addOnChangeEvent(IPropertyBagChangedDelegate change) { - onChange.add(change); - } - - /** - * Remove the event from happening when property changed. - * - * @param change change event - */ - public void removeChangeEvent(IPropertyBagChangedDelegate change) { - onChange.remove(change); - } - - /** - * Returns an iterator over a set of elements of type T. - * - * @return an Iterator. - */ - @Override - public Iterator> iterator() { - return (Iterator>) this.items.keySet().iterator(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/WebAsyncCallStateAnchor.java b/src/main/java/microsoft/exchange/webservices/data/core/WebAsyncCallStateAnchor.java deleted file mode 100644 index a2358bd84..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/WebAsyncCallStateAnchor.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.core.request.HttpWebRequest; -import microsoft.exchange.webservices.data.core.request.ServiceRequestBase; -import microsoft.exchange.webservices.data.misc.AsyncCallback; - -public class WebAsyncCallStateAnchor { - - ServiceRequestBase serviceRequest; - HttpWebRequest webRequest; - AsyncCallback asyncCallback; - Object asyncState; - - public WebAsyncCallStateAnchor(ServiceRequestBase serviceRequest, - HttpWebRequest webRequest, - AsyncCallback asyncCallback, - Object asyncState) - throws Exception { - EwsUtilities.validateParam(serviceRequest, "serviceRequest"); - EwsUtilities.validateParam(webRequest, "webRequest"); - this.serviceRequest = serviceRequest; - this.webRequest = webRequest; - this.asyncCallback = asyncCallback; - this.asyncState = asyncState; - } - - public ServiceRequestBase getServiceRequest() { - return this.serviceRequest; - } - - public void setAsyncCallback(AsyncCallback asyncCallback) { - this.asyncCallback = asyncCallback; - } - - public AsyncCallback getAsyncCallback() { - return this.asyncCallback; - } - - public void setServiceRequest(ServiceRequestBase wasserviceRequest) { - serviceRequest = wasserviceRequest; - } - - public void setHttpWebRequest(HttpWebRequest waswebRequest) { - webRequest = waswebRequest; - } - - public HttpWebRequest getHttpWebRequest() { - return this.webRequest; - } - - public void setAsynncState(Object wasasyncState) { - asyncState = wasasyncState; - } - - public Object getAsyncState() { - return this.asyncState; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/WebProxy.java b/src/main/java/microsoft/exchange/webservices/data/core/WebProxy.java deleted file mode 100644 index 5f814fa13..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/WebProxy.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.credential.WebProxyCredentials; - -/** - * WebProxy is used for setting proxy details for proxy authentication schemes such as - * basic, digest, NTLM, and Kerberos authentication. - */ -public class WebProxy { - - private String host; - - private int port; - - private WebProxyCredentials credentials; - - - /** - * Initializes a new instance to use specified proxy details. - * - * @param host proxy host. - * @param port proxy port. - */ - public WebProxy(String host, int port) { - this.host = host; - this.port = port; - } - - /** - * Initializes a new instance to use specified proxy with default port 80. - * - * @param host proxy host. - */ - public WebProxy(String host) { - this.host = host; - this.port = 80; - } - - /** - * Initializes a new instance to use specified proxy with default port 80. - * - * @param host proxy host. - * @param credentials the credential to use for the proxy. - */ - public WebProxy(String host, WebProxyCredentials credentials) { - this.host = host; - this.credentials = credentials; - } - - /** - * Initializes a new instance to use specified proxy details. - * - * @param host proxy host. - * @param port proxy port. - * @param credentials the credential to use for the proxy. - */ - public WebProxy(String host, int port, WebProxyCredentials credentials) { - this.host = host; - this.port = port; - this.credentials = credentials; - } - - /** - * Gets the Proxy Host. - * - * @return the host - */ - public String getHost() { - return this.host; - } - - /** - * Gets the Proxy Port. - * - * @return the port - */ - public int getPort() { - return this.port; - } - - public boolean hasCredentials() { - return credentials != null; - } - - /** - * Gets the Proxy Credentials. - * - * @return the proxy credential - */ - public WebProxyCredentials getCredentials() { - return credentials; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/XmlAttributeNames.java b/src/main/java/microsoft/exchange/webservices/data/core/XmlAttributeNames.java deleted file mode 100644 index c1d97c3e0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/XmlAttributeNames.java +++ /dev/null @@ -1,386 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -/** - * XML attribute names. - */ -public class XmlAttributeNames { - - /** - * The Constant XmlNs. - */ - public static final String XmlNs = "xmlns"; - - /** - * The Constant Id. - */ - public static final String Id = "Id"; - - /** - * The Constant ChangeKey. - */ - public static final String ChangeKey = "ChangeKey"; - - /** - * The Constant RecurringMasterId. - */ - public static final String RecurringMasterId = "RecurringMasterId"; - - /** - * The Constant InstanceIndex. - */ - public static final String InstanceIndex = "InstanceIndex"; - - /** - * The Constant OccurrenceId. - */ - public static final String OccurrenceId = "OccurrenceId"; - - /** - * The Constant Traversal. - */ - public static final String Traversal = "Traversal"; - - /** - * The Constant Offset. - */ - public static final String Offset = "Offset"; - - /** - * The Constant MaxEntriesReturned. - */ - public static final String MaxEntriesReturned = "MaxEntriesReturned"; - - /** - * The Constant BasePoint. - */ - public static final String BasePoint = "BasePoint"; - - /** - * The Constant ResponseClass. - */ - public static final String ResponseClass = "ResponseClass"; - - /** - * The Constant IndexedPagingOffset. - */ - public static final String IndexedPagingOffset = "IndexedPagingOffset"; - - /** - * The Constant TotalItemsInView. - */ - public static final String TotalItemsInView = "TotalItemsInView"; - - /** - * The Constant IncludesLastItemInRange. - */ - public static final String IncludesLastItemInRange = - "IncludesLastItemInRange"; - - /** - * The Constant BodyType. - */ - public static final String BodyType = "BodyType"; - - /** - * The Constant MessageDisposition. - */ - public static final String MessageDisposition = "MessageDisposition"; - - /** - * The Constant SaveItemToFolder. - */ - public static final String SaveItemToFolder = "SaveItemToFolder"; - - /** - * The Constant RootItemChangeKey. - */ - public static final String RootItemChangeKey = "RootItemChangeKey"; - - /** - * The Constant DeleteType. - */ - public static final String DeleteType = "DeleteType"; - - /** - * The Constant DeleteSubFolders. - */ - public static final String DeleteSubFolders = "DeleteSubFolders"; - - /** - * The Constant AffectedTaskOccurrences. - */ - public static final String AffectedTaskOccurrences = - "AffectedTaskOccurrences"; - - /** - * The Constant SendMeetingCancellations. - */ - public static final String SendMeetingCancellations = - "SendMeetingCancellations"; - - /** - * The Constant FieldURI. - */ - public static final String FieldURI = "FieldURI"; - - /** - * The Constant FieldIndex. - */ - public static final String FieldIndex = "FieldIndex"; - - /** - * The Constant ConflictResolution. - */ - public static final String ConflictResolution = "ConflictResolution"; - - /** - * The Constant SendMeetingInvitationsOrCancellations. - */ - public static final String SendMeetingInvitationsOrCancellations = - "SendMeetingInvitationsOrCancellations"; - - /** - * The Constant CharacterSet. - */ - public static final String CharacterSet = "CharacterSet"; - - /** - * The Constant HeaderName. - */ - public static final String HeaderName = "HeaderName"; - - /** - * The Constant SendMeetingInvitations. - */ - public static final String SendMeetingInvitations = - "SendMeetingInvitations"; - - /** - * The Constant Key. - */ - public static final String Key = "Key"; - - /** - * The Constant RoutingType. - */ - public static final String RoutingType = "RoutingType"; - - /** - * The Constant MailboxType. - */ - public static final String MailboxType = "MailboxType"; - - /** - * The Constant DistinguishedPropertySetId. - */ - public static final String DistinguishedPropertySetId = - "DistinguishedPropertySetId"; - - /** - * The Constant PropertySetId. - */ - public static final String PropertySetId = "PropertySetId"; - - /** - * The Constant PropertyTag. - */ - public static final String PropertyTag = "PropertyTag"; - - /** - * The Constant PropertyName. - */ - public static final String PropertyName = "PropertyName"; - - /** - * The Constant PropertyId. - */ - public static final String PropertyId = "PropertyId"; - - /** - * The Constant PropertyType. - */ - public static final String PropertyType = "PropertyType"; - - /** - * The Constant TimeZoneName. - */ - public static final String TimeZoneName = "TimeZoneName"; - - /** - * The Constant ReturnFullContactData. - */ - public static final String ReturnFullContactData = "ReturnFullContactData"; - - /** - * The Constant ContactDataShape. - */ - public static final String ContactDataShape = "ContactDataShape"; - - /** - * The Constant Numerator. - */ - public static final String Numerator = "Numerator"; - - /** - * The Constant Denominator. - */ - public static final String Denominator = "Numerator"; - - /** - * The Constant Value. - */ - public static final String Value = "Value"; - - /** - * The Constant ContainmentMode. - */ - public static final String ContainmentMode = "ContainmentMode"; - - /** - * The Constant ContainmentComparison. - */ - public static final String ContainmentComparison = "ContainmentComparison"; - - /** - * The Constant Order. - */ - public static final String Order = "Order"; - - /** - * The Constant StartDate. - */ - public static final String StartDate = "StartDate"; - - /** - * The Constant EndDate. - */ - public static final String EndDate = "EndDate"; - - /** - * The Constant Version. - */ - public static final String Version = "Version"; - - /** - * The Constant Aggregate. - */ - public static final String Aggregate = "Aggregate"; - - /** - * The Constant SearchScope. - */ - public static final String SearchScope = "SearchScope"; - - /** - * The Constant Format. - */ - public static final String Format = "Format"; - - /** - * The Constant Mailbox. - */ - public static final String Mailbox = "Mailbox"; - - /** - * The Constant DestinationFormat. - */ - public static final String DestinationFormat = "DestinationFormat"; - - /** - * The Constant FolderId. - */ - public static final String FolderId = "FolderId"; - - /** - * The Constant ItemId. - */ - public static final String ItemId = "ItemId"; - - /** - * The Constant IncludePermissions. - */ - public static final String IncludePermissions = "IncludePermissions"; - - /** - * The Constant InitialName. - */ - public static final String InitialName = "InitialName"; - - /** - * The Constant FinalName. - */ - public static final String FinalName = "FinalName"; - - /** - * The Constant AuthenticationMethod. - */ - public static final String AuthenticationMethod = "AuthenticationMethod"; - - /** - * The Constant Time. - */ - public static final String Time = "Time"; - - /** - * The Constant Name. - */ - public static final String Name = "Name"; - - /** - * The Constant Bias. - */ - public static final String Bias = "Bias"; - - /** - * The Constant Kind. - */ - public static final String Kind = "Kind"; - - /** - * The Constant SubscribeToAllFolders. - */ - public static final String SubscribeToAllFolders = "SubscribeToAllFolders"; - - /** - * The Constant PublicFolderServer. - */ - public static final String PublicFolderServer = "PublicFolderServer"; - - /** - * The Constant IsArchive. - */ - public static final String IsArchive = "IsArchive"; - // xsi attribute - /** - * The Constant Nil. - */ - public static final String Nil = "nil"; - - /** - * The Constant Type. - */ - public static final String Type = "type"; -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/XmlElementNames.java b/src/main/java/microsoft/exchange/webservices/data/core/XmlElementNames.java deleted file mode 100644 index 8fca4f048..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/XmlElementNames.java +++ /dev/null @@ -1,4788 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -/** - * XML element names. - */ -public class XmlElementNames { - - /** - * The Constant AllProperties. - */ - public static final String AllProperties = "AllProperties"; - - /** - * The Constant ParentFolderIds. - */ - public static final String ParentFolderIds = "ParentFolderIds"; - - /** - * The Constant DistinguishedFolderId. - */ - public static final String DistinguishedFolderId = "DistinguishedFolderId"; - - /** - * The Constant ItemId. - */ - public static final String ItemId = "ItemId"; - - /** - * The Constant ItemIds. - */ - public static final String ItemIds = "ItemIds"; - - /** - * The Constant FolderId. - */ - public static final String FolderId = "FolderId"; - - /** - * The Constant FolderIds. - */ - public static final String FolderIds = "FolderIds"; - - /** - * The Constant OccurrenceItemId. - */ - public static final String OccurrenceItemId = "OccurrenceItemId"; - - /** - * The Constant RecurringMasterItemId. - */ - public static final String RecurringMasterItemId = "RecurringMasterItemId"; - - /** - * The Constant ItemShape. - */ - public static final String ItemShape = "ItemShape"; - - /** - * The Constant FolderShape. - */ - public static final String FolderShape = "FolderShape"; - - /** - * The Constant BaseShape. - */ - public static final String BaseShape = "BaseShape"; - - /** - * The Constant IndexedPageItemView. - */ - public static final String IndexedPageItemView = "IndexedPageItemView"; - - /** - * The Constant IndexedPageFolderView. - */ - public static final String IndexedPageFolderView = "IndexedPageFolderView"; - - /** - * The Constant FractionalPageItemView. - */ - public static final String FractionalPageItemView = "FractionalPageItemView"; - - /** - * The Constant FractionalPageFolderView. - */ - public static final String FractionalPageFolderView = - "FractionalPageFolderView"; - - /** - * The Constant ResponseCode. - */ - public static final String ResponseCode = "ResponseCode"; - - /** - * The Constant RootFolder. - */ - public static final String RootFolder = "RootFolder"; - - /** - * The Constant Folder. - */ - public static final String Folder = "Folder"; - - /** - * The Constant ContactsFolder. - */ - public static final String ContactsFolder = "ContactsFolder"; - - /** - * The Constant TasksFolder. - */ - public static final String TasksFolder = "TasksFolder"; - - /** - * The Constant SearchFolder. - */ - public static final String SearchFolder = "SearchFolder"; - - /** - * The Constant Folders. - */ - public static final String Folders = "Folders"; - - /** - * The Constant Item. - */ - public static final String Item = "Item"; - - /** - * The Constant Items. - */ - public static final String Items = "Items"; - - /** - * The Constant Message. - */ - public static final String Message = "Message"; - - /** - * The Constant Mailbox. - */ - public static final String Mailbox = "Mailbox"; - - /** - * The Constant Body. - */ - public static final String Body = "Body"; - - /** - * The Constant From. - */ - public static final String From = "From"; - - /** - * The Constant Sender. - */ - public static final String Sender = "Sender"; - - /** - * The Constant Name. - */ - public static final String Name = "Name"; - - /** - * The Constant Address. - */ - public static final String Address = "Address"; - - /** - * The Constant EmailAddress. - */ - public static final String EmailAddress = "EmailAddress"; - - /** - * The Constant RoutingType. - */ - public static final String RoutingType = "RoutingType"; - - /** - * The Constant MailboxType. - */ - public static final String MailboxType = "MailboxType"; - - /** - * The Constant ToRecipients. - */ - public static final String ToRecipients = "ToRecipients"; - - /** - * The Constant CcRecipients. - */ - public static final String CcRecipients = "CcRecipients"; - - /** - * The Constant BccRecipients. - */ - public static final String BccRecipients = "BccRecipients"; - - /** - * The Constant ReplyTo. - */ - public static final String ReplyTo = "ReplyTo"; - - /** - * The Constant ConversationTopic. - */ - public static final String ConversationTopic = "ConversationTopic"; - - /** - * The Constant ConversationIndex. - */ - public static final String ConversationIndex = "ConversationIndex"; - - /** - * The Constant IsDeliveryReceiptRequested. - */ - public static final String IsDeliveryReceiptRequested = - "IsDeliveryReceiptRequested"; - - /** - * The Constant IsRead. - */ - public static final String IsRead = "IsRead"; - - /** - * The Constant IsReadReceiptRequested. - */ - public static final String IsReadReceiptRequested = "IsReadReceiptRequested"; - - /** - * The Constant IsResponseRequested. - */ - public static final String IsResponseRequested = "IsResponseRequested"; - - /** - * The Constant InternetMessageId. - */ - public static final String InternetMessageId = "InternetMessageId"; - - /** - * The Constant References. - */ - public static final String References = "References"; - - /** - * The Constant ParentItemId. - */ - public static final String ParentItemId = "ParentItemId"; - - /** - * The Constant ParentFolderId. - */ - public static final String ParentFolderId = "ParentFolderId"; - - /** - * The Constant ChildFolderCount. - */ - public static final String ChildFolderCount = "ChildFolderCount"; - - /** - * The Constant DisplayName. - */ - public static final String DisplayName = "DisplayName"; - - /** - * The Constant TotalCount. - */ - public static final String TotalCount = "TotalCount"; - - /** - * The Constant ItemClass. - */ - public static final String ItemClass = "ItemClass"; - - /** - * The Constant FolderClass. - */ - public static final String FolderClass = "FolderClass"; - - /** - * The Constant Subject. - */ - public static final String Subject = "Subject"; - - /** - * The Constant MimeContent. - */ - public static final String MimeContent = "MimeContent"; - - /** - * The Constant Sensitivity. - */ - public static final String Sensitivity = "Sensitivity"; - - /** - * The Constant Attachments. - */ - public static final String Attachments = "Attachments"; - - /** - * The Constant DateTimeReceived. - */ - public static final String DateTimeReceived = "DateTimeReceived"; - - /** - * The Constant Size. - */ - public static final String Size = "Size"; - - /** - * The Constant Categories. - */ - public static final String Categories = "Categories"; - - /** - * The Constant Importance. - */ - public static final String Importance = "Importance"; - - /** - * The Constant InReplyTo. - */ - public static final String InReplyTo = "InReplyTo"; - - /** - * The Constant IsSubmitted. - */ - public static final String IsSubmitted = "IsSubmitted"; - - /** - * The Constant IsAssociated. - */ - public static final String IsAssociated = "IsAssociated"; - - /** - * The Constant IsDraft. - */ - public static final String IsDraft = "IsDraft"; - - /** - * The Constant IsFromMe. - */ - public static final String IsFromMe = "IsFromMe"; - - /** - * The Constant IsResend. - */ - public static final String IsResend = "IsResend"; - - /** - * The Constant IsUnmodified. - */ - public static final String IsUnmodified = "IsUnmodified"; - - /** - * The Constant InternetMessageHeader. - */ - public static final String InternetMessageHeader = "InternetMessageHeader"; - - /** - * The Constant InternetMessageHeaders. - */ - public static final String InternetMessageHeaders = "InternetMessageHeaders"; - - /** - * The Constant DateTimeSent. - */ - public static final String DateTimeSent = "DateTimeSent"; - - /** - * The Constant DateTimeCreated. - */ - public static final String DateTimeCreated = "DateTimeCreated"; - - /** - * The Constant ResponseObjects. - */ - public static final String ResponseObjects = "ResponseObjects"; - - /** - * The Constant ReminderDueBy. - */ - public static final String ReminderDueBy = "ReminderDueBy"; - - /** - * The Constant ReminderIsSet. - */ - public static final String ReminderIsSet = "ReminderIsSet"; - - /** - * The Constant ReminderMinutesBeforeStart. - */ - public static final String ReminderMinutesBeforeStart = - "ReminderMinutesBeforeStart"; - - /** - * The Constant DisplayCc. - */ - public static final String DisplayCc = "DisplayCc"; - - /** - * The Constant DisplayTo. - */ - public static final String DisplayTo = "DisplayTo"; - - /** - * The Constant HasAttachments. - */ - public static final String HasAttachments = "HasAttachments"; - - /** - * The Constant ExtendedProperty. - */ - public static final String ExtendedProperty = "ExtendedProperty"; - - /** - * The Constant Culture. - */ - public static final String Culture = "Culture"; - - /** - * The Constant FileAttachment. - */ - public static final String FileAttachment = "FileAttachment"; - - /** - * The Constant ItemAttachment. - */ - public static final String ItemAttachment = "ItemAttachment"; - - /** - * The Constant AttachmentIds. - */ - public static final String AttachmentIds = "AttachmentIds"; - - /** - * The Constant AttachmentId. - */ - public static final String AttachmentId = "AttachmentId"; - - /** - * The Constant ContentType. - */ - public static final String ContentType = "ContentType"; - - /** - * The Constant ContentLocation. - */ - public static final String ContentLocation = "ContentLocation"; - - /** - * The Constant ContentId. - */ - public static final String ContentId = "ContentId"; - - /** - * The Constant Content. - */ - public static final String Content = "Content"; - - /** - * The Constant SavedItemFolderId. - */ - public static final String SavedItemFolderId = "SavedItemFolderId"; - - /** - * The Constant MessageText. - */ - public static final String MessageText = "MessageText"; - - /** - * The Constant DescriptiveLinkKey. - */ - public static final String DescriptiveLinkKey = "DescriptiveLinkKey"; - - /** - * The Constant ItemChange. - */ - public static final String ItemChange = "ItemChange"; - - /** - * The Constant ItemChanges. - */ - public static final String ItemChanges = "ItemChanges"; - - /** - * The Constant FolderChange. - */ - public static final String FolderChange = "FolderChange"; - - /** - * The Constant FolderChanges. - */ - public static final String FolderChanges = "FolderChanges"; - - /** - * The Constant Updates. - */ - public static final String Updates = "Updates"; - - /** - * The Constant AppendToItemField. - */ - public static final String AppendToItemField = "AppendToItemField"; - - /** - * The Constant SetItemField. - */ - public static final String SetItemField = "SetItemField"; - - /** - * The Constant DeleteItemField. - */ - public static final String DeleteItemField = "DeleteItemField"; - - /** - * The Constant SetFolderField. - */ - public static final String SetFolderField = "SetFolderField"; - - /** - * The Constant DeleteFolderField. - */ - public static final String DeleteFolderField = "DeleteFolderField"; - - /** - * The Constant FieldURI. - */ - public static final String FieldURI = "FieldURI"; - - /** - * The Constant RootItemId. - */ - public static final String RootItemId = "RootItemId"; - - /** - * The Constant ReferenceItemId. - */ - public static final String ReferenceItemId = "ReferenceItemId"; - - /** - * The Constant NewBodyContent. - */ - public static final String NewBodyContent = "NewBodyContent"; - - /** - * The Constant ReplyToItem. - */ - public static final String ReplyToItem = "ReplyToItem"; - - /** - * The Constant ReplyAllToItem. - */ - public static final String ReplyAllToItem = "ReplyAllToItem"; - - /** - * The Constant ForwardItem. - */ - public static final String ForwardItem = "ForwardItem"; - - /** - * The Constant AcceptItem. - */ - public static final String AcceptItem = "AcceptItem"; - - /** - * The Constant TentativelyAcceptItem. - */ - public static final String TentativelyAcceptItem = "TentativelyAcceptItem"; - - /** - * The Constant DeclineItem. - */ - public static final String DeclineItem = "DeclineItem"; - - /** - * The Constant CancelCalendarItem. - */ - public static final String CancelCalendarItem = "CancelCalendarItem"; - - /** - * The Constant RemoveItem. - */ - public static final String RemoveItem = "RemoveItem"; - - /** - * The Constant SuppressReadReceipt. - */ - public static final String SuppressReadReceipt = "SuppressReadReceipt"; - - /** - * The Constant String. - */ - public static final String String = "String"; - - /** - * The Constant Start. - */ - public static final String Start = "Start"; - - /** - * The Constant End. - */ - public static final String End = "End"; - - /** - * The Constant OriginalStart. - */ - public static final String OriginalStart = "OriginalStart"; - - /** - * The Constant IsAllDayEvent. - */ - public static final String IsAllDayEvent = "IsAllDayEvent"; - - /** - * The Constant LegacyFreeBusyStatus. - */ - public static final String LegacyFreeBusyStatus = "LegacyFreeBusyStatus"; - - /** - * The Constant Location. - */ - public static final String Location = "Location"; - - /** - * The Constant When. - */ - public static final String When = "When"; - - /** - * The Constant IsMeeting. - */ - public static final String IsMeeting = "IsMeeting"; - - /** - * The Constant IsCancelled. - */ - public static final String IsCancelled = "IsCancelled"; - - /** - * The Constant IsRecurring. - */ - public static final String IsRecurring = "IsRecurring"; - - /** - * The Constant MeetingRequestWasSent. - */ - public static final String MeetingRequestWasSent = "MeetingRequestWasSent"; - - /** - * The Constant CalendarItemType. - */ - public static final String CalendarItemType = "CalendarItemType"; - - /** - * The Constant MyResponseType. - */ - public static final String MyResponseType = "MyResponseType"; - - /** - * The Constant Organizer. - */ - public static final String Organizer = "Organizer"; - - /** - * The Constant RequiredAttendees. - */ - public static final String RequiredAttendees = "RequiredAttendees"; - - /** - * The Constant OptionalAttendees. - */ - public static final String OptionalAttendees = "OptionalAttendees"; - - /** - * The Constant Resources. - */ - public static final String Resources = "Resources"; - - /** - * The Constant ConflictingMeetingCount. - */ - public static final String ConflictingMeetingCount = - "ConflictingMeetingCount"; - - /** - * The Constant AdjacentMeetingCount. - */ - public static final String AdjacentMeetingCount = "AdjacentMeetingCount"; - - /** - * The Constant ConflictingMeetings. - */ - public static final String ConflictingMeetings = "ConflictingMeetings"; - - /** - * The Constant AdjacentMeetings. - */ - public static final String AdjacentMeetings = "AdjacentMeetings"; - - /** - * The Constant Duration. - */ - public static final String Duration = "Duration"; - - /** - * The Constant TimeZone. - */ - public static final String TimeZone = "TimeZone"; - - /** - * The Constant AppointmentReplyTime. - */ - public static final String AppointmentReplyTime = "AppointmentReplyTime"; - - /** - * The Constant AppointmentSequenceNumber. - */ - public static final String AppointmentSequenceNumber = - "AppointmentSequenceNumber"; - - /** - * The Constant AppointmentState. - */ - public static final String AppointmentState = "AppointmentState"; - - /** - * The Constant Recurrence. - */ - public static final String Recurrence = "Recurrence"; - - /** - * The Constant FirstOccurrence. - */ - public static final String FirstOccurrence = "FirstOccurrence"; - - /** - * The Constant LastOccurrence. - */ - public static final String LastOccurrence = "LastOccurrence"; - - /** - * The Constant ModifiedOccurrences. - */ - public static final String ModifiedOccurrences = "ModifiedOccurrences"; - - /** - * The Constant DeletedOccurrences. - */ - public static final String DeletedOccurrences = "DeletedOccurrences"; - - /** - * The Constant MeetingTimeZone. - */ - public static final String MeetingTimeZone = "MeetingTimeZone"; - - /** - * The Constant ConferenceType. - */ - public static final String ConferenceType = "ConferenceType"; - - /** - * The Constant AllowNewTimeProposal. - */ - public static final String AllowNewTimeProposal = "AllowNewTimeProposal"; - - /** - * The Constant IsOnlineMeeting. - */ - public static final String IsOnlineMeeting = "IsOnlineMeeting"; - - /** - * The Constant MeetingWorkspaceUrl. - */ - public static final String MeetingWorkspaceUrl = "MeetingWorkspaceUrl"; - - /** - * The Constant NetShowUrl. - */ - public static final String NetShowUrl = "NetShowUrl"; - - /** - * The Constant CalendarItem. - */ - public static final String CalendarItem = "CalendarItem"; - - /** - * The Constant CalendarFolder. - */ - public static final String CalendarFolder = "CalendarFolder"; - - /** - * The Constant Attendee. - */ - public static final String Attendee = "Attendee"; - - /** - * The Constant ResponseType. - */ - public static final String ResponseType = "ResponseType"; - - /** - * The Constant LastResponseTime. - */ - public static final String LastResponseTime = "LastResponseTime"; - - /** - * The Constant Occurrence. - */ - public static final String Occurrence = "Occurrence"; - - /** - * The Constant DeletedOccurrence. - */ - public static final String DeletedOccurrence = "DeletedOccurrence"; - - /** - * The Constant RelativeYearlyRecurrence. - */ - public static final String RelativeYearlyRecurrence = - "RelativeYearlyRecurrence"; - - /** - * The Constant AbsoluteYearlyRecurrence. - */ - public static final String AbsoluteYearlyRecurrence = - "AbsoluteYearlyRecurrence"; - - /** - * The Constant RelativeMonthlyRecurrence. - */ - public static final String RelativeMonthlyRecurrence = - "RelativeMonthlyRecurrence"; - - /** - * The Constant AbsoluteMonthlyRecurrence. - */ - public static final String AbsoluteMonthlyRecurrence = - "AbsoluteMonthlyRecurrence"; - - /** - * The Constant WeeklyRecurrence. - */ - public static final String WeeklyRecurrence = "WeeklyRecurrence"; - - /** - * The Constant DailyRecurrence. - */ - public static final String DailyRecurrence = "DailyRecurrence"; - - /** - * The Constant DailyRegeneration. - */ - public static final String DailyRegeneration = "DailyRegeneration"; - - /** - * The Constant WeeklyRegeneration. - */ - public static final String WeeklyRegeneration = "WeeklyRegeneration"; - - /** - * The Constant MonthlyRegeneration. - */ - public static final String MonthlyRegeneration = "MonthlyRegeneration"; - - /** - * The Constant YearlyRegeneration. - */ - public static final String YearlyRegeneration = "YearlyRegeneration"; - - /** - * The Constant NoEndRecurrence. - */ - public static final String NoEndRecurrence = "NoEndRecurrence"; - - /** - * The Constant EndDateRecurrence. - */ - public static final String EndDateRecurrence = "EndDateRecurrence"; - - /** - * The Constant NumberedRecurrence. - */ - public static final String NumberedRecurrence = "NumberedRecurrence"; - - /** - * The Constant Interval. - */ - public static final String Interval = "Interval"; - - /** - * The Constant DayOfMonth. - */ - public static final String DayOfMonth = "DayOfMonth"; - - /** - * The Constant DayOfWeek. - */ - public static final String DayOfWeek = "DayOfWeek"; - - /** - * The Constant DaysOfWeek. - */ - public static final String DaysOfWeek = "DaysOfWeek"; - - /** - * The Constant DayOfWeekIndex. - */ - public static final String DayOfWeekIndex = "DayOfWeekIndex"; - - /** - * The Constant Month. - */ - public static final String Month = "Month"; - - /** - * The Constant StartDate. - */ - public static final String StartDate = "StartDate"; - - /** - * The Constant EndDate. - */ - public static final String EndDate = "EndDate"; - - /** - * The Constant StartTime. - */ - public static final String StartTime = "StartTime"; - - /** - * The Constant EndTime. - */ - public static final String EndTime = "EndTime"; - - /** - * The Constant NumberOfOccurrences. - */ - public static final String NumberOfOccurrences = "NumberOfOccurrences"; - - /** - * The Constant AssociatedCalendarItemId. - */ - public static final String AssociatedCalendarItemId = - "AssociatedCalendarItemId"; - - /** - * The Constant IsDelegated. - */ - public static final String IsDelegated = "IsDelegated"; - - /** - * The Constant IsOutOfDate. - */ - public static final String IsOutOfDate = "IsOutOfDate"; - - /** - * The Constant HasBeenProcessed. - */ - public static final String HasBeenProcessed = "HasBeenProcessed"; - - /** - * The Constant MeetingMessage. - */ - public static final String MeetingMessage = "MeetingMessage"; - - /** - * The Constant FileAs. - */ - public static final String FileAs = "FileAs"; - - /** - * The Constant FileAsMapping. - */ - public static final String FileAsMapping = "FileAsMapping"; - - /** - * The Constant GivenName. - */ - public static final String GivenName = "GivenName"; - - /** - * The Constant Initials. - */ - public static final String Initials = "Initials"; - - /** - * The Constant MiddleName. - */ - public static final String MiddleName = "MiddleName"; - - /** - * The Constant NickName. - */ - public static final String NickName = "Nickname"; - - /** - * The Constant CompleteName. - */ - public static final String CompleteName = "CompleteName"; - - /** - * The Constant CompanyName. - */ - public static final String CompanyName = "CompanyName"; - - /** - * The Constant EmailAddresses. - */ - public static final String EmailAddresses = "EmailAddresses"; - - /** - * The Constant PhysicalAddresses. - */ - public static final String PhysicalAddresses = "PhysicalAddresses"; - - /** - * The Constant PhoneNumbers. - */ - public static final String PhoneNumbers = "PhoneNumbers"; - - /** - * The Constant PhoneNumber. - */ - public static final String PhoneNumber = "PhoneNumber"; - - /** - * The Constant AssistantName. - */ - public static final String AssistantName = "AssistantName"; - - /** - * The Constant Birthday. - */ - public static final String Birthday = "Birthday"; - - /** - * The Constant BusinessHomePage. - */ - public static final String BusinessHomePage = "BusinessHomePage"; - - /** - * The Constant Children. - */ - public static final String Children = "Children"; - - /** - * The Constant Companies. - */ - public static final String Companies = "Companies"; - - /** - * The Constant ContactSource. - */ - public static final String ContactSource = "ContactSource"; - - /** - * The Constant Department. - */ - public static final String Department = "Department"; - - /** - * The Constant Generation. - */ - public static final String Generation = "Generation"; - - /** - * The Constant ImAddresses. - */ - public static final String ImAddresses = "ImAddresses"; - - /** - * The Constant ImAddress. - */ - public static final String ImAddress = "ImAddress"; - - /** - * The Constant JobTitle. - */ - public static final String JobTitle = "JobTitle"; - - /** - * The Constant Manager. - */ - public static final String Manager = "Manager"; - - /** - * The Constant Mileage. - */ - public static final String Mileage = "Mileage"; - - /** - * The Constant OfficeLocation. - */ - public static final String OfficeLocation = "OfficeLocation"; - - /** - * The Constant PostalAddressIndex. - */ - public static final String PostalAddressIndex = "PostalAddressIndex"; - - /** - * The Constant Profession. - */ - public static final String Profession = "Profession"; - - /** - * The Constant SpouseName. - */ - public static final String SpouseName = "SpouseName"; - - /** - * The Constant Surname. - */ - public static final String Surname = "Surname"; - - /** - * The Constant WeddingAnniversary. - */ - public static final String WeddingAnniversary = "WeddingAnniversary"; - - /** - * The Constant HasPicture. - */ - public static final String HasPicture = "HasPicture"; - - /** - * The Constant Title. - */ - public static final String Title = "Title"; - - /** - * The Constant FirstName. - */ - public static final String FirstName = "FirstName"; - - /** - * The Constant LastName. - */ - public static final String LastName = "LastName"; - - /** - * The Constant Suffix. - */ - public static final String Suffix = "Suffix"; - - /** - * The Constant FullName. - */ - public static final String FullName = "FullName"; - - /** - * The Constant YomiFirstName. - */ - public static final String YomiFirstName = "YomiFirstName"; - - /** - * The Constant YomiLastName. - */ - public static final String YomiLastName = "YomiLastName"; - - /** - * The Constant Contact. - */ - public static final String Contact = "Contact"; - - /** - * The Constant Entry. - */ - public static final String Entry = "Entry"; - - /** - * The Constant Street. - */ - public static final String Street = "Street"; - - /** - * The Constant City. - */ - public static final String City = "City"; - - /** - * The Constant State. - */ - public static final String State = "State"; - - /** - * The Constant CountryOrRegion. - */ - public static final String CountryOrRegion = "CountryOrRegion"; - - /** - * The Constant PostalCode. - */ - public static final String PostalCode = "PostalCode"; - - /** - * The Constant Members. - */ - public static final String Members = "Members"; - - /** - * The Constant Member. - */ - public static final String Member = "Member"; - - /** - * The Constant AdditionalProperties. - */ - public static final String AdditionalProperties = "AdditionalProperties"; - - /** - * The Constant ExtendedFieldURI. - */ - public static final String ExtendedFieldURI = "ExtendedFieldURI"; - - /** - * The Constant Value. - */ - public static final String Value = "Value"; - - /** - * The Constant Values. - */ - public static final String Values = "Values"; - - /** - * The Constant ToFolderId. - */ - public static final String ToFolderId = "ToFolderId"; - - /** - * The Constant ActualWork. - */ - public static final String ActualWork = "ActualWork"; - - /** - * The Constant AssignedTime. - */ - public static final String AssignedTime = "AssignedTime"; - - /** - * The Constant BillingInformation. - */ - public static final String BillingInformation = "BillingInformation"; - - /** - * The Constant ChangeCount. - */ - public static final String ChangeCount = "ChangeCount"; - - /** - * The Constant CompleteDate. - */ - public static final String CompleteDate = "CompleteDate"; - - /** - * The Constant Contacts. - */ - public static final String Contacts = "Contacts"; - - /** - * The Constant DelegationState. - */ - public static final String DelegationState = "DelegationState"; - - /** - * The Constant Delegator. - */ - public static final String Delegator = "Delegator"; - - /** - * The Constant DueDate. - */ - public static final String DueDate = "DueDate"; - - /** - * The Constant IsAssignmentEditable. - */ - public static final String IsAssignmentEditable = "IsAssignmentEditable"; - - /** - * The Constant IsComplete. - */ - public static final String IsComplete = "IsComplete"; - - /** - * The Constant IsTeamTask. - */ - public static final String IsTeamTask = "IsTeamTask"; - - /** - * The Constant Owner. - */ - public static final String Owner = "Owner"; - - /** - * The Constant PercentComplete. - */ - public static final String PercentComplete = "PercentComplete"; - - /** - * The Constant Status. - */ - public static final String Status = "Status"; - - /** - * The Constant StatusDescription. - */ - public static final String StatusDescription = "StatusDescription"; - - /** - * The Constant TotalWork. - */ - public static final String TotalWork = "TotalWork"; - - /** - * The Constant Task. - */ - public static final String Task = "Task"; - - /** - * The Constant MailboxCulture. - */ - public static final String MailboxCulture = "MailboxCulture"; - - /** - * The Constant MeetingRequestType. - */ - public static final String MeetingRequestType = "MeetingRequestType"; - - /** - * The Constant IntendedFreeBusyStatus. - */ - public static final String IntendedFreeBusyStatus = "IntendedFreeBusyStatus"; - - /** - * The Constant MeetingRequest. - */ - public static final String MeetingRequest = "MeetingRequest"; - - /** - * The Constant MeetingResponse. - */ - public static final String MeetingResponse = "MeetingResponse"; - - /** - * The Constant MeetingCancellation. - */ - public static final String MeetingCancellation = "MeetingCancellation"; - - /** - * The Constant BaseOffset. - */ - public static final String BaseOffset = "BaseOffset"; - - /** - * The Constant Offset. - */ - public static final String Offset = "Offset"; - - /** - * The Constant Standard. - */ - public static final String Standard = "Standard"; - - /** - * The Constant Daylight. - */ - public static final String Daylight = "Daylight"; - - /** - * The Constant Time. - */ - public static final String Time = "Time"; - - /** - * The Constant AbsoluteDate. - */ - public static final String AbsoluteDate = "AbsoluteDate"; - - /** - * The Constant UnresolvedEntry. - */ - public static final String UnresolvedEntry = "UnresolvedEntry"; - - /** - * The Constant ResolutionSet. - */ - public static final String ResolutionSet = "ResolutionSet"; - - /** - * The Constant Resolution. - */ - public static final String Resolution = "Resolution"; - - /** - * The Constant DistributionList. - */ - public static final String DistributionList = "DistributionList"; - - /** - * The Constant DLExpansion. - */ - public static final String DLExpansion = "DLExpansion"; - - /** - * The Constant IndexedFieldURI. - */ - public static final String IndexedFieldURI = "IndexedFieldURI"; - - /** - * The Constant PullSubscriptionRequest. - */ - public static final String PullSubscriptionRequest = - "PullSubscriptionRequest"; - - /** - * The Constant PushSubscriptionRequest. - */ - public static final String PushSubscriptionRequest = - "PushSubscriptionRequest"; - - /** - * The Constant StreamingSubscriptionRequest. - */ - public static final String StreamingSubscriptionRequest = - "StreamingSubscriptionRequest"; - /** - * The Constant EventTypes. - */ - public static final String EventTypes = "EventTypes"; - - /** - * The Constant EventType. - */ - public static final String EventType = "EventType"; - - /** - * The Constant Timeout. - */ - public static final String Timeout = "Timeout"; - - /** - * The Constant Watermark. - */ - public static final String Watermark = "Watermark"; - - /** - * The Constant SubscriptionId. - */ - public static final String SubscriptionId = "SubscriptionId"; - - /** - * The Constant SubscriptionId. - */ - public static final String SubscriptionIds = "SubscriptionIds"; - - /** - * The Constant StatusFrequency. - */ - public static final String StatusFrequency = "StatusFrequency"; - - /** - * The Constant URL. - */ - public static final String URL = "URL"; - - /** - * The Constant Notification. - */ - public static final String Notification = "Notification"; - - /** - * The Constant Notifications. - */ - public static final String Notifications = "Notifications"; - - /** - * The Constant PreviousWatermark. - */ - public static final String PreviousWatermark = "PreviousWatermark"; - - /** - * The Constant MoreEvents. - */ - public static final String MoreEvents = "MoreEvents"; - - /** - * The Constant TimeStamp. - */ - public static final String TimeStamp = "TimeStamp"; - - /** - * The Constant UnreadCount. - */ - public static final String UnreadCount = "UnreadCount"; - - /** - * The Constant OldParentFolderId. - */ - public static final String OldParentFolderId = "OldParentFolderId"; - - /** - * The Constant CopiedEvent. - */ - public static final String CopiedEvent = "CopiedEvent"; - - /** - * The Constant CreatedEvent. - */ - public static final String CreatedEvent = "CreatedEvent"; - - /** - * The Constant DeletedEvent. - */ - public static final String DeletedEvent = "DeletedEvent"; - - /** - * The Constant ModifiedEvent. - */ - public static final String ModifiedEvent = "ModifiedEvent"; - - /** - * The Constant MovedEvent. - */ - public static final String MovedEvent = "MovedEvent"; - - /** - * The Constant NewMailEvent. - */ - public static final String NewMailEvent = "NewMailEvent"; - - /** - * The Constant StatusEvent. - */ - public static final String StatusEvent = "StatusEvent"; - - /** - * The Constant FreeBusyChangedEvent. - */ - public static final String FreeBusyChangedEvent = "FreeBusyChangedEvent"; - - /** - * The Constant ExchangeImpersonation. - */ - public static final String ExchangeImpersonation = "ExchangeImpersonation"; - - /** - * The Constant ConnectingSID. - */ - public static final String ConnectingSID = "ConnectingSID"; - - /** - * The Constant SyncFolderId. - */ - public static final String SyncFolderId = "SyncFolderId"; - - /** - * The Constant SyncScope. - */ - public static final String SyncScope = "SyncScope"; - - /** - * The Constant SyncState. - */ - public static final String SyncState = "SyncState"; - - /** - * The Constant Ignore. - */ - public static final String Ignore = "Ignore"; - - /** - * The Constant MaxChangesReturned. - */ - public static final String MaxChangesReturned = "MaxChangesReturned"; - - /** - * The Constant Changes. - */ - public static final String Changes = "Changes"; - - /** - * The Constant IncludesLastItemInRange. - */ - public static final String IncludesLastItemInRange = - "IncludesLastItemInRange"; - - /** - * The Constant IncludesLastFolderInRange. - */ - public static final String IncludesLastFolderInRange = - "IncludesLastFolderInRange"; - - /** - * The Constant Create. - */ - public static final String Create = "Create"; - - /** - * The Constant Update. - */ - public static final String Update = "Update"; - - /** - * The Constant Delete. - */ - public static final String Delete = "Delete"; - - /** - * The Constant ReadFlagChange. - */ - public static final String ReadFlagChange = "ReadFlagChange"; - - /** - * The Constant SearchParameters. - */ - public static final String SearchParameters = "SearchParameters"; - - /** - * The Constant SoftDeleted. - */ - public static final String SoftDeleted = "SoftDeleted"; - - /** - * The Constant Shallow. - */ - public static final String Shallow = "Shallow"; - - /** - * The Constant Associated. - */ - public static final String Associated = "Associated"; - - /** - * The Constant BaseFolderIds. - */ - public static final String BaseFolderIds = "BaseFolderIds"; - - /** - * The Constant SortOrder. - */ - public static final String SortOrder = "SortOrder"; - - /** - * The Constant FieldOrder. - */ - public static final String FieldOrder = "FieldOrder"; - - /** - * The Constant CanDelete. - */ - public static final String CanDelete = "CanDelete"; - - /** - * The Constant CanRenameOrMove. - */ - public static final String CanRenameOrMove = "CanRenameOrMove"; - - /** - * The Constant MustDisplayComment. - */ - public static final String MustDisplayComment = "MustDisplayComment"; - - /** - * The Constant HasQuota. - */ - public static final String HasQuota = "HasQuota"; - - /** - * The Constant IsManagedFoldersRoot. - */ - public static final String IsManagedFoldersRoot = "IsManagedFoldersRoot"; - - /** - * The Constant ManagedFolderId. - */ - public static final String ManagedFolderId = "ManagedFolderId"; - - /** - * The Constant Comment. - */ - public static final String Comment = "Comment"; - - /** - * The Constant StorageQuota. - */ - public static final String StorageQuota = "StorageQuota"; - - /** - * The Constant FolderSize. - */ - public static final String FolderSize = "FolderSize"; - - /** - * The Constant HomePage. - */ - public static final String HomePage = "HomePage"; - - /** - * The Constant ManagedFolderInformation. - */ - public static final String ManagedFolderInformation = - "ManagedFolderInformation"; - - /** - * The Constant CalendarView. - */ - public static final String CalendarView = "CalendarView"; - - /** - * The Constant PostedTime. - */ - public static final String PostedTime = "PostedTime"; - - /** - * The Constant PostItem. - */ - public static final String PostItem = "PostItem"; - - /** - * The Constant RequestServerVersion. - */ - public static final String RequestServerVersion = "RequestServerVersion"; - - /** - * The Constant PostReplyItem. - */ - public static final String PostReplyItem = "PostReplyItem"; - - /** - * The Constant CreateAssociated. - */ - public static final String CreateAssociated = "CreateAssociated"; - - /** - * The Constant CreateContents. - */ - public static final String CreateContents = "CreateContents"; - - /** - * The Constant CreateHierarchy. - */ - public static final String CreateHierarchy = "CreateHierarchy"; - - /** - * The Constant Modify. - */ - public static final String Modify = "Modify"; - - /** - * The Constant Read. - */ - public static final String Read = "Read"; - - /** - * The Constant EffectiveRights. - */ - public static final String EffectiveRights = "EffectiveRights"; - - /** - * The Constant LastModifiedName. - */ - public static final String LastModifiedName = "LastModifiedName"; - - /** - * The Constant LastModifiedTime. - */ - public static final String LastModifiedTime = "LastModifiedTime"; - - /** - * The Constant ConversationId. - */ - public static final String ConversationId = "ConversationId"; - - /** - * The Constant UniqueBody. - */ - public static final String UniqueBody = "UniqueBody"; - - /** - * The Constant BodyType. - */ - public static final String BodyType = "BodyType"; - - /** - * The Constant AttachmentShape. - */ - public static final String AttachmentShape = "AttachmentShape"; - - /** - * The Constant UserId. - */ - public static final String UserId = "UserId"; - - /** - * The Constant UserIds. - */ - public static final String UserIds = "UserIds"; - - /** - * The Constant CanCreateItems. - */ - public static final String CanCreateItems = "CanCreateItems"; - - /** - * The Constant CanCreateSubFolders. - */ - public static final String CanCreateSubFolders = "CanCreateSubFolders"; - - /** - * The Constant IsFolderOwner. - */ - public static final String IsFolderOwner = "IsFolderOwner"; - - /** - * The Constant IsFolderVisible. - */ - public static final String IsFolderVisible = "IsFolderVisible"; - - /** - * The Constant IsFolderContact. - */ - public static final String IsFolderContact = "IsFolderContact"; - - /** - * The Constant EditItems. - */ - public static final String EditItems = "EditItems"; - - /** - * The Constant DeleteItems. - */ - public static final String DeleteItems = "DeleteItems"; - - /** - * The Constant ReadItems. - */ - public static final String ReadItems = "ReadItems"; - - /** - * The Constant PermissionLevel. - */ - public static final String PermissionLevel = "PermissionLevel"; - - /** - * The Constant CalendarPermissionLevel. - */ - public static final String CalendarPermissionLevel = - "CalendarPermissionLevel"; - - /** - * The Constant SID. - */ - public static final String SID = "SID"; - - /** - * The Constant PrimarySmtpAddress. - */ - public static final String PrimarySmtpAddress = "PrimarySmtpAddress"; - - /** - * The Constant DistinguishedUser. - */ - public static final String DistinguishedUser = "DistinguishedUser"; - - /** - * The Constant PermissionSet. - */ - public static final String PermissionSet = "PermissionSet"; - - /** - * The Constant Permissions. - */ - public static final String Permissions = "Permissions"; - - /** - * The Constant Permission. - */ - public static final String Permission = "Permission"; - - /** - * The Constant CalendarPermissions. - */ - public static final String CalendarPermissions = "CalendarPermissions"; - - /** - * The Constant CalendarPermission. - */ - public static final String CalendarPermission = "CalendarPermission"; - - /** - * The Constant GroupBy. - */ - public static final String GroupBy = "GroupBy"; - - /** - * The Constant AggregateOn. - */ - public static final String AggregateOn = "AggregateOn"; - - /** - * The Constant Groups. - */ - public static final String Groups = "Groups"; - - /** - * The Constant GroupedItems. - */ - public static final String GroupedItems = "GroupedItems"; - - /** - * The Constant GroupIndex. - */ - public static final String GroupIndex = "GroupIndex"; - - /** - * The Constant ConflictResults. - */ - public static final String ConflictResults = "ConflictResults"; - - /** - * The Constant Count. - */ - public static final String Count = "Count"; - - /** - * The Constant OofSettings. - */ - public static final String OofSettings = "OofSettings"; - - /** - * The Constant UserOofSettings. - */ - public static final String UserOofSettings = "UserOofSettings"; - - /** - * The Constant OofState. - */ - public static final String OofState = "OofState"; - - /** - * The Constant ExternalAudience. - */ - public static final String ExternalAudience = "ExternalAudience"; - - /** - * The Constant AllowExternalOof. - */ - public static final String AllowExternalOof = "AllowExternalOof"; - - /** - * The Constant InternalReply. - */ - public static final String InternalReply = "InternalReply"; - - /** - * The Constant ExternalReply. - */ - public static final String ExternalReply = "ExternalReply"; - - /** - * The Constant Bias. - */ - public static final String Bias = "Bias"; - - /** - * The Constant DayOrder. - */ - public static final String DayOrder = "DayOrder"; - - /** - * The Constant Year. - */ - public static final String Year = "Year"; - - /** - * The Constant StandardTime. - */ - public static final String StandardTime = "StandardTime"; - - /** - * The Constant DaylightTime. - */ - public static final String DaylightTime = "DaylightTime"; - - /** - * The Constant MailboxData. - */ - public static final String MailboxData = "MailboxData"; - - /** - * The Constant MailboxDataArray. - */ - public static final String MailboxDataArray = "MailboxDataArray"; - - /** - * The Constant Email. - */ - public static final String Email = "Email"; - - /** - * The Constant AttendeeType. - */ - public static final String AttendeeType = "AttendeeType"; - - /** - * The Constant ExcludeConflicts. - */ - public static final String ExcludeConflicts = "ExcludeConflicts"; - - /** - * The Constant FreeBusyViewOptions. - */ - public static final String FreeBusyViewOptions = "FreeBusyViewOptions"; - - /** - * The Constant SuggestionsViewOptions. - */ - public static final String SuggestionsViewOptions = "SuggestionsViewOptions"; - - /** - * The Constant FreeBusyView. - */ - public static final String FreeBusyView = "FreeBusyView"; - - /** - * The Constant TimeWindow. - */ - public static final String TimeWindow = "TimeWindow"; - - /** - * The Constant MergedFreeBusyIntervalInMinutes. - */ - public static final String MergedFreeBusyIntervalInMinutes = - "MergedFreeBusyIntervalInMinutes"; - - /** - * The Constant RequestedView. - */ - public static final String RequestedView = "RequestedView"; - - /** - * The Constant FreeBusyViewType. - */ - public static final String FreeBusyViewType = "FreeBusyViewType"; - - /** - * The Constant CalendarEventArray. - */ - public static final String CalendarEventArray = "CalendarEventArray"; - - /** - * The Constant CalendarEvent. - */ - public static final String CalendarEvent = "CalendarEvent"; - - /** - * The Constant BusyType. - */ - public static final String BusyType = "BusyType"; - - /** - * The Constant MergedFreeBusy. - */ - public static final String MergedFreeBusy = "MergedFreeBusy"; - - /** - * The Constant WorkingHours. - */ - public static final String WorkingHours = "WorkingHours"; - - /** - * The Constant WorkingPeriodArray. - */ - public static final String WorkingPeriodArray = "WorkingPeriodArray"; - - /** - * The Constant WorkingPeriod. - */ - public static final String WorkingPeriod = "WorkingPeriod"; - - /** - * The Constant StartTimeInMinutes. - */ - public static final String StartTimeInMinutes = "StartTimeInMinutes"; - - /** - * The Constant EndTimeInMinutes. - */ - public static final String EndTimeInMinutes = "EndTimeInMinutes"; - - /** - * The Constant GoodThreshold. - */ - public static final String GoodThreshold = "GoodThreshold"; - - /** - * The Constant MaximumResultsByDay. - */ - public static final String MaximumResultsByDay = "MaximumResultsByDay"; - - /** - * The Constant MaximumNonWorkHourResultsByDay. - */ - public static final String MaximumNonWorkHourResultsByDay = - "MaximumNonWorkHourResultsByDay"; - - /** - * The Constant MeetingDurationInMinutes. - */ - public static final String MeetingDurationInMinutes = - "MeetingDurationInMinutes"; - - /** - * The Constant MinimumSuggestionQuality. - */ - public static final String MinimumSuggestionQuality = - "MinimumSuggestionQuality"; - - /** - * The Constant DetailedSuggestionsWindow. - */ - public static final String DetailedSuggestionsWindow = - "DetailedSuggestionsWindow"; - - /** - * The Constant CurrentMeetingTime. - */ - public static final String CurrentMeetingTime = "CurrentMeetingTime"; - - /** - * The Constant GlobalObjectId. - */ - public static final String GlobalObjectId = "GlobalObjectId"; - - /** - * The Constant SuggestionDayResultArray. - */ - public static final String SuggestionDayResultArray = - "SuggestionDayResultArray"; - - /** - * The Constant SuggestionDayResult. - */ - public static final String SuggestionDayResult = "SuggestionDayResult"; - - /** - * The Constant Date. - */ - public static final String Date = "Date"; - - /** - * The Constant DayQuality. - */ - public static final String DayQuality = "DayQuality"; - - /** - * The Constant SuggestionArray. - */ - public static final String SuggestionArray = "SuggestionArray"; - - /** - * The Constant Suggestion. - */ - public static final String Suggestion = "Suggestion"; - - /** - * The Constant MeetingTime. - */ - public static final String MeetingTime = "MeetingTime"; - - /** - * The Constant IsWorkTime. - */ - public static final String IsWorkTime = "IsWorkTime"; - - /** - * The Constant SuggestionQuality. - */ - public static final String SuggestionQuality = "SuggestionQuality"; - - /** - * The Constant AttendeeConflictDataArray. - */ - public static final String AttendeeConflictDataArray = - "AttendeeConflictDataArray"; - - /** - * The Constant UnknownAttendeeConflictData. - */ - public static final String UnknownAttendeeConflictData = - "UnknownAttendeeConflictData"; - - /** - * The Constant TooBigGroupAttendeeConflictData. - */ - public static final String TooBigGroupAttendeeConflictData = - "TooBigGroupAttendeeConflictData"; - - /** - * The Constant IndividualAttendeeConflictData. - */ - public static final String IndividualAttendeeConflictData = - "IndividualAttendeeConflictData"; - - /** - * The Constant GroupAttendeeConflictData. - */ - public static final String GroupAttendeeConflictData = - "GroupAttendeeConflictData"; - - /** - * The Constant NumberOfMembers. - */ - public static final String NumberOfMembers = "NumberOfMembers"; - - /** - * The Constant NumberOfMembersAvailable. - */ - public static final String NumberOfMembersAvailable = - "NumberOfMembersAvailable"; - - /** - * The Constant NumberOfMembersWithConflict. - */ - public static final String NumberOfMembersWithConflict = - "NumberOfMembersWithConflict"; - - /** - * The Constant NumberOfMembersWithNoData. - */ - public static final String NumberOfMembersWithNoData = - "NumberOfMembersWithNoData"; - - /** - * The Constant SourceIds. - */ - public static final String SourceIds = "SourceIds"; - - /** - * The Constant AlternateId. - */ - public static final String AlternateId = "AlternateId"; - - /** - * The Constant AlternatePublicFolderId. - */ - public static final String AlternatePublicFolderId = - "AlternatePublicFolderId"; - - /** - * The Constant AlternatePublicFolderItemId. - */ - public static final String AlternatePublicFolderItemId = - "AlternatePublicFolderItemId"; - - /** - * The Constant DelegatePermissions. - */ - public static final String DelegatePermissions = "DelegatePermissions"; - - /** - * The Constant ReceiveCopiesOfMeetingMessages. - */ - public static final String ReceiveCopiesOfMeetingMessages = - "ReceiveCopiesOfMeetingMessages"; - - /** - * The Constant ViewPrivateItems. - */ - public static final String ViewPrivateItems = "ViewPrivateItems"; - - /** - * The Constant CalendarFolderPermissionLevel. - */ - public static final String CalendarFolderPermissionLevel = - "CalendarFolderPermissionLevel"; - - /** - * The Constant TasksFolderPermissionLevel. - */ - public static final String TasksFolderPermissionLevel = - "TasksFolderPermissionLevel"; - - /** - * The Constant InboxFolderPermissionLevel. - */ - public static final String InboxFolderPermissionLevel = - "InboxFolderPermissionLevel"; - - /** - * The Constant ContactsFolderPermissionLevel. - */ - public static final String ContactsFolderPermissionLevel = - "ContactsFolderPermissionLevel"; - - /** - * The Constant NotesFolderPermissionLevel. - */ - public static final String NotesFolderPermissionLevel = - "NotesFolderPermissionLevel"; - - /** - * The Constant JournalFolderPermissionLevel. - */ - public static final String JournalFolderPermissionLevel = - "JournalFolderPermissionLevel"; - - /** - * The Constant DelegateUser. - */ - public static final String DelegateUser = "DelegateUser"; - - /** - * The Constant DelegateUsers. - */ - public static final String DelegateUsers = "DelegateUsers"; - - /** - * The Constant DeliverMeetingRequests. - */ - public static final String DeliverMeetingRequests = "DeliverMeetingRequests"; - - /** - * The Constant MessageXml. - */ - public static final String MessageXml = "MessageXml"; - - /** - * The Constant UserConfiguration. - */ - public static final String UserConfiguration = "UserConfiguration"; - - /** - * The Constant UserConfigurationName. - */ - public static final String UserConfigurationName = "UserConfigurationName"; - - /** - * The Constant UserConfigurationProperties. - */ - public static final String UserConfigurationProperties = - "UserConfigurationProperties"; - - /** - * The Constant Dictionary. - */ - public static final String Dictionary = "Dictionary"; - - /** - * The Constant DictionaryEntry. - */ - public static final String DictionaryEntry = "DictionaryEntry"; - - /** - * The Constant DictionaryKey. - */ - public static final String DictionaryKey = "DictionaryKey"; - - /** - * The Constant DictionaryValue. - */ - public static final String DictionaryValue = "DictionaryValue"; - - /** - * The Constant XmlData. - */ - public static final String XmlData = "XmlData"; - - /** - * The Constant BinaryData. - */ - public static final String BinaryData = "BinaryData"; - - /** - * The Constant FilterHtmlContent. - */ - public static final String FilterHtmlContent = "FilterHtmlContent"; - - /** - * The Constant ConvertHtmlCodePageToUTF8. - */ - public static final String ConvertHtmlCodePageToUTF8 = - "ConvertHtmlCodePageToUTF8"; - - /** - * The Constant UnknownEntries. - */ - public static final String UnknownEntries = "UnknownEntries"; - - /** - * The Constant UnknownEntry. - */ - public static final String UnknownEntry = "UnknownEntry"; - - /** - * The Constant PhoneCallId. - */ - public static final String PhoneCallId = "PhoneCallId"; - - /** - * The Constant DialString. - */ - public static final String DialString = "DialString"; - - /** - * The Constant PhoneCallInformation. - */ - public static final String PhoneCallInformation = "PhoneCallInformation"; - - /** - * The Constant PhoneCallState. - */ - public static final String PhoneCallState = "PhoneCallState"; - - /** - * The Constant ConnectionFailureCause. - */ - public static final String ConnectionFailureCause = "ConnectionFailureCause"; - - /** - * The Constant SIPResponseCode. - */ - public static final String SIPResponseCode = "SIPResponseCode"; - - /** - * The Constant SIPResponseText. - */ - public static final String SIPResponseText = "SIPResponseText"; - - /** - * The Constant WebClientReadFormQueryString. - */ - public static final String WebClientReadFormQueryString = - "WebClientReadFormQueryString"; - - /** - * The Constant WebClientEditFormQueryString. - */ - public static final String WebClientEditFormQueryString = - "WebClientEditFormQueryString"; - - /** - * The Constant Ids. - */ - public static final String Ids = "Ids"; - - /** - * The Constant Id. - */ - public static final String Id = "Id"; - - /** - * The Constant TimeZoneDefinitions. - */ - public static final String TimeZoneDefinitions = "TimeZoneDefinitions"; - - /** - * The Constant TimeZoneDefinition. - */ - public static final String TimeZoneDefinition = "TimeZoneDefinition"; - - /** - * The Constant Periods. - */ - public static final String Periods = "Periods"; - - /** - * The Constant Period. - */ - public static final String Period = "Period"; - - /** - * The Constant TransitionsGroups. - */ - public static final String TransitionsGroups = "TransitionsGroups"; - - /** - * The Constant TransitionsGroup. - */ - public static final String TransitionsGroup = "TransitionsGroup"; - - /** - * The Constant Transitions. - */ - public static final String Transitions = "Transitions"; - - /** - * The Constant Transition. - */ - public static final String Transition = "Transition"; - - /** - * The Constant AbsoluteDateTransition. - */ - public static final String AbsoluteDateTransition = "AbsoluteDateTransition"; - - /** - * The Constant RecurringDayTransition. - */ - public static final String RecurringDayTransition = "RecurringDayTransition"; - - /** - * The Constant RecurringDateTransition. - */ - public static final String RecurringDateTransition = - "RecurringDateTransition"; - - /** - * The Constant DateTime. - */ - public static final String DateTime = "DateTime"; - - /** - * The Constant TimeOffset. - */ - public static final String TimeOffset = "TimeOffset"; - - /** - * The Constant Day. - */ - public static final String Day = "Day"; - - /** - * The Constant TimeZoneContext. - */ - public static final String TimeZoneContext = "TimeZoneContext"; - - /** - * The Constant StartTimeZone. - */ - public static final String StartTimeZone = "StartTimeZone"; - - /** - * The Constant EndTimeZone. - */ - public static final String EndTimeZone = "EndTimeZone"; - - /** - * The Constant ReceivedBy. - */ - public static final String ReceivedBy = "ReceivedBy"; - - /** - * The Constant ReceivedRepresenting. - */ - public static final String ReceivedRepresenting = "ReceivedRepresenting"; - - /** - * The Constant Uid. - */ - public static final String Uid = "UID"; - - /** - * The Constant RecurrenceId. - */ - public static final String RecurrenceId = "RecurrenceId"; - - /** - * The Constant DateTimeStamp. - */ - public static final String DateTimeStamp = "DateTimeStamp"; - - /** - * The Constant IsInline. - */ - public static final String IsInline = "IsInline"; - - /** - * The Constant IsContactPhoto. - */ - public static final String IsContactPhoto = "IsContactPhoto"; - - /** - * The Constant QueryString. - */ - public static final String QueryString = "QueryString"; - - /** - * The Constant CalendarEventDetails. - */ - public static final String CalendarEventDetails = "CalendarEventDetails"; - - /** - * The Constant ID. - */ - public static final String ID = "ID"; - - /** - * The Constant IsException. - */ - public static final String IsException = "IsException"; - - /** - * The Constant IsReminderSet. - */ - public static final String IsReminderSet = "IsReminderSet"; - - /** - * The Constant IsPrivate. - */ - public static final String IsPrivate = "IsPrivate"; - - /** - * The Constant FirstDayOfWeek. - */ - public static final String FirstDayOfWeek = "FirstDayOfWeek"; - - /** - * The Constant Verb. - */ - public static final String Verb = "Verb"; - - /** - * The Constant Parameter. - */ - public static final String Parameter = "Parameter"; - - /** - * The Constant ReturnValue. - */ - public static final String ReturnValue = "ReturnValue"; - - /** - * The Constant ReturnNewItemIds. - */ - public static final String ReturnNewItemIds = "ReturnNewItemIds"; - - /** - * The Constant DateTimePrecision. - */ - public static final String DateTimePrecision = "DateTimePrecision"; - - /** - * The Constant PasswordExpirationDate. - */ - public static final String PasswordExpirationDate = "PasswordExpirationDate"; - - /** - * The Constant StoreEntryId. - */ - public static final String StoreEntryId = "StoreEntryId"; - - // Conversations - /** - * The Constant Conversations. - */ - public static final String Conversations = "Conversations"; - - /** - * The Constant Conversation. - */ - public static final String Conversation = "Conversation"; - - /** - * The Constant UniqueRecipients. - */ - public static final String UniqueRecipients = "UniqueRecipients"; - - /** - * The Constant GlobalUniqueRecipients. - */ - public static final String GlobalUniqueRecipients = "GlobalUniqueRecipients"; - - /** - * The Constant UniqueUnreadSenders. - */ - public static final String UniqueUnreadSenders = "UniqueUnreadSenders"; - - /** - * The Constant GlobalUniqueUnreadSenders. - */ - public static final String GlobalUniqueUnreadSenders = - "GlobalUniqueUnreadSenders"; - - /** - * The Constant UniqueSenders. - */ - public static final String UniqueSenders = "UniqueSenders"; - - /** - * The Constant GlobalUniqueSenders. - */ - public static final String GlobalUniqueSenders = "GlobalUniqueSenders"; - - /** - * The Constant LastDeliveryTime. - */ - public static final String LastDeliveryTime = "LastDeliveryTime"; - - /** - * The Constant GlobalLastDeliveryTime. - */ - public static final String GlobalLastDeliveryTime = "GlobalLastDeliveryTime"; - - /** - * The Constant GlobalCategories. - */ - public static final String GlobalCategories = "GlobalCategories"; - - /** - * The Constant FlagStatus. - */ - public static final String FlagStatus = "FlagStatus"; - - /** - * The Constant GlobalFlagStatus. - */ - public static final String GlobalFlagStatus = "GlobalFlagStatus"; - - /** - * The Constant GlobalHasAttachments. - */ - public static final String GlobalHasAttachments = "GlobalHasAttachments"; - - /** - * The Constant MessageCount. - */ - public static final String MessageCount = "MessageCount"; - - /** - * The Constant GlobalMessageCount. - */ - public static final String GlobalMessageCount = "GlobalMessageCount"; - - /** - * The Constant GlobalUnreadCount. - */ - public static final String GlobalUnreadCount = "GlobalUnreadCount"; - - /** - * The Constant GlobalSize. - */ - public static final String GlobalSize = "GlobalSize"; - - /** - * The Constant ItemClasses. - */ - public static final String ItemClasses = "ItemClasses"; - - /** - * The Constant GlobalItemClasses. - */ - public static final String GlobalItemClasses = "GlobalItemClasses"; - - /** - * The Constant GlobalImportance. - */ - public static final String GlobalImportance = "GlobalImportance"; - - /** - * The Constant GlobalItemIds. - */ - public static final String GlobalItemIds = "GlobalItemIds"; - - // ApplyConversationAction - - /** - * The Constant ApplyConversationAction. - */ - public static final String ApplyConversationAction = - "ApplyConversationAction"; - - /** - * The Constant ConversationActions. - */ - public static final String ConversationActions = "ConversationActions"; - - /** - * The Constant ConversationAction. - */ - public static final String ConversationAction = "ConversationAction"; - - /** - * The Constant ApplyConversationActionResponse. - */ - public static final String ApplyConversationActionResponse = - "ApplyConversationActionResponse"; - - /** - * The Constant ApplyConversationActionResponseMessage. - */ - public static final String ApplyConversationActionResponseMessage = - "ApplyConversationActionResponseMessage"; - - /** - * The Constant EnableAlwaysDelete. - */ - public static final String EnableAlwaysDelete = "EnableAlwaysDelete"; - - /** - * The Constant ProcessRightAway. - */ - public static final String ProcessRightAway = "ProcessRightAway"; - - /** - * The Constant DestinationFolderId. - */ - public static final String DestinationFolderId = "DestinationFolderId"; - - /** - * The Constant ContextFolderId. - */ - public static final String ContextFolderId = "ContextFolderId"; - - /** - * The Constant ConversationLastSyncTime. - */ - public static final String ConversationLastSyncTime = - "ConversationLastSyncTime"; - - /** - * The Constant AlwaysCategorize. - */ - public static final String AlwaysCategorize = "AlwaysCategorize"; - - /** - * The Constant AlwaysDelete. - */ - public static final String AlwaysDelete = "AlwaysDelete"; - - /** - * The Constant AlwaysMove. - */ - public static final String AlwaysMove = "AlwaysMove"; - - /** - * The Constant Move. - */ - public static final String Move = "Move"; - - /** - * The Constant Copy. - */ - public static final String Copy = "Copy"; - - /** - * The Constant SetReadState. - */ - public static final String SetReadState = "SetReadState"; - - /** - * The Constant DeleteType. - */ - public static final String DeleteType = "DeleteType"; - // RoomList & Room - - /** - * The Constant RoomLists. - */ - public static final String RoomLists = "RoomLists"; - - /** - * The Constant Rooms. - */ - public static final String Rooms = "Rooms"; - - /** - * The Constant Room. - */ - public static final String Room = "Room"; - - /** - * The Constant RoomList. - */ - public static final String RoomList = "RoomList"; - - /** - * The Constant RoomId. - */ - public static final String RoomId = "Id"; - - // Autodiscover - - /** - * The Constant Autodiscover. - */ - public static final String Autodiscover = "Autodiscover"; - - /** - * The Constant BinarySecret. - */ - public static final String BinarySecret = "BinarySecret"; - - /** - * The Constant Response. - */ - public static final String Response = "Response"; - - /** - * The Constant User. - */ - public static final String User = "User"; - - /** - * The Constant LegacyDN. - */ - public static final String LegacyDN = "LegacyDN"; - - /** - * The Constant DeploymentId. - */ - public static final String DeploymentId = "DeploymentId"; - - /** - * The Constant Account. - */ - public static final String Account = "Account"; - - /** - * The Constant AccountType. - */ - public static final String AccountType = "AccountType"; - - /** - * The Constant Action. - */ - public static final String Action = "Action"; - - /** - * The Constant To. - */ - public static final String To = "To"; - - /** - * The Constant RedirectAddr. - */ - public static final String RedirectAddr = "RedirectAddr"; - - /** - * The Constant RedirectUrl. - */ - public static final String RedirectUrl = "RedirectUrl"; - - /** - * The Constant Protocol. - */ - public static final String Protocol = "Protocol"; - - /** - * The Constant Type. - */ - public static final String Type = "Type"; - - /** - * The Constant Server. - */ - public static final String Server = "Server"; - - /** - * The Constant ServerDN. - */ - public static final String ServerDN = "ServerDN"; - - /** - * The Constant ServerVersion. - */ - public static final String ServerVersion = "ServerVersion"; - - /** - * The Constant ServerVersionInfo. - */ - public static final String ServerVersionInfo = "ServerVersionInfo"; - - - /** - * The Constant SmtpAddress. - */ - public static final String SmtpAddress = "SmtpAddress"; - - /** - * The Constant OwnerSmtpAddress. - */ - public static final String OwnerSmtpAddress = "OwnerSmtpAddress"; - - /** - * The Constant AD. - */ - public static final String AD = "AD"; - - /** - * The Constant AuthPackage. - */ - public static final String AuthPackage = "AuthPackage"; - - /** - * The Constant MdbDN. - */ - public static final String MdbDN = "MdbDN"; - - /** - * The Constant EWSUrl. - */ - public static final String EWSUrl = "EWSUrl"; - - /** - * The Constant ASUrl. - */ - public static final String ASUrl = "ASUrl"; - - /** - * The Constant OOFUrl. - */ - public static final String OOFUrl = "OOFUrl"; - - /** - * The Constant UMUrl. - */ - public static final String UMUrl = "UMUrl"; - - /** - * The Constant OABUrl. - */ - public static final String OABUrl = "OABUrl"; - - /** - * The Constant Internal. - */ - public static final String Internal = "Internal"; - - /** - * The Constant External. - */ - public static final String External = "External"; - - /** - * The Constant OWAUrl. - */ - public static final String OWAUrl = "OWAUrl"; - - /** - * The Constant Error. - */ - public static final String Error = "Error"; - - /** - * The Constant ErrorCode. - */ - public static final String ErrorCode = "ErrorCode"; - - /** - * The Constant DebugData. - */ - public static final String DebugData = "DebugData"; - - /** - * The Constant Users. - */ - public static final String Users = "Users"; - - /** - * The Constant RequestedSettings. - */ - public static final String RequestedSettings = "RequestedSettings"; - - /** - * The Constant Setting. - */ - public static final String Setting = "Setting"; - - /** - * The Constant GetUserSettingsRequestMessage. - */ - public static final String GetUserSettingsRequestMessage = - "GetUserSettingsRequestMessage"; - - /** - * The Constant RequestedServerVersion. - */ - public static final String RequestedServerVersion = "RequestedServerVersion"; - - /** - * The Constant Request. - */ - public static final String Request = "Request"; - - /** - * The Constant RedirectTarget. - */ - public static final String RedirectTarget = "RedirectTarget"; - - /** - * The Constant UserSettings. - */ - public static final String UserSettings = "UserSettings"; - - /** - * The Constant UserSettingErrors. - */ - public static final String UserSettingErrors = "UserSettingErrors"; - - /** - * The Constant GetUserSettingsResponseMessage. - */ - public static final String GetUserSettingsResponseMessage = - "GetUserSettingsResponseMessage"; - - /** - * The Constant ErrorMessage. - */ - public static final String ErrorMessage = "ErrorMessage"; - - /** - * The Constant UserResponse. - */ - public static final String UserResponse = "UserResponse"; - - /** - * The Constant UserResponses. - */ - public static final String UserResponses = "UserResponses"; - - /** - * The Constant UserSettingError. - */ - public static final String UserSettingError = "UserSettingError"; - - /** - * The Constant Domain. - */ - public static final String Domain = "Domain"; - - /** - * The Constant Domains. - */ - public static final String Domains = "Domains"; - - /** - * The Constant DomainResponse. - */ - public static final String DomainResponse = "DomainResponse"; - - /** - * The Constant DomainResponses. - */ - public static final String DomainResponses = "DomainResponses"; - - /** - * The Constant DomainSetting. - */ - public static final String DomainSetting = "DomainSetting"; - - /** - * The Constant DomainSettings. - */ - public static final String DomainSettings = "DomainSettings"; - - /** - * The Constant DomainStringSetting. - */ - public static final String DomainStringSetting = "DomainStringSetting"; - - /** - * The Constant DomainSettingError. - */ - public static final String DomainSettingError = "DomainSettingError"; - - /** - * The Constant DomainSettingErrors. - */ - public static final String DomainSettingErrors = "DomainSettingErrors"; - - /** - * The Constant GetDomainSettingsRequestMessage. - */ - public static final String GetDomainSettingsRequestMessage = - "GetDomainSettingsRequestMessage"; - - /** - * The Constant GetDomainSettingsResponseMessage. - */ - public static final String GetDomainSettingsResponseMessage = - "GetDomainSettingsResponseMessage"; - - /** - * The Constant SettingName. - */ - public static final String SettingName = "SettingName"; - - /** - * The Constant UserSetting. - */ - public static final String UserSetting = "UserSetting"; - - /** - * The Constant StringSetting. - */ - public static final String StringSetting = "StringSetting"; - - /** - * The Constant WebClientUrlCollectionSetting. - */ - public static final String WebClientUrlCollectionSetting = - "WebClientUrlCollectionSetting"; - - /** - * The Constant WebClientUrls. - */ - public static final String WebClientUrls = "WebClientUrls"; - - /** - * The Constant WebClientUrl. - */ - public static final String WebClientUrl = "WebClientUrl"; - - /** - * The Constant AuthenticationMethods. - */ - public static final String AuthenticationMethods = "AuthenticationMethods"; - - /** - * The Constant Url. - */ - public static final String Url = "Url"; - - /** - * The Constant AlternateMailboxCollectionSetting. - */ - public static final String AlternateMailboxCollectionSetting = - "AlternateMailboxCollectionSetting"; - - /** - * The Constant AlternateMailboxes. - */ - public static final String AlternateMailboxes = "AlternateMailboxes"; - - /** - * The Constant AlternateMailbox. - */ - public static final String AlternateMailbox = "AlternateMailbox"; - - /** - * The Constant ProtocolConnectionCollectionSetting. - */ - public static final String ProtocolConnectionCollectionSetting = - "ProtocolConnectionCollectionSetting"; - - /** - * The Constant ProtocolConnections. - */ - public static final String ProtocolConnections = "ProtocolConnections"; - - /** - * The Constant ProtocolConnection. - */ - public static final String ProtocolConnection = "ProtocolConnection"; - - /** - * The Constant EncryptionMethod. - */ - public static final String EncryptionMethod = "EncryptionMethod"; - - /** - * The Constant Hostname. - */ - public static final String Hostname = "Hostname"; - - /** - * The Constant Port. - */ - public static final String Port = "Port"; - - /** - * The Constant Version. - */ - public static final String Version = "Version"; - - /** - * The Constant MajorVersion. - */ - public static final String MajorVersion = "MajorVersion"; - - /** - * The Constant MinorVersion. - */ - public static final String MinorVersion = "MinorVersion"; - - /** - * The Constant MajorBuildNumber. - */ - public static final String MajorBuildNumber = "MajorBuildNumber"; - - /** - * The Constant MinorBuildNumber. - */ - public static final String MinorBuildNumber = "MinorBuildNumber"; - - /** - * The Constant RequestedVersion. - */ - public static final String RequestedVersion = "RequestedVersion"; - - /** - * The Constant PublicFolderServer. - */ - public static final String PublicFolderServer = "PublicFolderServer"; - - /** - * The Constant Ssl. - */ - public static final String Ssl = "SSL"; - - /** - * The Constant SharingUrl. - */ - public static final String SharingUrl = "SharingUrl"; - - /** - * The Constant EcpUrl. - */ - public static final String EcpUrl = "EcpUrl"; - - /** - * The Constant EcpUrl_um. - */ - public static final String EcpUrl_um = "EcpUrl-um"; - - /** - * The Constant EcpUrl_aggr. - */ - public static final String EcpUrl_aggr = "EcpUrl-aggr"; - - /** - * The Constant EcpUrl_sms. - */ - public static final String EcpUrl_sms = "EcpUrl-sms"; - - /** - * The Constant EcpUrl_mt. - */ - public static final String EcpUrl_mt = "EcpUrl-mt"; - - /** - * The Constant EcpUrl_ret. - */ - public static final String EcpUrl_ret = "EcpUrl-ret"; - - /** - * The Constant EcpUrl_publish. - */ - public static final String EcpUrl_publish = "EcpUrl-publish"; - - /** - * The Constant ExchangeRpcUrl. - */ - public static final String ExchangeRpcUrl = "ExchangeRpcUrl"; - - /** - * The Constant PartnerToken. - */ - public static final String PartnerToken = "PartnerToken"; - - /** - * The Constant PartnerTokenReference. - */ - public static final String PartnerTokenReference = "PartnerTokenReference"; - - /** - * The Constant GroupingInformation. - */ - public static final String GroupingInformation = "GroupingInformation"; - - // InboxRule - /** - * The Constant MinorBuildNumber. - */ - public static final String MailboxSmtpAddress = "MailboxSmtpAddress"; - - /** - * The Constant RuleId. - */ - public static final String RuleId = "RuleId"; - - /** - * The Constant Priority. - */ - public static final String Priority = "Priority"; - - /** - * The Constant IsEnabled. - */ - public static final String IsEnabled = "IsEnabled"; - - /** - * The Constant IsNotSupported. - */ - public static final String IsNotSupported = "IsNotSupported"; - - /** - * The Constant IsInError. - */ - public static final String IsInError = "IsInError"; - - /** - * The Constant Conditions. - */ - public static final String Conditions = "Conditions"; - - /** - * The Constant Exceptions. - */ - public static final String Exceptions = "Exceptions"; - - /** - * The Constant Actions. - */ - public static final String Actions = "Actions"; - - /** - * The Constant InboxRules. - */ - public static final String InboxRules = "InboxRules"; - - /** - * The Constant Rule. - */ - public static final String Rule = "Rule"; - - /** - * The Constant OutlookRuleBlobExists. - */ - public static final String OutlookRuleBlobExists = "OutlookRuleBlobExists"; - - /** - * The Constant RemoveOutlookRuleBlob. - */ - public static final String RemoveOutlookRuleBlob = "RemoveOutlookRuleBlob"; - - /** - * The Constant ContainsBodyStrings. - */ - public static final String ContainsBodyStrings = "ContainsBodyStrings"; - - /** - * The Constant ContainsHeaderStrings. - */ - public static final String ContainsHeaderStrings = "ContainsHeaderStrings"; - - /** - * The Constant ContainsRecipientStrings. - */ - public static final String ContainsRecipientStrings = - "ContainsRecipientStrings"; - - /** - * The Constant ContainsSenderStrings. - */ - public static final String ContainsSenderStrings = "ContainsSenderStrings"; - - /** - * The Constant ContainsSubjectOrBodyStrings. - */ - public static final String ContainsSubjectOrBodyStrings = - "ContainsSubjectOrBodyStrings"; - - /** - * The Constant ContainsSubjectStrings. - */ - public static final String ContainsSubjectStrings = "ContainsSubjectStrings"; - - /** - * The Constant FlaggedForAction. - */ - public static final String FlaggedForAction = "FlaggedForAction"; - - /** - * The Constant FromAddresses. - */ - public static final String FromAddresses = "FromAddresses"; - - /** - * The Constant FromConnectedAccounts. - */ - public static final String FromConnectedAccounts = "FromConnectedAccounts"; - - /** - * The Constant IsApprovalRequest. - */ - public static final String IsApprovalRequest = "IsApprovalRequest"; - - /** - * The Constant IsAutomaticForward. - */ - public static final String IsAutomaticForward = "IsAutomaticForward"; - - /** - * The Constant IsAutomaticReply. - */ - public static final String IsAutomaticReply = "IsAutomaticReply"; - - /** - * The Constant IsEncrypted. - */ - public static final String IsEncrypted = "IsEncrypted"; - - /** - * The Constant IsMeetingRequest. - */ - public static final String IsMeetingRequest = "IsMeetingRequest"; - - /** - * The Constant IsMeetingResponse. - */ - public static final String IsMeetingResponse = "IsMeetingResponse"; - - /** - * The Constant IsNDR. - */ - public static final String IsNDR = "IsNDR"; - - /** - * The Constant IsPermissionControlled. - */ - public static final String IsPermissionControlled = "IsPermissionControlled"; - - /** - * The Constant IsSigned. - */ - public static final String IsSigned = "IsSigned"; - - /** - * The Constant IsVoicemail. - */ - public static final String IsVoicemail = "IsVoicemail"; - - /** - * The Constant IsReadReceipt. - */ - public static final String IsReadReceipt = "IsReadReceipt"; - - /** - * The Constant MessageClassifications. - */ - public static final String MessageClassifications = "MessageClassifications"; - - /** - * The Constant NotSentToMe. - */ - public static final String NotSentToMe = "NotSentToMe"; - - /** - * The Constant SentCcMe. - */ - public static final String SentCcMe = "SentCcMe"; - - /** - * The Constant SentOnlyToMe. - */ - public static final String SentOnlyToMe = "SentOnlyToMe"; - - /** - * The Constant SentToAddresses. - */ - public static final String SentToAddresses = "SentToAddresses"; - - /** - * The Constant SentToMe. - */ - public static final String SentToMe = "SentToMe"; - - /** - * The Constant SentToOrCcMe. - */ - public static final String SentToOrCcMe = "SentToOrCcMe"; - - /** - * The Constant WithinDateRange. - */ - public static final String WithinDateRange = "WithinDateRange"; - - /** - * The Constant WithinSizeRange. - */ - public static final String WithinSizeRange = "WithinSizeRange"; - - /** - * The Constant MinimumSize. - */ - public static final String MinimumSize = "MinimumSize"; - - /** - * The Constant MaximumSize. - */ - public static final String MaximumSize = "MaximumSize"; - - /** - * The Constant StartDateTime. - */ - public static final String StartDateTime = "StartDateTime"; - - /** - * The Constant EndDateTime. - */ - public static final String EndDateTime = "EndDateTime"; - - /** - * The Constant AssignCategories. - */ - public static final String AssignCategories = "AssignCategories"; - - /** - * The Constant CopyToFolder. - */ - public static final String CopyToFolder = "CopyToFolder"; - - /** - * The Constant FlagMessage. - */ - public static final String FlagMessage = "FlagMessage"; - - /** - * The Constant ForwardAsAttachmentToRecipients. - */ - public static final String ForwardAsAttachmentToRecipients = - "ForwardAsAttachmentToRecipients"; - - /** - * The Constant ForwardToRecipients. - */ - public static final String ForwardToRecipients = "ForwardToRecipients"; - - /** - * The Constant MarkImportance. - */ - public static final String MarkImportance = "MarkImportance"; - - /** - * The Constant MarkAsRead. - */ - public static final String MarkAsRead = "MarkAsRead"; - - /** - * The Constant MoveToFolder. - */ - public static final String MoveToFolder = "MoveToFolder"; - - /** - * The Constant PermanentDelete. - */ - public static final String PermanentDelete = "PermanentDelete"; - - /** - * The Constant RedirectToRecipients. - */ - public static final String RedirectToRecipients = "RedirectToRecipients"; - - /** - * The Constant SendSMSAlertToRecipients. - */ - public static final String SendSMSAlertToRecipients = - "SendSMSAlertToRecipients"; - - /** - * The Constant ServerReplyWithMessage. - */ - public static final String ServerReplyWithMessage = "ServerReplyWithMessage"; - - /** - * The Constant StopProcessingRules. - */ - public static final String StopProcessingRules = "StopProcessingRules"; - - /** - * The Constant CreateRuleOperation. - */ - public static final String CreateRuleOperation = "CreateRuleOperation"; - - /** - * The Constant SetRuleOperation. - */ - public static final String SetRuleOperation = "SetRuleOperation"; - - /** - * The Constant DeleteRuleOperation. - */ - public static final String DeleteRuleOperation = "DeleteRuleOperation"; - - /** - * The Constant Operations. - */ - public static final String Operations = "Operations"; - - /** - * The Constant RuleOperationErrors. - */ - public static final String RuleOperationErrors = "RuleOperationErrors"; - - /** - * The Constant RuleOperationError. - */ - public static final String RuleOperationError = "RuleOperationError"; - - /** - * The Constant OperationIndex. - */ - public static final String OperationIndex = "OperationIndex"; - - /** - * The Constant ValidationErrors. - */ - public static final String ValidationErrors = "ValidationErrors"; - - /** - * The Constant FieldValue. - */ - public static final String FieldValue = "FieldValue"; - - // Restrictions - /** - * The Constant Not. - */ - public static final String Not = "Not"; - - /** - * The Constant Bitmask. - */ - public static final String Bitmask = "Bitmask"; - - /** - * The Constant Constant. - */ - public static final String Constant = "Constant"; - - /** - * The Constant Restriction. - */ - public static final String Restriction = "Restriction"; - - /** - * The Constant Contains. - */ - public static final String Contains = "Contains"; - - /** - * The Constant Excludes. - */ - public static final String Excludes = "Excludes"; - - /** - * The Constant Exists. - */ - public static final String Exists = "Exists"; - - /** - * The Constant FieldURIOrConstant. - */ - public static final String FieldURIOrConstant = "FieldURIOrConstant"; - - /** - * The Constant And. - */ - public static final String And = "And"; - - /** - * The Constant Or. - */ - public static final String Or = "Or"; - - /** - * The Constant IsEqualTo. - */ - public static final String IsEqualTo = "IsEqualTo"; - - /** - * The Constant IsNotEqualTo. - */ - public static final String IsNotEqualTo = "IsNotEqualTo"; - - /** - * The Constant IsGreaterThan. - */ - public static final String IsGreaterThan = "IsGreaterThan"; - - /** - * The Constant IsGreaterThanOrEqualTo. - */ - public static final String IsGreaterThanOrEqualTo = "IsGreaterThanOrEqualTo"; - - /** - * The Constant IsLessThan. - */ - public static final String IsLessThan = "IsLessThan"; - - /** - * The Constant IsLessThanOrEqualTo. - */ - public static final String IsLessThanOrEqualTo = "IsLessThanOrEqualTo"; - - // Directory only contact property - /** - * The Constant PhoneticFullName. - */ - public static final String PhoneticFullName = "PhoneticFullName"; - - /** - * The Constant PhoneticFirstName. - */ - public static final String PhoneticFirstName = "PhoneticFirstName"; - - /** - * The Constant PhoneticLastName. - */ - public static final String PhoneticLastName = "PhoneticLastName"; - - /** - * The Constant Alias. - */ - public static final String Alias = "Alias"; - - /** - * The Constant Notes. - */ - public static final String Notes = "Notes"; - - /** - * The Constant Photo. - */ - public static final String Photo = "Photo"; - - /** - * The Constant UserSMIMECertificate. - */ - public static final String UserSMIMECertificate = "UserSMIMECertificate"; - - /** - * The Constant MSExchangeCertificate. - */ - public static final String MSExchangeCertificate = "MSExchangeCertificate"; - - /** - * The Constant DirectoryId. - */ - public static final String DirectoryId = "DirectoryId"; - - /** - * The Constant ManagerMailbox. - */ - public static final String ManagerMailbox = "ManagerMailbox"; - - /** - * The Constant DirectReports. - */ - public static final String DirectReports = "DirectReports"; - - // Request/response element names - /** - * The Constant ResponseMessage. - */ - public static final String ResponseMessage = "ResponseMessage"; - - /** - * The Constant ResponseMessages. - */ - public static final String ResponseMessages = "ResponseMessages"; - - // FindConversation - /** - * The Constant FindConversation. - */ - public static final String FindConversation = "FindConversation"; - - /** - * The Constant FindConversationResponse. - */ - public static final String FindConversationResponse = - "FindConversationResponse"; - - /** - * The Constant FindConversationResponseMessage. - */ - public static final String FindConversationResponseMessage = - "FindConversationResponseMessage"; - - // FindItem - /** - * The Constant FindItem. - */ - public static final String FindItem = "FindItem"; - - /** - * The Constant FindItemResponse. - */ - public static final String FindItemResponse = "FindItemResponse"; - - /** - * The Constant FindItemResponseMessage. - */ - public static final String FindItemResponseMessage = - "FindItemResponseMessage"; - - // GetItem - /** - * The Constant GetItem. - */ - public static final String GetItem = "GetItem"; - - /** - * The Constant GetItemResponse. - */ - public static final String GetItemResponse = "GetItemResponse"; - - /** - * The Constant GetItemResponseMessage. - */ - public static final String GetItemResponseMessage = "GetItemResponseMessage"; - - // CreateItem - /** - * The Constant CreateItem. - */ - public static final String CreateItem = "CreateItem"; - - /** - * The Constant CreateItemResponse. - */ - public static final String CreateItemResponse = "CreateItemResponse"; - - /** - * The Constant CreateItemResponseMessage. - */ - public static final String CreateItemResponseMessage = - "CreateItemResponseMessage"; - - // SendItem - /** - * The Constant SendItem. - */ - public static final String SendItem = "SendItem"; - - /** - * The Constant SendItemResponse. - */ - public static final String SendItemResponse = "SendItemResponse"; - - /** - * The Constant SendItemResponseMessage. - */ - public static final String SendItemResponseMessage = - "SendItemResponseMessage"; - - // DeleteItem - /** - * The Constant DeleteItem. - */ - public static final String DeleteItem = "DeleteItem"; - - /** - * The Constant DeleteItemResponse. - */ - public static final String DeleteItemResponse = "DeleteItemResponse"; - - /** - * The Constant DeleteItemResponseMessage. - */ - public static final String DeleteItemResponseMessage = - "DeleteItemResponseMessage"; - - // UpdateItem - /** - * The Constant UpdateItem. - */ - public static final String UpdateItem = "UpdateItem"; - - /** - * The Constant UpdateItemResponse. - */ - public static final String UpdateItemResponse = "UpdateItemResponse"; - - /** - * The Constant UpdateItemResponseMessage. - */ - public static final String UpdateItemResponseMessage = - "UpdateItemResponseMessage"; - - // CopyItem - /** - * The Constant CopyItem. - */ - public static final String CopyItem = "CopyItem"; - - /** - * The Constant CopyItemResponse. - */ - public static final String CopyItemResponse = "CopyItemResponse"; - - /** - * The Constant CopyItemResponseMessage. - */ - public static final String CopyItemResponseMessage = - "CopyItemResponseMessage"; - - // MoveItem - /** - * The Constant MoveItem. - */ - public static final String MoveItem = "MoveItem"; - - /** - * The Constant MoveItemResponse. - */ - public static final String MoveItemResponse = "MoveItemResponse"; - - /** - * The Constant MoveItemResponseMessage. - */ - public static final String MoveItemResponseMessage = - "MoveItemResponseMessage"; - - // FindFolder - /** - * The Constant FindFolder. - */ - public static final String FindFolder = "FindFolder"; - - /** - * The Constant FindFolderResponse. - */ - public static final String FindFolderResponse = "FindFolderResponse"; - - /** - * The Constant FindFolderResponseMessage. - */ - public static final String FindFolderResponseMessage = - "FindFolderResponseMessage"; - - // GetFolder - /** - * The Constant GetFolder. - */ - public static final String GetFolder = "GetFolder"; - - /** - * The Constant GetFolderResponse. - */ - public static final String GetFolderResponse = "GetFolderResponse"; - - /** - * The Constant GetFolderResponseMessage. - */ - public static final String GetFolderResponseMessage = - "GetFolderResponseMessage"; - - // CreateFolder - /** - * The Constant CreateFolder. - */ - public static final String CreateFolder = "CreateFolder"; - - /** - * The Constant CreateFolderResponse. - */ - public static final String CreateFolderResponse = "CreateFolderResponse"; - - /** - * The Constant CreateFolderResponseMessage. - */ - public static final String CreateFolderResponseMessage = - "CreateFolderResponseMessage"; - - // DeleteFolder - /** - * The Constant DeleteFolder. - */ - public static final String DeleteFolder = "DeleteFolder"; - - /** - * The Constant DeleteFolderResponse. - */ - public static final String DeleteFolderResponse = "DeleteFolderResponse"; - - /** - * The Constant DeleteFolderResponseMessage. - */ - public static final String DeleteFolderResponseMessage = - "DeleteFolderResponseMessage"; - - // EmptyFolder - /** - * The Constant EmptyFolder. - */ - public static final String EmptyFolder = "EmptyFolder"; - - /** - * The Constant EmptyFolderResponse. - */ - public static final String EmptyFolderResponse = "EmptyFolderResponse"; - - /** - * The Constant EmptyFolderResponseMessage. - */ - public static final String EmptyFolderResponseMessage = - "EmptyFolderResponseMessage"; - - // UpdateFolder - /** - * The Constant UpdateFolder. - */ - public static final String UpdateFolder = "UpdateFolder"; - - /** - * The Constant UpdateFolderResponse. - */ - public static final String UpdateFolderResponse = "UpdateFolderResponse"; - - /** - * The Constant UpdateFolderResponseMessage. - */ - public static final String UpdateFolderResponseMessage = - "UpdateFolderResponseMessage"; - - // CopyFolder - /** - * The Constant CopyFolder. - */ - public static final String CopyFolder = "CopyFolder"; - - /** - * The Constant CopyFolderResponse. - */ - public static final String CopyFolderResponse = "CopyFolderResponse"; - - /** - * The Constant CopyFolderResponseMessage. - */ - public static final String CopyFolderResponseMessage = - "CopyFolderResponseMessage"; - - // MoveFolder - /** - * The Constant MoveFolder. - */ - public static final String MoveFolder = "MoveFolder"; - - /** - * The Constant MoveFolderResponse. - */ - public static final String MoveFolderResponse = "MoveFolderResponse"; - - /** - * The Constant MoveFolderResponseMessage. - */ - public static final String MoveFolderResponseMessage = - "MoveFolderResponseMessage"; - - // GetAttachment - /** - * The Constant GetAttachment. - */ - public static final String GetAttachment = "GetAttachment"; - - /** - * The Constant GetAttachmentResponse. - */ - public static final String GetAttachmentResponse = "GetAttachmentResponse"; - - /** - * The Constant GetAttachmentResponseMessage. - */ - public static final String GetAttachmentResponseMessage = - "GetAttachmentResponseMessage"; - - // CreateAttachment - /** - * The Constant CreateAttachment. - */ - public static final String CreateAttachment = "CreateAttachment"; - - /** - * The Constant CreateAttachmentResponse. - */ - public static final String CreateAttachmentResponse = - "CreateAttachmentResponse"; - - /** - * The Constant CreateAttachmentResponseMessage. - */ - public static final String CreateAttachmentResponseMessage = - "CreateAttachmentResponseMessage"; - - // DeleteAttachment - /** - * The Constant DeleteAttachment. - */ - public static final String DeleteAttachment = "DeleteAttachment"; - - /** - * The Constant DeleteAttachmentResponse. - */ - public static final String DeleteAttachmentResponse = - "DeleteAttachmentResponse"; - - /** - * The Constant DeleteAttachmentResponseMessage. - */ - public static final String DeleteAttachmentResponseMessage = - "DeleteAttachmentResponseMessage"; - - // ResolveNames - /** - * The Constant ResolveNames. - */ - public static final String ResolveNames = "ResolveNames"; - - /** - * The Constant ResolveNamesResponse. - */ - public static final String ResolveNamesResponse = "ResolveNamesResponse"; - - /** - * The Constant ResolveNamesResponseMessage. - */ - public static final String ResolveNamesResponseMessage = - "ResolveNamesResponseMessage"; - - // ExpandDL - /** - * The Constant ExpandDL. - */ - public static final String ExpandDL = "ExpandDL"; - - /** - * The Constant ExpandDLResponse. - */ - public static final String ExpandDLResponse = "ExpandDLResponse"; - - /** - * The Constant ExpandDLResponseMessage. - */ - public static final String ExpandDLResponseMessage = - "ExpandDLResponseMessage"; - - // Subscribe - /** - * The Constant Subscribe. - */ - public static final String Subscribe = "Subscribe"; - - /** - * The Constant SubscribeResponse. - */ - public static final String SubscribeResponse = "SubscribeResponse"; - - /** - * The Constant SubscribeResponseMessage. - */ - public static final String SubscribeResponseMessage = - "SubscribeResponseMessage"; - - // Unsubscribe - /** - * The Constant Unsubscribe. - */ - public static final String Unsubscribe = "Unsubscribe"; - - /** - * The Constant UnsubscribeResponse. - */ - public static final String UnsubscribeResponse = "UnsubscribeResponse"; - - /** - * The Constant UnsubscribeResponseMessage. - */ - public static final String UnsubscribeResponseMessage = - "UnsubscribeResponseMessage"; - - // GetEvents - /** - * The Constant GetEvents. - */ - public static final String GetEvents = "GetEvents"; - - /** - * The Constant GetEventsResponse. - */ - public static final String GetEventsResponse = "GetEventsResponse"; - - /** - * The Constant GetEventsResponseMessage. - */ - public static final String GetEventsResponseMessage = - "GetEventsResponseMessage"; - - // GetStreamingEvents - /** - * The Constant GetStreamingEvents. - */ - public static final String GetStreamingEvents = "GetStreamingEvents"; - - /** - * The Constant GetStreamingEventsResponse. - */ - public static final String GetStreamingEventsResponse = - "GetStreamingEventsResponse"; - - /** - * The Constant GetStreamingEventsResponseMessage. - */ - public static final String GetStreamingEventsResponseMessage = - "GetStreamingEventsResponseMessage"; - - /** - * The Constant ConnectionStatus. - */ - public static final String ConnectionStatus = "ConnectionStatus"; - - /** - * The Constant ErrorSubscriptionIds. - */ - public static final String ErrorSubscriptionIds = "ErrorSubscriptionIds"; - - /** - * The Constant ConnectionTimeout. - */ - public static final String ConnectionTimeout = "ConnectionTimeout"; - - /** - * The Constant HeartbeatFrequency. - */ - public static final String HeartbeatFrequency = "HeartbeatFrequency"; - - - // SyncFolderItems - /** - * The Constant SyncFolderItems. - */ - public static final String SyncFolderItems = "SyncFolderItems"; - - /** - * The Constant SyncFolderItemsResponse. - */ - public static final String SyncFolderItemsResponse = - "SyncFolderItemsResponse"; - - /** - * The Constant SyncFolderItemsResponseMessage. - */ - public static final String SyncFolderItemsResponseMessage = - "SyncFolderItemsResponseMessage"; - - // SyncFolderHierarchy - /** - * The Constant SyncFolderHierarchy. - */ - public static final String SyncFolderHierarchy = "SyncFolderHierarchy"; - - /** - * The Constant SyncFolderHierarchyResponse. - */ - public static final String SyncFolderHierarchyResponse = - "SyncFolderHierarchyResponse"; - - /** - * The Constant SyncFolderHierarchyResponseMessage. - */ - public static final String SyncFolderHierarchyResponseMessage = - "SyncFolderHierarchyResponseMessage"; - - // GetUserOofSettings - /** - * The Constant GetUserOofSettingsRequest. - */ - public static final String GetUserOofSettingsRequest = - "GetUserOofSettingsRequest"; - - /** - * The Constant GetUserOofSettingsResponse. - */ - public static final String GetUserOofSettingsResponse = - "GetUserOofSettingsResponse"; - - // SetUserOofSettings - /** - * The Constant SetUserOofSettingsRequest. - */ - public static final String SetUserOofSettingsRequest = - "SetUserOofSettingsRequest"; - - /** - * The Constant SetUserOofSettingsResponse. - */ - public static final String SetUserOofSettingsResponse = - "SetUserOofSettingsResponse"; - - // GetUserAvailability - /** - * The Constant GetUserAvailabilityRequest. - */ - public static final String GetUserAvailabilityRequest = - "GetUserAvailabilityRequest"; - - /** - * The Constant GetUserAvailabilityResponse. - */ - public static final String GetUserAvailabilityResponse = - "GetUserAvailabilityResponse"; - - /** - * The Constant FreeBusyResponseArray. - */ - public static final String FreeBusyResponseArray = "FreeBusyResponseArray"; - - /** - * The Constant FreeBusyResponse. - */ - public static final String FreeBusyResponse = "FreeBusyResponse"; - - /** - * The Constant SuggestionsResponse. - */ - public static final String SuggestionsResponse = "SuggestionsResponse"; - - // GetRoomLists - /** - * The Constant GetRoomListsRequest. - */ - public static final String GetRoomListsRequest = "GetRoomLists"; - - /** - * The Constant GetRoomListsResponse. - */ - public static final String GetRoomListsResponse = "GetRoomListsResponse"; - - // GetRooms - /** - * The Constant GetRoomsRequest. - */ - public static final String GetRoomsRequest = "GetRooms"; - - /** - * The Constant GetRoomsResponse. - */ - public static final String GetRoomsResponse = "GetRoomsResponse"; - - // ConvertId - /** - * The Constant ConvertId. - */ - public static final String ConvertId = "ConvertId"; - - /** - * The Constant ConvertIdResponse. - */ - public static final String ConvertIdResponse = "ConvertIdResponse"; - - /** - * The Constant ConvertIdResponseMessage. - */ - public static final String ConvertIdResponseMessage = - "ConvertIdResponseMessage"; - - // AddDelegate - /** - * The Constant AddDelegate. - */ - public static final String AddDelegate = "AddDelegate"; - - /** - * The Constant AddDelegateResponse. - */ - public static final String AddDelegateResponse = "AddDelegateResponse"; - - /** - * The Constant DelegateUserResponseMessageType. - */ - public static final String DelegateUserResponseMessageType = - "DelegateUserResponseMessageType"; - - // RemoveDelegte - /** - * The Constant RemoveDelegate. - */ - public static final String RemoveDelegate = "RemoveDelegate"; - - /** - * The Constant RemoveDelegateResponse. - */ - public static final String RemoveDelegateResponse = "RemoveDelegateResponse"; - - // GetDelegate - /** - * The Constant GetDelegate. - */ - public static final String GetDelegate = "GetDelegate"; - - /** - * The Constant GetDelegateResponse. - */ - public static final String GetDelegateResponse = "GetDelegateResponse"; - - // UpdateDelegate - /** - * The Constant UpdateDelegate. - */ - public static final String UpdateDelegate = "UpdateDelegate"; - - /** - * The Constant UpdateDelegateResponse. - */ - public static final String UpdateDelegateResponse = "UpdateDelegateResponse"; - - // CreateUserConfiguration - /** - * The Constant CreateUserConfiguration. - */ - public static final String CreateUserConfiguration = - "CreateUserConfiguration"; - - /** - * The Constant CreateUserConfigurationResponse. - */ - public static final String CreateUserConfigurationResponse = - "CreateUserConfigurationResponse"; - - /** - * The Constant CreateUserConfigurationResponseMessage. - */ - public static final String CreateUserConfigurationResponseMessage = - "CreateUserConfigurationResponseMessage"; - - // DeleteUserConfiguration - /** - * The Constant DeleteUserConfiguration. - */ - public static final String DeleteUserConfiguration = - "DeleteUserConfiguration"; - - /** - * The Constant DeleteUserConfigurationResponse. - */ - public static final String DeleteUserConfigurationResponse = - "DeleteUserConfigurationResponse"; - - /** - * The Constant DeleteUserConfigurationResponseMessage. - */ - public static final String DeleteUserConfigurationResponseMessage = - "DeleteUserConfigurationResponseMessage"; - - // GetUserConfiguration - /** - * The Constant GetUserConfiguration. - */ - public static final String GetUserConfiguration = "GetUserConfiguration"; - - /** - * The Constant GetUserConfigurationResponse. - */ - public static final String GetUserConfigurationResponse = - "GetUserConfigurationResponse"; - - /** - * The Constant GetUserConfigurationResponseMessage. - */ - public static final String GetUserConfigurationResponseMessage = - "GetUserConfigurationResponseMessage"; - - // UpdateUserConfiguration - /** - * The Constant UpdateUserConfiguration. - */ - public static final String UpdateUserConfiguration = - "UpdateUserConfiguration"; - - /** - * The Constant UpdateUserConfigurationResponse. - */ - public static final String UpdateUserConfigurationResponse = - "UpdateUserConfigurationResponse"; - - /** - * The Constant UpdateUserConfigurationResponseMessage. - */ - public static final String UpdateUserConfigurationResponseMessage = - "UpdateUserConfigurationResponseMessage"; - - // PlayOnPhone - /** - * The Constant PlayOnPhone. - */ - public static final String PlayOnPhone = "PlayOnPhone"; - - /** - * The Constant PlayOnPhoneResponse. - */ - public static final String PlayOnPhoneResponse = "PlayOnPhoneResponse"; - - // GetPhoneCallInformation - /** - * The Constant GetPhoneCall. - */ - public static final String GetPhoneCall = "GetPhoneCallInformation"; - - /** - * The Constant GetPhoneCallResponse. - */ - public static final String GetPhoneCallResponse = - "GetPhoneCallInformationResponse"; - - // DisconnectCall - /** - * The Constant DisconnectPhoneCall. - */ - public static final String DisconnectPhoneCall = "DisconnectPhoneCall"; - - /** - * The Constant DisconnectPhoneCallResponse. - */ - public static final String DisconnectPhoneCallResponse = - "DisconnectPhoneCallResponse"; - - // GetServerTimeZones - /** - * The Constant GetServerTimeZones. - */ - public static final String GetServerTimeZones = "GetServerTimeZones"; - - /** - * The Constant GetServerTimeZonesResponse. - */ - public static final String GetServerTimeZonesResponse = - "GetServerTimeZonesResponse"; - - /** - * The Constant GetServerTimeZonesResponseMessage. - */ - public static final String GetServerTimeZonesResponseMessage = - "GetServerTimeZonesResponseMessage"; - - // GetInboxRules - /** - * The Constant GetInboxRules. - */ - public static final String GetInboxRules = "GetInboxRules"; - - /** - * The Constant GetInboxRulesResponse. - */ - public static final String GetInboxRulesResponse = "GetInboxRulesResponse"; - - // UpdateInboxRules - /** - * The Constant UpdateInboxRules. - */ - public static final String UpdateInboxRules = "UpdateInboxRules"; - - /** - * The Constant UpdateInboxRulesResponse. - */ - public static final String UpdateInboxRulesResponse = - "UpdateInboxRulesResponse"; - - // ExecuteDiagnosticMethod - /** - * The Constant ExecuteDiagnosticMethod. - */ - public static final String ExecuteDiagnosticMethod = - "ExecuteDiagnosticMethod"; - - /** - * The Constant ExecuteDiagnosticMethodResponse. - */ - public static final String ExecuteDiagnosticMethodResponse = - "ExecuteDiagnosticMethodResponse"; - - /** - * The Constant ExecuteDiagnosticMethodResponseMEssage. - */ - public static final String ExecuteDiagnosticMethodResponseMEssage = - "ExecuteDiagnosticMethodResponseMessage"; - - // GetPasswordExpirationDate - /** - * The Constant GetPasswordExpirationDate. - */ - public static final String GetPasswordExpirationDateRequest = - "GetPasswordExpirationDate"; - - /** - * The Constant GetPasswordExpirationDateResponse. - */ - public static final String GetPasswordExpirationDateResponse = - "GetPasswordExpirationDateResponse"; - - // SOAP element names - - /** - * The Constant SOAPEnvelopeElementName. - */ - public static final String SOAPEnvelopeElementName = "Envelope"; - - /** - * The Constant SOAPHeaderElementName. - */ - public static final String SOAPHeaderElementName = "Header"; - - /** - * The Constant SOAPBodyElementName. - */ - public static final String SOAPBodyElementName = "Body"; - - /** - * The Constant SOAPFaultElementName. - */ - public static final String SOAPFaultElementName = "Fault"; - - /** - * The Constant SOAPFaultCodeElementName. - */ - public static final String SOAPFaultCodeElementName = "faultcode"; - - /** - * The Constant SOAPFaultStringElementName. - */ - public static final String SOAPFaultStringElementName = "faultstring"; - - /** - * The Constant SOAPFaultActorElementName. - */ - public static final String SOAPFaultActorElementName = "faultactor"; - - /** - * The Constant SOAPDetailElementName. - */ - public static final String SOAPDetailElementName = "detail"; - - /** - * The Constant EwsResponseCodeElementName. - */ - public static final String EwsResponseCodeElementName = "ResponseCode"; - - /** - * The Constant EwsMessageElementName. - */ - public static final String EwsMessageElementName = "Message"; - - /** - * The Constant EwsLineElementName. - */ - public static final String EwsLineElementName = "Line"; - - /** - * The Constant EwsPositionElementName. - */ - public static final String EwsPositionElementName = "Position"; - - /** - * The Constant EwsErrorCodeElementName. - */ - public static final String EwsErrorCodeElementName = "ErrorCode"; // Generated - - - // by - // Availability - /** - * The Constant EwsExceptionTypeElementName. - */ - public static final String EwsExceptionTypeElementName = "ExceptionType"; // Generated - - // by - // UM - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/attribute/EditorBrowsableState.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/attribute/EditorBrowsableState.java deleted file mode 100644 index 827be1cd8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/attribute/EditorBrowsableState.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.attribute; - -/** - * The Enum EditorBrowsableState. - */ -public enum EditorBrowsableState { - - // Summary: - // The property or method is always browsable from within an editor. - /** - * The Always. - */ - Always, - // - // Summary: - // The property or method is never browsable from within an editor. - /** - * The Never. - */ - Never, - // - // Summary: - // The property or method is a feature that only advanced users should see. - // An editor can either show or hide such property. - /** - * The Advanced. - */ - Advanced, -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/availability/FreeBusyViewType.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/availability/FreeBusyViewType.java deleted file mode 100644 index 4efa1ecea..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/availability/FreeBusyViewType.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.availability; - -/** - * Defines the type of free/busy information returned by a GetUserAvailability - * operation. - */ -public enum FreeBusyViewType { - - // No view could be returned. This value cannot be specified in a call to - // GetUserAvailability. - /** - * The None. - */ - None, - - // Represents an aggregated free/busy stream. In cross-forest scenarios in - // which the target user in one forest - // does not have an Availability service configured, the Availability - // service of the requestor retrieves the - // target users free/busy information from the free/busy public folder. - // Because public folder only store - // free/busy information in merged form, MergedOnly is the only available - // information. - /** - * The Merged only. - */ - MergedOnly, - - // Represents the legacy status information: free, busy, tentative, and OOF. - // This also includes the start/end - // times of the appointments. This view is richer than the legacy free/busy - // view because individual meeting - // start and end times are provided instead of an aggregated free/busy - // stream. - /** - * The Free busy. - */ - FreeBusy, - - // Represents all the property in FreeBusy with a stream of merged - // free/busy availability information. - /** - * The Free busy merged. - */ - FreeBusyMerged, - - // Represents the legacy status information: free, busy, tentative, and OOF; - // the start/end times of the - // appointments; and various property of the appointment such as subject, - // location, and importance. - // This requested view will return the maximum amount of information for - // which the requesting user is privileged. - // If merged free/busy information only is available, as with requesting - // information for users in a Microsoft - // Exchange Server 2003 forest, MergedOnly will be returned. Otherwise, - // FreeBusy or Detailed will be returned. - /** - * The Detailed. - */ - Detailed, - - // Represents all the property in Detailed with a stream of merged - // free/busy availability - // information. If only merged free/busy information is available, for - // example if the mailbox exists on a computer - // running Exchange 2003, MergedOnly will be returned. Otherwise, - // FreeBusyMerged or DetailedMerged will be returned. - /** - * The Detailed merged. - */ - DetailedMerged - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/availability/MeetingAttendeeType.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/availability/MeetingAttendeeType.java deleted file mode 100644 index 04276c003..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/availability/MeetingAttendeeType.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.availability; - -/** - * Defines the type of a meeting attendee. - */ -public enum MeetingAttendeeType { - - // The attendee is the organizer of the meeting. - /** - * The Organizer. - */ - Organizer, - - // The attendee is required. - /** - * The Required. - */ - Required, - - // The attendee is optional. - /** - * The Optional. - */ - Optional, - - // The attendee is a room. - /** - * The Room. - */ - Room, - - // The attendee is a resource. - /** - * The Resource. - */ - Resource - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/dns/DnsRecordType.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/dns/DnsRecordType.java deleted file mode 100644 index 8b7225b45..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/dns/DnsRecordType.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.dns; - -/** - * DNS record types. - */ -enum DnsRecordType { - // RFC 1034/1035 Address Record - /** - * The A. - */ - A(0x0001), - - // Canonical Name Record - /** - * The CNAME. - */ - CNAME(0x0005), - - // / Start of Authority Record - /** - * The SOA. - */ - SOA(0x0006), - - // / Pointer Record - /** - * The PTR. - */ - PTR(0x000c), - - // / Mail Exchange Record - /** - * The MX. - */ - MX(0x000f), - - // / Text Record - /** - * The TXT. - */ - TXT(0x0010), - - // / RFC 1886 (IPv6 Address) - /** - * The AAAA. - */ - AAAA(0x001c), - - // / Service location - RFC 2052 - /** - * The SRV. - */ - SRV(0x0021); - - /** - * The dns record. - */ - private final int dnsRecord; - - /** - * Instantiates a new dns record type. - * - * @param dnsRecord the dns record - */ - DnsRecordType(int dnsRecord) { - this.dnsRecord = dnsRecord; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/ConversationActionType.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/ConversationActionType.java deleted file mode 100644 index c52ae8d8f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/ConversationActionType.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.misc; - -/** - * Defines actions applicable to Conversation. - */ -public enum ConversationActionType { - - /** - * Categorizes every current and future message in the conversation - */ - AlwaysCategorize, - - /** - * Deletes every current and future message in the conversation - */ - AlwaysDelete, - - /** - * Moves every current and future message in the conversation - */ - AlwaysMove, - - /** - * Deletes current item in context folder in the conversation - */ - Delete, - - /** - * Moves current item in context folder in the conversation - */ - Move, - - /** - * Copies current item in context folder in the conversation - */ - Copy, - - /** - * Marks current item in context folder in the conversation with - * provided read state - */ - SetReadState, - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/ExchangeVersion.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/ExchangeVersion.java deleted file mode 100644 index d58db3dda..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/ExchangeVersion.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.misc; - -/** - * Defines the each available Exchange release version. - */ -public enum ExchangeVersion { - - // / Microsoft Exchange 2007, Service Pack 1 - /** - * The Exchange2007_ s p1. - */ - Exchange2007_SP1, - // / Microsoft Exchange 2010 - /** - * The Exchange2010. - */ - Exchange2010, - - /// Microsoft Exchange 2010, Service Pack 1 - /** - * Exchange2010_SP1. - */ - Exchange2010_SP1, - - // Microsoft Exchange 2010, Service Pack 2 - /** - * Exchange2010_SP2. - */ - Exchange2010_SP2, -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/FlaggedForAction.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/FlaggedForAction.java deleted file mode 100644 index ba39e4230..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/FlaggedForAction.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.misc; - -/** - * Defines the follow-up actions that may be stamped on a message. - */ -public enum FlaggedForAction { - - /** - * The message is flagged with any action. - */ - Any, - - /** - * The recipient is requested to call the sender. - */ - Call, - - /** - * The recipient is requested not to forward the message. - */ - DoNotForward, - - /** - * The recipient is requested to follow up on the message. - */ - FollowUp, - - /** - * The recipient received the message for information. - */ - FYI, - - /** - * The recipient is requested to forward the message. - */ - Forward, - - /** - * The recipient is informed that a response to the message is not required. - */ - NoResponseNecessary, - - /** - * The recipient is requested to read the message. - */ - Read, - - /** - * The recipient is requested to reply to the sender of the message. - */ - Reply, - - /** - * The recipient is requested to reply to everyone the message was sent to. - */ - ReplyToAll, - - /** - * The recipient is requested to review the message. - */ - Review - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/IdFormat.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/IdFormat.java deleted file mode 100644 index 0b62caead..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/IdFormat.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.misc; - -/** - * Defines supported Id formats in ConvertId operations. - */ -public enum IdFormat { - - // The EWS Id format used in Exchange 2007 RTM. - /** - * The Ews legacy id. - */ - EwsLegacyId, - - // The EWS Id format used in Exchange 2007 SP1 and above. - /** - * The Ews id. - */ - EwsId, - - // The base64-encoded PR_ENTRYID property. - /** - * The Entry id. - */ - EntryId, - - // The hexadecimal representation of the PR_ENTRYID property. - /** - * The Hex entry id. - */ - HexEntryId, - - // The Store Id format. - /** - * The Store id. - */ - StoreId, - - // The Outlook Web Access Id format. - /** - * The Owa id. - */ - OwaId -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/TraceFlags.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/TraceFlags.java deleted file mode 100644 index fbd8b7ab0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/TraceFlags.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.misc; - -/** - * Defines flags to control tracing details. - */ -public enum TraceFlags { - /* - * No tracing. - */ - /** - * The None. - */ - None, - /* - * Trace EWS request messages. - */ - /** - * The Ews request. - */ - EwsRequest, - /* - * Trace EWS response messages. - */ - /** - * The Ews response. - */ - EwsResponse, - /* - * Trace EWS response HTTP headers. - */ - /** - * The Ews response http headers. - */ - EwsResponseHttpHeaders, - /* - * Trace Autodiscover request messages. - */ - /** - * The Autodiscover request. - */ - AutodiscoverRequest, - /* - * Trace Autodiscover response messages. - */ - /** - * The Autodiscover response. - */ - AutodiscoverResponse, - /* - * Trace Autodiscover response HTTP headers. - */ - /** - * The Autodiscover response http headers. - */ - AutodiscoverResponseHttpHeaders, - /* - * Trace Autodiscover configuration logic. - */ - /** - * The Autodiscover configuration. - */ - AutodiscoverConfiguration, - - /* - * Trace messages used in debugging the Exchange Web Services Managed API - */ - /** - * The Debug Message. - */ - DebugMessage, - - /* - * Trace EWS request HTTP headers. - */ - /** - * The Ews Request Http Headers. - */ - EwsRequestHttpHeaders, - - /* - * Trace Autodiscover request HTTP headers. - */ - /** - * The Autodiscover Request HttpHeaders - */ - AutodiscoverRequestHttpHeaders, - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/UserConfigurationProperties.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/UserConfigurationProperties.java deleted file mode 100644 index 72323ac64..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/UserConfigurationProperties.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.misc; - -/** - * Identifies the user configuration property to retrieve. - */ -public enum UserConfigurationProperties { - - // Retrieve the Id property. - /** - * The Id. - */ - Id(1), - - // Retrieve the Dictionary property. - /** - * The Dictionary. - */ - Dictionary(2), - - // Retrieve the XmlData property. - /** - * The Xml data. - */ - XmlData(4), - - // Retrieve the BinaryData property. - /** - * The Binary data. - */ - BinaryData(8), - - // Retrieve all property. - /** - * The All. - */ - All(UserConfigurationProperties.Id, UserConfigurationProperties.Dictionary, - UserConfigurationProperties.XmlData, - UserConfigurationProperties.BinaryData); - - /** - * The config property. - */ - private int configProperties = 0; - - /** - * Instantiates a new user configuration property. - * - * @param configProperties the config property - */ - UserConfigurationProperties(int configProperties) { - this.configProperties = configProperties; - } - - /** - * Instantiates a new user configuration property. - * - * @param id the id - * @param dictionary the dictionary - * @param xmlData the xml data - * @param binaryData the binary data - */ - UserConfigurationProperties(UserConfigurationProperties id, - UserConfigurationProperties dictionary, - UserConfigurationProperties xmlData, - UserConfigurationProperties binaryData) { - - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/XmlNamespace.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/XmlNamespace.java deleted file mode 100644 index 7637313d4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/XmlNamespace.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.misc; - -import microsoft.exchange.webservices.data.core.EwsUtilities; - -/** - * Defines the namespaces as used by the EwsXmlReader, EwsServiceXmlReader, and - * EwsServiceXmlWriter classes. - */ -public enum XmlNamespace { - /* - * The namespace is not specified. - */ - /** - * The Not specified. - */ - NotSpecified("", ""), - - /** - * The Messages. - */ - Messages(EwsUtilities.EwsMessagesNamespacePrefix, - EwsUtilities.EwsMessagesNamespace), - - /** - * The Types. - */ - Types(EwsUtilities.EwsTypesNamespacePrefix, EwsUtilities.EwsTypesNamespace), - - /** - * The Errors. - */ - Errors(EwsUtilities.EwsErrorsNamespacePrefix, - EwsUtilities.EwsErrorsNamespace), - - /** - * The Soap. - */ - Soap(EwsUtilities.EwsSoapNamespacePrefix, EwsUtilities.EwsSoapNamespace), - - /** - * The Soap12. - */ - Soap12(EwsUtilities.EwsSoapNamespacePrefix, - EwsUtilities.EwsSoap12Namespace), - - /** - * The Xml schema instance. - */ - XmlSchemaInstance(EwsUtilities.EwsXmlSchemaInstanceNamespacePrefix, - EwsUtilities.EwsXmlSchemaInstanceNamespace), - - /** - * The Passport soap fault. - */ - PassportSoapFault(EwsUtilities.PassportSoapFaultNamespacePrefix, - EwsUtilities.PassportSoapFaultNamespace), - - /** - * The WS trust february2005. - */ - WSTrustFebruary2005(EwsUtilities.WSTrustFebruary2005NamespacePrefix, - EwsUtilities.WSTrustFebruary2005Namespace), - - /** - * The WS addressing. - */ - WSAddressing(EwsUtilities.WSAddressingNamespacePrefix, - EwsUtilities.WSAddressingNamespace), - - /** - * The Autodiscover. - */ - Autodiscover(EwsUtilities.AutodiscoverSoapNamespacePrefix, - EwsUtilities.AutodiscoverSoapNamespace); - - /** - * The prefix. - */ - private String prefix; - - /** - * The name space uri. - */ - private String nameSpaceUri; - - /** - * Instantiates a new xml namespace. - * - * @param prefix the prefix - * @param nameSpaceUri the name space uri - */ - XmlNamespace(String prefix, String nameSpaceUri) { - this.prefix = prefix; - this.nameSpaceUri = nameSpaceUri; - } - - /** - * Gets the name space uri. - * - * @return the name space uri - */ - public String getNameSpaceUri() { - return this.nameSpaceUri; - } - - /** - * Gets the name space prefix. - * - * @return the name space prefix - */ - public String getNameSpacePrefix() { - return this.prefix; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/error/ServiceError.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/error/ServiceError.java deleted file mode 100644 index 744c4eeec..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/error/ServiceError.java +++ /dev/null @@ -1,2193 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.misc.error; - -/** - * Defines the error codes that can be returned by the Exchange Web Services. - */ -public enum ServiceError { - - // NoError. Indicates that an error has not occurred. - /** - * The No error. - */ - NoError, - - // ErrorAccessDenied - /** - * The Error access denied. - */ - ErrorAccessDenied, - - // ErrorAccessModeSpecified - /** - * The impersonation authentication header should not be included. - */ - ErrorAccessModeSpecified, - - // ErrorAccountDisabled - /** - * The Error account disabled. - */ - ErrorAccountDisabled, - - // ErrorAddDelegatesFailed - /** - * The Error add delegates failed. - */ - ErrorAddDelegatesFailed, - - // ErrorAddressSpaceNotFound - /** - * ErrorAddressSpaceNotFound - */ - ErrorAddressSpaceNotFound, - - // ErrorADOperation - /** - * The Error ad operation. - */ - ErrorADOperation, - - // ErrorADSessionFilter - /** - * The Error ad session filter. - */ - ErrorADSessionFilter, - - // ErrorADUnavailable - /** - * The Error ad unavailable. - */ - ErrorADUnavailable, - - // ErrorAffectedTaskOccurrencesRequired - /** - * The Error affected task occurrences required. - */ - ErrorAffectedTaskOccurrencesRequired, - - /** - * The conversation action alwayscategorize or alwaysmove or alwaysdelete - * has failed. - */ - ErrorApplyConversationActionFailed, - - /** - * The item has attachment at more than the maximum supported nest level. - */ - ErrorAttachmentNestLevelLimitExceeded, - - // ErrorAttachmentSizeLimitExceeded - /** - * The Error attachment size limit exceeded. - */ - ErrorAttachmentSizeLimitExceeded, - - // ErrorAutoDiscoverFailed - /** - * The Error auto discover failed. - */ - ErrorAutoDiscoverFailed, - - // ErrorAvailabilityConfigNotFound - /** - * The Error availability config not found. - */ - ErrorAvailabilityConfigNotFound, - - // ErrorBatchProcessingStopped - /** - * The Error batch processing stopped. - */ - ErrorBatchProcessingStopped, - - // ErrorCalendarCannotMoveOrCopyOccurrence - /** - * The Error calendar cannot move or copy occurrence. - */ - ErrorCalendarCannotMoveOrCopyOccurrence, - - // ErrorCalendarCannotUpdateDeletedItem - /** - * The Error calendar cannot update deleted item. - */ - ErrorCalendarCannotUpdateDeletedItem, - - // ErrorCalendarCannotUseIdForOccurrenceId - /** - * The Error calendar cannot use id for occurrence id. - */ - ErrorCalendarCannotUseIdForOccurrenceId, - - // ErrorCalendarCannotUseIdForRecurringMasterId - /** - * The Error calendar cannot use id for recurring master id. - */ - ErrorCalendarCannotUseIdForRecurringMasterId, - - // ErrorCalendarDurationIsTooLong - /** - * The Error calendar duration is too long. - */ - ErrorCalendarDurationIsTooLong, - - // ErrorCalendarEndDateIsEarlierThanStartDate - /** - * The Error calendar end date is earlier than start date. - */ - ErrorCalendarEndDateIsEarlierThanStartDate, - - // ErrorCalendarFolderIsInvalidForCalendarView - /** - * The Error calendar folder is invalid for calendar view. - */ - ErrorCalendarFolderIsInvalidForCalendarView, - - // ErrorCalendarInvalidAttributeValue - /** - * The Error calendar invalid attribute value. - */ - ErrorCalendarInvalidAttributeValue, - - // ErrorCalendarInvalidDayForTimeChangePattern - /** - * The Error calendar invalid day for time change pattern. - */ - ErrorCalendarInvalidDayForTimeChangePattern, - - // ErrorCalendarInvalidDayForWeeklyRecurrence - /** - * The Error calendar invalid day for weekly recurrence. - */ - ErrorCalendarInvalidDayForWeeklyRecurrence, - - // ErrorCalendarInvalidPropertyState - /** - * The Error calendar invalid property state. - */ - ErrorCalendarInvalidPropertyState, - - // ErrorCalendarInvalidPropertyValue - /** - * The Error calendar invalid property value. - */ - ErrorCalendarInvalidPropertyValue, - - // ErrorCalendarInvalidRecurrence - /** - * The Error calendar invalid recurrence. - */ - ErrorCalendarInvalidRecurrence, - - // ErrorCalendarInvalidTimeZone - /** - * The Error calendar invalid time zone. - */ - ErrorCalendarInvalidTimeZone, - - // ErrorCalendarIsCancelledForAccept - /** - * The Error calendar is cancelled for accept. - */ - ErrorCalendarIsCancelledForAccept, - - // ErrorCalendarIsCancelledForDecline - /** - * The Error calendar is cancelled for decline. - */ - ErrorCalendarIsCancelledForDecline, - - // ErrorCalendarIsCancelledForRemove - /** - * The Error calendar is cancelled for remove. - */ - ErrorCalendarIsCancelledForRemove, - - // ErrorCalendarIsCancelledForTentative - /** - * The Error calendar is cancelled for tentative. - */ - ErrorCalendarIsCancelledForTentative, - - // ErrorCalendarIsDelegatedForAccept - /** - * The Error calendar is delegated for accept. - */ - ErrorCalendarIsDelegatedForAccept, - - // ErrorCalendarIsDelegatedForDecline - /** - * The Error calendar is delegated for decline. - */ - ErrorCalendarIsDelegatedForDecline, - - // ErrorCalendarIsDelegatedForRemove - /** - * The Error calendar is delegated for remove. - */ - ErrorCalendarIsDelegatedForRemove, - - // ErrorCalendarIsDelegatedForTentative - /** - * The Error calendar is delegated for tentative. - */ - ErrorCalendarIsDelegatedForTentative, - - // ErrorCalendarIsNotOrganizer - /** - * The Error calendar is not organizer. - */ - ErrorCalendarIsNotOrganizer, - - // ErrorCalendarIsOrganizerForAccept - /** - * The Error calendar is organizer for accept. - */ - ErrorCalendarIsOrganizerForAccept, - - // ErrorCalendarIsOrganizerForDecline - /** - * The Error calendar is organizer for decline. - */ - ErrorCalendarIsOrganizerForDecline, - - // ErrorCalendarIsOrganizerForRemove - /** - * The Error calendar is organizer for remove. - */ - ErrorCalendarIsOrganizerForRemove, - - // ErrorCalendarIsOrganizerForTentative - /** - * The Error calendar is organizer for tentative. - */ - ErrorCalendarIsOrganizerForTentative, - - // ErrorCalendarMeetingRequestIsOutOfDate - /** - * The Error calendar meeting request is out of date. - */ - ErrorCalendarMeetingRequestIsOutOfDate, - - // ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange - /** - * The Error calendar occurrence index is out of recurrence range. - */ - ErrorCalendarOccurrenceIndexIsOutOfRecurrenceRange, - - // ErrorCalendarOccurrenceIsDeletedFromRecurrence - /** - * The Error calendar occurrence is deleted from recurrence. - */ - ErrorCalendarOccurrenceIsDeletedFromRecurrence, - - // ErrorCalendarOutOfRange - /** - * The Error calendar out of range. - */ - ErrorCalendarOutOfRange, - - // ErrorCalendarViewRangeTooBig - /** - * The Error calendar view range too big. - */ - ErrorCalendarViewRangeTooBig, - - // ErrorCallerIsInvalidADAccount - /** - * The Error caller is invalid ad account. - */ - ErrorCallerIsInvalidADAccount, - - // ErrorCannotCreateCalendarItemInNonCalendarFolder - /** - * The Error cannot create calendar item in non calendar folder. - */ - ErrorCannotCreateCalendarItemInNonCalendarFolder, - - // ErrorCannotCreateContactInNonContactFolder - /** - * The Error cannot create contact in non contact folder. - */ - ErrorCannotCreateContactInNonContactFolder, - - // ErrorCannotCreatePostItemInNonMailFolder - /** - * The Error cannot create post item in non mail folder. - */ - ErrorCannotCreatePostItemInNonMailFolder, - - // ErrorCannotCreateTaskInNonTaskFolder - /** - * The Error cannot create task in non task folder. - */ - ErrorCannotCreateTaskInNonTaskFolder, - - // ErrorCannotDeleteObject - /** - * The Error cannot delete object. - */ - ErrorCannotDeleteObject, - - // ErrorCannotDeleteTaskOccurrence - /** - * The Error cannot delete task occurrence. - */ - ErrorCannotDeleteTaskOccurrence, - - /** - * Folder cannot be emptied. - */ - ErrorCannotEmptyFolder, - - // ErrorCannotOpenFileAttachment - /** - * The Error cannot open file attachment. - */ - ErrorCannotOpenFileAttachment, - - // ErrorCannotSetCalendarPermissionOnNonCalendarFolder - /** - * The Error cannot set calendar permission on non calendar folder. - */ - ErrorCannotSetCalendarPermissionOnNonCalendarFolder, - - // ErrorCannotSetNonCalendarPermissionOnCalendarFolder - /** - * The Error cannot set non calendar permission on calendar folder. - */ - ErrorCannotSetNonCalendarPermissionOnCalendarFolder, - - // ErrorCannotSetPermissionUnknownEntries - /** - * The Error cannot set permission unknown entries. - */ - ErrorCannotSetPermissionUnknownEntries, - - // ErrorCannotUseFolderIdForItemId - /** - * The Error cannot use folder id for item id. - */ - ErrorCannotUseFolderIdForItemId, - - // ErrorCannotUseItemIdForFolderId - /** - * The Error cannot use item id for folder id. - */ - ErrorCannotUseItemIdForFolderId, - - // ErrorChangeKeyRequired - /** - * The Error change key required. - */ - ErrorChangeKeyRequired, - - // ErrorChangeKeyRequiredForWriteOperations - /** - * The Error change key required for write operations. - */ - ErrorChangeKeyRequiredForWriteOperations, - - /** - * ErrorClientDisconnected - */ - ErrorClientDisconnected, - - // ErrorConnectionFailed - /** - * The Error connection failed. - */ - ErrorConnectionFailed, - - // ErrorContainsFilterWrongType - /** - * The Error contains filter wrong type. - */ - ErrorContainsFilterWrongType, - - // ErrorContentConversionFailed - /** - * The Error content conversion failed. - */ - ErrorContentConversionFailed, - - // ErrorCorruptData - /** - * The Error corrupt data. - */ - ErrorCorruptData, - - // ErrorCreateItemAccessDenied - /** - * The Error create item access denied. - */ - ErrorCreateItemAccessDenied, - - // ErrorCreateManagedFolderPartialCompletion - /** - * The Error create managed folder partial completion. - */ - ErrorCreateManagedFolderPartialCompletion, - - // ErrorCreateSubfolderAccessDenied - /** - * The Error create subfolder access denied. - */ - ErrorCreateSubfolderAccessDenied, - - // ErrorCrossMailboxMoveCopy - /** - * The Error cross mailbox move copy. - */ - ErrorCrossMailboxMoveCopy, - - // ErrorCrossSiteRequest - /** - * The Error cross site request. - */ - ErrorCrossSiteRequest, - - // ErrorDataSizeLimitExceeded - /** - * The Error data size limit exceeded. - */ - ErrorDataSizeLimitExceeded, - - // ErrorDataSourceOperation - /** - * The Error data source operation. - */ - ErrorDataSourceOperation, - - // ErrorDelegateAlreadyExists - /** - * The Error delegate already exists. - */ - ErrorDelegateAlreadyExists, - - // ErrorDelegateCannotAddOwner - /** - * The Error delegate cannot add owner. - */ - ErrorDelegateCannotAddOwner, - - // ErrorDelegateMissingConfiguration - /** - * The Error delegate missing configuration. - */ - ErrorDelegateMissingConfiguration, - - // ErrorDelegateNoUser - /** - * The Error delegate no user. - */ - ErrorDelegateNoUser, - - // ErrorDelegateValidationFailed - /** - * The Error delegate validation failed. - */ - ErrorDelegateValidationFailed, - - // ErrorDeleteDistinguishedFolder - /** - * The Error delete distinguished folder. - */ - ErrorDeleteDistinguishedFolder, - - // ErrorDeleteItemsFailed - /** - * The Error delete item failed. - */ - ErrorDeleteItemsFailed, - - // ErrorDistinguishedUserNotSupported - /** - * The Error distinguished user not supported. - */ - ErrorDistinguishedUserNotSupported, - - // ErrorDistributionListMemberNotExist - /** - * The Error distribution list member not exist. - */ - ErrorDistributionListMemberNotExist, - - // ErrorDuplicateInputFolderNames - /** - * The Error duplicate input folder names. - */ - ErrorDuplicateInputFolderNames, - - // ErrorDuplicateSOAPHeader - /** - * The Error duplicate soap header. - */ - ErrorDuplicateSOAPHeader, - - // ErrorDuplicateUserIdsSpecified - /** - * The Error duplicate user ids specified. - */ - ErrorDuplicateUserIdsSpecified, - - // ErrorEmailAddressMismatch - /** - * The Error email address mismatch. - */ - ErrorEmailAddressMismatch, - - // ErrorEventNotFound - /** - * The Error event not found. - */ - ErrorEventNotFound, - - // ErrorExceededConnectionCount - /** - * The Error exceeded connection count. - */ - ErrorExceededConnectionCount, - - // ErrorExceededFindCountLimmit - /** - * The Error exceeded find count limit. - */ - ErrorExceededFindCountLimit, - - // ErrorExceededSubscritionCount - /** - * The Error exceeded subscription count. - */ - ErrorExceededSubscriptionCount, - - // ErrorExpiredSubscription - /** - * The Error expired subscription. - */ - ErrorExpiredSubscription, - - // ErrorFolderCorrupt - /** - * The Error folder corrupt. - */ - ErrorFolderCorrupt, - - // ErrorFolderExists - /** - * The Error folder exists. - */ - ErrorFolderExists, - - // ErrorFolderNotFound - /** - * The specified folder could not be found in the store. - */ - ErrorFolderNotFound, - - // ErrorFolderPropertRequestFailed - /** - * ErrorFolderPropertRequestFailed - */ - ErrorFolderPropertRequestFailed, - - // ErrorFolderSave - /** - * The folder save operation did not succeed. - */ - ErrorFolderSave, - - // ErrorFolderSaveFailed - /** - * The save operation failed or partially succeeded. - */ - ErrorFolderSaveFailed, - - // ErrorFolderSavePropertyError - /** - * The folder save operation failed due to invalid property values. - */ - ErrorFolderSavePropertyError, - - // ErrorFreeBusyDLLimitReached - /** - * ErrorFreeBusyDLLimitReached - */ - ErrorFreeBusyDLLimitReached, - - // ErrorFreeBusyGenerationFailed - /** - * ErrorFreeBusyGenerationFailed - */ - ErrorFreeBusyGenerationFailed, - - // ErrorGetServerSecurityDescriptorFailed - /** - * ErrorGetServerSecurityDescriptorFailed - */ - ErrorGetServerSecurityDescriptorFailed, - - // ErrorImpersonateUserDenied - /** - * The account does not have permission to impersonate the requested user. - */ - ErrorImpersonateUserDenied, - - // ErrorImpersonationDenied - /** - * ErrorImpersonationDenied - */ - ErrorImpersonationDenied, - - // ErrorImpersonationFailed - /** - * Impersonation failed. - */ - ErrorImpersonationFailed, - - // ErrorInboxRulesValidationError - /** - * ErrorInboxRulesValidationError - */ - ErrorInboxRulesValidationError, - - // ErrorIncorrectSchemaVersion - /** - * The request is valid but does not specify the correct server version in - * the RequestServerVersion SOAP header. Ensure that the - * RequestServerVersion SOAP header is set with the correct - * RequestServerVersionValue. - */ - ErrorIncorrectSchemaVersion, - - // ErrorIncorrectUpdatePropertyCount - /** - * An object within a change description must contain one and only one - * property to modify. - */ - ErrorIncorrectUpdatePropertyCount, - - // ErrorIndividualMailboxLimitReached - /** - * ErrorIndividualMailboxLimitReached - */ - ErrorIndividualMailboxLimitReached, - - // ErrorInsufficientResources - /** - * Resources are unavailable. Try again later. - */ - ErrorInsufficientResources, - - // ErrorInternalServerError - /** - * An internal server error occurred. The operation failed. - */ - ErrorInternalServerError, - - // ErrorInternalServerTransientError - /** - * An internal server error occurred. Try again later. - */ - ErrorInternalServerTransientError, - - // ErrorInvalidAccessLevel - /** - * ErrorInvalidAccessLevel - */ - ErrorInvalidAccessLevel, - - // ErrorInvalidArgument - /** - * ErrorInvalidArgument - */ - ErrorInvalidArgument, - - // ErrorInvalidAttachmentId - /** - * The specified attachment Id is invalid. - */ - ErrorInvalidAttachmentId, - - // ErrorInvalidAttachmentSubfilter - /** - * Attachment subfilters must have a single TextFilter therein. - */ - ErrorInvalidAttachmentSubfilter, - - // ErrorInvalidAttachmentSubfilterTextFilter - /** - * Attachment subfilters must have a single TextFilter on the display name - * only. - */ - ErrorInvalidAttachmentSubfilterTextFilter, - - // ErrorInvalidAuthorizationContext - /** - * ErrorInvalidAuthorizationContext - */ - ErrorInvalidAuthorizationContext, - - // ErrorInvalidChangeKey - /** - * The change key is invalid. - */ - ErrorInvalidChangeKey, - - // ErrorInvalidClientSecurityContext - /** - * ErrorInvalidClientSecurityContext - */ - ErrorInvalidClientSecurityContext, - - // ErrorInvalidCompleteDate - /** - * CompleteDate cannot be set to a date in the future. - */ - ErrorInvalidCompleteDate, - - // ErrorInvalidContactEmailAddress - /** - * The e-mail address that was supplied isn't valid. - */ - ErrorInvalidContactEmailAddress, - - // ErrorInvalidContactEmailIndex - /** - * The e-mail index supplied isn't valid. - */ - ErrorInvalidContactEmailIndex, - - // ErrorInvalidCrossForestCredentials - /** - * ErrorInvalidCrossForestCredentials - */ - ErrorInvalidCrossForestCredentials, - - /** - * Invalid Delegate Folder Permission. - */ - ErrorInvalidDelegatePermission, - - /** - * One or more UserId parameters are invalid. Make sure that the - * PrimarySmtpAddress, Sid and DisplayName property refer to the same user - * when specified. - */ - ErrorInvalidDelegateUserId, - - /** - * An ExchangeImpersonation SOAP header must contain a user principal name, - * user SID, or primary SMTP address. - */ - ErrorInvalidExchangeImpersonationHeaderData, - - /** - * Second operand in Excludes expression must be uint compatible. - */ - ErrorInvalidExcludesRestriction, - - /** - * FieldURI can only be used in Contains expressions. - */ - ErrorInvalidExpressionTypeForSubFilter, - - /** - * The extended property attribute combination is invalid. - */ - ErrorInvalidExtendedProperty, - - /** - * The extended property value is inconsistent with its type. - */ - ErrorInvalidExtendedPropertyValue, - - /** - * The original sender of the message (initiator field in the sharing - * metadata) is not valid. - */ - ErrorInvalidExternalSharingInitiator, - - /** - * The sharing message is not intended for this caller. - */ - ErrorInvalidExternalSharingSubscriber, - - /** - * The organization is either not federated, or it's configured incorrectly. - */ - ErrorInvalidFederatedOrganizationId, - - /** - * Folder Id is invalid. - */ - ErrorInvalidFolderId, - - /** - * ErrorInvalidFolderTypeForOperation - */ - ErrorInvalidFolderTypeForOperation, - - /** - * Invalid fractional paging offset values. - */ - ErrorInvalidFractionalPagingParameters, - - /** - * ErrorInvalidFreeBusyViewType - */ - ErrorInvalidFreeBusyViewType, - - /** - * Either DataType or SharedFolderId must be specified, but not both. - */ - ErrorInvalidGetSharingFolderRequest, - - // ErrorInvalidId - /** - * The Error invalid id. - */ - ErrorInvalidId, - - /** - * Id must be non-empty. - */ - ErrorInvalidIdEmpty, - - /** - * Id is malformed. - */ - ErrorInvalidIdMalformed, - - /** - * The EWS Id is in EwsLegacyId format which is not supported by the - * Exchange version specified by your request. Please use the ConvertId - * method to convert from EwsLegacyId to EwsId format. - */ - ErrorInvalidIdMalformedEwsLegacyIdFormat, - - /** - * Moniker exceeded allowable length. - */ - ErrorInvalidIdMonikerTooLong, - - /** - * The Id does not represent an item attachment. - */ - ErrorInvalidIdNotAnItemAttachmentId, - - /** - * ResolveNames returned an invalid Id. - */ - ErrorInvalidIdReturnedByResolveNames, - - /** - * Id exceeded allowable length. - */ - ErrorInvalidIdStoreObjectIdTooLong, - - /** - * Too many attachment levels. - */ - ErrorInvalidIdTooManyAttachmentLevels, - - /** - * The Id Xml is invalid. - */ - ErrorInvalidIdXml, - - /** - * The specified indexed paging values are invalid. - */ - ErrorInvalidIndexedPagingParameters, - - /** - * Only one child node is allowed when setting an Internet Message Header. - */ - ErrorInvalidInternetHeaderChildNodes, - - /** - * Item type is invalid for AcceptItem action. - */ - ErrorInvalidItemForOperationAcceptItem, - - /** - * Item type is invalid for CancelCalendarItem action. - */ - ErrorInvalidItemForOperationCancelItem, - - /** - * Item type is invalid for CreateItem operation. - */ - ErrorInvalidItemForOperationCreateItem, - - /** - * Item type is invalid for CreateItemAttachment operation. - */ - ErrorInvalidItemForOperationCreateItemAttachment, - - /** - * Item type is invalid for DeclineItem operation. - */ - ErrorInvalidItemForOperationDeclineItem, - - /** - * ExpandDL operation does not support this item type. - */ - ErrorInvalidItemForOperationExpandDL, - - /** - * Item type is invalid for RemoveItem operation. - */ - ErrorInvalidItemForOperationRemoveItem, - - /** - * Item type is invalid for SendItem operation. - */ - ErrorInvalidItemForOperationSendItem, - - /** - * The item of this type is invalid for TentativelyAcceptItem action. - */ - ErrorInvalidItemForOperationTentative, - - /** - * The logon type isn't valid. - */ - ErrorInvalidLogonType, - - /** - * Mailbox is invalid. Verify the specified Mailbox property. - */ - ErrorInvalidMailbox, - - /** - * The Managed Folder property is corrupt or otherwise invalid. - */ - ErrorInvalidManagedFolderProperty, - - /** - * The managed folder has an invalid quota. - */ - ErrorInvalidManagedFolderQuota, - - /** - * The managed folder has an invalid storage limit value. - */ - ErrorInvalidManagedFolderSize, - - /** - * ErrorInvalidMergedFreeBusyInterval - */ - ErrorInvalidMergedFreeBusyInterval, - - /** - * The specified value is not a valid name for name resolution. - */ - ErrorInvalidNameForNameResolution, - - /** - * ErrorInvalidNetworkServiceContext - */ - ErrorInvalidNetworkServiceContext, - - /** - * ErrorInvalidOofParameter - */ - ErrorInvalidOofParameter, - - /** - * ErrorInvalidOperation - */ - ErrorInvalidOperation, - - /** - * ErrorInvalidOrganizationRelationshipForFreeBusy - */ - ErrorInvalidOrganizationRelationshipForFreeBusy, - - /** - * MaxEntriesReturned must be greater than zero. - */ - ErrorInvalidPagingMaxRows, - - /** - * Cannot create a subfolder within a SearchFolder. - */ - ErrorInvalidParentFolder, - - /** - * PercentComplete must be an integer between 0 and 100. - */ - ErrorInvalidPercentCompleteValue, - - /** - * The permission settings were not valid. - */ - ErrorInvalidPermissionSettings, - - /** - * The phone call ID isn't valid. - */ - ErrorInvalidPhoneCallId, - - /** - * The phone number isn't valid. - */ - ErrorInvalidPhoneNumber, - - /** - * The append action is not supported for this property. - */ - ErrorInvalidPropertyAppend, - - /** - * The delete action is not supported for this property. - */ - ErrorInvalidPropertyDelete, - - /** - * Property cannot be used in Exists expression. Use IsEqualTo instead. - */ - ErrorInvalidPropertyForExists, - - /** - * Property is not valid for this operation. - */ - ErrorInvalidPropertyForOperation, - - /** - * Property is not valid for this object type. - */ - ErrorInvalidPropertyRequest, - - /** - * Set action is invalid for property. - */ - ErrorInvalidPropertySet, - - // / - // / Update operation is invalid for property of a sent message. - // / - ErrorInvalidPropertyUpdateSentMessage, - - // / - // / The proxy security context is invalid. - // / - ErrorInvalidProxySecurityContext, - - // / - // / SubscriptionId is invalid. Subscription is not a pull subscription. - // / - ErrorInvalidPullSubscriptionId, - - // / - // / URL specified for push subscription is invalid. - // / - ErrorInvalidPushSubscriptionUrl, - - // / - // / One or more recipients are invalid. - // / - ErrorInvalidRecipients, - - // / - // / Recipient subfilters are only supported when - // /there are two expressions within a single - // / AND filter. - // / - ErrorInvalidRecipientSubfilter, - - // / - // / Recipient subfilter must have a comparison filter - // /that tests equality to recipient type - // / or attendee type. - // / - ErrorInvalidRecipientSubfilterComparison, - - // / - // / Recipient subfilters must have a text filter - // /and a comparison filter in that order. - // / - ErrorInvalidRecipientSubfilterOrder, - - // / - // / Recipient subfilter must have a TextFilter on the SMTP address only. - // / - ErrorInvalidRecipientSubfilterTextFilter, - - // / - // / The reference item does not support the requested operation. - // / - ErrorInvalidReferenceItem, - - // / - // / The request is invalid. - // / - ErrorInvalidRequest, - - // / - // / The restriction is invalid. - // / - ErrorInvalidRestriction, - - // / - // / The routing type format is invalid. - // / - ErrorInvalidRoutingType, - - // / - // / ErrorInvalidScheduledOofDuration - // / - ErrorInvalidScheduledOofDuration, - - // / - // / The mailbox that was requested doesn't support - // /the specified RequestServerVersion. - // / - ErrorInvalidSchemaVersionForMailboxVersion, - - // / - // / ErrorInvalidSecurityDescriptor - // / - ErrorInvalidSecurityDescriptor, - - // / - // / Invalid combination of SaveItemToFolder - // /attribute and SavedItemFolderId element. - // / - ErrorInvalidSendItemSaveSettings, - - // / - // / Invalid serialized access token. - // / - ErrorInvalidSerializedAccessToken, - - // / - // / The specified server version is invalid. - // / - ErrorInvalidServerVersion, - - // / - // / The sharing message metadata is not valid. - // / - ErrorInvalidSharingData, - - // / - // / The sharing message is not valid. - // / - ErrorInvalidSharingMessage, - - // / - // / A SID with an invalid format was encountered. - // / - ErrorInvalidSid, - - // / - // / The SIP address isn't valid. - // / - ErrorInvalidSIPUri, - - // / - // / The SMTP address format is invalid. - // / - ErrorInvalidSmtpAddress, - - // / - // / Invalid subFilterType. - // / - ErrorInvalidSubfilterType, - - // / - // / SubFilterType is not attendee type. - // / - ErrorInvalidSubfilterTypeNotAttendeeType, - - // / - // / SubFilterType is not recipient type. - // / - ErrorInvalidSubfilterTypeNotRecipientType, - - // / - // / Subscription is invalid. - // / - ErrorInvalidSubscription, - - // / - // / A subscription can only be established on - // /a single public folder or on folder from a - // / single mailbox. - // / - ErrorInvalidSubscriptionRequest, - - // / - // / Synchronization state data is corrupt or otherwise invalid. - // / - ErrorInvalidSyncStateData, - - // / - // / ErrorInvalidTimeInterval - // / - ErrorInvalidTimeInterval, - - // / - // / A UserId was not valid. - // / - ErrorInvalidUserInfo, - - // / - // / ErrorInvalidUserOofSettings - // / - ErrorInvalidUserOofSettings, - - // / - // / The impersonation principal name is invalid. - // / - ErrorInvalidUserPrincipalName, - - // / - // / The user SID is invalid or does not map - // /to a user in the Active Directory. - // / - ErrorInvalidUserSid, - - // / - // / ErrorInvalidUserSidMissingUPN - // / - ErrorInvalidUserSidMissingUPN, - - // / - // / The specified value is invalid for property. - // / - ErrorInvalidValueForProperty, - - // / - // / The watermark is invalid. - // / - ErrorInvalidWatermark, - - // / - // / A valid IP gateway couldn't be found. - // / - ErrorIPGatewayNotFound, - - // / - // / The send or update operation could not be - // /performed because the change key passed in the - // / request does not match the current change key for the item. - // / - ErrorIrresolvableConflict, - - // / - // / The item is corrupt. - // / - ErrorItemCorrupt, - - // / - // / The specified object was not found in the store. - // / - ErrorItemNotFound, - - // / - // / One or more of the property requested for - // /this item could not be retrieved. - // / - ErrorItemPropertyRequestFailed, - - // / - // / The item save operation did not succeed. - // / - ErrorItemSave, - - // / - // / Item save operation did not succeed. - // / - ErrorItemSavePropertyError, - - // / - // / ErrorLegacyMailboxFreeBusyViewTypeNotMerged - // / - ErrorLegacyMailboxFreeBusyViewTypeNotMerged, - - // / - // / ErrorLocalServerObjectNotFound - // / - ErrorLocalServerObjectNotFound, - - // / - // / ErrorLogonAsNetworkServiceFailed - // / - ErrorLogonAsNetworkServiceFailed, - - // / - // / Unable to access an account or mailbox. - // / - ErrorMailboxConfiguration, - - // / - // / ErrorMailboxDataArrayEmpty - // / - ErrorMailboxDataArrayEmpty, - - // / - // / ErrorMailboxDataArrayTooBig - // / - ErrorMailboxDataArrayTooBig, - - // / - // / ErrorMailboxFailover - // / - ErrorMailboxFailover, - - // / - // / ErrorMailboxLogonFailed - // / - ErrorMailboxLogonFailed, - - // / - // / Mailbox move in progress. Try again later. - // / - ErrorMailboxMoveInProgress, - - // / - // / The mailbox database is temporarily unavailable. - // / - ErrorMailboxStoreUnavailable, - - // / - // / ErrorMailRecipientNotFound - // / - ErrorMailRecipientNotFound, - - // / - // / MailTips aren't available for your organization. - // / - ErrorMailTipsDisabled, - - // / - // / The specified Managed Folder already exists in the mailbox. - // / - ErrorManagedFolderAlreadyExists, - - // / - // / Unable to find the specified managed folder in the Active Directory. - // / - ErrorManagedFolderNotFound, - - // / - // / Failed to create or bind to the folder: Managed Folders - // / - ErrorManagedFoldersRootFailure, - - // / - // / ErrorMeetingSuggestionGenerationFailed - // / - ErrorMeetingSuggestionGenerationFailed, - - // / - // / MessageDisposition attribute is required. - // / - ErrorMessageDispositionRequired, - - // / - // / The message exceeds the maximum supported size. - // / - ErrorMessageSizeExceeded, - - // / - // / The domain specified in the tracking request doesn't exist. - // / - ErrorMessageTrackingNoSuchDomain, - - // / - // / The log search service can't track this message. - // / - ErrorMessageTrackingPermanentError, - - // / - // / The log search service isn't currently - // /available. Please try again later. - // / - ErrorMessageTrackingTransientError, - - // / - // / MIME content conversion failed. - // / - ErrorMimeContentConversionFailed, - - // / - // / Invalid MIME content. - // / - ErrorMimeContentInvalid, - - // / - // / Invalid base64 string for MIME content. - // / - ErrorMimeContentInvalidBase64String, - - // / - // / The subscription has missed events, - // /but will continue service on this connection. - // / - ErrorMissedNotificationEvents, - - // / - // / ErrorMissingArgument - // / - ErrorMissingArgument, - - // / - // / When making a request as an account that does - // /not have a mailbox, you must specify the - // / mailbox primary SMTP address for any distinguished folder Ids. - // / - ErrorMissingEmailAddress, - - // / - // / When making a request with an account that does not - // /have a mailbox, you must specify the - // / primary SMTP address for an existing mailbox. - // / - ErrorMissingEmailAddressForManagedFolder, - - // / - // / EmailAddress or ItemId must be included in the request. - // / - ErrorMissingInformationEmailAddress, - - // / - // / ReferenceItemId must be included in the request. - // / - ErrorMissingInformationReferenceItemId, - - // / - // / SharingFolderId must be included in the request. - // / - ErrorMissingInformationSharingFolderId, - - // / - // / An item must be specified when creating an item attachment. - // / - ErrorMissingItemForCreateItemAttachment, - - // / - // / The managed folder Id is missing. - // / - ErrorMissingManagedFolderId, - - // / - // / A message needs to have at least one recipient. - // / - ErrorMissingRecipients, - - // / - // / Missing information for delegate user. You must - // /either specify a valid SMTP address or - // / SID. - // / - ErrorMissingUserIdInformation, - - // / - // / Only one access mode header may be specified. - // / - ErrorMoreThanOneAccessModeSpecified, - - // / - // / The move or copy operation failed. - // / - ErrorMoveCopyFailed, - - // / - // / Cannot move distinguished folder. - // / - ErrorMoveDistinguishedFolder, - - // / - // / Multiple results were found. - // / - ErrorNameResolutionMultipleResults, - - // / - // / User must have a mailbox for name resolution operations. - // / - ErrorNameResolutionNoMailbox, - - // / - // / No results were found. - // / - ErrorNameResolutionNoResults, - - // / - // / Another connection was opened against this subscription. - // / - ErrorNewEventStreamConnectionOpened, - - // / - // / Exchange Web Services are not currently available - // /for this request because there are no - // / available Client Access Services Servers in the target AD Site. - // / - ErrorNoApplicableProxyCASServersAvailable, - - // / - // / ErrorNoCalendar - // / - ErrorNoCalendar, - - // / - // / Exchange Web Services aren't available for this - // /request because there is no Client Access - // / server with the necessary configuration in the - // /Active Directory site where the mailbox is - // / stored. If the problem continues, click Help. - // / - ErrorNoDestinationCASDueToKerberosRequirements, - - // / - // / Exchange Web Services aren't currently available - // /for this request because an SSL - // / connection couldn't be established to the Client - // /Access server that should be used for - // / mailbox access. If the problem continues, click Help. - // / - ErrorNoDestinationCASDueToSSLRequirements, - - // / - // / Exchange Web Services aren't currently available - // /for this request because the Client - // / Access server used for proxying has an older - // /version of Exchange installed than the - // / Client Access server in the mailbox Active Directory site. - // / - ErrorNoDestinationCASDueToVersionMismatch, - - // / - // / You cannot specify the FolderClass when creating a non-generic folder. - // / - ErrorNoFolderClassOverride, - - // / - // / ErrorNoFreeBusyAccess - // / - ErrorNoFreeBusyAccess, - - // / - // / Mailbox does not exist. - // / - ErrorNonExistentMailbox, - - // / - // / The primary SMTP address must be specified when referencing a mailbox. - // / - ErrorNonPrimarySmtpAddress, - - // / - // / Custom property cannot be specified using - // /property tags. The GUID and Id/Name - // / combination must be used instead. - // / - ErrorNoPropertyTagForCustomProperties, - - // / - // / ErrorNoPublicFolderReplicaAvailable - // / - ErrorNoPublicFolderReplicaAvailable, - - // / - // / There are no public folder servers available. - // / - ErrorNoPublicFolderServerAvailable, - - // / - // / Exchange Web Services are not currently available - // /for this request because none of the - // / Client Access Servers in the destination site could process the - // request. - // / - ErrorNoRespondingCASInDestinationSite, - - // / - // / Policy does not allow granting of permissions to external users. - // / - ErrorNotAllowedExternalSharingByPolicy, - - // / - // / The user is not a delegate for the mailbox. - // / - ErrorNotDelegate, - - // / - // / There was not enough memory to complete the request. - // / - ErrorNotEnoughMemory, - - // / - // / The sharing message is not supported. - // / - ErrorNotSupportedSharingMessage, - - // / - // / Operation would change object type, which is not permitted. - // / - ErrorObjectTypeChanged, - - // / - // / Modified occurrence is crossing or overlapping adjacent occurrence. - // / - ErrorOccurrenceCrossingBoundary, - - // / - // / One occurrence of the recurring calendar item - // /overlaps with another occurrence of the - // / same calendar item. - // / - ErrorOccurrenceTimeSpanTooBig, - - // / - // / Operation not allowed with public folder root. - // / - ErrorOperationNotAllowedWithPublicFolderRoot, - - // / - // / Organization is not federated. - // / - ErrorOrganizationNotFederated, - - // / - // / ErrorOutlookRuleBlobExists - // / - ErrorOutlookRuleBlobExists, - - // / - // / You must specify the parent folder Id for this operation. - // / - ErrorParentFolderIdRequired, - - // / - // / The specified parent folder could not be found. - // / - ErrorParentFolderNotFound, - - // / - // / Password change is required. - // / - ErrorPasswordChangeRequired, - - // / - // / Password has expired. Change password. - // / - ErrorPasswordExpired, - - // / - // / Policy does not allow granting permission level to user. - // / - ErrorPermissionNotAllowedByPolicy, - - // / - // / Dialing restrictions are preventing the phone number - // /that was entered from being dialed. - // / - ErrorPhoneNumberNotDialable, - - // / - // / Property update did not succeed. - // / - ErrorPropertyUpdate, - - // / - // / At least one property failed validation. - // / - ErrorPropertyValidationFailure, - - // / - // / Subscription related request failed because EWS - // /could not contact the appropriate CAS - // / server for this request. If this problem persists, - // /recreate the subscription. - // / - ErrorProxiedSubscriptionCallFailure, - - // / - // / Request failed because EWS could not contact - // /the appropriate CAS server for this request. - // / - ErrorProxyCallFailed, - - // / - // / Exchange Web Services (EWS) is not available for - // /this mailbox because the user account - // / associated with the mailbox is a member of - // /too many groups. EWS limits the group - // / membership it can proxy between Client Access Service Servers to 3000. - // / - ErrorProxyGroupSidLimitExceeded, - - // / - // / ErrorProxyRequestNotAllowed - // / - ErrorProxyRequestNotAllowed, - - // / - // / ErrorProxyRequestProcessingFailed - // / - ErrorProxyRequestProcessingFailed, - - // / - // / Exchange Web Services are not currently - // /available for this mailbox because it could not - // / determine the Client Access Services Server to use for the mailbox. - // / - ErrorProxyServiceDiscoveryFailed, - - // / - // / Proxy token has expired. - // / - ErrorProxyTokenExpired, - - // / - // / ErrorPublicFolderRequestProcessingFailed - // / - ErrorPublicFolderRequestProcessingFailed, - - // / - // / ErrorPublicFolderServerNotFound - // / - ErrorPublicFolderServerNotFound, - - // / - // / The search folder has a restriction that is too long to return. - // / - ErrorQueryFilterTooLong, - - // / - // / Mailbox has exceeded maximum mailbox size. - // / - ErrorQuotaExceeded, - - // / - // / Unable to retrieve events for this subscription. - // /The subscription must be recreated. - // / - ErrorReadEventsFailed, - - // / - // / Unable to suppress read receipt. Read receipts are not pending. - // / - ErrorReadReceiptNotPending, - - // / - // / Recurrence end date can not exceed Sep 1, 4500 00:00:00. - // / - ErrorRecurrenceEndDateTooBig, - - // / - // / Recurrence has no occurrences in the specified range. - // / - ErrorRecurrenceHasNoOccurrence, - - // / - // / Failed to remove one or more delegates. - // / - ErrorRemoveDelegatesFailed, - - // / - // / ErrorRequestAborted - // / - ErrorRequestAborted, - - // / - // / ErrorRequestStreamTooBig - // / - ErrorRequestStreamTooBig, - - // / - // / Required property is missing. - // / - ErrorRequiredPropertyMissing, - - // / - // / Cannot perform ResolveNames for non-contact folder. - // / - ErrorResolveNamesInvalidFolderType, - - // / - // / Only one contacts folder can be specified in request. - // / - ErrorResolveNamesOnlyOneContactsFolderAllowed, - - // / - // / The response failed schema validation. - // / - ErrorResponseSchemaValidation, - - // / - // / The restriction or sort order is too complex for this operation. - // / - ErrorRestrictionTooComplex, - - // / - // / Restriction contained too many elements. - // / - ErrorRestrictionTooLong, - - // / - // / ErrorResultSetTooBig - // / - ErrorResultSetTooBig, - - // / - // / ErrorRulesOverQuota - // / - ErrorRulesOverQuota, - - // / - // / The folder in which item were to be saved could not be found. - // / - ErrorSavedItemFolderNotFound, - - // / - // / The request failed schema validation. - // / - ErrorSchemaValidation, - - // / - // / The search folder is not initialized. - // / - ErrorSearchFolderNotInitialized, - - // / - // / The user account which was used to submit this request - // /does not have the right to send - // / mail on behalf of the specified sending account. - // / - ErrorSendAsDenied, - - // / - // / SendMeetingCancellations attribute is required for Calendar item. - // / - ErrorSendMeetingCancellationsRequired, - - // / - // / The SendMeetingInvitationsOrCancellations attribute - // /is required for calendar item. - // / - ErrorSendMeetingInvitationsOrCancellationsRequired, - - // ErrorSendMeetingInvitationsRequired - /** - * The SendMeetingInvitations attribute is required for calendar item. - */ - ErrorSendMeetingInvitationsRequired, - - // ErrorSentMeetingRequestUpdate - /** - * The meeting request has already been sent and might not be updated. - */ - ErrorSentMeetingRequestUpdate, - - // ErrorSentTaskRequestUpdate - /** - * The task request has already been sent and may not be updated. - */ - ErrorSentTaskRequestUpdate, - - // ErrorServerBusy - /** - * The server cannot service this request right now. Try again later. - */ - ErrorServerBusy, - - // ErrorServiceDiscoveryFailed - /** - * ErrorServiceDiscoveryFailed - */ - ErrorServiceDiscoveryFailed, - - // ErrorSharingNoExternalEwsAvailable - /** - * No external Exchange Web Service URL available. - */ - ErrorSharingNoExternalEwsAvailable, - - // ErrorSharingSynchronizationFailed - /** - * Failed to synchronize the sharing folder. - */ - ErrorSharingSynchronizationFailed, - - // ErrorStaleObject - /** - * The current ChangeKey is required for this operation. - */ - ErrorStaleObject, - - // ErrorSubmissionQuotaExceeded - /** - * The message couldn't be sent because the sender's submission quota was - * exceeded. Please try again later. - */ - ErrorSubmissionQuotaExceeded, - - // ErrorSubscriptionAccessDenied - /** - * Access is denied. Only the subscription owner may access the - * subscription. - */ - ErrorSubscriptionAccessDenied, - - // ErrorSubscriptionDelegateAccessNotSupported - /** - * Subscriptions are not supported for delegate user access. - */ - ErrorSubscriptionDelegateAccessNotSupported, - - // ErrorSubscriptionNotFound - /** - * The specified subscription was not found. - */ - ErrorSubscriptionNotFound, - - // ErrorSubscriptionUnsubscribed - /** - * The StreamingSubscription was unsubscribed while the current connection - * was servicing it. - */ - ErrorSubscriptionUnsubscribed, - - // ErrorSyncFolderNotFound - /** - * The folder to be synchronized could not be found. - */ - ErrorSyncFolderNotFound, - - // ErrorTimeIntervalTooBig - /** - * ErrorTimeIntervalTooBig - */ - ErrorTimeIntervalTooBig, - - // ErrorTimeoutExpired - /** - * ErrorTimeoutExpired - */ - ErrorTimeoutExpired, - - // ErrorTimeZone - /** - * The time zone isn't valid. - */ - ErrorTimeZone, - - // ErrorToFolderNotFound - /** - * The specified target folder could not be found. - */ - ErrorToFolderNotFound, - - // ErrorTokenSerializationDenied - /** - * The requesting account does not have permission to serialize tokens. - */ - ErrorTokenSerializationDenied, - - // ErrorUnableToGetUserOofSettings - /** - * ErrorUnableToGetUserOofSettings - */ - ErrorUnableToGetUserOofSettings, - - // ErrorUnifiedMessagingDialPlanNotFound - /** - * A dial plan could not be found. - */ - ErrorUnifiedMessagingDialPlanNotFound, - - // ErrorUnifiedMessagingRequestFailed - /** - * The UnifiedMessaging request failed. - */ - ErrorUnifiedMessagingRequestFailed, - - // ErrorUnifiedMessagingServerNotFound - /** - * A connection couldn't be made to the Unified Messaging server. - */ - ErrorUnifiedMessagingServerNotFound, - - // ErrorUnsupportedCulture - /** - * The specified item culture is not supported on this server. - */ - ErrorUnsupportedCulture, - - // ErrorUnsupportedMapiPropertyType - /** - * The MAPI property type is not supported. - */ - ErrorUnsupportedMapiPropertyType, - - // ErrorUnsupportedMimeConversion - /** - * MIME conversion is not supported for this item type. - */ - ErrorUnsupportedMimeConversion, - - // ErrorUnsupportedPathForQuery - /** - * The property can not be used with this type of restriction. - */ - ErrorUnsupportedPathForQuery, - - // ErrorUnsupportedPathForSortGroup - /** - * The property can not be used for sorting or grouping results. - */ - ErrorUnsupportedPathForSortGroup, - - // ErrorUnsupportedPropertyDefinition - /** - * PropertyDefinition is not supported in searches. - */ - ErrorUnsupportedPropertyDefinition, - - // ErrorUnsupportedQueryFilter - /** - * QueryFilter type is not supported. - */ - ErrorUnsupportedQueryFilter, - - // ErrorUnsupportedRecurrence - /** - * The specified recurrence is not supported. - */ - ErrorUnsupportedRecurrence, - - // ErrorUnsupportedSubFilter - /** - * Unsupported subfilter type. - */ - ErrorUnsupportedSubFilter, - - // ErrorUnsupportedTypeForConversion - /** - * Unsupported type for restriction conversion. - */ - ErrorUnsupportedTypeForConversion, - - // ErrorUpdateDelegatesFailed - /** - * Failed to update one or more delegates. - */ - ErrorUpdateDelegatesFailed, - - // ErrorUpdatePropertyMismatch - /** - * Property for update does not match property in object. - */ - ErrorUpdatePropertyMismatch, - - // ErrorUserNotAllowedByPolicy - /** - * Policy does not allow granting permissions to user. - */ - ErrorUserNotAllowedByPolicy, - - // ErrorUserNotUnifiedMessagingEnabled - /** - * The user isn't enabled for Unified Messaging - */ - ErrorUserNotUnifiedMessagingEnabled, - - // ErrorUserWithoutFederatedProxyAddress - /** - * The user doesn't have an SMTP proxy address from a federated domain. - */ - ErrorUserWithoutFederatedProxyAddress, - - // ErrorValueOutOfRange - /** - * The value is out of range. - */ - ErrorValueOutOfRange, - - // ErrorVirusDetected - /** - * Virus detected in the message. - */ - ErrorVirusDetected, - - // ErrorVirusMessageDeleted - /** - * The item has been deleted as a result of a virus scan. - */ - ErrorVirusMessageDeleted, - - // ErrorVoiceMailNotImplemented - /** - * The Voice Mail distinguished folder is not implemented. - */ - ErrorVoiceMailNotImplemented, - - // ErrorWebRequestInInvalidState - /** - * ErrorWebRequestInInvalidState - */ - ErrorWebRequestInInvalidState, - - // ErrorWin32InteropError - /** - * ErrorWin32InteropError - */ - ErrorWin32InteropError, - - // ErrorWorkingHoursSaveFailed - /** - * ErrorWorkingHoursSaveFailed - */ - ErrorWorkingHoursSaveFailed, - - // ErrorWorkingHoursXmlMalformed - /** - * ErrorWorkingHoursXmlMalformed - */ - ErrorWorkingHoursXmlMalformed, - - // ErrorWrongServerVersion - /** - * The Client Access server version doesn't match the Mailbox server version - * of the resource that was being accessed. To determine the correct URL to - * use to access the resource, use Autodiscover with the address of the - * resource. - */ - ErrorWrongServerVersion, - - // ErrorWrongServerVersionDelegate - /** - * The mailbox of the authenticating user and the mailbox of the resource - * being accessed must have the same Mailbox server version. - */ - ErrorWrongServerVersionDelegate, - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/error/WebExceptionStatus.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/error/WebExceptionStatus.java deleted file mode 100644 index 8fe4bce40..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/misc/error/WebExceptionStatus.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.misc.error; - -public enum WebExceptionStatus { - // Summary: - // No error was encountered. - Success, - // - // Summary: - // The name resolver service could not resolve the host name. - NameResolutionFailure, - // - // Summary: - // The remote service point could not be contacted at the transport level. - ConnectFailure, - // - // Summary: - // A complete response was not received from the remote server. - ReceiveFailure, - // - // Summary: - // A complete request could not be sent to the remote server. - SendFailure, - // - // Summary: - // The request was a piplined request and the connection was closed before the - // response was received. - PipelineFailure, - // - // Summary: - // The request was canceled, the System.Net.WebRequest.Abort() method was called, - // or an unclassifiable error occurred. This is the default value for System.Net.WebException.Status. - RequestCanceled, - // - // Summary: - // The response received from the server was complete but indicated a protocol-level - // error. For example, an HTTP protocol error such as 401 Access Denied would - // use this status. - ProtocolError, - // - // Summary: - // The connection was prematurely closed. - ConnectionClosed, - // - // Summary: - // A server certificate could not be validated. - TrustFailure, - // - // Summary: - // An error occurred while establishing a connection using SSL. - SecureChannelFailure, - // - // Summary: - // The server response was not a valid HTTP response. - ServerProtocolViolation, - // - // Summary: - // The connection for a request that specifies the Keep-alive header was closed - // unexpectedly. - KeepAliveFailure, - // - // Summary: - // An internal asynchronous request is pending. - Pending, - // - // Summary: - // No response was received during the time-out period for a request. - Timeout, - // - // Summary: - // The name resolver service could not resolve the proxy host name. - ProxyNameResolutionFailure, - // - // Summary: - // An exception of unknown type has occurred. - UnknownError, - // - // Summary: - // A message was received that exceeded the specified limit when sending a request - // or receiving a response from the server. - MessageLengthLimitExceeded, - // - // Summary: - // The specified cache entry was not found. - CacheEntryNotFound, - // - // Summary: - // The request was not permitted by the cache policy. In general, this occurs - // when a request is not cacheable and the effective policy prohibits sending - // the request to the server. You might receive this status if a request method - // implies the presence of a request body, a request method requires direct - // interaction with the server, or a request contains a conditional header. - RequestProhibitedByCachePolicy, - // - // Summary: - // This request was not permitted by the proxy. - RequestProhibitedByProxy, - - -} - diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/notification/EventType.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/notification/EventType.java deleted file mode 100644 index f4bdb5739..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/notification/EventType.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.notification; - -import microsoft.exchange.webservices.data.attribute.EwsEnum; -import microsoft.exchange.webservices.data.attribute.RequiredServerVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Defines the types of event that can occur in a folder. - */ -public enum EventType { - // This event is sent to a client application by push notification to - // indicate that - // the subscription is still alive. - /** - * The Status. - */ - @EwsEnum(schemaName = "StatusEvent") - Status, - - // This event indicates that a new e-mail message was received. - /** - * The New mail. - */ - @EwsEnum(schemaName = "NewMailEvent") - NewMail, - - // This event indicates that an item or folder has been deleted. - /** - * The Deleted. - */ - @EwsEnum(schemaName = "DeletedEvent") - Deleted, - - // This event indicates that an item or folder has been modified. - /** - * The Modified. - */ - @EwsEnum(schemaName = "ModifiedEvent") - Modified, - - // This event indicates that an item or folder has been moved to another - // folder. - /** - * The Moved. - */ - @EwsEnum(schemaName = "MovedEvent") - Moved, - - // This event indicates that an item or folder has been copied to another - // folder. - /** - * The Copied. - */ - @EwsEnum(schemaName = "CopiedEvent") - Copied, - - // This event indicates that a new item or folder has been created. - /** - * The Created. - */ - @EwsEnum(schemaName = "CreatedEvent") - Created, - - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - @EwsEnum(schemaName = "FreeBusyChangedEvent") - FreeBusyChanged - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/permission/folder/DelegateFolderPermissionLevel.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/permission/folder/DelegateFolderPermissionLevel.java deleted file mode 100644 index f2816fec1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/permission/folder/DelegateFolderPermissionLevel.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.permission.folder; - -/** - * Defines a delegate user's permission level on a specific folder. - */ -public enum DelegateFolderPermissionLevel { - - // The delegate has no permission. - /** - * The None. - */ - None, - - // The delegate has Editor permissions. - /** - * The Editor. - */ - Editor, - - // The delegate has Reviewer permissions. - /** - * The Reviewer. - */ - Reviewer, - - // The delegate has Author permissions. - /** - * The Author. - */ - Author, - - // The delegate has custom permissions. - /** - * The Custom. - */ - Custom -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/permission/folder/FolderPermissionLevel.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/permission/folder/FolderPermissionLevel.java deleted file mode 100644 index 7cae3a7a6..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/permission/folder/FolderPermissionLevel.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.permission.folder; - -//TODO : Do we want to include more information about -//what those levels actually allow users to do? - - -/** - * Defines permission levels for calendar folder. - */ -public enum FolderPermissionLevel { - - // No permission is granted. - /** - * The None. - */ - None, - - // The Owner level. - /** - * The Owner. - */ - Owner, - - // The Publishing Editor level. - /** - * The Publishing editor. - */ - PublishingEditor, - - // The Editor level. - /** - * The Editor. - */ - Editor, - - // The Pusnlishing Author level. - /** - * The Publishing author. - */ - PublishingAuthor, - - // The Author level. - /** - * The Author. - */ - Author, - - // The Non-editing Author level. - /** - * The Nonediting author. - */ - NoneditingAuthor, - - // The Reviewer level. - /** - * The Reviewer. - */ - Reviewer, - - // The Contributor level. - /** - * The Contributor. - */ - Contributor, - - // The Free/busy Time Only level. (Can only be applied to Calendar folder). - /** - * The Free busy time only. - */ - FreeBusyTimeOnly, - - // The Free/busy Time, Subject and Location level. (Can only be applied to - // Calendar folder). - /** - * The Free busy time and subject and location. - */ - FreeBusyTimeAndSubjectAndLocation, - - // The Custom level. - /** - * The Custom. - */ - Custom -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/permission/folder/FolderPermissionReadAccess.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/permission/folder/FolderPermissionReadAccess.java deleted file mode 100644 index ac65717e4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/permission/folder/FolderPermissionReadAccess.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.permission.folder; - -/** - * Defines a user's read access permission on item in a non-calendar folder. - */ -public enum FolderPermissionReadAccess { - - // The user has no read access on the item in the folder. - /** - * The None. - */ - None, - - // The user can read the start and end date and time of appointments. (Can - // only be applied to Calendar folder). - /** - * The Time only. - */ - TimeOnly, - - // The user can read the start and end date and time, subject and location - // of appointments. (Can only be applied to Calendar folder). - /** - * The Time and subject and location. - */ - TimeAndSubjectAndLocation, - - // The user has access to the full details of item. - /** - * The Full details. - */ - FullDetails -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/BasePropertySet.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/BasePropertySet.java deleted file mode 100644 index 75851cab4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/BasePropertySet.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -/** - * Defines base property sets that are used as the base for custom property - * sets. - */ -public enum BasePropertySet { - - // Only includes the Id of item and folder. - /** - * The Id only. - */ - IdOnly("IdOnly"), - - // Includes all the first class property of item and folder. - /** - * The First class property. - */ - FirstClassProperties("AllProperties"); - - /** - * The base shape value. - */ - private String baseShapeValue; - - /** - * Instantiates a new base property set. - * - * @param baseShapeValue the base shape value - */ - BasePropertySet(String baseShapeValue) { - this.baseShapeValue = baseShapeValue; - } - - /** - * Gets the base shape value. - * - * @return the base shape value - */ - public String getBaseShapeValue() { - return this.baseShapeValue; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/ConflictType.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/ConflictType.java deleted file mode 100644 index 0e1122bd5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/ConflictType.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -/** - * Defines the conflict types that can be returned in meeting time suggestions. - */ -public enum ConflictType { - - // There is a conflict with an indicidual attendee. - /** - * The Individual attendee conflict. - */ - IndividualAttendeeConflict, - - // There is a conflict with at least one member of a group. - /** - * The Group conflict. - */ - GroupConflict, - - // There is a conflict with at least one member of a group, but the group - // was too big for detailed information to be returned. - /** - * The Group too big conflict. - */ - GroupTooBigConflict, - - // There is a conflict with an unresolvable attendee or an attendee that is - // not a user, group, or contact. - /** - * The Unknown attendee conflict. - */ - UnknownAttendeeConflict - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/DefaultExtendedPropertySet.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/DefaultExtendedPropertySet.java deleted file mode 100644 index ac6d4fcff..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/DefaultExtendedPropertySet.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -/** - * Defines the default sets of extended property. - */ -public enum DefaultExtendedPropertySet { - - // The Meeting extended property set. - /** - * The Meeting. - */ - Meeting, - - // The Appointment extended property set. - /** - * The Appointment. - */ - Appointment, - - // The Common extended property set. - /** - * The Common. - */ - Common, - - // The PublicStrings extended property set. - /** - * The Public strings. - */ - PublicStrings, - - // The Address extended property set. - /** - * The Address. - */ - Address, - - // The InternetHeaders extended property set. - /** - * The Internet headers. - */ - InternetHeaders, - - // The CalendarAssistants extended property set. - /** - * The Calendar assistant. - */ - CalendarAssistant, - - // The UnifiedMessaging extended property set. - /** - * The Unified messaging. - */ - UnifiedMessaging, - - // The Task extended property set. - /** - * The Task. - */ - Task - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/LegacyFreeBusyStatus.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/LegacyFreeBusyStatus.java deleted file mode 100644 index 06e18d19a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/LegacyFreeBusyStatus.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -/** - * Defines the legacy free/busy status associated with an appointment. - */ -public enum LegacyFreeBusyStatus { - - // The time slot associated with the appointment appears as free. - /** - * The Free. - */ - Free(0), - - // The time slot associated with the appointment appears as tentative. - /** - * The Tentative. - */ - Tentative(1), - - // The time slot associated with the appointment appears as busy. - /** - * The Busy. - */ - Busy(2), - - // The time slot associated with the appointment appears as Out of Office. - /** - * The OOF. - */ - OOF(3), - - // No free/busy status is associated with the appointment. - /** - * The No data. - */ - NoData(4); - - /** - * The busy status. - */ - private final int busyStatus; - - /** - * Instantiates a new legacy free busy status. - * - * @param busyStatus the busy status - */ - LegacyFreeBusyStatus(int busyStatus) { - this.busyStatus = busyStatus; - } - - public int getBusyStatus() { - return busyStatus; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/MailboxType.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/MailboxType.java deleted file mode 100644 index 902ad7805..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/MailboxType.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -import microsoft.exchange.webservices.data.attribute.EwsEnum; -import microsoft.exchange.webservices.data.attribute.RequiredServerVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Defines the type of an EmailAddress object. - */ -public enum MailboxType { - - // Unknown mailbox type (Exchange 2010 or later). - /** - * The Unknown. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010) - Unknown, - - // The EmailAddress represents a one-off contact (Exchange 2010 or later). - /** - * The One off. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010) - OneOff, - - // The EmailAddress represents a mailbox. - /** - * The Mailbox. - */ - Mailbox, - - // The EmailAddress represents a public folder. - /** - * The Public folder. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2007_SP1) - PublicFolder, - - // The EmailAddress represents a Public Group. - /** - * The Public group. - */ - @EwsEnum(schemaName = "PublicDL") - PublicGroup, - - // The EmailAddress represents a Contact Group. - /** - * The Contact group. - */ - @EwsEnum(schemaName = "PrivateDL") - ContactGroup, - - // The EmailAddress represents a store contact or AD mail contact. - /** - * The Contact. - */ - Contact, - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/MapiPropertyType.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/MapiPropertyType.java deleted file mode 100644 index 98a0c486a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/MapiPropertyType.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -/** - * Defines the MAPI type of an extended property. - */ -public enum MapiPropertyType { - - // The property is of type ApplicationTime. - /** - * The Application time. - */ - ApplicationTime, - - // The property is of type ApplicationTimeArray. - /** - * The Application time array. - */ - ApplicationTimeArray, - - // The property is of type Binary. - /** - * The Binary. - */ - Binary, - - // The property is of type BinaryArray. - /** - * The Binary array. - */ - BinaryArray, - - // The property is of type Boolean. - /** - * The Boolean. - */ - Boolean, - - // The property is of type CLSID. - /** - * The CLSID. - */ - CLSID, - - // The property is of type CLSIDArray. - /** - * The CLSID array. - */ - CLSIDArray, - - // The property is of type Currency. - /** - * The Currency. - */ - Currency, - - // The property is of type CurrencyArray. - /** - * The Currency array. - */ - CurrencyArray, - - // The property is of type Double. - /** - * The Double. - */ - Double, - - // The property is of type DoubleArray. - /** - * The Double array. - */ - DoubleArray, - - // The property is of type Error. - /** - * The Error. - */ - Error, - - // The property is of type Float. - /** - * The Float. - */ - Float, - - // The property is of type FloatArray. - /** - * The Float array. - */ - FloatArray, - - // The property is of type Integer. - /** - * The Integer. - */ - Integer, - - // The property is of type IntegerArray. - /** - * The Integer array. - */ - IntegerArray, - - // The property is of type Long. - /** - * The Long. - */ - Long, - - // The property is of type LongArray. - /** - * The Long array. - */ - LongArray, - - // The property is of type Null. - /** - * The Null. - */ - Null, - - // The property is of type Object. - /** - * The Object. - */ - Object, - - // The property is of type ObjectArray. - /** - * The Object array. - */ - ObjectArray, - - // The property is of type Short. - /** - * The Short. - */ - Short, - - // The property is of type ShortArray. - /** - * The Short array. - */ - ShortArray, - - // The property is of type SystemTime. - /** - * The System time. - */ - SystemTime, - - // The property is of type SystemTimeArray. - /** - * The System time array. - */ - SystemTimeArray, - - // The property is of type String. - /** - * The String. - */ - String, - - // The property is of type StringArray. - /** - * The String array. - */ - StringArray -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/MeetingResponseType.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/MeetingResponseType.java deleted file mode 100644 index 458d56ff9..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/MeetingResponseType.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -/** - * Defines the types of response given to a meeting request. - */ -public enum MeetingResponseType { - - // The response type is inknown. - /** - * The Unknown. - */ - Unknown, - - // There was no response. The authenticated is the organizer of the meeting. - /** - * The Organizer. - */ - Organizer, - - // The meeting was tentatively accepted. - /** - * The Tentative. - */ - Tentative, - - // The meeting was accepted. - /** - * The Accept. - */ - Accept, - - // The meeting was declined. - /** - * The Decline. - */ - Decline, - - // No response was received for the meeting. - /** - * The No response received. - */ - NoResponseReceived - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/OofExternalAudience.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/OofExternalAudience.java deleted file mode 100644 index 0364076de..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/OofExternalAudience.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -/** - * Defines the external audience of an Out of Office notification. - */ -public enum OofExternalAudience { - - // No external recipients should receive Out of Office notification. - /** - * The None. - */ - None, - - // Only recipients that are in the user's Contacts frolder should receive - // Out of Office notification. - /** - * The Known. - */ - Known, - - // All recipients should receive Out of Office notification. - /** - * The All. - */ - All -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/PhoneNumberKey.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/PhoneNumberKey.java deleted file mode 100644 index 67cf66272..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/PhoneNumberKey.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -/** - * Defines phone number entries for a contact. - */ -public enum PhoneNumberKey { - - // The assistant's phone number. - /** - * The Assistant phone. - */ - AssistantPhone, - - // The business fax number. - /** - * The Business fax. - */ - BusinessFax, - - // The business phone number. - /** - * The Business phone. - */ - BusinessPhone, - - // The second business phone number. - /** - * The Business phone2. - */ - BusinessPhone2, - - // The callback number. - /** - * The Callback. - */ - Callback, - - // The car phone number. - /** - * The Car phone. - */ - CarPhone, - - // The company's main phone number. - /** - * The Company main phone. - */ - CompanyMainPhone, - - // The home fax number. - /** - * The Home fax. - */ - HomeFax, - - // The home phone number. - /** - * The Home phone. - */ - HomePhone, - - // The second home phone number. - /** - * The Home phone2. - */ - HomePhone2, - - // The ISDN number. - /** - * The Isdn. - */ - Isdn, - - // The mobile phone number. - /** - * The Mobile phone. - */ - MobilePhone, - - // An alternate fax number. - /** - * The Other fax. - */ - OtherFax, - - // An alternate phone number. - /** - * The Other telephone. - */ - OtherTelephone, - - // The pager number. - /** - * The Pager. - */ - Pager, - - // The primary phone number. - /** - * The Primary phone. - */ - PrimaryPhone, - - // The radio phone number. - /** - * The Radio phone. - */ - RadioPhone, - - // The Telex number. - /** - * The Telex. - */ - Telex, - - // The TTY/TTD phone number. - /** - * The Tty tdd phone. - */ - TtyTddPhone -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/PropertyDefinitionFlags.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/PropertyDefinitionFlags.java deleted file mode 100644 index 4657ec9a2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/PropertyDefinitionFlags.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -/** - * defines how a complex property behaves. - */ -public enum PropertyDefinitionFlags { - - /** - * No specific behavior. - */ - None, - - /** - * The property is automatically instantiated when it is read. - */ - AutoInstantiateOnRead, - - /** - * The existing instance of the property is reusable. - */ - ReuseInstance, - - /** - * The property can be set. - */ - CanSet, - - /** - * The property can be updated. - */ - CanUpdate, - - /** - * The property can be deleted. - */ - CanDelete, - - /** - * The property can be searched. - */ - CanFind, - - /** - * The property must be loaded explicitly. - */ - MustBeExplicitlyLoaded, - - /** - * Only meaningful for "collection" property. With this flag, the item in the collection gets updated, - * instead of creating and adding new item to the collection. - * Should be used together with the ReuseInstance flag. - */ - - UpdateCollectionItems; - -} - diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/RuleProperty.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/RuleProperty.java deleted file mode 100644 index 8796fa7e0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/RuleProperty.java +++ /dev/null @@ -1,577 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -import microsoft.exchange.webservices.data.attribute.EwsEnum; - -public enum RuleProperty { - /** - * The RuleId property of a rule. - */ - @EwsEnum(schemaName = "RuleId") - RuleId, - - - /** - * The DisplayName property of a rule. - */ - @EwsEnum(schemaName = "DisplayName") - DisplayName, - - /** - * The Priority property of a rule. - */ - @EwsEnum(schemaName = "Priority") - Priority, - - /** - * The IsNotSupported property of a rule. - */ - @EwsEnum(schemaName = "IsNotSupported") - IsNotSupported, - - /** - * The Actions property of a rule. - */ - @EwsEnum(schemaName = "Actions") - Actions, - - /** - * The Categories property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:Categories") - ConditionCategories, - - /** - * The ContainsBodyStrings property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:ContainsBodyStrings") - ConditionContainsBodyStrings, - - /** - * The ContainsHeaderStrings property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:ContainsHeaderStrings") - ConditionContainsHeaderStrings, - - /** - * The ContainsRecipientStrings property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:ContainsRecipientStrings") - ConditionContainsRecipientStrings, - - /** - * The ContainsSenderStrings property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:ContainsSenderStrings") - ConditionContainsSenderStrings, - - /** - * The ContainsSubjectOrBodyStrings property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:ContainsSubjectOrBodyStrings") - ConditionContainsSubjectOrBodyStrings, - - /** - * The ContainsSubjectStrings property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:ContainsSubjectStrings") - ConditionContainsSubjectStrings, - - /** - * The FlaggedForAction property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:FlaggedForAction") - ConditionFlaggedForAction, - - /** - * The FromAddresses property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:FromAddresses") - ConditionFromAddresses, - - /** - * The FromConnectedAccounts property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:FromConnectedAccounts") - ConditionFromConnectedAccounts, - - /** - * The HasAttachments property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:HasAttachments") - ConditionHasAttachments, - - /** - * The Importance property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:Importance") - ConditionImportance, - - /** - * The IsApprovalRequest property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:IsApprovalRequest") - ConditionIsApprovalRequest, - - - /** - * The IsAutomaticForward property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:IsAutomaticForward") - ConditionIsAutomaticForward, - - /** - * The IsAutomaticForward property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:IsAutomaticReply") - ConditionIsAutomaticReply, - - /** - * The IsEncrypted property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:IsEncrypted") - ConditionIsEncrypted, - - /** - * The IsMeetingRequest property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:IsMeetingRequest") - ConditionIsMeetingRequest, - - /** - * The IsMeetingResponse property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:IsMeetingResponse") - ConditionIsMeetingResponse, - - /** - * The IsNonDeliveryReport property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:IsNDR") - ConditionIsNonDeliveryReport, - - /** - * The IsPermissionControlled property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:IsPermissionControlled") - ConditionIsPermissionControlled, - - /** - * The IsRead property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:IsRead") - ConditionIsRead, - - /** - * The IsSigned property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:IsSigned") - ConditionIsSigned, - - /** - * The IsVoicemail property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:IsVoicemail") - ConditionIsVoicemail, - - /** - * The IsReadReceipt property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:IsReadReceipt") - ConditionIsReadReceipt, - - /** - * The ItemClasses property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:ItemClasses") - ConditionItemClasses, - - /** - * The MessageClassifications property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:MessageClassifications") - ConditionMessageClassifications, - - /** - * The NotSentToMe property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:NotSentToMe") - ConditionNotSentToMe, - - /** - * The SentCcMe property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:SentCcMe") - ConditionSentCcMe, - - /** - * The SentOnlyToMe property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:SentOnlyToMe") - ConditionSentOnlyToMe, - - /** - * The SentToAddresses property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:SentToAddresses") - ConditionSentToAddresses, - - /** - * The SentToMe property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:SentToMe") - ConditionSentToMe, - - /** - * The SentToOrCcMe property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:SentToOrCcMe") - ConditionSentToOrCcMe, - - /** - * The Sensitivity property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:Sensitivity") - ConditionSensitivity, - - /** - * The WithinDateRange property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:WithinDateRange") - ConditionWithinDateRange, - - /** - * The WithinSizeRange property of a rule's set of conditions. - */ - @EwsEnum(schemaName = "Condition:WithinSizeRange") - ConditionWithinSizeRange, - - /** - * The Categories property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:Categories") - ExceptionCategories, - - /** - * The ContainsBodyStrings property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:ContainsBodyStrings") - ExceptionContainsBodyStrings, - - /** - * The ContainsHeaderStrings property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:ContainsHeaderStrings") - ExceptionContainsHeaderStrings, - - /** - * The ContainsRecipientStrings property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:ContainsRecipientStrings") - ExceptionContainsRecipientStrings, - - /** - * The ContainsSenderStrings property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:ContainsSenderStrings") - ExceptionContainsSenderStrings, - - /** - * The ContainsSubjectOrBodyStrings property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:ContainsSubjectOrBodyStrings") - ExceptionContainsSubjectOrBodyStrings, - - /** - * The ContainsSubjectStrings property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:ContainsSubjectStrings") - ExceptionContainsSubjectStrings, - - /** - * The FlaggedForAction property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:FlaggedForAction") - ExceptionFlaggedForAction, - - /** - * The FromAddresses property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:FromAddresses") - ExceptionFromAddresses, - - /** - * The FromConnectedAccounts property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:FromConnectedAccounts") - ExceptionFromConnectedAccounts, - - /** - * The HasAttachments property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:HasAttachments") - ExceptionHasAttachments, - - /** - * The Importance property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:Importance") - ExceptionImportance, - - /** - * The IsApprovalRequest property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:IsApprovalRequest") - ExceptionIsApprovalRequest, - - /** - * The IsAutomaticForward property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:IsAutomaticForward") - ExceptionIsAutomaticForward, - - /** - * The IsAutomaticReply property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:IsAutomaticReply") - ExceptionIsAutomaticReply, - - /** - * The IsEncrypted property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:IsEncrypted") - ExceptionIsEncrypted, - - /** - * The IsMeetingRequest property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:IsMeetingRequest") - ExceptionIsMeetingRequest, - - /** - * The IsMeetingResponse property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:IsMeetingResponse") - ExceptionIsMeetingResponse, - - /** - * The IsNonDeliveryReport property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:IsNDR") - ExceptionIsNonDeliveryReport, - - /** - * The IsPermissionControlled property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:IsPermissionControlled") - ExceptionIsPermissionControlled, - - /** - * The IsRead property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:IsRead") - ExceptionIsRead, - - /** - * The IsSigned property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:IsSigned") - ExceptionIsSigned, - - /** - * The IsVoicemail property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:IsVoicemail") - ExceptionIsVoicemail, - - /** - * The ItemClasses property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:ItemClasses") - ExceptionItemClasses, - - /** - * The MessageClassifications property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:MessageClassifications") - ExceptionMessageClassifications, - - /** - * The NotSentToMe property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:NotSentToMe") - ExceptionNotSentToMe, - - /** - * The SentCcMe property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:SentCcMe") - ExceptionSentCcMe, - - /** - * The SentOnlyToMe property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:SentOnlyToMe") - ExceptionSentOnlyToMe, - - /** - * The SentToAddresses property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:SentToAddresses") - ExceptionSentToAddresses, - - /** - * The SentToMe property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:SentToMe") - ExceptionSentToMe, - - /** - * The SentToOrCcMe property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:SentToOrCcMe") - ExceptionSentToOrCcMe, - - /** - * The Sensitivity property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:Sensitivity") - ExceptionSensitivity, - - /** - * The WithinDateRange property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:WithinDateRange") - ExceptionWithinDateRange, - - /** - * The WithinSizeRange property of a rule's set of exception. - */ - @EwsEnum(schemaName = "Exception:WithinSizeRange") - ExceptionWithinSizeRange, - - /** - * The Categories property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:Categories") - ActionCategories, - - /** - * The CopyToFolder property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:CopyToFolder") - ActionCopyToFolder, - - /** - * The Delete property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:Delete") - ActionDelete, - - /** - * The ForwardAsAttachmentToRecipients property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:ForwardAsAttachmentToRecipients") - ActionForwardAsAttachmentToRecipients, - - /** - * The ForwardToRecipients property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:ForwardToRecipients") - ActionForwardToRecipients, - - /** - * The Importance property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:Importance") - ActionImportance, - - /** - * The MarkAsRead property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:MarkAsRead") - ActionMarkAsRead, - - /** - * The MoveToFolder property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:MoveToFolder") - ActionMoveToFolder, - - /** - * The PermanentDelete property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:PermanentDelete") - ActionPermanentDelete, - - /** - * The RedirectToRecipients property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:RedirectToRecipients") - ActionRedirectToRecipients, - - /** - * The SendSMSAlertToRecipients property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:SendSMSAlertToRecipients") - ActionSendSMSAlertToRecipients, - - /** - * The ServerReplyWithMessage property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:ServerReplyWithMessage") - ActionServerReplyWithMessage, - - /** - * The StopProcessingRules property in a rule's set of actions. - */ - @EwsEnum(schemaName = "Action:StopProcessingRules") - ActionStopProcessingRules, - - /** - * The IsEnabled property of a rule, indicating if the rule is enabled. - */ - @EwsEnum(schemaName = "IsEnabled") - IsEnabled, - - /** - * The IsInError property of a rule, indicating if the rule is in error. - */ - @EwsEnum(schemaName = "IsInError") - IsInError, - - /** - * The Conditions property of a rule, contains all conditions of the rule. - */ - @EwsEnum(schemaName = "Conditions") - Conditions, - - /** - * The Exceptions property of a rule, contains all exception of the rule. - */ - @EwsEnum(schemaName = "Exceptions") - Exceptions - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/TaskDelegationState.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/TaskDelegationState.java deleted file mode 100644 index 807881753..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/TaskDelegationState.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -/** - * This maps to the bogus TaskDelegationState in the EWS schema. - * The schema enum has 6 values, but XSO should never return anything but - * values between 0 and 3, so we should be safe without mappings for - * EWS's Declined and Max values - */ - - -/** - * Defines the delegation state of a task. - */ -public enum TaskDelegationState { - - // The task is not delegated - /** - * The No delegation. - */ - NoDelegation, // Maps to NoMatch - - // The task's delegation state is unknown. - /** - * The Unknown. - */ - Unknown, // Maps to OwnNew - - // The task was delegated and the delegation was accepted. - /** - * The Accepted. - */ - Accepted, // Maps to Owned - - // The task was delegated but the delegation was declined. - /** - * The Declined. - */ - Declined - // Maps to Accepted - - // The original Declined value has no mapping - // The original Max value has no mapping - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/UserConfigurationDictionaryObjectType.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/UserConfigurationDictionaryObjectType.java deleted file mode 100644 index 666e80d7b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/UserConfigurationDictionaryObjectType.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -/** - * Identifies the user configuration dictionary key and value types. - */ -public enum UserConfigurationDictionaryObjectType { - - // DateTime type. - /** - * The Date time. - */ - DateTime, - - // Boolean type. - /** - * The Boolean. - */ - Boolean, - - // Byte type. - /** - * The Byte. - */ - Byte, - - // String type. - /** - * The String. - */ - String, - - // 32-bit integer type. - /** - * The Integer32. - */ - Integer32, - - // 32-bit unsigned integer type. - /** - * The Unsigned integer32. - */ - UnsignedInteger32, - - // 64-bit integer type. - /** - * The Integer64. - */ - Integer64, - - // 64-bit unsigned integer type. - /** - * The Unsigned integer64. - */ - UnsignedInteger64, - - // String array type. - /** - * The String array. - */ - StringArray, - - // Byte array type - /** - * The Byte array. - */ - ByteArray, - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/WellKnownFolderName.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/WellKnownFolderName.java deleted file mode 100644 index dbd7fc862..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/WellKnownFolderName.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property; - -import microsoft.exchange.webservices.data.attribute.RequiredServerVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Defines well known folder names. - */ -public enum WellKnownFolderName { - // The Calendar folder. - /** - * The Calendar. - */ - Calendar, - - // The Contacts folder. - /** - * The Contacts. - */ - Contacts, - - // The Deleted Items folder - /** - * The Deleted item. - */ - DeletedItems, - - // The Drafts folder. - /** - * The Drafts. - */ - Drafts, - - // The Inbox folder. - /** - * The Inbox. - */ - Inbox, - - // The Journal folder. - /** - * The Journal. - */ - Journal, - - // The Notes folder. - /** - * The Notes. - */ - Notes, - - // The Outbox folder. - /** - * The Outbox. - */ - Outbox, - - // The Sent Items folder. - /** - * The Sent item. - */ - SentItems, - - // The Tasks folder. - /** - * The Tasks. - */ - Tasks, - - // The message folder root. - /** - * The Msg folder root. - */ - MsgFolderRoot, - - // The root of the Public Folders hierarchy. - /** - * The Public folder root. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2007_SP1) - PublicFoldersRoot, - - // The root of the mailbox. - /** - * The Root. - */ - Root, - - // The Junk E-mail folder. - /** - * The Junk email. - */ - JunkEmail, - - // The Search Folders folder, also known as the Finder folder. - /** - * The Search folder. - */ - SearchFolders, - - // The Voicemail folder. - /** - * The Voice mail. - */ - VoiceMail, - - /** - * The Dumpster 2.0 root folder. - */ - - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - RecoverableItemsRoot, - - /** - * The Dumpster 2.0 soft deletions folder. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - RecoverableItemsDeletions, - - /** - * The Dumpster 2.0 versions folder. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - RecoverableItemsVersions, - - /** - * The Dumpster 2.0 hard deletions folder. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - RecoverableItemsPurges, - - /** - * The root of the archive mailbox. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - ArchiveRoot, - - /** - * The message folder root in the archive mailbox. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - ArchiveMsgFolderRoot, - - /** - * The Deleted Items folder in the archive mailbox. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - ArchiveDeletedItems, - - /** - * The Dumpster 2.0 root folder in the archive mailbox. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - ArchiveRecoverableItemsRoot, - - /** - * The Dumpster 2.0 soft deletions folder in the archive mailbox. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - ArchiveRecoverableItemsDeletions, - - /** - * The Dumpster 2.0 versions folder in the archive mailbox. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - ArchiveRecoverableItemsVersions, - - /** - * The Dumpster 2.0 hard deletions folder in the archive mailbox. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - ArchiveRecoverableItemsPurges, - - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/error/RuleErrorCode.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/error/RuleErrorCode.java deleted file mode 100644 index d465b848a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/error/RuleErrorCode.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property.error; - -/** - * Defines the error codes identifying why a rule failed validation. - */ -public enum RuleErrorCode { - - /** - * Active Directory operation failed. - */ - ADOperationFailure, - - /** - * The e-mail account specified in the - * FromConnectedAccounts predicate was not found. - */ - ConnectedAccountNotFound, - - /** - * The Rule object in a CreateInboxRuleOperation has an Id. The Ids of new - * rules are generated server side and - * should not be provided by the client. - */ - CreateWithRuleId, - - /** - * The value is empty. An empty value is not allowed for the property. - */ - EmptyValueFound, - - /** - * There already is a rule with the same priority. - */ - DuplicatedPriority, - - /** - * There are multiple operations against the same rule. - * Only one operation per rule is allowed. - */ - DuplicatedOperationOnTheSameRule, - - /** - * The folder does not exist in the user's mailbox. - */ - FolderDoesNotExist, - - /** - * The e-mail address is invalid. - */ - InvalidAddress, - - /** - * The date range is invalid. - */ - InvalidDateRange, - - /** - * The folder Id is invalid. - */ - InvalidFolderId, - - /** - * The size range is invalid. - */ - InvalidSizeRange, - - /** - * The value is invalid. - */ - InvalidValue, - - /** - * The message classification was not found. - */ - MessageClassificationNotFound, - - /** - * No action was specified. At least one action must be specified. - */ - MissingAction, - - /** - * The required parameter is missing. - */ - MissingParameter, - - /** - * The range value is missing. - */ - MissingRangeValue, - - /** - * The property cannot be modified. - */ - NotSettable, - - /** - * The recipient does not exist. - */ - RecipientDoesNotExist, - - /** - * The rule was not found. - */ - RuleNotFound, - - /** - * The size is less than zero. - */ - SizeLessThanZero, - - /** - * The string value is too big. - */ - StringValueTooBig, - - /** - * The address is unsupported. - */ - UnsupportedAddress, - - /** - * An unexpected error occured. - */ - UnexpectedError, - - /** - * The rule is not supported. - */ - UnsupportedRule -} - diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/time/DayOfTheWeek.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/time/DayOfTheWeek.java deleted file mode 100644 index 44394d2e0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/time/DayOfTheWeek.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property.time; - -import java.util.Calendar; - -/** - * Specifies the day of the week. For the standard days of the week (Sunday, - * Monday...) the DayOfTheWeek enum value is the same as the System.DayOfWeek - * enum type. These values can be safely cast between the two enum types. The - * special days of the week (Day, Weekday and WeekendDay) are used for monthly - * and yearly recurrences and cannot be cast to System.DayOfWeek values. - */ -public enum DayOfTheWeek { - - // Sunday - /** - * The Sunday. - */ - Sunday(Calendar.SUNDAY), - - // Monday - /** - * The Monday. - */ - Monday(Calendar.MONDAY), - - // Tuesday - /** - * The Tuesday. - */ - Tuesday(Calendar.TUESDAY), - - // Wednesday - /** - * The Wednesday. - */ - Wednesday(Calendar.WEDNESDAY), - - // Thursday - /** - * The Thursday. - */ - Thursday(Calendar.THURSDAY), - - // Friday - /** - * The Friday. - */ - Friday(Calendar.FRIDAY), - - // Saturday - /** - * The Saturday. - */ - Saturday(Calendar.SATURDAY), - - // Any day of the week - /** - * The Day. - */ - Day(), - - // Any day of the usual business week (Monday-Friday) - /** - * The Weekday. - */ - Weekday(), - - // Any weekend day (Saturday or Sunday) - /** - * The Weekend day. - */ - WeekendDay; - - /** - * The day of week. - */ - private int dayOfWeek = 0; - - /** - * Instantiates a new day of the week. - * - * @param dayOfWeek the day of week - */ - DayOfTheWeek(int dayOfWeek) { - this.dayOfWeek = dayOfWeek; - } - - /** - * Instantiates a new day of the week. - */ - DayOfTheWeek() { - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/time/DayOfTheWeekIndex.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/time/DayOfTheWeekIndex.java deleted file mode 100644 index 350101a0b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/time/DayOfTheWeekIndex.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property.time; - -/** - * Defines the index of a week day within a month. - */ -public enum DayOfTheWeekIndex { - - // The first specific day of the week in the month. For example, the first - // Tuesday of the month. - /** - * The First. - */ - First, - - // The second specific day of the week in the month. For example, the second - // Tuesday of the month. - /** - * The Second. - */ - Second, - - // The third specific day of the week in the month. For example, the third - // Tuesday of the month. - /** - * The Third. - */ - Third, - - // The fourth specific day of the week in the month. For example, the fourth - // Tuesday of the month. - /** - * The Fourth. - */ - Fourth, - - // The last specific day of the week in the month. For example, the last - // Tuesday of the month. - /** - * The Last. - */ - Last -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/time/Month.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/time/Month.java deleted file mode 100644 index f43a0714b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/property/time/Month.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.property.time; - -/** - * Defines months of the year. - */ -public enum Month { - - // January. - /** - * The January. - */ - January(1), - - // February. - /** - * The February. - */ - February(2), - - // March. - /** - * The March. - */ - March(3), - - // April. - /** - * The April. - */ - April(4), - - // May. - /** - * The May. - */ - May(5), - - // June. - /** - * The June. - */ - June(6), - - // July. - /** - * The July. - */ - July(7), - - // August. - /** - * The August. - */ - August(8), - - // September. - /** - * The September. - */ - September(9), - - // October. - /** - * The October. - */ - October(10), - - // November. - /** - * The November. - */ - November(11), - - // December. - /** - * The December. - */ - December(12); - - /** - * The month. - */ - private final int month; - - /** - * Instantiates a new month. - * - * @param month the month - */ - Month(int month) { - this.month = month; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/ComparisonMode.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/ComparisonMode.java deleted file mode 100644 index 0732df02f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/ComparisonMode.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.search; - -/** - * Defines the way values are compared in search filter. - */ -public enum ComparisonMode { - - // The comparison is exact. - /** - * The Exact. - */ - Exact, - - // The comparison ignores casing. - /** - * The Ignore case. - */ - IgnoreCase, - - // The comparison ignores spacing characters. - /** - * The Ignore non spacing characters. - */ - IgnoreNonSpacingCharacters, - - // The comparison ignores casing and spacing characters. - /** - * The Ignore case and non spacing characters. - */ - IgnoreCaseAndNonSpacingCharacters - - // From bug E12:113326 - // - // Although the following four values are defined in - // the EWS schema, they are useless - // as they are all thechnically equivalent to Loose. - // We are not exposing those values - // in this API. When we encounter one of these - // values on an existing search folder - // restriction, we map it to IgnoreCaseAndNonSpacingCharacters. - // - // Loose, - // LooseAndIgnoreCase, - // LooseAndIgnoreNonSpace, - // LooseAndIgnoreCaseAndIgnoreNonSpace -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/ContainmentMode.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/ContainmentMode.java deleted file mode 100644 index 653772441..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/ContainmentMode.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.search; - -/** - * Defines the containment mode for Contains search filter. - */ -public enum ContainmentMode { - - // The comparison is between the full string and the constant. The property - // value and the supplied constant are precisely the same. - /** - * The Full string. - */ - FullString, - - // The comparison is between the string prefix and the constant. - /** - * The Prefixed. - */ - Prefixed, - - // The comparison is between a substring of the string and the constant. - /** - * The Substring. - */ - Substring, - - // The comparison is between a prefix on individual words in the string and - // the constant. - /** - * The Prefix on words. - */ - PrefixOnWords, - - // The comparison is between an exact phrase in the string and the constant. - /** - * The Exact phrase. - */ - ExactPhrase -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/ItemTraversal.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/ItemTraversal.java deleted file mode 100644 index c2322bcfe..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/ItemTraversal.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.search; - -import microsoft.exchange.webservices.data.attribute.RequiredServerVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Defines the scope of FindItems operations. - */ -public enum ItemTraversal { - - // All non deleted item in the specified folder are retrieved. - /** - * The Shallow. - */ - Shallow, - - // Only soft-deleted item are retrieved. - /** - * The Soft deleted. - */ - SoftDeleted, - - // Only associated item are retrieved (Exchange 2010 or later). - /** - * The Associated. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010) - Associated -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/ResolveNameSearchLocation.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/ResolveNameSearchLocation.java deleted file mode 100644 index 242a8d646..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/search/ResolveNameSearchLocation.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.search; - -/** - * Defines the location where a ResolveName operation searches for contacts. - */ -public enum ResolveNameSearchLocation { - - // The name is resolved against the Global Address List. - /** - * The Directory only. - */ - DirectoryOnly, - - // The name is resolved against the Global Address List and then against the - // Contacts folder if no match was found. - /** - * The Directory then contacts. - */ - DirectoryThenContacts, - - // The name is resolved against the Contacts folder. - /** - * The Contacts only. - */ - ContactsOnly, - - // The name is resolved against the Contacts folder and then against the - // Global Address List if no match was found. - /** - * The Contacts then directory. - */ - ContactsThenDirectory -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ConflictResolutionMode.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ConflictResolutionMode.java deleted file mode 100644 index a7bf56369..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ConflictResolutionMode.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - -/** - * Defines how conflict resolutions are handled in update operations. - */ -public enum ConflictResolutionMode { - - // Local property changes are discarded. - /** - * The Never overwrite. - */ - NeverOverwrite, - - // Local property changes are applied to the server unless the server-side - // copy is more recent than the local copy. - /** - * The Auto resolve. - */ - AutoResolve, - - // Local property changes overwrite server-side changes. - /** - * The Always overwrite. - */ - AlwaysOverwrite - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/DeleteMode.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/DeleteMode.java deleted file mode 100644 index 0dbec5e89..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/DeleteMode.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - -/** - * Represents deletion modes. - */ -public enum DeleteMode { - - // The item or folder will be permanently deleted. - /** - * The Hard delete. - */ - HardDelete, - - // The item or folder will be moved to the dumpster. Items and folder in - // the dumpster can be recovered. - /** - * The Soft delete. - */ - SoftDelete, - - // The item or folder will be moved to the mailbox' Deleted Items folder. - /** - * The Move to deleted item. - */ - MoveToDeletedItems - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/EffectiveRights.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/EffectiveRights.java deleted file mode 100644 index eb76d36af..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/EffectiveRights.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - -/** - * Defines the effective user rights associated with an item or folder. - */ -public enum EffectiveRights { - - // The user has no acces right on the item or folder. - /** - * The None. - */ - None(0), - - // The user can create associated item (FAI) - /** - * The Create associated. - */ - CreateAssociated(1), - - // The user can create item. - /** - * The Create contents. - */ - CreateContents(2), - - // The user can create sub-folder. - - /** - * The Create hierarchy. - */ - CreateHierarchy(4), - - // The user can delete item and/or folder. - /** - * The Delete. - */ - Delete(8), - - // The user can modify the property of item and/or folder. - /** - * The Modify. - */ - Modify(16), - - // The user can read the contents of item. - /** - * The Read. - */ - Read(32), - - /// The user can view private item. - /** - * The View Private Items. - */ - ViewPrivateItems(64); - - - /** - * The effective rights. - */ - private final int effectiveRights; - - /** - * Instantiates a new effective rights. - * - * @param effectiveRights the effective rights - */ - EffectiveRights(int effectiveRights) { - this.effectiveRights = effectiveRights; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/FileAsMapping.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/FileAsMapping.java deleted file mode 100644 index 88aeedb6f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/FileAsMapping.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - -import microsoft.exchange.webservices.data.attribute.EwsEnum; -import microsoft.exchange.webservices.data.attribute.RequiredServerVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Defines the way the FileAs property of a contact is automatically formatted. - */ -public enum FileAsMapping { - // No automatic formatting is used. - /** - * The None. - */ - None, - - // Surname, GivenName - /** - * The Surname comma given name. - */ - @EwsEnum(schemaName = "LastCommaFirst") - SurnameCommaGivenName, - - // GivenName Surname - /** - * The Given name space surname. - */ - @EwsEnum(schemaName = "FirstSpaceLast") - GivenNameSpaceSurname, - - // Company - /** - * The Company. - */ - Company, - - // Surname, GivenName (Company) - /** - * The Surname comma given name company. - */ - @EwsEnum(schemaName = "LastCommaFirstCompany") - SurnameCommaGivenNameCompany, - - // Company (SurnameGivenName) - /** - * The Company surname given name. - */ - @EwsEnum(schemaName = "CompanyLastFirst") - CompanySurnameGivenName, - - // SurnameGivenName - /** - * The Surname given name. - */ - @EwsEnum(schemaName = "LastFirst") - SurnameGivenName, - - // SurnameGivenName (Company) - /** - * The Surname given name company. - */ - @EwsEnum(schemaName = "LastFirstCompany") - SurnameGivenNameCompany, - - // Company (Surname, GivenName) - /** - * The Company surname comma given name. - */ - @EwsEnum(schemaName = "CompanyLastCommaFirst") - CompanySurnameCommaGivenName, - - // SurnameGivenName Suffix - /** - * The Surname given name suffix. - */ - @EwsEnum(schemaName = "LastFirstSuffix") - SurnameGivenNameSuffix, - - // Surname GivenName (Company) - /** - * The Surname space given name company. - */ - @EwsEnum(schemaName = "LastSpaceFirstCompany") - SurnameSpaceGivenNameCompany, - - // Company (Surname GivenName) - /** - * The Company surname space given name. - */ - @EwsEnum(schemaName = "CompanyLastSpaceFirst") - CompanySurnameSpaceGivenName, - - // Surname GivenName - /** - * The Surname space given name. - */ - @EwsEnum(schemaName = "LastSpaceFirst") - SurnameSpaceGivenName, - - // Display Name (Exchange 2010 or later). - /** - * The Display name. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010) - DisplayName, - - // GivenName (Exchange 2010 or later). - /** - * The Given name. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010) - @EwsEnum(schemaName = "FirstName") - GivenName, - - // Surname GivenName Middle Suffix (Exchange 2010 or later). - /** - * The Surname given name middle suffix. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010) - @EwsEnum(schemaName = "LastFirstMiddleSuffix") - SurnameGivenNameMiddleSuffix, - - // Surname (Exchange 2010 or later). - /** - * The Surname. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010) - @EwsEnum(schemaName = "LastName") - Surname, - - // Empty (Exchange 2010 or later). - /** - * The Empty. - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010) - Empty -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/MeetingRequestType.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/MeetingRequestType.java deleted file mode 100644 index b49f043a2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/MeetingRequestType.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - -/** - * Defines the type of a meeting request. - */ -public enum MeetingRequestType { - - // Undefined meeting request type. - /** - * The None. - */ - None, - - // The meeting request is an update to the original meeting. - /** - * The Full update. - */ - FullUpdate, - - // The meeting request is an information update. - /** - * The Informational update. - */ - InformationalUpdate, - - // The meeting request is for a new meeting. - /** - * The New meeting request. - */ - NewMeetingRequest, - - // The meeting request is outdated. - /** - * The Outdated. - */ - Outdated, - - // The meeting update is a silent update to an existing meeting. - /** - * The Silent update. - */ - SilentUpdate, - - // The meeting update was forwarded to a delegate, and this copy is - // informational. - /** - * The Principal wants copy. - */ - PrincipalWantsCopy - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/MeetingRequestsDeliveryScope.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/MeetingRequestsDeliveryScope.java deleted file mode 100644 index a7c54626c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/MeetingRequestsDeliveryScope.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - -import microsoft.exchange.webservices.data.attribute.RequiredServerVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Defines how meeting request are sent to delegates. - */ -public enum MeetingRequestsDeliveryScope { - - // Meeting request are sent to delegates only. - /** - * The Delegates only. - */ - DelegatesOnly, - - // Meeting request are sent to delegates and to the owner of the mailbox. - /** - * The Delegates and me. - */ - DelegatesAndMe, - - // Meeting request are sent to delegates and informational messages are - // sent to the owner of the mailbox. - /** - * The Delegates and send information to me. - */ - DelegatesAndSendInformationToMe, - - //Meeting request are not sent to delegates. This value is - //supported only for Exchange 2010 SP1 or later - //server versions. - @RequiredServerVersion(version = ExchangeVersion.Exchange2010_SP1) - NoForward -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/PhoneCallState.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/PhoneCallState.java deleted file mode 100644 index ba8b1552a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/PhoneCallState.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - -/** - * The PhoneCallState enumeration. - */ -public enum PhoneCallState { - - // Idle - /** - * The Idle. - */ - Idle, - - // Connecting - /** - * The Connecting. - */ - Connecting, - - // Alerted - /** - * The Alerted. - */ - Alerted, - - // Connected - /** - * The Connected. - */ - Connected, - - // Disconnected - /** - * The Disconnected. - */ - Disconnected, - - // Incoming - /** - * The Incoming. - */ - Incoming, - - // Transferring - /** - * The Transferring. - */ - Transferring, - - // Forwarding - /** - * The Forwarding. - */ - Forwarding - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ResponseActions.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ResponseActions.java deleted file mode 100644 index dac090f95..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/ResponseActions.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - - -import microsoft.exchange.webservices.data.attribute.Flags; - -/** - * Defines the response actions that can be taken on an item. - */ -@Flags -public enum ResponseActions { - - // No action can be taken. - /** - * The None. - */ - None(0), - - // The item can be accepted. - /** - * The Accept. - */ - Accept(1), - - // The item can be tentatively accepted. - /** - * The Tentatively accept. - */ - TentativelyAccept(2), - - // The item can be declined. - /** - * The Decline. - */ - Decline(4), - - // The item can be replied to. - - /** - * The Reply. - */ - Reply(8), - - // The item can be replied to. - /** - * The Reply all. - */ - ReplyAll(16), - - // The item can be forwarded. - /** - * The Forward. - */ - Forward(32), - - // The item can be cancelled. - /** - * The Cancel. - */ - Cancel(64), - - // The item can be removed from the calendar. - /** - * The Remove from calendar. - */ - RemoveFromCalendar(128), - - // The item's read receipt can be suppressed. - /** - * The Suppress read receipt. - */ - SuppressReadReceipt(256), - - // A reply to the item can be posted. - /** - * The Post reply. - */ - PostReply(512); - - /** - * The response act. - */ - private final int responseAct; - - /** - * Instantiates a new response actions. - * - * @param responseAct the response act - */ - ResponseActions(int responseAct) { - this.responseAct = responseAct; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/SendCancellationsMode.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/SendCancellationsMode.java deleted file mode 100644 index 407f2e197..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/SendCancellationsMode.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - -/** - * Defines how meeting cancellations should be sent to attendees when an - * appointment is deleted. - */ -public enum SendCancellationsMode { - - // No meeting cancellation is sent. - /** - * The Send to none. - */ - SendToNone, - - // Meeting cancellations are sent to all attendees. - /** - * The Send only to all. - */ - SendOnlyToAll, - - // Meeting cancellations are sent to all attendees and a copy of the meeting - // is saved in the organizer's Sent Items folder. - /** - * The Send to all and save copy. - */ - SendToAllAndSaveCopy, - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/SendInvitationsMode.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/SendInvitationsMode.java deleted file mode 100644 index ce62415b0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/SendInvitationsMode.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - -/** - * Defines if/how meeting invitations are sent. - */ -public enum SendInvitationsMode { - - // No meeting invitation is sent. - /** - * The Send to none. - */ - SendToNone, - - // Meeting invitations are sent to all attendees. - /** - * The Send only to all. - */ - SendOnlyToAll, - - // Meeting invitations are sent to all attendees and a copy of the - // invitation message is saved. - /** - * The Send to all and save copy. - */ - SendToAllAndSaveCopy - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/SendInvitationsOrCancellationsMode.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/SendInvitationsOrCancellationsMode.java deleted file mode 100644 index c5b74d19e..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/SendInvitationsOrCancellationsMode.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - -/** - * Defines if/how meeting invitations or cancellations should be sent to - * attendees when an appointment is updated. - */ -public enum SendInvitationsOrCancellationsMode { - - // No meeting invitation/cancellation is sent. - /** - * The Send to none. - */ - SendToNone, - - // Meeting invitations/cancellations are sent to all attendees. - /** - * The Send only to all. - */ - SendOnlyToAll, - - // Meeting invitations/cancellations are sent only to attendees that have - // been added or modified. - /** - * The Send only to changed. - */ - SendOnlyToChanged, - - // Meeting invitations/cancellations are sent to all attendees and a copy is - // saved in the organizer's Sent Items folder. - /** - * The Send to all and save copy. - */ - SendToAllAndSaveCopy, - - // Meeting invitations/cancellations are sent only to attendees that have - // been added or modified and a copy is saved in the organizer's Sent Items - // folder. - /** - * The Send to changed and save copy. - */ - SendToChangedAndSaveCopy - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/TaskMode.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/TaskMode.java deleted file mode 100644 index ae9c9bdeb..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/TaskMode.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - -/** - * Defines the modes of a Task. - */ -public enum TaskMode { - - // The task is normal - /** - * The Normal. - */ - Normal(0), - - // The task is a task assignment request - /** - * The Request. - */ - Request(1), - - // The task assignment request was accepted - /** - * The Request accepted. - */ - RequestAccepted(2), - - // The task assignment request was declined - /** - * The Request declined. - */ - RequestDeclined(3), - - // The task has been updated - /** - * The Update. - */ - Update(4), - - // The task is self delegated - /** - * The Self delegated. - */ - SelfDelegated(5); - - /** - * The task mode. - */ - private final int taskMode; - - /** - * Instantiates a new task mode. - * - * @param taskMode the task mode - */ - TaskMode(int taskMode) { - this.taskMode = taskMode; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/TaskStatus.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/TaskStatus.java deleted file mode 100644 index 5394014d4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/TaskStatus.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service; - -/** - * Defines the execution status of a task. - */ -public enum TaskStatus { - - // The execution of the task is not started. - /** - * The Not started. - */ - NotStarted, - - // The execution of the task is in progress. - /** - * The In progress. - */ - InProgress, - - // The execution of the task is completed. - /** - * The Completed. - */ - Completed, - - // The execution of the task is waiting on others. - /** - * The Waiting on others. - */ - WaitingOnOthers, - - // The execution of the task is deferred. - /** - * The Deferred. - */ - Deferred - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/calendar/AppointmentType.java b/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/calendar/AppointmentType.java deleted file mode 100644 index 597d6a1a6..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/enumeration/service/calendar/AppointmentType.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.enumeration.service.calendar; - -/** - * Defines the type of an appointment. - */ -public enum AppointmentType { - // The appointment is non-recurring. - /** - * The Single. - */ - Single, - - // The appointment is an occurrence of a recurring appointment. - /** - * The Occurrence. - */ - Occurrence, - - // The appointment is an exception of a recurring appointment. - /** - * The Exception. - */ - Exception, - - // The appointment is the recurring master of a series. - /** - * The Recurring master. - */ - RecurringMaster -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/dns/DnsException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/dns/DnsException.java deleted file mode 100644 index d652ad51d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/dns/DnsException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.dns; - -/** - * Defines DnsException class. - */ -public class DnsException extends Exception { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new dns exception. - * - * @param exceptionMessage the exception message - */ - public DnsException(String exceptionMessage) { - super(exceptionMessage); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/http/EWSHttpException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/http/EWSHttpException.java deleted file mode 100644 index 89f0b2915..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/http/EWSHttpException.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.http; - -/** - * The Class EWSHttpException. - */ -public class EWSHttpException extends Exception { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new EWS http exception. - */ - public EWSHttpException() { - super(); - - } - - /** - * Instantiates a new EWS http exception. - * - * @param arg0 the arg0 - * @param arg1 the arg1 - */ - public EWSHttpException(String arg0, Throwable arg1) { - super(arg0, arg1); - - } - - /** - * Instantiates a new EWS http exception. - * - * @param arg0 the arg0 - */ - public EWSHttpException(String arg0) { - super(arg0); - - } - - /** - * Instantiates a new EWS http exception. - * - * @param arg0 the arg0 - */ - public EWSHttpException(Throwable arg0) { - super(arg0); - - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/http/HttpErrorException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/http/HttpErrorException.java deleted file mode 100644 index ef3196ddd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/http/HttpErrorException.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.http; - - -/** - * User: nwoodham Date: 3/8/11 Time: 5:30 PM - */ -public class HttpErrorException extends Exception { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - private final int code; - - public HttpErrorException() { - super(); - this.code = 0; - } - - public HttpErrorException(String message, int code) { - super(message); - this.code = code; - } - - public int getHttpErrorCode() { - return this.code; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/ArgumentException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/ArgumentException.java deleted file mode 100644 index f2b278c31..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/ArgumentException.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.misc; - -import java.security.PrivilegedActionException; - -/** - * The Class ArgumentException. - */ -public class ArgumentException extends IllegalArgumentException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 2L; - - /** - * ParamName that causes the Exception - */ - private String paramName = null; - - /** - * Constructs an IllegalArgumentException with no detail message. - */ - protected ArgumentException() { - super(); - } - - /** - * Constructs an IllegalArgumentException with the specified detail message. - * - * @param message the detail message. - */ - public ArgumentException(String message) { - super(message); - } - - /** - * Constructs an IllegalArgumentException with the specified detail message. - * - * @param s the detail message. - * @param paramName the Name of the Param that causes the exception - */ - public ArgumentException(String s, String paramName) { - super(s); - this.paramName = paramName; - } - - /** - * Constructs a new exception with the specified detail message and cause. - *

- *

Note that the detail message associated with cause is not automatically - * incorporated in this exception's detail message. - * - * @param message the detail message (which is saved for later retrieval by the {@link - * Throwable#getMessage()} method). - * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method). - * (A null value is permitted, and indicates that the cause is nonexistent or - * unknown.) - * @since 1.5 - */ - public ArgumentException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Constructs a new exception with the specified cause and a detail message of (cause==null ? null : - * cause.toString()) (which typically contains the class and detail message of cause). This - * constructor is useful for exceptions that are little more than wrappers for other throwables (for - * example, {@link PrivilegedActionException}). - * - * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method). - * (A null value is permitted, and indicates that the cause is nonexistent or - * unknown.) - * @since 1.5 - */ - public ArgumentException(Throwable cause) { - super(cause); - } - - /** - * Constructs a new exception with the specified cause and a detail message of (cause==null ? null : - * cause.toString()) (which typically contains the class and detail message of cause). This - * constructor is useful for exceptions that are little more than wrappers for other throwables (for - * example, {@link PrivilegedActionException}). - * - * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} - * method). (A null value is permitted, and indicates that the cause is - * nonexistent or unknown.) - * @param paramName the Name of the Param that causes the exception - */ - public ArgumentException(Throwable cause, String paramName) { - super(cause); - this.paramName = paramName; - } - - /** - * Initializes a new instance of the System. ArgumentException class with a specified error message and the - * name of the parameter that causes this exception. - * - * @param message The error message that explains the reason for the exception. - * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} - * method). (A null value is permitted, and indicates that the cause is - * nonexistent or unknown.) - * @param paramName the Name of the Param that causes the exception - */ - public ArgumentException(String message, Throwable cause, String paramName) { - super(message + " Parameter that caused " + - "the current exception :" + paramName); - this.paramName = paramName; - } - - /** - * Get the Name of the Param that causes the exception - * @return the ParamName (or null if not set) - */ - public String getParamName() { - return paramName; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/ArgumentNullException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/ArgumentNullException.java deleted file mode 100644 index 1bc9c18bd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/ArgumentNullException.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.misc; - -public class ArgumentNullException extends ArgumentException { - - /** - * Constructs an IllegalArgumentException with the specified detail message. - * - * @param message the detail message. - */ - public ArgumentNullException(String message) { - super(message); - } - - /** - * Constructs an IllegalArgumentException with the specified detail message. - * - * @param s the detail message. - * @param paramName the Name of the Param that causes the exception - */ - public ArgumentNullException(String s, String paramName) { - super(s, paramName); - } - - /** - * Constructs a new exception with the specified detail message and cause. - *

- *

Note that the detail message associated with cause is not automatically - * incorporated in this exception's detail message. - * - * @param message the detail message (which is saved for later retrieval by the {@link - * Throwable#getMessage()} method). - * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method). - * (A null value is permitted, and indicates that the cause is nonexistent or - * unknown.) - * @since 1.5 - */ - public ArgumentNullException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Constructs a new exception with the specified cause and a detail message of (cause==null ? null : - * cause.toString()) (which typically contains the class and detail message of cause). This - * constructor is useful for exceptions that are little more than wrappers for other throwables (for - * example, {@link java.security.PrivilegedActionException}). - * - * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} method). - * (A null value is permitted, and indicates that the cause is nonexistent or - * unknown.) - * @since 1.5 - */ - public ArgumentNullException(Throwable cause) { - super(cause); - } - - /** - * Constructs a new exception with the specified cause and a detail message of (cause==null ? null : - * cause.toString()) (which typically contains the class and detail message of cause). This - * constructor is useful for exceptions that are little more than wrappers for other throwables (for - * example, {@link java.security.PrivilegedActionException}). - * - * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} - * method). (A null value is permitted, and indicates that the cause is - * nonexistent or unknown.) - * @param paramName the Name of the Param that causes the exception - */ - public ArgumentNullException(Throwable cause, String paramName) { - super(cause, paramName); - } - - /** - * Initializes a new instance of the System. ArgumentException class with a specified error message and the - * name of the parameter that causes this exception. - * - * @param message The error message that explains the reason for the exception. - * @param cause the cause (which is saved for later retrieval by the {@link Throwable#getCause()} - * method). (A null value is permitted, and indicates that the cause is - * nonexistent or unknown.) - * @param paramName the Name of the Param that causes the exception - */ - public ArgumentNullException(String message, Throwable cause, String paramName) { - super(message, cause, paramName); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/ArgumentOutOfRangeException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/ArgumentOutOfRangeException.java deleted file mode 100644 index a16d71745..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/ArgumentOutOfRangeException.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.misc; - -/** - * The Class ArgumentOutOfRangeException. - */ -public class ArgumentOutOfRangeException extends Exception { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new argument out of range exception. - */ - public ArgumentOutOfRangeException() { - super(); - - } - - /** - * Instantiates a new argument out of range exception. - * - * @param arg0 the arg0 - */ - public ArgumentOutOfRangeException(final String arg0) { - super(arg0); - - } - - /** - * Instantiates a new argument out of range exception. - * - * @param arg0 the arg0 - * @param arg1 the arg1 - */ - public ArgumentOutOfRangeException(final String arg0, final String arg1) { - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/FormatException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/FormatException.java deleted file mode 100644 index 8808a8781..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/FormatException.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.misc; - -/** - * The Class FormatException. - */ -public class FormatException extends IllegalArgumentException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new format exception. - */ - public FormatException() { - super(); - - } - - /** - * Instantiates a new format exception. - * - * @param arg0 the arg0 - * @param arg1 the arg1 - */ - public FormatException(final String arg0, final Throwable arg1) { - super(arg0, arg1); - - } - - /** - * Instantiates a new format exception. - * - * @param arg0 the arg0 - */ - public FormatException(final String arg0) { - super(arg0); - - } - - /** - * Instantiates a new format exception. - * - * @param arg0 the arg0 - */ - public FormatException(final Throwable arg0) { - super(arg0); - - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/InvalidOperationException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/InvalidOperationException.java deleted file mode 100644 index 6148d50dd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/misc/InvalidOperationException.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.misc; - -/** - * The Class InvalidOperationException. - */ -public class InvalidOperationException extends Exception { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new invalid operation exception. - */ - public InvalidOperationException() { - - } - - /** - * Instantiates a new invalid operation exception. - * - * @param strMessage the str message - */ - public InvalidOperationException(String strMessage) { - super(strMessage); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/InvalidOrUnsupportedTimeZoneDefinitionException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/InvalidOrUnsupportedTimeZoneDefinitionException.java deleted file mode 100644 index f750b443d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/InvalidOrUnsupportedTimeZoneDefinitionException.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.local; - -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -/** - * The Class InvalidOrUnsupportedTimeZoneDefinitionException. - * - * Thrown when time zone definition is not valid. - * - * @see microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition - * @see microsoft.exchange.webservices.data.property.complex.time.TimeZoneTransitionGroup - */ -public class InvalidOrUnsupportedTimeZoneDefinitionException extends ServiceLocalException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Constructs an InvalidOrUnsupportedTimeZoneDefinitionException with no detail message. - */ - public InvalidOrUnsupportedTimeZoneDefinitionException() { - super(); - } - - /** - * Constructs an InvalidOrUnsupportedTimeZoneDefinitionException with the specified detail message. - * - * @param message the detail message. - */ - public InvalidOrUnsupportedTimeZoneDefinitionException(String message) { - super(message); - } - - /** - * Constructs a new exception with the specified detail message and cause. - * - * @param message the detail message (which is saved for later retrieval by the {@link - * Throwable#getMessage()} method). - * @param innerException the cause (which is saved for later retrieval by the {@link Throwable#getCause()} - * method). (A null value is permitted, and indicates that the cause is nonexistent - * or unknown.) - */ - public InvalidOrUnsupportedTimeZoneDefinitionException(String message, Exception innerException) { - super(message, innerException); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/PropertyException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/PropertyException.java deleted file mode 100644 index ca3c39437..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/PropertyException.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.local; - -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -/** - * Represents an error that occurs when an operation on a property fails. - */ -public class PropertyException extends ServiceLocalException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * The name. - */ - private String name; - - /** - * Instantiates a new property exception. - */ - public PropertyException() { - super(); - } - - /** - * Instantiates a new property exception. - * - * @param name the name - */ - public PropertyException(String name) { - super(); - this.name = name; - } - - /** - * Instantiates a new property exception. - * - * @param message the message - * @param name the name - */ - public PropertyException(String message, String name) { - super(message); - this.name = name; - } - - /** - * Instantiates a new property exception. - * - * @param message the message - * @param name the name - * @param innerException the inner exception - */ - public PropertyException(String message, String name, - Exception innerException) { - super(message, innerException); - this.name = name; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return name; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceLocalException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceLocalException.java deleted file mode 100644 index 4f5212d75..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceLocalException.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.local; - -/** - * Represents an error that occurs when a service operation fails locally (e.g. - * validation error). - */ -public class ServiceLocalException extends Exception { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * ServiceLocalException Constructor. - */ - public ServiceLocalException() { - super(); - } - - /** - * ServiceLocalException Constructor. - * - * @param message the message - */ - public ServiceLocalException(String message) { - super(message); - } - - /** - * ServiceLocalException Constructor. - * - * @param message the message - * @param innerException the inner exception - */ - public ServiceLocalException(String message, Exception innerException) { - super(message, innerException); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceObjectPropertyException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceObjectPropertyException.java deleted file mode 100644 index f86d25e9d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceObjectPropertyException.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.local; - -import microsoft.exchange.webservices.data.property.definition.PropertyDefinitionBase; - -/** - * Represents an error that occurs when an operation on a property fails. - */ -public class ServiceObjectPropertyException extends PropertyException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * The property definition. - */ - private PropertyDefinitionBase propertyDefinition; - - /** - * ServiceObjectPropertyException constructor. - * - * @param propertyDefinition The definition of the property that is at the origin of the - * exception. - */ - public ServiceObjectPropertyException( - PropertyDefinitionBase propertyDefinition) { - super(propertyDefinition.getPrintableName()); - this.propertyDefinition = propertyDefinition; - } - - /** - * ServiceObjectPropertyException constructor. - * - * @param message Error message text. - * @param propertyDefinition The definition of the property that is at the origin of the - * exception. - */ - public ServiceObjectPropertyException(String message, - PropertyDefinitionBase propertyDefinition) { - super(message, propertyDefinition.getPrintableName()); - this.propertyDefinition = propertyDefinition; - } - - /** - * ServiceObjectPropertyException constructor. - * - * @param message Error message text. - * @param propertyDefinition The definition of the property that is at the origin of the - * exception. - * @param innerException the inner exception - */ - public ServiceObjectPropertyException(String message, - PropertyDefinitionBase propertyDefinition, - Exception innerException) { - super(message, propertyDefinition.getPrintableName(), innerException); - this.propertyDefinition = propertyDefinition; - } - - /** - * The definition of the property that is at the origin of the exception. - * - * @return The definition of the property. - */ - public PropertyDefinitionBase getPropertyDefinition() { - return propertyDefinition; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceValidationException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceValidationException.java deleted file mode 100644 index 4c620ec30..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceValidationException.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.local; - -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -/** - * Represents an error that occurs when a validation check fails. - */ -public final class ServiceValidationException extends ServiceLocalException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * ServiceValidationException Constructor. - */ - public ServiceValidationException() { - super(); - } - - /** - * ServiceValidationException Constructor. - * - * @param message the message - */ - public ServiceValidationException(String message) { - super(message); - } - - /** - * Instantiates a new service validation exception. - * - * @param message the message - * @param innerException the inner exception - */ - public ServiceValidationException(String message, - Exception innerException) { - super(message, innerException); - - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceVersionException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceVersionException.java deleted file mode 100644 index 3a8d102d7..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceVersionException.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.local; - -/** - * Represents an error that occurs when a request cannot be handled due to a - * service version mismatch. - */ -public final class ServiceVersionException extends ServiceLocalException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Initializes a new instance of the class. - */ - public ServiceVersionException() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param message the message - */ - public ServiceVersionException(String message) { - super(message); - } - - /** - * Instantiates a new service version exception. - * - * @param message the message - * @param innerException the inner exception - */ - public ServiceVersionException(String message, Exception innerException) { - super(message, innerException); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceXmlDeserializationException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceXmlDeserializationException.java deleted file mode 100644 index 22b2a6430..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceXmlDeserializationException.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.local; - -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -/** - * Represents an error that occurs when the XML for a response cannot be - * deserialized. - */ -public final class ServiceXmlDeserializationException extends ServiceLocalException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * ServiceXmlDeserializationException Constructor. - */ - public ServiceXmlDeserializationException() { - super(); - } - - /** - * ServiceXmlDeserializationException Constructor. - * - * @param message the message - */ - public ServiceXmlDeserializationException(String message) { - super(message); - } - - /** - * ServiceXmlDeserializationException Constructor. - * - * @param message the message - * @param innerException the inner exception - */ - public ServiceXmlDeserializationException(String message, - Exception innerException) { - super(message, innerException); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceXmlSerializationException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceXmlSerializationException.java deleted file mode 100644 index c642d2209..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/ServiceXmlSerializationException.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.local; - -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -/** - * Represents an error that occurs when the XML for a request cannot be - * serialized. - */ -public class ServiceXmlSerializationException extends ServiceLocalException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * ServiceXmlSerializationException Constructor. - */ - public ServiceXmlSerializationException() { - super(); - } - - /** - * Instantiates a new service xml serialization exception. - * - * @param message the message - */ - public ServiceXmlSerializationException(String message) { - super(message); - - } - - /** - * Instantiates a new service xml serialization exception. - * - * @param message the message - * @param innerException the inner exception - */ - public ServiceXmlSerializationException(String message, - Exception innerException) { - super(message, innerException); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/TimeZoneConversionException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/TimeZoneConversionException.java deleted file mode 100644 index ea5459d14..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/local/TimeZoneConversionException.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.local; - -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -/** - * Represents an error that occurs when a date and time cannot be converted from - * one time zone to another. - */ -public class TimeZoneConversionException extends ServiceLocalException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * ServiceLocalException Constructor. - */ - public TimeZoneConversionException() { - super(); - } - - /** - * ServiceLocalException Constructor. - * - * @param message the message - */ - public TimeZoneConversionException(String message) { - super(message); - } - - /** - * ServiceLocalException Constructor. - * - * @param message the message - * @param innerException the inner exception - */ - public TimeZoneConversionException(String message, - Exception innerException) { - super(message, innerException); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/AccountIsLockedException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/AccountIsLockedException.java deleted file mode 100644 index 1edbf36dd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/AccountIsLockedException.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.remote; - -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRemoteException; - -import java.net.URI; - -/** - * Represents an error that occurs when the account that is - * being accessed is locked and requires user interaction to be unlocked. - */ -public class AccountIsLockedException extends ServiceRemoteException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - private URI accountUnlockUrl; - - - /** - * Initializes a new instance of the AccountIsLockedException class. - * - * @param message Error message text. - * @param accountUnlockUrl URL for client to visit to unlock account. - */ - public AccountIsLockedException(String message, URI accountUnlockUrl, - Exception innerException) { - - super(message, innerException); - this.setAccountUnlockUrl(accountUnlockUrl); - } - - /** - * Gets the URL of a web page where the user - * can navigate to unlock his or her account. - */ - public URI getAccountUnlockUrl() { - return accountUnlockUrl; - } - - - /** - * Sets the URL of a web page where the - * user can navigate to unlock his or her account. - */ - private void setAccountUnlockUrl(URI value) { - this.accountUnlockUrl = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/CreateAttachmentException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/CreateAttachmentException.java deleted file mode 100644 index 54755c10d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/CreateAttachmentException.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.remote; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.response.CreateAttachmentResponse; -import microsoft.exchange.webservices.data.core.response.ServiceResponseCollection; - -/** - * Represents an error that occurs when a call to the CreateAttachment web - * method fails. - */ -public final class CreateAttachmentException extends ServiceRemoteException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * The response. - */ - private ServiceResponseCollection responses; - - /** - * Initializes a new instance of CreateAttachmentException. - * - * @param serviceResponses the service response - * @param message the message - */ - public CreateAttachmentException(ServiceResponseCollection serviceResponses, - String message) { - super(message); - EwsUtilities.ewsAssert(serviceResponses != null, - "MultiServiceResponseException.ctor", "serviceResponses is null"); - - this.responses = serviceResponses; - } - - /** - * Initializes a new instance of CreateAttachmentException. - * - * @param serviceResponses the service response - * @param message the message - * @param innerException the inner exception - */ - protected CreateAttachmentException( - ServiceResponseCollection serviceResponses, - String message, Exception innerException) { - super(message, innerException); - EwsUtilities.ewsAssert(serviceResponses != null, - "MultiServiceResponseException.ctor", "serviceResponses is null"); - - this.responses = serviceResponses; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/DeleteAttachmentException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/DeleteAttachmentException.java deleted file mode 100644 index c640b85a1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/DeleteAttachmentException.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.remote; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.response.DeleteAttachmentResponse; -import microsoft.exchange.webservices.data.core.response.ServiceResponseCollection; - -/** - * Represents an error that occurs when a call to the DeleteAttachment web - * method fails. - */ -public final class DeleteAttachmentException extends ServiceRemoteException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * The response. - */ - private ServiceResponseCollection responses; - - /** - * Initializes a new instance of DeleteAttachmentException. - * - * @param serviceResponses The list of response to be associated with this exception. - * @param message The message that describes the error. - */ - public DeleteAttachmentException(ServiceResponseCollection serviceResponses, - String message) { - super(message); - EwsUtilities.ewsAssert(serviceResponses != null, - "MultiServiceResponseException.ctor", "serviceResponses is null"); - - this.responses = serviceResponses; - } - - /** - * Initializes a new instance of DeleteAttachmentException. - * - * @param serviceResponses The list of response to be associated with this exception. - * @param message The message that describes the error. - * @param innerException The exception that is the cause of the current exception. - */ - protected DeleteAttachmentException( - ServiceResponseCollection serviceResponses, - String message, Exception innerException) { - super(message, innerException); - EwsUtilities.ewsAssert(serviceResponses != null, - "MultiServiceResponseException.ctor", "serviceResponses is null"); - - this.responses = serviceResponses; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/ServiceRemoteException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/ServiceRemoteException.java deleted file mode 100644 index 975498fb5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/ServiceRemoteException.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.remote; - -/** - * Represents an error that occurs when a service operation fails remotely. - */ -public class ServiceRemoteException extends Exception { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * ServiceRemoteException Constructor. - */ - public ServiceRemoteException() { - super(); - } - - /** - * ServiceRemoteException Constructor. - * - * @param message the message - */ - public ServiceRemoteException(String message) { - super(message); - } - - /** - * ServiceRemoteException Constructor. - * - * @param message the message - * @param innerException the inner exception - */ - public ServiceRemoteException(String message, Exception innerException) { - super(message, innerException); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/ServiceRequestException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/ServiceRequestException.java deleted file mode 100644 index 78c21ae3b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/ServiceRequestException.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.remote; - -/** - * The Class ServiceRequestException. - */ -public class ServiceRequestException extends ServiceRemoteException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * ServiceRequestException Constructor. - */ - public ServiceRequestException() { - super(); - } - - /** - * ServiceRequestException Constructor. - * - * @param message the message - */ - public ServiceRequestException(String message) { - super(message); - } - - /** - * ServiceRequestException Constructor. - * - * @param message the message - * @param innerException the inner exception - */ - public ServiceRequestException(String message, Exception innerException) { - super(message, innerException); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/ServiceResponseException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/ServiceResponseException.java deleted file mode 100644 index 5d8616e56..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/ServiceResponseException.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.remote; - -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.error.ServiceError; - -/** - * Represents a remote service exception that has a single response. - */ -public class ServiceResponseException extends ServiceRemoteException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Error details Value keys. - */ - private static final String ExceptionClassKey = "ExceptionClass"; - - /** - * The Exception message key. - */ - private static final String ExceptionMessageKey = "ExceptionMessage"; - - /** - * The Stack trace key. - */ - private static final String StackTraceKey = "StackTrace"; - - /** - * ServiceResponse when service operation failed remotely. - */ - private ServiceResponse response; - - /** - * Initializes a new instance. - * - * @param response the response - */ - public ServiceResponseException(ServiceResponse response) { - this.response = response; - } - - /** - * Gets the ServiceResponse for the exception. - * - * @return the response - */ - public ServiceResponse getResponse() { - return response; - } - - /** - * Gets the service error code. - * - * @return the error code - */ - public ServiceError getErrorCode() { - return this.response.getErrorCode(); - } - - /** - * Gets a message that describes the current exception. - * - * @return The error message that explains the reason for the exception. - */ - - public String getMessage() { - - // Bug E14:134792 -- Special case for Internal Server Error. If the - // server returned - // stack trace information, include it in the exception message. - if (this.response.getErrorCode() == ServiceError.ErrorInternalServerError) { - String exceptionClass; - String exceptionMessage; - String stackTrace; - - if (this.response.getErrorDetails().containsKey(ExceptionClassKey) && - this.response.getErrorDetails().containsKey( - ExceptionMessageKey) && - this.response.getErrorDetails().containsKey( - StackTraceKey)) { - exceptionClass = this.response.getErrorDetails().get( - ExceptionClassKey); - exceptionMessage = this.response.getErrorDetails().get( - ExceptionMessageKey); - stackTrace = this.response.getErrorDetails().get(StackTraceKey); - - // return - return String.format("%s -- Server Error: %s: %s %s", this.response - .getErrorMessage(), exceptionClass, - exceptionMessage, stackTrace); - } - } - - return this.response.getErrorMessage(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/UpdateInboxRulesException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/UpdateInboxRulesException.java deleted file mode 100644 index 03313513a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/service/remote/UpdateInboxRulesException.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.service.remote; - -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.response.UpdateInboxRulesResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.error.ServiceError; -import microsoft.exchange.webservices.data.property.complex.RuleOperation; -import microsoft.exchange.webservices.data.property.complex.RuleOperationError; -import microsoft.exchange.webservices.data.property.complex.RuleOperationErrorCollection; - -/** - * Represents an exception thrown when an error occurs as a result of calling - * the UpdateInboxRules operation. - */ -public class UpdateInboxRulesException extends ServiceRemoteException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * ServiceResponse when service operation failed remotely. - */ - private ServiceResponse serviceResponse; - - /** - * Rule operation error collection. - */ - private RuleOperationErrorCollection errors; - - /** - * Initializes a new instance of the UpdateInboxRulesException class. - * - * @param serviceResponse The rule operation service response. - * @param ruleOperations The original operations. - */ - public UpdateInboxRulesException(UpdateInboxRulesResponse serviceResponse, - Iterable ruleOperations) { - super(); - this.serviceResponse = serviceResponse; - this.errors = serviceResponse.getErrors(); - for (RuleOperationError error : this.errors) { - error.setOperationByIndex(ruleOperations.iterator()); - } - } - - /** - * Gets the ServiceResponse for the exception. - */ - public ServiceResponse getServiceResponse() { - return this.serviceResponse; - } - - /** - * Gets the rule operation error collection. - */ - public RuleOperationErrorCollection getErrors() { - return this.errors; - } - - /** - * Gets the rule operation error code. - */ - public ServiceError getErrorCode() { - return this.serviceResponse.getErrorCode(); - } - - /** - * Gets the rule operation error message. - */ - public String getErrorMessage() { - return this.serviceResponse.getErrorMessage(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/xml/XmlDtdException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/xml/XmlDtdException.java deleted file mode 100644 index baa405c11..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/xml/XmlDtdException.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.xml; - -/** - * Exception class for banned xml parsing - */ -class XmlDtdException extends XmlException { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Gets the xml exception message. - */ - - @Override - public String getMessage() { - return "For security reasons DTD is prohibited in this XML document."; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/exception/xml/XmlException.java b/src/main/java/microsoft/exchange/webservices/data/core/exception/xml/XmlException.java deleted file mode 100644 index e6bd293b9..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/exception/xml/XmlException.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.exception.xml; - -public class XmlException extends Exception { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiates a new argument exception. - */ - public XmlException() { - super(); - - } - - /** - * Instantiates a new argument exception. - * - * @param arg0 the arg0 - */ - public XmlException(final String arg0) { - super(arg0); - - } - - /** - * ServiceXmlDeserializationException Constructor. - * - * @param message the message - * @param innerException the inner exception - */ - public XmlException(String message, Exception innerException) { - super(message, innerException); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/AddDelegateRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/AddDelegateRequest.java deleted file mode 100644 index fac5d8f3f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/AddDelegateRequest.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.DelegateManagementResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.MeetingRequestsDeliveryScope; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.DelegateUser; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents an AddDelegate request. - */ -public class AddDelegateRequest extends - DelegateManagementRequestBase { - - /** - * The delegate users. - */ - private List delegateUsers = new ArrayList(); - - /** - * The meeting request delivery scope. - */ - private MeetingRequestsDeliveryScope meetingRequestsDeliveryScope; - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception - */ - public AddDelegateRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Initializes a new instance of the class. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParamCollection(this.getDelegateUsers().iterator(), "DelegateUsers"); - for (DelegateUser delegateUser : this.getDelegateUsers()) { - delegateUser.validateUpdateDelegate(); - } - - if (this.meetingRequestsDeliveryScope != null) { - EwsUtilities.validateEnumVersionValue(this. - getMeetingRequestsDeliveryScope(), - this.getService().getRequestedServerVersion()); - } - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - super.writeElementsToXml(writer); - - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.DelegateUsers); - - for (DelegateUser delegateUser : this.getDelegateUsers()) { - delegateUser.writeToXml(writer, XmlElementNames.DelegateUser); - } - - writer.writeEndElement(); // DelegateUsers - - if (this.getMeetingRequestsDeliveryScope() != null) { - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.DeliverMeetingRequests, this - .getMeetingRequestsDeliveryScope()); - } - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.AddDelegate; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.AddDelegateResponse; - } - - /** - * Creates the response. - * - * @return Service response. - */ - @Override - protected DelegateManagementResponse createResponse() { - return new DelegateManagementResponse(true, this.delegateUsers); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the meeting request delivery scope. The meeting - * request delivery scope. - * - * @return the meeting request delivery scope - */ - public MeetingRequestsDeliveryScope getMeetingRequestsDeliveryScope() { - return this.meetingRequestsDeliveryScope; - } - - /** - * Sets the meeting request delivery scope. - * - * @param meetingRequestsDeliveryScope the new meeting request delivery scope - */ - public void setMeetingRequestsDeliveryScope( - MeetingRequestsDeliveryScope meetingRequestsDeliveryScope) { - this.meetingRequestsDeliveryScope = meetingRequestsDeliveryScope; - } - - /** - * Gets the delegate users. The delegate users. - * - * @return the delegate users - */ - public List getDelegateUsers() { - return this.delegateUsers; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/ByteArrayOSRequestEntity.java b/src/main/java/microsoft/exchange/webservices/data/core/request/ByteArrayOSRequestEntity.java deleted file mode 100644 index cd94d2824..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/ByteArrayOSRequestEntity.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import org.apache.http.Header; -import org.apache.http.entity.BasicHttpEntity; -import org.apache.http.message.BasicHeader; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -public class ByteArrayOSRequestEntity extends BasicHttpEntity { - - private ByteArrayOutputStream os = null; - - /** - * Constructor for ByteArrayOSRequestEntity. - */ - public ByteArrayOSRequestEntity(OutputStream os) { - super(); - this.os = (ByteArrayOutputStream) os; - } - - @Override - public long getContentLength() { - return os.size(); - } - - @Override - public Header getContentType() { - return new BasicHeader("Content-Type", "text/xml; charset=utf-8"); - } - - @Override - public boolean isRepeatable() { - return true; - } - - @Override - public void writeTo(OutputStream out) throws IOException { - os.writeTo(out); - } - - @Override - public boolean isStreaming() { - return false; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/ConvertIdRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/ConvertIdRequest.java deleted file mode 100644 index 17f45951f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/ConvertIdRequest.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ConvertIdResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.IdFormat; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.id.AlternateIdBase; - -import javax.xml.stream.XMLStreamException; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a ConvertId request. - */ -public final class ConvertIdRequest extends - MultiResponseServiceRequest { - - /** - * The destination format. - */ - private IdFormat destinationFormat = IdFormat.EwsId; - - /** - * The ids. - */ - private List ids = new ArrayList(); - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - public ConvertIdRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param responseIndex the response index - * @return the convert id response - */ - @Override - protected ConvertIdResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new ConvertIdResponse(); - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.ConvertIdResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.ConvertIdResponseMessage; - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.ids.size(); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.ConvertId; - } - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParamCollection(this.ids.iterator(), "Ids"); - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.DestinationFormat, - this.destinationFormat); - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.SourceIds); - for (AlternateIdBase alternateId : this.ids) { - alternateId.writeToXml(writer); - } - - writer.writeEndElement(); // SourceIds - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the destination format. - * - * @return the destination format - */ - public IdFormat getDestinationFormat() { - return this.destinationFormat; - } - - /** - * Sets the destination format. - * - * @param destinationFormat the new destination format - */ - public void setDestinationFormat(IdFormat destinationFormat) { - this.destinationFormat = destinationFormat; - } - - /** - * Gets the ids. - * - * @return the ids - */ - public List getIds() { - return this.ids; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/CopyFolderRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/CopyFolderRequest.java deleted file mode 100644 index 5218ef44e..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/CopyFolderRequest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.MoveCopyFolderResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Represents a CopyFolder request. - */ -public class CopyFolderRequest extends MoveCopyFolderRequest { - - /** - * Initializes a new instance of the CopyFolderRequest class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - public CopyFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Creates the service response. - * - * @param service The Service - * @param responseIndex Index of the response. - * @return Service response. - */ - @Override - protected MoveCopyFolderResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new MoveCopyFolderResponse(); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.CopyFolder; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.CopyFolderResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.CopyFolderResponseMessage; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/CopyItemRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/CopyItemRequest.java deleted file mode 100644 index 99c190b86..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/CopyItemRequest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.MoveCopyItemResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Represents a CopyItem request. - */ -public class CopyItemRequest extends MoveCopyItemRequest { - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - public CopyItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response. - */ - @Override - protected MoveCopyItemResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new MoveCopyItemResponse(); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.CopyItem; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.CopyItemResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name. - */ - protected String getResponseMessageXmlElementName() { - return XmlElementNames.CopyItemResponseMessage; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateAttachmentRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/CreateAttachmentRequest.java deleted file mode 100644 index 1994c97c0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateAttachmentRequest.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.CreateAttachmentResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.Attachment; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; - -import java.util.ArrayList; -import java.util.ListIterator; - -/** - * Represents a CreateAttachment request. - */ - -public final class CreateAttachmentRequest extends - MultiResponseServiceRequest { - - /** - * The parent item id. - */ - private String parentItemId; - - /** - * The attachments. - */ - private ArrayList attachments = new ArrayList(); - - /** - * Gets the attachments. - * - * @return attachments - */ - public ArrayList getAttachments() { - return attachments; - } - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - public CreateAttachmentRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validate request.. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.parentItemId, "ParentItemId"); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.attachments.size(); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.CreateAttachment; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.CreateAttachmentResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.CreateAttachmentResponseMessage; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets a value indicating whether the TimeZoneContext SOAP header should be - * emitted. - */ - protected boolean emitTimeZoneHeader() throws ServiceLocalException, Exception { - { - - ListIterator items = this.getAttachments() - .listIterator(); - - while (items.hasNext()) - - { - - ItemAttachment itemAttachment = (ItemAttachment) items.next(); - - if ((itemAttachment.getItem() != null) - && itemAttachment - .getItem() - .getIsTimeZoneHeaderRequired(false /* isUpdateOperation */)) { - return true; - } - } - - return false; - } - } - - /** - * Gets the parent item id. - * - * @return parentItemId - */ - public String getParentItemId() { - return parentItemId; - } - - /** - * Sets the parent item id. - * - * @param parentItemId the new parent item id - */ - public void setParentItemId(String parentItemId) { - this.parentItemId = parentItemId; - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.ParentItemId); - writer.writeAttributeValue(XmlAttributeNames.Id, this.parentItemId); - writer.writeEndElement(); - - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.Attachments); - for (Attachment attachment : this.attachments) { - attachment.writeToXml(writer, attachment.getXmlElementName()); - } - writer.writeEndElement(); - - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return the creates the attachment response - */ - @Override - protected CreateAttachmentResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new CreateAttachmentResponse( - this.attachments.get(responseIndex)); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateFolderRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/CreateFolderRequest.java deleted file mode 100644 index 8d066da53..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateFolderRequest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.CreateFolderResponse; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -import java.util.Collection; - -/** - * Represents a CreateFolder request. - */ -public final class CreateFolderRequest extends CreateRequest { - - /** - * Initializes a new instance of the CreateFolderRequest class. - * - * @param service The service - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - public CreateFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.getFolders(), "Folders"); - - // Validate each folder. - for (Folder folder : this.getFolders()) { - folder.validate(); - } - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex Index of the response. - * @return Service response. - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new CreateFolderResponse((Folder) EwsUtilities - .getEnumeratedObjectAt(this.getFolders(), responseIndex)); - } - - /** - * Gets the name of the XML element. - * - * @return Xml element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.CreateFolder; - } - - /** - * Gets the name of the response XML element. - * - * @return Xml element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.CreateFolderResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return Xml element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.CreateFolderResponseMessage; - } - - /** - * Gets the name of the parent folder XML element. - * - * @return Xml element name - */ - @Override - protected String getParentFolderXmlElementName() { - return XmlElementNames.ParentFolderId; - } - - /** - * Gets the name of the object collection XML element. - * - * @return Xml element name - */ - @Override - protected String getObjectCollectionXmlElementName() { - return XmlElementNames.Folders; - } - - /** - * Gets the request version. Earliest Exchange version in which this request - * is supported. - * - * @return the minimum required server version - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the folder. - * - * @return the folder - */ - public Iterable getFolders() { - return this.getObjects(); - } - - /** - * Sets the folder. - * - * @param folder the new folder - */ - public void setFolders(Iterable folder) { - this.setObjects((Collection) folder); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateItemRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/CreateItemRequest.java deleted file mode 100644 index 93773814d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateItemRequest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.CreateItemResponse; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -/** - * Represents a CreateItem request. - */ -public final class CreateItemRequest extends - CreateItemRequestBase { - - /** - * Initializes a new instance. - * - * @param service The service. - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - public CreateItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return the service response - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new CreateItemResponse((Item) EwsUtilities - .getEnumeratedObjectAt(this.getItems(), responseIndex)); - } - - /** - * Validate request.. - * - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - @Override - protected void validate() throws ServiceLocalException, Exception { - super.validate(); - // Iterable item = this.getItems(); - // Validate each item. - for (Item item : this.getItems()) { - item.validate(); - } - } - - /** - * Gets the request version. Returns earliest Exchange version in which - * this request is supported. - * - * @return the minimum required server version - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateItemRequestBase.java b/src/main/java/microsoft/exchange/webservices/data/core/request/CreateItemRequestBase.java deleted file mode 100644 index 52fcee289..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateItemRequestBase.java +++ /dev/null @@ -1,208 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition; -import microsoft.exchange.webservices.data.core.enumeration.service.SendInvitationsMode; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import java.util.Collection; - -/** - * Represents an abstract CreateItem request. - * - * @param The type of the service object. - * @param The type of the response. - */ -abstract class CreateItemRequestBase - extends CreateRequest { - - /** - * The message disposition. - */ - private MessageDisposition messageDisposition = null; - - /** - * The send invitations mode. - */ - private SendInvitationsMode sendInvitationsMode = null; - - /** - * Initializes a new instance. - * - * @param service The service. - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - protected CreateItemRequestBase(ExchangeService service, - ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validate the request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.getItems(), "Items"); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.CreateItem; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.CreateItemResponse; - } - - /** - * Gets the name of the response message XML element. XML element name. - * - * @return the response message xml element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.CreateItemResponseMessage; - } - - /** - * Gets the name of the parent folder XML element. - * - * @return XML element name. - */ - @Override - protected String getParentFolderXmlElementName() { - return XmlElementNames.SavedItemFolderId; - } - - /** - * Gets the name of the object collection XML element. - * - * @return XML element name. - */ - @Override - protected String getObjectCollectionXmlElementName() { - return XmlElementNames.Items; - } - - /** - * Writes the attribute to XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - if (this.messageDisposition != null) { - writer.writeAttributeValue(XmlAttributeNames.MessageDisposition, - this.getMessageDisposition()); - } - if (this.sendInvitationsMode != null) { - writer.writeAttributeValue( - XmlAttributeNames.SendMeetingInvitations, - this.sendInvitationsMode); - } - } - - /** - * Gets the message disposition. - * - * @return the message disposition - */ - public MessageDisposition getMessageDisposition() { - return messageDisposition; - } - - /** - * Sets the message disposition. - * - * @param value the new message disposition - */ - public void setMessageDisposition(MessageDisposition value) { - messageDisposition = value; - } - - /** - * Gets the send invitations mode. - * - * @return the send invitations mode - */ - public SendInvitationsMode getSendInvitationsMode() { - return sendInvitationsMode; - } - - /** - * Sets the send invitations mode. - * - * @param value the new send invitations mode - */ - public void setSendInvitationsMode(SendInvitationsMode value) { - sendInvitationsMode = value; - } - - /** - * Gets the item. - * - * @param value the new item - */ - public void setItems(Collection value) { - this.setObjects(value); - } - - /** - * Gets the item. - * - * @return the item - */ - public Iterable getItems() { - return this.getObjects(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/CreateRequest.java deleted file mode 100644 index a3601f1f3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateRequest.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -import java.util.Collection; - -/** - * Represents an abstract Create request. - * - * @param The type of the service object. - * @param The type of the response. - */ -abstract class CreateRequest - extends MultiResponseServiceRequest { - - /** - * The parent folder id. - */ - private FolderId parentFolderId; - - /** - * The objects. - */ - private Collection objects; - - /** - * Initializes a new instance. - * - * @param service The service. - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - protected CreateRequest(ExchangeService service, - ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validates the request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - if (this.getParentFolderId() != null) { - this.getParentFolderId().validate( - this.getService().getRequestedServerVersion()); - } - } - - /** - * Gets the expected response message count. - * - * @return the expected response message count - */ - @Override - protected int getExpectedResponseMessageCount() { - return EwsUtilities.getEnumeratedObjectCount(this.objects.iterator()); - } - - /** - * Gets the name of the parent folder XML element. - * - * @return The name of the parent folder XML element. - */ - protected abstract String getParentFolderXmlElementName(); - - /** - * Gets the name of the object collection XML element. - * - * @return The name of the object collection XML element. - */ - protected abstract String getObjectCollectionXmlElementName(); - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.ServiceRequestBase#writeElementsToXml( - * microsoft.exchange.webservices.EwsServiceXmlWriter) - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - if (this.parentFolderId != null) { - writer.writeStartElement(XmlNamespace.Messages, this - .getParentFolderXmlElementName()); - this.getParentFolderId().writeToXml(writer); - writer.writeEndElement(); - } - - writer.writeStartElement(XmlNamespace.Messages, this - .getObjectCollectionXmlElementName()); - if (null != this.objects) { - for (ServiceObject obj : this.objects) { - obj.writeToXml(writer); - } - } - writer.writeEndElement(); - - } - - /** - * Gets the service objects. - * - * @return Iterator - */ - protected Iterable getObjects() { - return this.objects; - } - - /** - * Sets the service objects. - * - * @param value Iterator - */ - protected void setObjects(Collection value) { - this.objects = value; - } - - /** - * Gets the parent folder id. - * - * @return FolderId. - */ - public FolderId getParentFolderId() { - return this.parentFolderId; - } - - /** - * Sets the parent folder id. - * - * @param value FolderId. - */ - public void setParentFolderId(FolderId value) { - this.parentFolderId = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateResponseObjectRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/CreateResponseObjectRequest.java deleted file mode 100644 index e3f06d803..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateResponseObjectRequest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.CreateResponseObjectResponse; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Represents a CreateItem request for a response object. - */ -public final class CreateResponseObjectRequest extends - CreateItemRequestBase { - - /** - * Initializes a new instance of the CreateResponseObjectRequest class. - * - * @param service The Service - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - public CreateResponseObjectRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service object. - */ - @Override - protected CreateResponseObjectResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new CreateResponseObjectResponse(); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateUserConfigurationRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/CreateUserConfigurationRequest.java deleted file mode 100644 index 7db2fcfaa..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/CreateUserConfigurationRequest.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.UserConfiguration; - -/** - * Represents a CreateUserConfiguration request. - */ -public class CreateUserConfigurationRequest extends - MultiResponseServiceRequest { - - /** - * The user configuration. - */ - protected UserConfiguration userConfiguration; - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.userConfiguration, "userConfiguration"); - } - - /** - * Creates the service response. - * - * @param service The service. - * @param responseIndex Index of the response. - * @return Service response. - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new ServiceResponse(); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010; - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name, - */ - @Override public String getXmlElementName() { - return XmlElementNames.CreateUserConfiguration; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name, - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.CreateUserConfigurationResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name, - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.CreateUserConfigurationResponseMessage; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - // Write UserConfiguation element - this.userConfiguration.writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.UserConfiguration); - } - - /** - * Initializes a new instance of the class. - * - * @param service The service. - * @throws Exception - */ - public CreateUserConfigurationRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - } - - /** - * Gets the user configuration. - * - * @return The userConfiguration. - */ - public UserConfiguration getUserConfiguration() { - return this.userConfiguration; - - } - - /** - * Sets the user configuration. - * - * @param value the new user configuration - */ - public void setUserConfiguration(UserConfiguration value) { - this.userConfiguration = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/DelegateManagementRequestBase.java b/src/main/java/microsoft/exchange/webservices/data/core/request/DelegateManagementRequestBase.java deleted file mode 100644 index 257493fa4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/DelegateManagementRequestBase.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.DelegateManagementResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.Mailbox; - -/** - * Represents an abstract delegate management request. - * - * @param The type of the response. - */ -abstract class DelegateManagementRequestBase - extends SimpleServiceRequestBase { - - /** - * The mailbox. - */ - private Mailbox mailbox; - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception - */ - protected DelegateManagementRequestBase(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Validate request. - * - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - @Override - protected void validate() throws ServiceLocalException, Exception { - super.validate(); - EwsUtilities.validateParam(this.getMailbox(), "Mailbox"); - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.getMailbox().writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.Mailbox); - } - - /** - * Creates the response. - * - * @return Response object. - */ - protected abstract TResponse createResponse(); - - /** - * {@inheritDoc} - */ - @Override - protected TResponse parseResponse(EwsServiceXmlReader reader) - throws Exception { - TResponse response = this.createResponse(); - response.loadFromXml(reader, this.getResponseXmlElementName()); - return response; - } - - /** - * Executes this request. - * - * @return Response object. - * @throws Exception the exception - */ - public TResponse execute() throws Exception { - TResponse serviceResponse = internalExecute(); - serviceResponse.throwIfNecessary(); - return serviceResponse; - } - - /** - * Gets the mailbox. The mailbox. - * - * @return the mailbox - */ - public Mailbox getMailbox() { - return this.mailbox; - } - - /** - * Sets the mailbox. - * - * @param mailbox the new mailbox - */ - public void setMailbox(Mailbox mailbox) { - this.mailbox = mailbox; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteAttachmentRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteAttachmentRequest.java deleted file mode 100644 index fe7e1cb5d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteAttachmentRequest.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -/** - * Represents a DeleteAttachment request. - */ -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.DeleteAttachmentResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.Attachment; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.ArrayList; -import java.util.List; - -/** - * The Class DeleteAttachmentRequest. - */ -public final class DeleteAttachmentRequest extends - MultiResponseServiceRequest { - - private static final Log LOG = LogFactory.getLog(DeleteAttachmentRequest.class); - - /** - * The attachments. - */ - private List attachments = new ArrayList(); - - /** - * Initializes a new instance of the DeleteAttachmentRequest class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - public DeleteAttachmentRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validate request. - */ - @Override - protected void validate() { - try { - super.validate(); - EwsUtilities.validateParamCollection(this.getAttachments().iterator(), "Attachments"); - for (int i = 0; i < this.attachments.size(); i++) { - EwsUtilities.validateParam(this.attachments.get(i).getId(), - String.format("Attachment[%d].Id ", i)); - } - } catch (ServiceLocalException e) { - LOG.error(e); - } catch (Exception e) { - LOG.error(e); - } - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service object. - */ - @Override - protected DeleteAttachmentResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new DeleteAttachmentResponse( - this.attachments.get(responseIndex)); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.attachments.size(); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.DeleteAttachment; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.DeleteAttachmentResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.DeleteAttachmentResponseMessage; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.AttachmentIds); - - for (Attachment attachment : this.attachments) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.AttachmentId); - writer - .writeAttributeValue(XmlAttributeNames.Id, attachment - .getId()); - writer.writeEndElement(); - } - - writer.writeEndElement(); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the attachments. - * - * @return the attachments - */ - public List getAttachments() { - return this.attachments; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteFolderRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteFolderRequest.java deleted file mode 100644 index 8aa137323..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteFolderRequest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.FolderIdWrapperList; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Represents a DeleteFolder request. - */ -public final class DeleteFolderRequest extends DeleteRequest { - private static final Log LOG = LogFactory.getLog(DeleteFolderRequest.class); - /** - * The folder ids. - */ - private FolderIdWrapperList folderIds = new FolderIdWrapperList(); - - /** - * Initializes a new instance of the DeleteFolderRequest class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - public DeleteFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.getFolderIds(), "FolderIds"); - this.getFolderIds().validate( - this.getService().getRequestedServerVersion()); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.getFolderIds().getCount(); - } - - /** - * Creates the service response. - * - * @param service The service. - * @param responseIndex Index of the response. - * @return Service object. - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new ServiceResponse(); - } - - /** - * Gets the name of the XML element. - * - * @return Xml element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.DeleteFolder; - } - - /** - * Gets the name of the response XML element. - * - * @return Xml element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.DeleteFolderResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return Xml element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.DeleteFolderResponseMessage; - } - - /** - * Writes XML elements. - * - * @param writer The writer - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) { - try { - this.getFolderIds().writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.FolderIds); - } catch (Exception e) { - LOG.error(e); - } - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the folder ids. - * - * @return The folder ids. - */ - public FolderIdWrapperList getFolderIds() { - return this.folderIds; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteItemRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteItemRequest.java deleted file mode 100644 index 0954247a8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteItemRequest.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.ItemIdWrapperList; - -/** - * Represents a DeleteItem request. - */ -public final class DeleteItemRequest extends DeleteRequest { - - /** - * The item ids. - */ - private ItemIdWrapperList itemIds = new ItemIdWrapperList(); - - /** - * The affected task occurrences. - */ - private AffectedTaskOccurrence affectedTaskOccurrences; - - /** - * The send cancellations mode. - */ - private SendCancellationsMode sendCancellationsMode; - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - public DeleteItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.itemIds, "ItemIds"); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.itemIds.getCount(); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response. - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new ServiceResponse(); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.DeleteItem; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.DeleteItemResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.DeleteItemResponseMessage; - } - - /** - * Writes XML attribute. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - - if (this.affectedTaskOccurrences != null) { - writer.writeAttributeValue( - XmlAttributeNames.AffectedTaskOccurrences, this - .getAffectedTaskOccurrences()); - } - - if (this.sendCancellationsMode != null) { - writer.writeAttributeValue( - XmlAttributeNames.SendMeetingCancellations, this - .getSendCancellationsMode()); - } - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.itemIds.writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.ItemIds); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the item ids. - * - * @return the item ids - */ - public ItemIdWrapperList getItemIds() { - return this.itemIds; - } - - /** - * Gets the affected task occurrences. - * - * @return the affected task occurrences - */ - AffectedTaskOccurrence getAffectedTaskOccurrences() { - return this.affectedTaskOccurrences; - } - - /** - * Sets the affected task occurrences. - * - * @param affectedTaskOccurrences the new affected task occurrences - */ - public void setAffectedTaskOccurrences(AffectedTaskOccurrence affectedTaskOccurrences) { - this.affectedTaskOccurrences = affectedTaskOccurrences; - } - - /** - * Gets the send cancellations. - * - * @return the send cancellations mode - */ - SendCancellationsMode getSendCancellationsMode() { - return this.sendCancellationsMode; - } - - /** - * Sets the send cancellations mode. - * - * @param sendCancellationsMode the new send cancellations mode - */ - public void setSendCancellationsMode(SendCancellationsMode sendCancellationsMode) { - this.sendCancellationsMode = sendCancellationsMode; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteRequest.java deleted file mode 100644 index 366edd9f8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteRequest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Represents an abstract Delete request. - * - * @param The type of the response. - */ -abstract class DeleteRequest extends - MultiResponseServiceRequest { - - private static final Log LOG = LogFactory.getLog(DeleteRequest.class); - - /** - * Delete mode. Default is SoftDelete. - */ - private DeleteMode deleteMode = DeleteMode.SoftDelete; - - /** - * Initializes a new instance of the DeleteRequest class. - * - * @param service The Servcie - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - protected DeleteRequest(ExchangeService service, - ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Writes XML attribute. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - - try { - writer.writeAttributeValue(XmlAttributeNames.DeleteType, this - .getDeleteMode()); - } catch (ServiceXmlSerializationException e) { - LOG.error(e); - } - } - - /** - * Gets the delete mode. - * - * @return the delete mode - */ - public DeleteMode getDeleteMode() { - return this.deleteMode; - } - - /** - * Gets the delete mode.e - * - * @param deleteMode the new delete mode - */ - public void setDeleteMode(DeleteMode deleteMode) { - this.deleteMode = deleteMode; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteUserConfigurationRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteUserConfigurationRequest.java deleted file mode 100644 index cc8b0d2d8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/DeleteUserConfigurationRequest.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.UserConfiguration; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -/** - * Represents a DeleteUserConfiguration request. - */ -public class DeleteUserConfigurationRequest extends - MultiResponseServiceRequest { - - /** - * The name. - */ - private String name; - - /** - * The parent folder id. - */ - private FolderId parentFolderId; - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.name, "name"); - EwsUtilities.validateParam(this.parentFolderId, "parentFolderId"); - this.getParentFolderId().validate( - this.getService().getRequestedServerVersion()); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response. - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new ServiceResponse(); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010; - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.DeleteUserConfiguration; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.DeleteUserConfigurationResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.DeleteUserConfigurationResponseMessage; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - // Write UserConfiguationName element - UserConfiguration - .writeUserConfigurationNameToXml(writer, XmlNamespace.Messages, this.name, this.parentFolderId); - } - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception on error - */ - public DeleteUserConfigurationRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - } - - /** - * Gets the name. - * - * @return the name - */ - protected String getName() { - return this.name; - } - - /** - * Sets the name. - * - * @param name the new name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Gets the parent folThe parent folder Id. - * - * @return the parent folder id - */ - protected FolderId getParentFolderId() { - return this.parentFolderId; - } - - /** - * Sets the parent folder id. - * - * @param parentFolderId the new parent folder id - */ - public void setParentFolderId(FolderId parentFolderId) { - this.parentFolderId = parentFolderId; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/DisconnectPhoneCallRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/DisconnectPhoneCallRequest.java deleted file mode 100644 index 4853c94c0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/DisconnectPhoneCallRequest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.messaging.PhoneCallId; - -/** - * Represents a DisconnectPhoneCall request. - */ -public final class DisconnectPhoneCallRequest extends SimpleServiceRequestBase { - - /** - * The id. - */ - private PhoneCallId id; - - /** - * Initializes a new instance of the DisconnectPhoneCallRequest class. - * - * @param service the service - * @throws Exception - */ - public DisconnectPhoneCallRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.DisconnectPhoneCall; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.id.writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.PhoneCallId); - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.DisconnectPhoneCallResponse; - } - - /** - * {@inheritDoc} - */ - @Override - protected ServiceResponse parseResponse(EwsServiceXmlReader reader) - throws Exception { - ServiceResponse serviceResponse = new ServiceResponse(); - serviceResponse.loadFromXml(reader, - XmlElementNames.DisconnectPhoneCallResponse); - return serviceResponse; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010; - } - - /** - * Executes this request. - * - * @return Service response. - * @throws Exception the exception - */ - public ServiceResponse execute() throws Exception { - ServiceResponse serviceResponse = internalExecute(); - serviceResponse.throwIfNecessary(); - return serviceResponse; - } - - /** - * Gets the Id of the phone call. - * - * @return the id - */ - protected PhoneCallId getId() { - return this.id; - } - - /** - * Sets the id. - * - * @param id the new id - */ - public void setId(PhoneCallId id) { - this.id = id; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/EmptyFolderRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/EmptyFolderRequest.java deleted file mode 100644 index 064107ea2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/EmptyFolderRequest.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.FolderIdWrapperList; - -/** - * Represents an EmptyFolder request. - */ -public final class EmptyFolderRequest extends DeleteRequest { - - private FolderIdWrapperList folderIds = new FolderIdWrapperList(); - private boolean deleteSubFolders; - - /** - * Initializes a new instance of the EmptyFolderRequest class. - * - * @param service The service. - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception on error - */ - public EmptyFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validates request. - * - * @throws Exception on error - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.getFolderIds(), "FolderIds"); - this.getFolderIds().validate(this.getService(). - getRequestedServerVersion()); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.getFolderIds().getCount(); - } - - /** - * Creates the service response. - * - * @param service The service. - * @param responseIndex Index of the response. - * @return Service object - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new ServiceResponse(); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.EmptyFolder; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.EmptyFolderResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.EmptyFolderResponseMessage; - } - - /** - * Writes XML elements. - * - * @param writer The writer. - * @throws Exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.getFolderIds().writeToXml( - writer, - XmlNamespace.Messages, - XmlElementNames.FolderIds); - } - - /** - * Writes XML attribute. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - writer.writeAttributeValue(XmlAttributeNames.DeleteSubFolders, - this.deleteSubFolders); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010_SP1; - } - - /** - * Gets the folder ids. - * - * @return The folder ids. - */ - public FolderIdWrapperList getFolderIds() { - return this.folderIds; - } - - /** - * Gets a value indicating whether empty folder should also delete sub folder. - * - * @value true if empty folder should also delete sub folder, otherwise false. - */ - protected boolean getDeleteSubFolders() { - return deleteSubFolders; - } - - /** - * Sets a value indicating whether empty folder should also delete sub folder. - * - * @value true if empty folder should also delete sub folder, otherwise false. - */ - public void setDeleteSubFolders(boolean value) { - this.deleteSubFolders = value; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/ExecuteDiagnosticMethodRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/ExecuteDiagnosticMethodRequest.java deleted file mode 100644 index 9304e5624..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/ExecuteDiagnosticMethodRequest.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ExecuteDiagnosticMethodResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import org.w3c.dom.Node; - -import javax.xml.stream.XMLStreamException; - -/** - * Defines the ExecuteDiagnosticMethodRequest class. - */ -public final class ExecuteDiagnosticMethodRequest extends - MultiResponseServiceRequest { - - private Node xmlNode; - private String verb; - - /** - * Initializes a new instance of the ExecuteDiagnosticMethodRequest class. - * - * @throws Exception - */ - public ExecuteDiagnosticMethodRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - } - - /** - * Gets the name of the XML element. - * - * @return XmlElementNames - */ - @Override public String getXmlElementName() { - return XmlElementNames.ExecuteDiagnosticMethod; - } - - /** - * Writes XML elements. - * - * @param writer The writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.Verb, this.getVerb()); - - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.Parameter); - writer.writeNode(this.getParameter()); - writer.writeEndElement(); - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.ExecuteDiagnosticMethodResponse; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - /** Set to 2007_SP1 because only test code - * will be using this method (it's marked internal. - * If it were marked for 2010_SP1, test cases - * would have to create new ExchangeService instances - * when using this method for tests running under older versions. - */ - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the verb of the method to execute. - */ - protected String getVerb() { - return verb; - } - - /** - * Sets the verb of the method to execute. - */ - public void setVerb(String value) { - this.verb = value; - } - - /** - * Gets the parameter to the executing method. - */ - protected Node getParameter() { - return xmlNode; - } - - /** - * Sets the parameter to the executing method. - */ - public void setParameter(Node value) { - this.xmlNode = value; - } - - /** - * Creates the service response. - * - * @param service The service - * @param responseIndex Index of the response - * @return Service response - */ - @Override - protected ExecuteDiagnosticMethodResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new ExecuteDiagnosticMethodResponse(service); - } - - /** - * Gets the name of the response message XML element. - * - * @return XmlElementNames - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.ExecuteDiagnosticMethodResponseMEssage; - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/ExpandGroupRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/ExpandGroupRequest.java deleted file mode 100644 index c761a8fd9..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/ExpandGroupRequest.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ExpandGroupResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; - -/** - * Represents an ExpandGroup request. - */ -public class ExpandGroupRequest extends - MultiResponseServiceRequest { - - /** - * The email address. - */ - private EmailAddress emailAddress; - - /** - * Represents an ExpandGroup request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.getEmailAddress(), "EmailAddress"); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response. - */ - @Override - protected ExpandGroupResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new ExpandGroupResponse(); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.ExpandDL; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.ExpandDLResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.ExpandDLResponseMessage; - } - - /** - * writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - if (this.getEmailAddress() != null) { - this.getEmailAddress().writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.Mailbox); - } - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception on error - */ - public ExpandGroupRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - } - - /** - * Gets the email address. - * - * @return the email address - */ - public EmailAddress getEmailAddress() { - return this.emailAddress; - } - - /** - * Sets the email address. - * - * @param emailAddress the new email address - */ - public void setEmailAddress(EmailAddress emailAddress) { - this.emailAddress = emailAddress; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/FindConversationRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/FindConversationRequest.java deleted file mode 100644 index 6f4db973a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/FindConversationRequest.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.FindConversationResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.FolderIdWrapper; -import microsoft.exchange.webservices.data.search.ConversationIndexedItemView; -import microsoft.exchange.webservices.data.search.filter.SearchFilter; - -/** - * Represents a request to a Find Conversation operation - */ -public final class FindConversationRequest extends SimpleServiceRequestBase { - - - private ConversationIndexedItemView view; - private SearchFilter.IsEqualTo searchFilter; - private FolderIdWrapper folderId; - - /** - * @throws Exception - */ - public FindConversationRequest(ExchangeService service) - throws Exception { - super(service); - } - - - /** - * Gets or sets the view controlling the number of conversations returned. - */ - protected ConversationIndexedItemView getIndexedItemView() { - return this.view; - } - - public void setIndexedItemView(ConversationIndexedItemView value) { - this.view = value; - } - - - - /** - * Gets or sets the search filter. - */ - protected SearchFilter.IsEqualTo getConversationViewFilter() { - - return this.searchFilter; - } - - public void setConversationViewFilter(SearchFilter.IsEqualTo value) { - this.searchFilter = value; - - } - - /** - * Gets or sets folder id - */ - protected FolderIdWrapper getFolderId() { - return this.folderId; - } - - public void setFolderId(FolderIdWrapper value) { - this.folderId = value; - } - - - /** - * Validate request. - * - * @throws Exception - * @throws ServiceLocalException - */ - @Override - protected void validate() throws ServiceLocalException, Exception { - super.validate(); - this.view.internalValidate(this); - } - - - /** - * Writes XML attribute. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - } - - - /** - * Writes XML attribute. - * - * @param writer The writer. - * @throws Exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.getIndexedItemView().writeToXml(writer); - - if (this.getConversationViewFilter() != null) { - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.Restriction); - this.getConversationViewFilter().writeToXml(writer); - writer.writeEndElement(); // Restriction - } - - this.getIndexedItemView().writeOrderByToXml(writer); - - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.ParentFolderId); - this.getFolderId().writeToXml(writer); - writer.writeEndElement(); - } - - /** - * {@inheritDoc} - */ - @Override - protected FindConversationResponse parseResponse(EwsServiceXmlReader reader) - throws Exception { - FindConversationResponse response = new FindConversationResponse(); - response.loadFromXml(reader, - XmlElementNames.FindConversationResponse); - return response; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.FindConversation; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.FindConversationResponse; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010_SP1; - } - - /** - * Executes this request. - * - * @return Service response. - * @throws Exception - * @throws ServiceLocalException - */ - public FindConversationResponse execute() - throws ServiceLocalException, Exception { - FindConversationResponse serviceResponse = internalExecute(); - serviceResponse.throwIfNecessary(); - return serviceResponse; - } -} - diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/FindFolderRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/FindFolderRequest.java deleted file mode 100644 index ed0300fae..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/FindFolderRequest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.FindFolderResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Represents a FindFolder request. - */ -public final class FindFolderRequest extends FindRequest { - - /** - * Initializes a new instance of the FindFolderRequest class. - * - * @param exchangeService The Service - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - public FindFolderRequest(ExchangeService exchangeService, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(exchangeService, errorHandlingMode); - } - - /** - * Creates the service response. - * - * @param service The service - * @param responseIndex Index of the response. Service response. - * @return the find folder response - */ - @Override - protected FindFolderResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new FindFolderResponse(this.getView().getPropertySetOrDefault()); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.FindFolder; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.FindFolderResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.FindFolderResponseMessage; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/FindItemRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/FindItemRequest.java deleted file mode 100644 index 7f9f0aa65..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/FindItemRequest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.FindItemResponse; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.search.Grouping; - -/** - * Represents a FindItem request. - * - * @param The type of the item. - */ -public final class FindItemRequest extends - FindRequest> { - - /** - * The group by. - */ - private Grouping groupBy; - - /** - * Initializes a new instance of the FindItemRequest class. - * - * @param service The Service - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - public FindItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Creates the service response. - * - * @param service The service - * @param responseIndex Index of the response. - * @return Service response. - */ - @Override - protected FindItemResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new FindItemResponse(this.getGroupBy() != null, this - .getView().getPropertySetOrDefault()); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.FindItem; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.FindItemResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.FindItemResponseMessage; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the group by. - * - * @return the group by - */ - public Grouping getGroupBy() { - return this.groupBy; - } - - /** - * Sets the group by. - * - * @param value the new group by - */ - public void setGroupBy(Grouping value) { - this.groupBy = value; - - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/FindRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/FindRequest.java deleted file mode 100644 index ff64b41ac..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/FindRequest.java +++ /dev/null @@ -1,250 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.FolderIdWrapperList; -import microsoft.exchange.webservices.data.search.Grouping; -import microsoft.exchange.webservices.data.search.ViewBase; -import microsoft.exchange.webservices.data.search.filter.SearchFilter; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Represents an abstract Find request. - * - * @param The type of the response. - */ -abstract class FindRequest extends - MultiResponseServiceRequest { - - private static final Log LOG = LogFactory.getLog(FindRequest.class); - - /** - * The parent folder ids. - */ - private FolderIdWrapperList parentFolderIds = new FolderIdWrapperList(); - - /** - * The search filter. - */ - private SearchFilter searchFilter; - - /** - * The query string. - */ - private String queryString; - - /** - * The view. - */ - private ViewBase view; - - /** - * Initializes a new instance of the FindRequest class. - * - * @param service The service. - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - protected FindRequest(ExchangeService service, - ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validate request. - * - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - @Override - protected void validate() throws ServiceLocalException, Exception { - super.validate(); - - this.getView().internalValidate(this); - - // query string parameter is only valid for Exchange2010 or higher - // - if (!(this.queryString == null || this.queryString.isEmpty()) - && this.getService().getRequestedServerVersion().ordinal() < - ExchangeVersion.Exchange2010.ordinal()) { - throw new ServiceVersionException(String.format( - "The parameter %s is only valid for Exchange Server version %s or a later version.", - "queryString", ExchangeVersion.Exchange2010)); - } - - if ((!(this.queryString == null || this.queryString.isEmpty())) - && this.searchFilter != null) { - throw new ServiceLocalException( - "Both search filter and query string can't be specified. One of them must be null."); - } - } - - /** - * Gets the expected response message count. - * - * @return XML element name. - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.getParentFolderIds().getCount(); - } - - /** - * Gets the group by clause. - * - * @return The group by clause, null if the request does not have or support - * grouping. - */ - protected Grouping getGroupBy() { - return null; - } - - /** - * Writes XML attribute. - * - * @param writer The Writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - - this.getView().writeAttributesToXml(writer); - } - - /** - * Writes XML elements. - * - * @param writer The Writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.getView().writeToXml(writer, this.getGroupBy()); - - if (this.getSearchFilter() != null) { - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.Restriction); - this.getSearchFilter().writeToXml(writer); - writer.writeEndElement(); // Restriction - } - - this.getView().writeOrderByToXml(writer); - - try { - this.getParentFolderIds().writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.ParentFolderIds); - } catch (Exception e) { - LOG.error(e); - } - - if (!(this.queryString == null || this.queryString.isEmpty())) { - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.QueryString, this.queryString); - } - } - - /** - * Gets the parent folder ids. - * - * @return the parent folder ids - */ - public FolderIdWrapperList getParentFolderIds() { - return this.parentFolderIds; - } - - /** - * Gets the search filter. Available search filter classes include - * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection. If SearchFilter is null, no search - * filter are applied. - * - * @return the search filter - */ - public SearchFilter getSearchFilter() { - return searchFilter; - } - - /** - * Sets the search filter. Available search filter classes include - * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection. If SearchFilter is null, no search - * filter are applied. - * - * @param searchFilter the new search filter - */ - public void setSearchFilter(SearchFilter searchFilter) { - this.searchFilter = searchFilter; - } - - /** - * Gets the query string for indexed search. - * - * @return the query string - */ - public String getQueryString() { - return queryString; - } - - /** - * Sets the query string for indexed search. - * - * @param queryString the new query string - */ - public void setQueryString(String queryString) { - this.queryString = queryString; - } - - /** - * Gets the view controlling the number of item or folder returned. - * - * @return the view - */ - public ViewBase getView() { - return view; - } - - /** - * Sets the view controlling the number of item or folder returned. - * - * @param view the new view - */ - public void setView(ViewBase view) { - this.view = view; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetAttachmentRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetAttachmentRequest.java deleted file mode 100644 index f48161587..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetAttachmentRequest.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.GetAttachmentResponse; -import microsoft.exchange.webservices.data.core.enumeration.property.BodyType; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.Attachment; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinitionBase; - -import javax.xml.stream.XMLStreamException; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a GetAttachment request. - */ -public final class GetAttachmentRequest extends - MultiResponseServiceRequest { - - /** - * The attachments. - */ - private List attachments = new ArrayList(); - - /** - * The additional property. - */ - private List additionalProperties = - new ArrayList(); - - /** - * The body type. - */ - private BodyType bodyType; - - /** - * Initializes a new instance of the GetAttachmentRequest class. - * - * @param service The service. - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - public GetAttachmentRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParamCollection(this.getAttachments().iterator(), "Attachments"); - for (int i = 0; i < this.getAdditionalProperties().size(); i++) { - EwsUtilities.validateParam(this.getAdditionalProperties().get(i), - String.format("AdditionalProperties[%d]", i)); - } - } - - /** - * Creates the service response. - * - * @param service The service. - * @param responseIndex Index of the response. - * @return Service response. - */ - @Override - protected GetAttachmentResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new GetAttachmentResponse(this.getAttachments().get( - responseIndex)); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.getAttachments().size(); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.GetAttachment; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetAttachmentResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.GetAttachmentResponseMessage; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - if ((this.getBodyType() != null) - || this.getAdditionalProperties().size() > 0) { - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.AttachmentShape); - - if (this.getBodyType() != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.BodyType, this.getBodyType()); - } - - if (this.getAdditionalProperties().size() > 0) { - PropertySet.writeAdditionalPropertiesToXml(writer, this.getAdditionalProperties().iterator()); - } - - writer.writeEndElement(); // AttachmentShape - } - - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.AttachmentIds); - - for (Attachment attachment : this.getAttachments()) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.AttachmentId); - writer - .writeAttributeValue(XmlAttributeNames.Id, attachment - .getId()); - writer.writeEndElement(); - } - - writer.writeEndElement(); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the attachments. - * - * @return the attachments - */ - public List getAttachments() { - return this.attachments; - } - - /** - * Gets the additional property. - * - * @return the additional property - */ - public List getAdditionalProperties() { - return this.additionalProperties; - } - - /** - * Gets the type of the body. - * - * @return the body type - */ - public BodyType getBodyType() { - - return this.bodyType; - - } - - /** - * Sets the body type. - * - * @param bodyType the new body type - */ - public void setBodyType(BodyType bodyType) { - this.bodyType = bodyType; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetDelegateRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetDelegateRequest.java deleted file mode 100644 index 8d1079147..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetDelegateRequest.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.GetDelegateResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.UserId; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a GetDelegate request. - */ -public class GetDelegateRequest extends - DelegateManagementRequestBase { - - /** - * The user ids. - */ - private List userIds = new ArrayList(); - - /** - * The include permissions. - */ - private boolean includePermissions; - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception - */ - public GetDelegateRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Creates the response. - * - * @return Service response. - */ - @Override - protected GetDelegateResponse createResponse() { - return new GetDelegateResponse(true); - } - - /** - * Writes XML attribute. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - writer.writeAttributeValue(XmlAttributeNames.IncludePermissions, this - .getIncludePermissions()); - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - super.writeElementsToXml(writer); - - if (this.getUserIds().size() > 0) { - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.UserIds); - - for (UserId userId : this.getUserIds()) { - userId.writeToXml(writer, XmlElementNames.UserId); - } - - writer.writeEndElement(); // UserIds - } - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetDelegateResponse; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.GetDelegate; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the user ids. The user ids. - * - * @return the user ids - */ - public List getUserIds() { - return this.userIds; - } - - /** - * Gets a value indicating whether permissions are included. - * - * @return the include permissions - */ - public boolean getIncludePermissions() { - return this.includePermissions; - - } - - /** - * Sets the include permissions. - * - * @param includePermissions the new include permissions - */ - public void setIncludePermissions(boolean includePermissions) { - this.includePermissions = includePermissions; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetEventsRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetEventsRequest.java deleted file mode 100644 index 83624b338..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetEventsRequest.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.GetEventsResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * GetEvents request. - */ -public class GetEventsRequest extends MultiResponseServiceRequest { - - /** - * The subscription id. - */ - private String subscriptionId; - - /** - * The watermark. - */ - private String watermark; - - /** - * Initializes a new instance. - * - * @param service the service - * @throws Exception - */ - public GetEventsRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response - */ - @Override - protected GetEventsResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new GetEventsResponse(); - } - - /** - * Gets the expected response message count. - * - * @return Response count - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.GetEvents; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetEventsResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.GetEventsResponseMessage; - } - - /** - * Validates the request. - * - * @throws Exception the exception - */ - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateNonBlankStringParam(this. - getSubscriptionId(), "SubscriptionId"); - EwsUtilities.validateNonBlankStringParam(this. - getWatermark(), "Watermark"); - } - - /** - * Writes the elements to XML writer. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.SubscriptionId, this.getSubscriptionId()); - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.Watermark, this.getWatermark()); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * gets the subscriptionId. - * - * @return the subscriptionId. - */ - public String getSubscriptionId() { - return subscriptionId; - } - - /** - * Sets the subscriptionId. - * - * @param subscriptionId the subscriptionId. - */ - public void setSubscriptionId(String subscriptionId) { - this.subscriptionId = subscriptionId; - } - - /** - * gets the watermark. - * - * @return the watermark. - */ - public String getWatermark() { - return watermark; - } - - /** - * Sets the watermark. - * - * @param watermark the new watermark - */ - public void setWatermark(String watermark) { - this.watermark = watermark; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetFolderRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetFolderRequest.java deleted file mode 100644 index 6cd911090..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetFolderRequest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.GetFolderResponse; - -/** - * Represents a GetFolder request. - */ -public final class GetFolderRequest extends GetFolderRequestBase { - - // private FolderIdWrapperList folderIds = new FolderIdWrapperList(); - - /** - * Initializes a new instance of the GetFolderRequest class. - * - * @param service the service - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - public GetFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Creates the service response. - * - * @param service The service - * @param responseIndex Index of the response. - * @return Service response. - */ - @Override - protected GetFolderResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new GetFolderResponse(this.getFolderIds() - .getFolderIdWrapperList(responseIndex).getFolder(), this - .getPropertySet()); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetFolderRequestBase.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetFolderRequestBase.java deleted file mode 100644 index e5a5940c4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetFolderRequestBase.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.FolderIdWrapperList; - -/** - * Represents an abstract GetFolder request. - * - * @param the generic type - */ -abstract class GetFolderRequestBase extends GetRequest { - - /** - * The folder ids. - */ - private FolderIdWrapperList folderIds = new FolderIdWrapperList(); - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - protected GetFolderRequestBase(ExchangeService service, - ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validate request. - * - * @throws Exception the exception - */ - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParamCollection(this.getFolderIds().iterator(), "FolderIds"); - this.getFolderIds().validate( - this.getService().getRequestedServerVersion()); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages - */ - protected int getExpectedResponseMessageCount() { - return this.getFolderIds().getCount(); - } - - /** - * Gets the type of the service object this request applies to. - * - * @return The type of service object the request applies to - */ - protected ServiceObjectType getServiceObjectType() { - return ServiceObjectType.Folder; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - super.writeElementsToXml(writer); - this.getFolderIds().writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.FolderIds); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - public String getXmlElementName() { - return XmlElementNames.GetFolder; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - protected String getResponseXmlElementName() { - return XmlElementNames.GetFolderResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - protected String getResponseMessageXmlElementName() { - return XmlElementNames.GetFolderResponseMessage; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported - */ - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the folder ids. - * - * @return the folder ids - */ - public FolderIdWrapperList getFolderIds() { - return this.folderIds; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetFolderRequestForLoad.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetFolderRequestForLoad.java deleted file mode 100644 index 19e958c24..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetFolderRequestForLoad.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.GetFolderResponse; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; - -/** - * Represents a GetFolder request specialized to return ServiceResponse. - */ -public final class GetFolderRequestForLoad extends - GetFolderRequestBase { - - /** - * Initializes a new instance of the GetFolderRequestForLoad class. - * - * @param exchangeService the exchange service - * @param throwonerror the throwonerror - * @throws Exception - */ - public GetFolderRequestForLoad(ExchangeService exchangeService, ServiceErrorHandling throwonerror) throws Exception { - super(exchangeService, throwonerror); - } - - /** - * Creates the service response. - * - * @param service The Service - * @param responseIndex the response index - * @return Service response. - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new GetFolderResponse(this.getFolderIds() - .getFolderIdWrapperList(responseIndex).getFolder(), this - .getPropertySet()); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetInboxRulesRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetInboxRulesRequest.java deleted file mode 100644 index 888b69604..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetInboxRulesRequest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.GetInboxRulesResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents a GetInboxRules request. - */ -public final class GetInboxRulesRequest extends SimpleServiceRequestBase { - - /** - * The smtp address of the mailbox from which to get the inbox rules. - */ - private String mailboxSmtpAddress; - - /** - * Initializes a new instance of the GetInboxRulesRequest class. - * - * @param service The service. - * @throws Exception - */ - public GetInboxRulesRequest(ExchangeService service) throws Exception { - super(service); - } - - /** - * Gets or sets the address of the mailbox - * from which to get the inbox rules. - * - * @return the mailboxSmtpAddress - */ - protected String getmailboxSmtpAddress() { - return this.mailboxSmtpAddress; - } - - /** - * sets the address of the mailbox from which to get the inbox rules. - */ - public void setmailboxSmtpAddress(String value) { - this.mailboxSmtpAddress = value; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.GetInboxRules; - } - - /** - * Writes XML elements. - * - * @param writer The writer. - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - if (!(this.mailboxSmtpAddress == null || - this.mailboxSmtpAddress.isEmpty())) { - writer.writeElementValue( - XmlNamespace.Messages, - XmlElementNames.MailboxSmtpAddress, - this.mailboxSmtpAddress); - } - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetInboxRulesResponse; - } - - /** - * {@inheritDoc} - */ - @Override - protected GetInboxRulesResponse parseResponse(EwsServiceXmlReader reader) - throws Exception { - GetInboxRulesResponse response = new GetInboxRulesResponse(); - response.loadFromXml(reader, XmlElementNames.GetInboxRulesResponse); - return response; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010_SP1; - } - - /** - * Executes this request. - * - * @return Service response. - * @throws Exception - * @throws ServiceLocalException - */ - public GetInboxRulesResponse execute() - throws ServiceLocalException, Exception { - GetInboxRulesResponse serviceResponse = internalExecute(); - serviceResponse.throwIfNecessary(); - return serviceResponse; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetItemRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetItemRequest.java deleted file mode 100644 index c453e4e67..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetItemRequest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.GetItemResponse; - -/** - * Represents an abstract GetItem request. - */ -public final class GetItemRequest extends GetItemRequestBase { - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - public GetItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response - */ - protected GetItemResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new GetItemResponse(this.getItemIds().getItemIdWrapperList( - responseIndex), this.getPropertySet()); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetItemRequestBase.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetItemRequestBase.java deleted file mode 100644 index 62b5e7c5f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetItemRequestBase.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.misc.ItemIdWrapperList; - -/** - * Represents an abstract GetItem request. - * - * @param the generic type - */ -abstract class GetItemRequestBase extends GetRequest { - - /** - * The item ids. - */ - private ItemIdWrapperList itemIds = new ItemIdWrapperList(); - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - protected GetItemRequestBase(ExchangeService service, - ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validate request. - * - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - protected void validate() throws ServiceLocalException, Exception { - super.validate(); - EwsUtilities.validateParamCollection(this.getItemIds().iterator(), "ItemIds"); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages - */ - protected int getExpectedResponseMessageCount() { - return this.itemIds.getCount(); - } - - /** - * Gets the type of the service object this request applies to. - * - * @return The type of service object the request applies to - */ - protected ServiceObjectType getServiceObjectType() { - return ServiceObjectType.Item; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - super.writeElementsToXml(writer); - - this.itemIds.writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.ItemIds); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - public String getXmlElementName() { - return XmlElementNames.GetItem; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - protected String getResponseXmlElementName() { - return XmlElementNames.GetItemResponse; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - protected String getResponseMessageXmlElementName() { - return XmlElementNames.GetItemResponseMessage; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported - */ - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the item ids. - * - * @return the item ids - */ - public ItemIdWrapperList getItemIds() { - return this.itemIds; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetItemRequestForLoad.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetItemRequestForLoad.java deleted file mode 100644 index 41226cfce..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetItemRequestForLoad.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.GetItemResponse; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; - -/** - * Represents a GetItem request specialized to return ServiceResponse. - */ -public final class GetItemRequestForLoad extends GetItemRequestBase { - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - public GetItemRequestForLoad(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response. - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new GetItemResponse(this.getItemIds().getItemIdWrapperList( - responseIndex), this.getPropertySet()); - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetPasswordExpirationDateRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetPasswordExpirationDateRequest.java deleted file mode 100644 index bee498e3d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetPasswordExpirationDateRequest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.GetPasswordExpirationDateResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -public final class GetPasswordExpirationDateRequest extends SimpleServiceRequestBase { - - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - // TODO Auto-generated method stub - return ExchangeVersion.Exchange2010_SP1; - } - - /** - * Initializes a new instance of the GetPasswordExpirationDateRequest class - * - * @throws Exception - */ - public GetPasswordExpirationDateRequest(ExchangeService service) throws Exception { - super(service); - } - - protected String getResponseXmlElementName() { - return XmlElementNames.GetPasswordExpirationDateResponse; - } - - /** - * Gets the name of the XML Element. - * returns XML element name - */ - public String getXmlElementName() { - return XmlElementNames.GetPasswordExpirationDateRequest; - } - - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) throws Exception { - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.MailboxSmtpAddress, - this.getMailboxSmtpAddress()); - } - - /** - * {@inheritDoc} - */ - @Override - protected GetPasswordExpirationDateResponse parseResponse(EwsServiceXmlReader reader) throws Exception { - GetPasswordExpirationDateResponse response = new GetPasswordExpirationDateResponse(); - response.loadFromXml(reader, XmlElementNames.GetPasswordExpirationDateResponse); - return response; - } - - /** - * Gets the request version - * @return Earliest Exchange version in which this request is supported. - *//* - protected ExchangeVersion getMinimumRequiredServerVersion(){ - return ExchangeVersion.Exchange2010_SP1; - }*/ - - /** - * Executes this request. - * - * @return Service response. - */ - public GetPasswordExpirationDateResponse execute() throws Exception { - GetPasswordExpirationDateResponse serviceResponse = internalExecute(); - serviceResponse.throwIfNecessary(); - return serviceResponse; - } - - /** - * Gets mailbox smtp address. - * - * @return The mailbox smtp address. - */ - protected String getMailboxSmtpAddress() { - return this.mailboxSmtpAddress; - } - - public void setMailboxSmtpAddress(String mailboxSmtpAddress) { - this.mailboxSmtpAddress = mailboxSmtpAddress; - } - - private String mailboxSmtpAddress; -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetPhoneCallRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetPhoneCallRequest.java deleted file mode 100644 index dca7e5c96..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetPhoneCallRequest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.GetPhoneCallResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.messaging.PhoneCallId; - -/** - * Represents a GetPhoneCall request. - */ -public final class GetPhoneCallRequest extends SimpleServiceRequestBase { - - /** - * The id. - */ - private PhoneCallId id; - - /** - * Initializes a new instance of the GetPhoneCallRequest class. - * - * @param service the service - * @throws Exception - */ - public GetPhoneCallRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.GetPhoneCall; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.id.writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.PhoneCallId); - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetPhoneCallResponse; - } - - /** - * {@inheritDoc} - */ - @Override - protected GetPhoneCallResponse parseResponse(EwsServiceXmlReader reader) - throws Exception { - GetPhoneCallResponse response = new GetPhoneCallResponse(getService()); - response.loadFromXml(reader, XmlElementNames.GetPhoneCallResponse); - return response; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010; - } - - /** - * Executes this request. - * - * @return Service response. - * @throws Exception the exception - */ - public GetPhoneCallResponse execute() throws Exception { - GetPhoneCallResponse serviceResponse = internalExecute(); - serviceResponse.throwIfNecessary(); - return serviceResponse; - } - - /** - * Gets the Id of the phone call. - * - * @return the id - */ - protected PhoneCallId getId() { - return id; - } - - /** - * Sets the id. - * - * @param id the new id - */ - public void setId(PhoneCallId id) { - this.id = id; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetRequest.java deleted file mode 100644 index 6b265d407..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetRequest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -/** - * Represents an abstract Get request. - * - * @param the generic type - * @param the generic type - */ -abstract class GetRequest - extends MultiResponseServiceRequest { - - /** - * The property set. - */ - private PropertySet propertySet; - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - protected GetRequest(ExchangeService service, - ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Validate request. - * - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - protected void validate() throws ServiceLocalException, Exception { - super.validate(); - EwsUtilities.validateParam(this.propertySet, "PropertySet"); - this.propertySet - .validateForRequest(this, false /* summaryPropertiesOnly */); - } - - /** - * Gets the type of the service object this request applies to. - * - * @return The type of service object the request applies to - */ - protected abstract ServiceObjectType getServiceObjectType(); - - /** - * Gets the type of the service object this request applies to. - * - * @param writer the writer - * @throws Exception - */ - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.propertySet.writeToXml(writer, this.getServiceObjectType()); - } - - /** - * Gets the property set. - * - * @return the property set - */ - public PropertySet getPropertySet() { - return this.propertySet; - } - - /** - * Sets the property set. - * - * @param propertySet the new property set - */ - public void setPropertySet(PropertySet propertySet) { - this.propertySet = propertySet; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetRoomListsRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetRoomListsRequest.java deleted file mode 100644 index 9c8c73112..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetRoomListsRequest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.GetRoomListsResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Represents a GetRoomList request. - */ -public final class GetRoomListsRequest extends SimpleServiceRequestBase { - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception - */ - public GetRoomListsRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.GetRoomListsRequest; - } - - /** - * Writes XML elements. - * - * @param writer the writer - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) { - // Don't have parameter in request - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetRoomListsResponse; - } - - /** - * {@inheritDoc} - */ - @Override - protected GetRoomListsResponse parseResponse(EwsServiceXmlReader reader) - throws Exception { - GetRoomListsResponse response = new GetRoomListsResponse(); - response.loadFromXml(reader, XmlElementNames.GetRoomListsResponse); - return response; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010; - } - - /** - * Executes this request. - * - * @return Service response - * @throws Exception the exception - */ - public GetRoomListsResponse execute() throws Exception { - GetRoomListsResponse serviceResponse = internalExecute(); - serviceResponse.throwIfNecessary(); - return serviceResponse; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetRoomsRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetRoomsRequest.java deleted file mode 100644 index e1f54fc03..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetRoomsRequest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.GetRoomsResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; - -/** - * Represents a GetRooms request. - */ -public final class GetRoomsRequest extends SimpleServiceRequestBase { - - /** - * Represents a GetRooms request. - * - * @param service the service - * @throws Exception - */ - public GetRoomsRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.GetRoomsRequest; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.getRoomList().writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.RoomList); - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetRoomsResponse; - } - - /** - * {@inheritDoc} - */ - @Override - protected GetRoomsResponse parseResponse(EwsServiceXmlReader reader) - throws Exception { - GetRoomsResponse response = new GetRoomsResponse(); - response.loadFromXml(reader, XmlElementNames.GetRoomsResponse); - return response; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010; - } - - /** - * Executes this request. - * - * @return Service response. - * @throws Exception the exception - */ - public GetRoomsResponse execute() throws Exception { - GetRoomsResponse serviceResponse = internalExecute(); - serviceResponse.throwIfNecessary(); - return serviceResponse; - } - - /** - * Gets the room list to retrieve rooms from. - * - * @return the room list - */ - protected EmailAddress getRoomList() { - return this.roomList; - } - - /** - * Sets the room list. - * - * @param value the new room list - */ - public void setRoomList(EmailAddress value) { - this.roomList = value; - } - - /** - * The room list. - */ - private EmailAddress roomList; - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetServerTimeZonesRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetServerTimeZonesRequest.java deleted file mode 100644 index 1f0101947..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetServerTimeZonesRequest.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.GetServerTimeZonesResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents a GetServerTimeZones request. - */ -public final class GetServerTimeZonesRequest extends - MultiResponseServiceRequest { - - /** - * The ids. - */ - private Iterable ids; - - /** - * Gets the XML element name associated with the transition. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - if (this.ids != null) { - EwsUtilities.validateParamCollection(this.getIds().iterator(), "Ids"); - } - } - - /** - * Initializes a new instance of the "GetServerTimeZonesRequest" class. - * - * @param service the service - * @throws Exception - */ - public GetServerTimeZonesRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response. - */ - @Override - protected GetServerTimeZonesResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new GetServerTimeZonesResponse(); - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name, - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.GetServerTimeZonesResponseMessage; - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name, - */ - @Override public String getXmlElementName() { - return XmlElementNames.GetServerTimeZones; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name, - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetServerTimeZonesResponse; - } - - /** - * Gets the minimum server version required to process this request. - * - * @return Exchange server version. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws XMLStreamException the XML stream exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - if (this.getIds() != null) { - writer - .writeStartElement(XmlNamespace.Messages, - XmlElementNames.Ids); - - for (String id : this.getIds()) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.Id, id); - } - - writer.writeEndElement(); // Ids - } - } - - /** - * Gets the ids of the time zones that should be returned by the - * server. - * - * @return the ids - */ - protected Iterable getIds() { - return this.ids; - } - - /** - * Sets the ids. - * - * @param ids the new ids - */ - protected void setIds(Iterable ids) { - this.ids = ids; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetStreamingEventsRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetStreamingEventsRequest.java deleted file mode 100644 index e5463f454..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetStreamingEventsRequest.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.GetStreamingEventsResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Defines the GetStreamingEventsRequest class. - */ -public class GetStreamingEventsRequest extends HangingServiceRequestBase { - - protected final static int HeartbeatFrequencyDefault = 45000; ////45s in ms - private static int heartbeatFrequency = HeartbeatFrequencyDefault; - - private Iterable subscriptionIds; - private int connectionTimeout; - - /** - * Initializes a new instance of the GetStreamingEventsRequest class. - * - * @param service The service - * @param serviceObjectHandler The serviceObjectHandler - * @param subscriptionIds The subscriptionIds - * @param connectionTimeout The connectionTimeout - * @throws ServiceVersionException - */ - public GetStreamingEventsRequest(ExchangeService service, IHandleResponseObject serviceObjectHandler, - Iterable subscriptionIds, int connectionTimeout) - throws ServiceVersionException { - super(service, serviceObjectHandler, - GetStreamingEventsRequest.heartbeatFrequency); - this.subscriptionIds = subscriptionIds; - this.connectionTimeout = connectionTimeout; - } - - /** - * Gets the name of the XML element. - * - * @return XmlElementNames - */ - @Override public String getXmlElementName() { - return XmlElementNames.GetStreamingEvents; - } - - /** - * Gets the name of the response XML element. - * - * @return XmlElementNames - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetStreamingEventsResponse; - } - - /** - * Writes the elements to XML writer. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.SubscriptionIds); - - for (String id : this.subscriptionIds) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.SubscriptionId, - id); - } - - writer.writeEndElement(); - - writer.writeElementValue( - XmlNamespace.Messages, - XmlElementNames.ConnectionTimeout, - this.connectionTimeout); - } - - /** - * Gets the request version. - * - * @return ExchangeVersion - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010_SP1; - } - - /** - * {@inheritDoc} - */ - @Override - protected GetStreamingEventsResponse parseResponse(EwsServiceXmlReader reader) - throws Exception { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.ResponseMessages); - - GetStreamingEventsResponse response = - new GetStreamingEventsResponse(this); - response.loadFromXml(reader, XmlElementNames. - GetStreamingEventsResponseMessage); - - reader.readEndElementIfNecessary(XmlNamespace.Messages, - XmlElementNames.ResponseMessages); - - return response; - } - - /** - * region Test hooks - * Allow test code to change heartbeat value - */ - protected static void setHeartbeatFrequency(int heartbeatFrequency) { - GetStreamingEventsRequest.heartbeatFrequency = heartbeatFrequency; - } - - @Override - protected HttpWebRequest buildEwsHttpWebRequest() throws Exception - { - return super.buildEwsHttpPoolingWebRequest(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetUserAvailabilityRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetUserAvailabilityRequest.java deleted file mode 100644 index 5bf34b152..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetUserAvailabilityRequest.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.AttendeeAvailability; -import microsoft.exchange.webservices.data.core.response.ServiceResponseCollection; -import microsoft.exchange.webservices.data.core.response.SuggestionsResponse; -import microsoft.exchange.webservices.data.core.enumeration.availability.AvailabilityData; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.error.ServiceError; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.availability.AttendeeInfo; -import microsoft.exchange.webservices.data.misc.availability.AvailabilityOptions; -import microsoft.exchange.webservices.data.misc.availability.GetUserAvailabilityResults; -import microsoft.exchange.webservices.data.misc.availability.LegacyAvailabilityTimeZone; -import microsoft.exchange.webservices.data.misc.availability.TimeWindow; - -/** - * Represents a GetUserAvailability request. - */ -public final class GetUserAvailabilityRequest extends SimpleServiceRequestBase { - - /** - * The attendees. - */ - private Iterable attendees; - - /** - * The time window. - */ - private TimeWindow timeWindow; - - /** - * The requested data. - */ - private AvailabilityData requestedData = - AvailabilityData.FreeBusyAndSuggestions; - - /** - * The options. - */ - private AvailabilityOptions options; - - /** - * Initializes a new instance of the "GetUserAvailabilityRequest" class. - * - * @param service the service - * @throws Exception - */ - public GetUserAvailabilityRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.GetUserAvailabilityRequest; - } - - /** - * Gets a value indicating whether free/busy data is requested. - * - * @return true, if is free busy view requested - */ - public boolean isFreeBusyViewRequested() { - return this.requestedData == AvailabilityData.FreeBusy || - this.requestedData == AvailabilityData. - FreeBusyAndSuggestions; - } - - /** - * Gets a value indicating whether suggestions are requested. - * - * @return true, if is suggestions view requested - */ - public boolean isSuggestionsViewRequested() { - return this.requestedData == AvailabilityData.Suggestions || - this.requestedData == AvailabilityData. - FreeBusyAndSuggestions; - } - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - - this.options.validate(this.timeWindow.getDuration()); - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - // Only serialize the TimeZone property against an Exchange 2007 SP1 - // server. - // Against Exchange 2010, the time zone is emitted in the request's SOAP - // header. - //if (writer.getService().getRequestedServerVersion() == - //ExchangeVersion.Exchange2007_SP1) { - LegacyAvailabilityTimeZone legacyTimeZone = - new LegacyAvailabilityTimeZone(); - - legacyTimeZone.writeToXml(writer, XmlElementNames.TimeZone); - - - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.MailboxDataArray); - - for (AttendeeInfo attendee : this.attendees) { - attendee.writeToXml(writer); - } - - writer.writeEndElement(); // MailboxDataArray - - this.options.writeToXml(writer, this); - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetUserAvailabilityResponse; - } - - /** - * {@inheritDoc} - */ - @Override - protected GetUserAvailabilityResults parseResponse(EwsServiceXmlReader reader) - throws Exception { - GetUserAvailabilityResults serviceResponse = - new GetUserAvailabilityResults(); - - if (this.isFreeBusyViewRequested()) { - serviceResponse - .setAttendeesAvailability(new ServiceResponseCollection()); - - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.FreeBusyResponseArray); - - do { - reader.read(); - - if (reader.isStartElement(XmlNamespace.Messages, - XmlElementNames.FreeBusyResponse)) { - AttendeeAvailability freeBusyResponse = - new AttendeeAvailability(); - - freeBusyResponse.loadFromXml(reader, - XmlElementNames.ResponseMessage); - - if (freeBusyResponse.getErrorCode().equals( - ServiceError.NoError)) { - freeBusyResponse.loadFreeBusyViewFromXml(reader, - this.options.getRequestedFreeBusyView()); - } - - serviceResponse.getAttendeesAvailability().add( - freeBusyResponse); - } - } while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.FreeBusyResponseArray)); - } - - if (this.isSuggestionsViewRequested()) { - serviceResponse.setSuggestionsResponse(new SuggestionsResponse()); - - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.SuggestionsResponse); - - serviceResponse.getSuggestionsResponse().loadFromXml(reader, - XmlElementNames.ResponseMessage); - - if (serviceResponse.getSuggestionsResponse().getErrorCode().equals( - ServiceError.NoError)) { - serviceResponse.getSuggestionsResponse() - .loadSuggestedDaysFromXml(reader); - } - - reader.readEndElement(XmlNamespace.Messages, - XmlElementNames.SuggestionsResponse); - } - - return serviceResponse; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Executes this request. - * - * @return Service response. - * @throws Exception the exception - */ - public GetUserAvailabilityResults execute() throws Exception { - return internalExecute(); - } - - /** - * Gets the attendees. - * - * @return the attendees - */ - public Iterable getAttendees() { - return attendees; - } - - /** - * Sets the attendees. - * - * @param attendees the new attendees - */ - public void setAttendees(Iterable attendees) { - this.attendees = attendees; - } - - /** - * Gets the time window in which to retrieve user availability - * information. - * - * @return the time window - */ - public TimeWindow getTimeWindow() { - return timeWindow; - } - - /** - * Sets the time window. - * - * @param timeWindow the new time window - */ - public void setTimeWindow(TimeWindow timeWindow) { - this.timeWindow = timeWindow; - } - - /** - * Gets a value indicating what data is requested (free/busy and/or - * suggestions). - * - * @return the requested data - */ - public AvailabilityData getRequestedData() { - return requestedData; - } - - /** - * Sets the requested data. - * - * @param requestedData the new requested data - */ - public void setRequestedData(AvailabilityData requestedData) { - this.requestedData = requestedData; - } - - /** - * Gets an object that allows you to specify options controlling the - * information returned by the GetUserAvailability request. - * - * @return the options - */ - public AvailabilityOptions getOptions() { - return options; - } - - /** - * Sets the options. - * - * @param options the new options - */ - public void setOptions(AvailabilityOptions options) { - this.options = options; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetUserConfigurationRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetUserConfigurationRequest.java deleted file mode 100644 index cc983b332..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetUserConfigurationRequest.java +++ /dev/null @@ -1,263 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.GetUserConfigurationResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.UserConfigurationProperties; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.misc.UserConfiguration; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -import java.util.EnumSet; - -/** - * The Class GetUserConfigurationRequest. - */ -public class GetUserConfigurationRequest extends - MultiResponseServiceRequest { - - /** - * The name. - */ - private String name; - - /** - * The parent folder id. - */ - private FolderId parentFolderId; - - /** - * The property. - */ - private EnumSet properties; - - /** - * The user configuration. - */ - private UserConfiguration userConfiguration; - - /** - * Validate request. - * - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - @Override - protected void validate() throws ServiceLocalException, Exception { - super.validate(); - - EwsUtilities.validateParam(this.name, "name"); - EwsUtilities.validateParam(this.parentFolderId, "parentFolderId"); - this.getParentFolderId().validate( - this.getService().getRequestedServerVersion()); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response. - * @throws Exception the exception - */ - @Override - protected GetUserConfigurationResponse createServiceResponse( - ExchangeService service, int responseIndex) throws Exception { - // In the case of UserConfiguration.Load(), this.userConfiguration is - // set. - if (this.userConfiguration == null) { - this.userConfiguration = new UserConfiguration(service, - this.properties); - this.userConfiguration.setName(this.name); - this.userConfiguration.setParentFolderId(this.parentFolderId); - } - - return new GetUserConfigurationResponse(this.userConfiguration); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010; - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.GetUserConfiguration; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetUserConfigurationResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.GetUserConfigurationResponseMessage; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - final String EnumDelimiter = ","; - - // Write UserConfiguationName element - UserConfiguration.writeUserConfigurationNameToXml(writer, - XmlNamespace.Messages, this.name, this.parentFolderId); - - // Write UserConfigurationProperties element - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.UserConfigurationProperties, this.properties - .toString().replace(EnumDelimiter, ""). - replace("[", "").replace("]", "")); - } - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception - */ - public GetUserConfigurationRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - } - - /** - * Gets the name. The name. - * - * @return the name - */ - protected String getName() { - return this.name; - } - - /** - * Sets the name. - * - * @param name the new name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Gets the parent folder Id. The parent folder Id. - * - * @return the parent folder id - */ - protected FolderId getParentFolderId() { - return this.parentFolderId; - } - - /** - * Sets the parent folder id. - * - * @param parentFolderId the new parent folder id - */ - public void setParentFolderId(FolderId parentFolderId) { - this.parentFolderId = parentFolderId; - } - - /** - * Gets the user configuration. The user - * configuration. - * - * @return the user configuration - */ - protected UserConfiguration getUserConfiguration() { - return this.userConfiguration; - } - - /** - * Sets the user configuration. - * - * @param userConfiguration the new user configuration - */ - public void setUserConfiguration(UserConfiguration userConfiguration) { - this.userConfiguration = userConfiguration; - this.name = this.userConfiguration.getName(); - this.parentFolderId = this.userConfiguration.getParentFolderId(); - } - - /** - * Gets the property. - * - * @return the property - */ - protected EnumSet getProperties() { - return this.properties; - } - - /** - * Sets the property. - * - * @param properties the new property - */ - public void setProperties(EnumSet properties) { - this.properties = properties; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/GetUserOofSettingsRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/GetUserOofSettingsRequest.java deleted file mode 100644 index f882be6bb..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/GetUserOofSettingsRequest.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.GetUserOofSettingsResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.OofExternalAudience; -import microsoft.exchange.webservices.data.core.enumeration.misc.error.ServiceError; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.availability.OofSettings; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents a GetUserOofSettings request. - */ -public final class GetUserOofSettingsRequest extends SimpleServiceRequestBase { - - /** - * The smtp address. - */ - private String smtpAddress; - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.GetUserOofSettingsRequest; - } - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - - EwsUtilities.validateParam(this.getSmtpAddress(), "SmtpAddress"); - } - - /** - * Validate request. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Mailbox); - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Address, - this.getSmtpAddress()); - writer.writeEndElement(); // Mailbox - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.GetUserOofSettingsResponse; - } - - /** - * {@inheritDoc} - */ - @Override - protected GetUserOofSettingsResponse parseResponse(EwsServiceXmlReader reader) - throws Exception { - GetUserOofSettingsResponse serviceResponse = - new GetUserOofSettingsResponse(); - - serviceResponse.loadFromXml(reader, XmlElementNames.ResponseMessage); - if (serviceResponse.getErrorCode() == ServiceError.NoError) { - reader.readStartElement(XmlNamespace.Types, - XmlElementNames.OofSettings); - - serviceResponse.setOofSettings(new OofSettings()); - serviceResponse.getOofSettings().loadFromXml(reader, - reader.getLocalName()); - - serviceResponse.getOofSettings().setAllowExternalOof( - reader.readElementValue(OofExternalAudience.class, - XmlNamespace.Messages, - XmlElementNames.AllowExternalOof)); - } - - return serviceResponse; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception - */ - public GetUserOofSettingsRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Executes this request. - * - * @return Service response. - * @throws Exception the exception - */ - public GetUserOofSettingsResponse execute() throws Exception { - GetUserOofSettingsResponse serviceResponse = internalExecute(); - serviceResponse.throwIfNecessary(); - return serviceResponse; - } - - /** - * Gets the SMTP address. - * - * @return the smtp address - */ - protected String getSmtpAddress() { - return this.smtpAddress; - } - - /** - * Sets the smtp address. - * - * @param smtpAddress the new smtp address - */ - public void setSmtpAddress(String smtpAddress) { - this.smtpAddress = smtpAddress; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/HangingRequestDisconnectEventArgs.java b/src/main/java/microsoft/exchange/webservices/data/core/request/HangingRequestDisconnectEventArgs.java deleted file mode 100644 index 2849c6293..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/HangingRequestDisconnectEventArgs.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.enumeration.misc.HangingRequestDisconnectReason; - -/** - * Represents a collection of arguments for the - * HangingServiceRequestBase.HangingRequestDisconnectHandler - * delegate method. - */ -public final class HangingRequestDisconnectEventArgs { - - /** - * Initializes a new instance of the - * HangingRequestDisconnectEventArgs class. - * - * @param reason The reason. - * @param exception The exception. - */ - public HangingRequestDisconnectEventArgs(HangingRequestDisconnectReason reason, Exception exception) { - this.reason = reason; - this.exception = exception; - } - - private HangingRequestDisconnectReason reason; - - /** - * Gets the reason that the user was disconnected. - * - * @return reason The reason. - */ - public HangingRequestDisconnectReason getReason() { - return reason; - } - - /** - * Sets the reason that the user was disconnected. - * - * @param value The reason. - */ - protected void setReason(HangingRequestDisconnectReason value) { - reason = value; - } - - private Exception exception; - - /** - * Gets the exception that caused the disconnection. Can be null. - * - * @return exception The Exception. - */ - public Exception getException() { - return exception; - } - - /** - * Sets the exception that caused the disconnection. Can be null. - * - * @param value The Exception. - */ - protected void setException(Exception value) { - exception = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/HangingServiceRequestBase.java b/src/main/java/microsoft/exchange/webservices/data/core/request/HangingServiceRequestBase.java deleted file mode 100644 index 04db10e43..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/HangingServiceRequestBase.java +++ /dev/null @@ -1,358 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceMultiResponseXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.enumeration.misc.HangingRequestDisconnectReason; -import microsoft.exchange.webservices.data.core.enumeration.misc.TraceFlags; -import microsoft.exchange.webservices.data.core.exception.http.EWSHttpException; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException; -import microsoft.exchange.webservices.data.core.exception.xml.XmlException; -import microsoft.exchange.webservices.data.misc.HangingTraceStream; -import microsoft.exchange.webservices.data.security.XmlNodeType; -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.xml.stream.XMLStreamException; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectStreamException; -import java.net.SocketTimeoutException; -import java.net.UnknownServiceException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - - -/** - * Represents an abstract, hanging service request. - */ -public abstract class HangingServiceRequestBase extends ServiceRequestBase { - - private static final Log LOG = LogFactory.getLog(HangingServiceRequestBase.class); - - - public interface IHandleResponseObject { - - /** - * Callback delegate to handle asynchronous response. - * - * @param response Response received from the server - * @throws ArgumentException - */ - void handleResponseObject(Object response) throws ArgumentException; - } - - - public static final int BUFFER_SIZE = 4096; - - /** - * Test switch to log all bytes that come across the wire. - * Helpful when parsing fails before certain bytes hit the trace logs. - */ - private static volatile boolean logAllWireBytes = false; - - /** - * Callback delegate to handle response objects - */ - private IHandleResponseObject responseHandler; - - /** - * Response from the server. - */ - private HttpWebRequest response; - - /** - * Expected minimum frequency in response, in milliseconds. - */ - protected int heartbeatFrequencyMilliseconds; - - - public interface IHangingRequestDisconnectHandler { - - /** - * Delegate method to handle a hanging request disconnection. - * - * @param sender the object invoking the delegate - * @param args event data - */ - void hangingRequestDisconnectHandler(Object sender, - HangingRequestDisconnectEventArgs args); - - } - - - public static boolean isLogAllWireBytes() { - return logAllWireBytes; - } - - public static void setLogAllWireBytes(final boolean logAllWireBytes) { - HangingServiceRequestBase.logAllWireBytes = logAllWireBytes; - } - - /** - * Disconnect events Occur when the hanging request is disconnected. - */ - private List onDisconnectList = - new ArrayList(); - - /** - * Set event to happen when property disconnect. - * - * @param disconnect disconnect event - */ - public void addOnDisconnectEvent(IHangingRequestDisconnectHandler disconnect) { - onDisconnectList.add(disconnect); - } - - /** - * Remove the event from happening when property disconnect. - * - * @param disconnect disconnect event - */ - protected void removeDisconnectEvent( - IHangingRequestDisconnectHandler disconnect) { - onDisconnectList.remove(disconnect); - } - - /** - * Clears disconnect events list. - */ - protected void clearDisconnectEvents() { - onDisconnectList.clear(); - } - - /** - * Initializes a new instance of the HangingServiceRequestBase class. - * - * @param service The service. - * @param handler Callback delegate to handle response objects - * @param heartbeatFrequency Frequency at which we expect heartbeats, in milliseconds. - */ - protected HangingServiceRequestBase(ExchangeService service, - IHandleResponseObject handler, int heartbeatFrequency) - throws ServiceVersionException { - super(service); - this.responseHandler = handler; - this.heartbeatFrequencyMilliseconds = heartbeatFrequency; - } - - /** - * Exectures the request. - */ - public void internalExecute() throws Exception { - synchronized (this) { - this.response = this.validateAndEmitRequest(); - this.internalOnConnect(); - } - } - - /** - * Parses the response. - * - */ - private void parseResponses() { - HangingTraceStream tracingStream = null; - ByteArrayOutputStream responseCopy = null; - - - try { - boolean traceEWSResponse = this.getService().isTraceEnabledFor(TraceFlags.EwsResponse); - InputStream responseStream = this.response.getInputStream(); - tracingStream = new HangingTraceStream(responseStream, - this.getService()); - //EWSServiceMultiResponseXmlReader. Create causes a read. - - if (traceEWSResponse) { - responseCopy = new ByteArrayOutputStream(); - tracingStream.setResponseCopy(responseCopy); - } - - while (this.isConnected()) { - T responseObject; - if (traceEWSResponse) { - EwsServiceMultiResponseXmlReader ewsXmlReader = - EwsServiceMultiResponseXmlReader.create(tracingStream, getService()); - responseObject = this.readResponse(ewsXmlReader); - this.responseHandler.handleResponseObject(responseObject); - - // reset the stream collector. - responseCopy.close(); - responseCopy = new ByteArrayOutputStream(); - tracingStream.setResponseCopy(responseCopy); - - } else { - EwsServiceMultiResponseXmlReader ewsXmlReader = - EwsServiceMultiResponseXmlReader.create(tracingStream, getService()); - responseObject = this.readResponse(ewsXmlReader); - this.responseHandler.handleResponseObject(responseObject); - } - } - } catch (SocketTimeoutException ex) { - // The connection timed out. - this.disconnect(HangingRequestDisconnectReason.Timeout, ex); - } catch (UnknownServiceException ex) { - // Stream is closed, so disconnect. - this.disconnect(HangingRequestDisconnectReason.Exception, ex); - } catch (ObjectStreamException ex) { - // Stream is closed, so disconnect. - this.disconnect(HangingRequestDisconnectReason.Exception, ex); - } catch (IOException ex) { - // Stream is closed, so disconnect. - this.disconnect(HangingRequestDisconnectReason.Exception, ex); - } catch (UnsupportedOperationException ex) { - LOG.error(ex); - // This is thrown if we close the stream during a - //read operation due to a user method call. - // Trying to delay closing until the read finishes - //simply results in a long-running connection. - this.disconnect(HangingRequestDisconnectReason.UserInitiated, null); - } catch (Exception ex) { - // Stream is closed, so disconnect. - this.disconnect(HangingRequestDisconnectReason.Exception, ex); - } finally { - IOUtils.closeQuietly(responseCopy); - } - } - - private boolean isConnected; - - /** - * Gets a value indicating whether this instance is connected. - * - * @return true, if this instance is connected; otherwise, false - */ - public boolean isConnected() { - return this.isConnected; - } - - private void setIsConnected(boolean value) { - this.isConnected = value; - } - - /** - * Disconnects the request. - */ - public void disconnect() { - synchronized (this) { - IOUtils.closeQuietly(this.response); - this.disconnect(HangingRequestDisconnectReason.UserInitiated, null); - } - } - - /** - * Disconnects the request with the specified reason and exception. - * - * @param reason The reason. - * @param exception The exception. - */ - public void disconnect(HangingRequestDisconnectReason reason, Exception exception) { - if (this.isConnected()) { - IOUtils.closeQuietly(this.response); - this.internalOnDisconnect(reason, exception); - } - } - - /** - * Perform any bookkeeping needed when we connect - * @throws XMLStreamException the XML stream exception - */ - private void internalOnConnect() throws XMLStreamException, - IOException, EWSHttpException { - if (!this.isConnected()) { - this.isConnected = true; - - if (this.getService().isTraceEnabledFor(TraceFlags.EwsResponseHttpHeaders)) { - // Trace Http headers - this.getService().processHttpResponseHeaders( - TraceFlags.EwsResponseHttpHeaders, - this.response); - } - int poolSize = 1; - - int maxPoolSize = 1; - - long keepAliveTime = 10; - - final ArrayBlockingQueue queue = - new ArrayBlockingQueue( - 1); - ThreadPoolExecutor threadPool = new ThreadPoolExecutor(poolSize, - maxPoolSize, - keepAliveTime, TimeUnit.SECONDS, queue); - threadPool.execute(new Runnable() { - public void run() { - parseResponses(); - } - }); - threadPool.shutdown(); - } - } - - /** - * Perform any bookkeeping needed when we disconnect (cleanly or forcefully) - * - * @param reason The reason. - * @param exception The exception. - */ - private void internalOnDisconnect(HangingRequestDisconnectReason reason, - Exception exception) { - if (this.isConnected()) { - this.isConnected = false; - for (IHangingRequestDisconnectHandler disconnect : onDisconnectList) { - disconnect.hangingRequestDisconnectHandler(this, - new HangingRequestDisconnectEventArgs(reason, exception)); - } - } - } - - /** - * Reads any preamble data not part of the core response. - * - * @param ewsXmlReader The EwsServiceXmlReader. - * @throws Exception - */ - @Override - protected void readPreamble(EwsServiceXmlReader ewsXmlReader) - throws Exception { - // Do nothing. - try { - ewsXmlReader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT)); - } catch (XmlException ex) { - throw new ServiceRequestException("The response received from the service didn't contain valid XML.", ex); - } catch (ServiceXmlDeserializationException ex) { - throw new ServiceRequestException("The response received from the service didn't contain valid XML.", ex); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/HttpClientWebRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/HttpClientWebRequest.java deleted file mode 100644 index 8cd6ccb8f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/HttpClientWebRequest.java +++ /dev/null @@ -1,352 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.WebProxy; -import microsoft.exchange.webservices.data.core.exception.http.EWSHttpException; -import org.apache.http.Header; -import org.apache.http.HttpHost; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.NTCredentials; -import org.apache.http.client.CredentialsProvider; -import org.apache.http.client.config.AuthSchemes; -import org.apache.http.client.config.RequestConfig; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.protocol.HttpClientContext; -import org.apache.http.impl.client.BasicCredentialsProvider; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.util.EntityUtils; - -import java.io.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - - -/** - * HttpClientWebRequest is used for making request to the server through NTLM Authentication by using Apache - * HttpClient 3.1 and JCIFS Library. - */ -public class HttpClientWebRequest extends HttpWebRequest { - - /** - * The Http Method. - */ - private HttpPost httpPost = null; - private CloseableHttpResponse response = null; - - private final CloseableHttpClient httpClient; - private final HttpClientContext httpContext; - - - /** - * Instantiates a new http native web request. - */ - public HttpClientWebRequest(CloseableHttpClient httpClient, HttpClientContext httpContext) { - this.httpClient = httpClient; - this.httpContext = httpContext; - } - - /** - * Releases the connection by Closing. - */ - @Override - public void close() throws IOException { - // First check if we can close the response, by consuming the complete response - // This releases the connection but keeps it alive for future request - // If that is not possible, we simply cleanup the whole connection - if (response != null && response.getEntity() != null) { - EntityUtils.consume(response.getEntity()); - } else if (httpPost != null) { - httpPost.releaseConnection(); - } - - // We set httpPost to null to prevent the connection from being closed again by an accidental - // second call to close() - // The response is kept, in case something in the library still wants to read something from it, - // like response code or headers - httpPost = null; - } - - /** - * Prepares the request by setting appropriate headers, authentication, timeouts, etc. - */ - @Override - public void prepareConnection() { - httpPost = new HttpPost(getUrl().toString()); - - // Populate headers. - httpPost.addHeader("Content-type", getContentType()); - httpPost.addHeader("User-Agent", getUserAgent()); - httpPost.addHeader("Accept", getAccept()); - httpPost.addHeader("Keep-Alive", "300"); - httpPost.addHeader("Connection", "Keep-Alive"); - - if (isAcceptGzipEncoding()) { - httpPost.addHeader("Accept-Encoding", "gzip,deflate"); - } - - if (getHeaders() != null) { - for (Map.Entry httpHeader : getHeaders().entrySet()) { - httpPost.addHeader(httpHeader.getKey(), httpHeader.getValue()); - } - } - - // Build request configuration. - // Disable Kerberos in the preferred auth schemes - EWS should usually allow NTLM or Basic auth - RequestConfig.Builder - requestConfigBuilder = - RequestConfig.custom().setAuthenticationEnabled(true).setConnectionRequestTimeout(getTimeout()) - .setConnectTimeout(getTimeout()).setRedirectsEnabled(isAllowAutoRedirect()) - .setSocketTimeout(getTimeout()) - .setTargetPreferredAuthSchemes(Arrays.asList(AuthSchemes.NTLM, AuthSchemes.BASIC)) - .setProxyPreferredAuthSchemes(Arrays.asList(AuthSchemes.NTLM, AuthSchemes.BASIC)); - - CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); - - // Add proxy credential if necessary. - WebProxy proxy = getProxy(); - if (proxy != null) { - HttpHost proxyHost = new HttpHost(proxy.getHost(), proxy.getPort()); - requestConfigBuilder.setProxy(proxyHost); - - if (proxy.hasCredentials()) { - NTCredentials - proxyCredentials = - new NTCredentials(proxy.getCredentials().getUsername(), proxy.getCredentials().getPassword(), "", - proxy.getCredentials().getDomain()); - - credentialsProvider.setCredentials(new AuthScope(proxyHost), proxyCredentials); - } - } - - // Add web service credential if necessary. - if (isAllowAuthentication() && getUsername() != null) { - NTCredentials webServiceCredentials = new NTCredentials(getUsername(), getPassword(), "", getDomain()); - credentialsProvider.setCredentials(new AuthScope(AuthScope.ANY), webServiceCredentials); - } - - httpContext.setCredentialsProvider(credentialsProvider); - - httpPost.setConfig(requestConfigBuilder.build()); - } - - /** - * Gets the input stream. - * - * @return the input stream - * @throws EWSHttpException the EWS http exception - */ - @Override - public InputStream getInputStream() throws EWSHttpException, IOException { - throwIfResponseIsNull(); - BufferedInputStream bufferedInputStream = null; - try { - bufferedInputStream = new BufferedInputStream(response.getEntity().getContent()); - } catch (IOException e) { - throw new EWSHttpException("Connection Error " + e); - } - return bufferedInputStream; - } - - /** - * Gets the error stream. - * - * @return the error stream - * @throws EWSHttpException the EWS http exception - */ - @Override - public InputStream getErrorStream() throws EWSHttpException { - throwIfResponseIsNull(); - BufferedInputStream bufferedInputStream = null; - try { - bufferedInputStream = new BufferedInputStream(response.getEntity().getContent()); - } catch (Exception e) { - throw new EWSHttpException("Connection Error " + e); - } - return bufferedInputStream; - } - - /** - * Gets the output stream. - * - * @return the output stream - * @throws EWSHttpException the EWS http exception - */ - @Override - public OutputStream getOutputStream() throws EWSHttpException { - OutputStream os = null; - throwIfRequestIsNull(); - os = new ByteArrayOutputStream(); - - httpPost.setEntity(new ByteArrayOSRequestEntity(os)); - return os; - } - - /** - * Gets the response headers. - * - * @return the response headers - * @throws EWSHttpException the EWS http exception - */ - @Override - public Map getResponseHeaders() throws EWSHttpException { - throwIfResponseIsNull(); - Map map = new HashMap(); - - Header[] hM = response.getAllHeaders(); - for (Header header : hM) { - // RFC2109: Servers may return multiple Set-Cookie headers - // Need to append the cookies before they are added to the map - if (header.getName().equals("Set-Cookie")) { - String cookieValue = ""; - if (map.containsKey("Set-Cookie")) { - cookieValue += map.get("Set-Cookie"); - cookieValue += ","; - } - cookieValue += header.getValue(); - map.put("Set-Cookie", cookieValue); - } else { - map.put(header.getName(), header.getValue()); - } - } - - return map; - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.HttpWebRequest#getResponseHeaderField( - * java.lang.String) - */ - @Override - public String getResponseHeaderField(String headerName) throws EWSHttpException { - throwIfResponseIsNull(); - Header hM = response.getFirstHeader(headerName); - return hM != null ? hM.getValue() : null; - } - - /** - * Gets the content encoding. - * - * @return the content encoding - * @throws EWSHttpException the EWS http exception - */ - @Override - public String getContentEncoding() throws EWSHttpException { - throwIfResponseIsNull(); - return response.getFirstHeader("content-encoding") != null ? response.getFirstHeader("content-encoding") - .getValue() : null; - } - - /** - * Gets the response content type. - * - * @return the response content type - * @throws EWSHttpException the EWS http exception - */ - @Override - public String getResponseContentType() throws EWSHttpException { - throwIfResponseIsNull(); - return response.getFirstHeader("Content-type") != null ? response.getFirstHeader("Content-type") - .getValue() : null; - } - - /** - * Executes Request by sending request xml data to server. - * - * @throws EWSHttpException the EWS http exception - * @throws java.io.IOException the IO Exception - */ - @Override - public int executeRequest() throws EWSHttpException, IOException { - throwIfRequestIsNull(); - response = httpClient.execute(httpPost, httpContext); - return response.getStatusLine().getStatusCode(); // ?? don't know what is wanted in return - } - - /** - * Gets the response code. - * - * @return the response code - * @throws EWSHttpException the EWS http exception - */ - @Override - public int getResponseCode() throws EWSHttpException { - throwIfResponseIsNull(); - return response.getStatusLine().getStatusCode(); - } - - /** - * Gets the response message. - * - * @return the response message - * @throws EWSHttpException the EWS http exception - */ - public String getResponseText() throws EWSHttpException { - throwIfResponseIsNull(); - return response.getStatusLine().getReasonPhrase(); - } - - /** - * Throw if conn is null. - * - * @throws EWSHttpException the EWS http exception - */ - private void throwIfRequestIsNull() throws EWSHttpException { - if (null == httpPost) { - throw new EWSHttpException("Connection not established"); - } - } - - private void throwIfResponseIsNull() throws EWSHttpException { - if (null == response) { - throw new EWSHttpException("Connection not established"); - } - } - - /** - * Gets the request property. - * - * @return the request property - * @throws EWSHttpException the EWS http exception - */ - public Map getRequestProperty() throws EWSHttpException { - throwIfRequestIsNull(); - Map map = new HashMap(); - - Header[] hM = httpPost.getAllHeaders(); - for (Header header : hM) { - map.put(header.getName(), header.getValue()); - } - return map; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/HttpWebRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/HttpWebRequest.java deleted file mode 100644 index f8abec964..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/HttpWebRequest.java +++ /dev/null @@ -1,571 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.EWSConstants; -import microsoft.exchange.webservices.data.core.WebProxy; -import microsoft.exchange.webservices.data.core.exception.http.EWSHttpException; - -import java.io.Closeable; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.URL; -import java.util.Map; - -/** - * The Class HttpWebRequest. - */ -public abstract class HttpWebRequest implements Closeable { - - /** - * The url. - */ - private URL url; - - /** - * The pre authenticate. - */ - private boolean preAuthenticate; - - /** - * The timeout. - */ - private int timeout; - - /** - * The content type. - */ - private String contentType = "text/xml; charset=utf-8"; - - /** - * The accept. - */ - private String accept = "text/xml"; - - /** - * The user agent. - */ - private String userAgent = "EWS SDK"; - - /** - * The allow auto redirect. - */ - private boolean allowAutoRedirect; - - /** - * The keep alive. - */ - private boolean keepAlive = true; - - /** - * The accept gzip encoding. - */ - private boolean acceptGzipEncoding; - - /** - * The use default credential. - */ - private boolean useDefaultCredentials; - - private boolean allowAuthentication = true; - - /** - * The user name. - */ - private String username; - - /** - * The password. - */ - private String password; - - /** - * The domain. - */ - private String domain; - - /** - * The request Method. - */ - private String requestMethod = "POST"; - - /** - * The request headers. - */ - private Map headers; - - /** - * The Web Proxy. - */ - private WebProxy proxy; - - /** - * Gets the Web Proxy. - * - * @return the proxy - */ - public WebProxy getProxy() { - return proxy; - } - - /** - * Sets the Web Proxy. - * - * @param proxy The Web Proxy - */ - public void setProxy(WebProxy proxy) { - this.proxy = proxy; - } - - /** - * Checks if is http scheme. - * - * @return true, if is http scheme - */ - public boolean isHttpScheme() { - return getUrl().getProtocol().equalsIgnoreCase(EWSConstants.HTTP_SCHEME); - } - - /** - * Checks if is https scheme. - * - * @return true, if is https scheme - */ - public boolean isHttpsScheme() { - return getUrl().getProtocol().equalsIgnoreCase(EWSConstants.HTTPS_SCHEME); - } - - /** - * Gets the user name. - * - * @return the user name - */ - public String getUsername() { - return username; - } - - /** - * Sets the user name. - * - * @param username the new user name - */ - public void setUsername(String username) { - this.username = username; - } - - /** - * Gets the password. - * - * @return the password - */ - public String getPassword() { - return password; - } - - /** - * Sets the password. - * - * @param password the new password - */ - public void setPassword(String password) { - this.password = password; - } - - /** - * Gets the domain. - * - * @return the domain - */ - public String getDomain() { - return domain; - } - - /** - * Sets the domain. - * - * @param domain the new domain - */ - public void setDomain(String domain) { - this.domain = domain; - } - - /** - * Gets the url. - * - * @return the url - */ - public URL getUrl() { - - return url; - } - - /** - * Sets the url. - * - * @param url the new url - */ - public void setUrl(URL url) { - this.url = url; - } - - /** - * Whether to use preemptive authentication. Currently not implemented, though. - */ - public boolean isPreAuthenticate() { - return preAuthenticate; - } - - /** - * Whether to use preemptive authentication. Currently not implemented, though. - */ - public void setPreAuthenticate(boolean preAuthenticate) { - this.preAuthenticate = preAuthenticate; - } - - /** - * Gets the timeout. - * - * @return the timeout - */ - public int getTimeout() { - return timeout; - } - - /** - * Sets the timeout. - * - * @param timeout the new timeout - */ - public void setTimeout(int timeout) { - this.timeout = timeout; - } - - /** - * Gets the content type. - * - * @return the content type - */ - public String getContentType() { - return contentType; - } - - /** - * Sets the content type. - * - * @param contentType the new content type - */ - public void setContentType(String contentType) { - this.contentType = contentType; - } - - /** - * Gets the accept. - * - * @return the accept - */ - public String getAccept() { - return accept; - } - - /** - * Sets the accept. - * - * @param accept the new accept - */ - public void setAccept(String accept) { - this.accept = accept; - } - - /** - * Gets the user agent. - * - * @return the user agent - */ - public String getUserAgent() { - return userAgent; - } - - /** - * Sets the user agent. - * - * @param userAgent the new user agent - */ - public void setUserAgent(String userAgent) { - this.userAgent = userAgent; - } - - /** - * Checks if is allow auto redirect. - * - * @return true, if is allow auto redirect - */ - public boolean isAllowAutoRedirect() { - return allowAutoRedirect; - } - - /** - * Sets the allow auto redirect. - * - * @param allowAutoRedirect the new allow auto redirect - */ - public void setAllowAutoRedirect(boolean allowAutoRedirect) { - this.allowAutoRedirect = allowAutoRedirect; - } - - /** - * Checks if is keep alive. - * - * @return true, if is keep alive - */ - public boolean isKeepAlive() { - return keepAlive; - } - - /** - * Sets the keep alive. - * - * @param keepAlive the new keep alive - */ - public void setKeepAlive(boolean keepAlive) { - this.keepAlive = keepAlive; - } - - /** - * Checks if is accept gzip encoding. - * - * @return true, if is accept gzip encoding - */ - public boolean isAcceptGzipEncoding() { - return acceptGzipEncoding; - } - - /** - * Sets the accept gzip encoding. - * - * @param acceptGzipEncoding the new accept gzip encoding - */ - public void setAcceptGzipEncoding(boolean acceptGzipEncoding) { - this.acceptGzipEncoding = acceptGzipEncoding; - } - - /** - * Checks if is use default credential. - * - * @return true, if is use default credential - */ - public boolean isUseDefaultCredentials() { - return useDefaultCredentials; - } - - /** - * Sets the use default credential. - * - * @param useDefaultCredentials the new use default credential - */ - public void setUseDefaultCredentials(boolean useDefaultCredentials) { - this.useDefaultCredentials = useDefaultCredentials; - } - - /** - * Whether web service authentication is allowed. - * This can be set to {@code false} to disallow sending credential with this request. - * - * This is useful for the autodiscover request to the legacy HTTP url, because this single request doesn't - * require authentication and we don't want to send credential over HTTP. - * - * @return {@code true} if authentication is allowed. - */ - public boolean isAllowAuthentication() { - return allowAuthentication; - } - - /** - * Whether web service authentication is allowed. - * This can be set to {@code false} to disallow sending credential with this request. - * - * This is useful for the autodiscover request to the legacy HTTP url, because this single request doesn't - * require authentication and we don't want to send credential over HTTP. - * - * Default is {@code true}. - * - * @param allowAuthentication {@code true} if authentication is allowed. - */ - public void setAllowAuthentication(boolean allowAuthentication) { - this.allowAuthentication = allowAuthentication; - } - - /** - * Gets the request method type. - * - * @return the request method type. - */ - public String getRequestMethod() { - return requestMethod; - } - - /** - * Sets the request method type. - * - * @param requestMethod the request method type. - */ - public void setRequestMethod(String requestMethod) { - this.requestMethod = requestMethod; - } - - /** - * Gets the Headers. - * - * @return the content type - */ - public Map getHeaders() { - return headers; - } - - /** - * Sets the Headers. - * - * @param headers The headers - */ - public void setHeaders(Map headers) { - this.headers = headers; - } - - /** - * Sets the credential. - * - * @param domain user domain - * @param user user name - * @param pwd password - */ - public void setCredentials(String domain, String user, String pwd) { - this.domain = domain; - this.username = user; - this.password = pwd; - } - - /** - * Gets the input stream. - * - * @return the input stream - * @throws EWSHttpException the eWS http exception - * @throws IOException the IO exception - */ - public abstract InputStream getInputStream() throws EWSHttpException, IOException; - - /** - * Gets the error stream. - * - * @return the error stream - * @throws EWSHttpException the eWS http exception - */ - public abstract InputStream getErrorStream() throws EWSHttpException; - - /** - * Gets the output stream. - * - * @return the output stream - * @throws EWSHttpException the eWS http exception - */ - public abstract OutputStream getOutputStream() throws EWSHttpException; - - /** - * Close. - */ - public abstract void close() throws IOException; - - /** - * Prepare connection. - */ - public abstract void prepareConnection(); - - /** - * Gets the response headers. - * - * @return the response headers - * @throws EWSHttpException the eWS http exception - */ - public abstract Map getResponseHeaders() - throws EWSHttpException; - - /** - * Gets the content encoding. - * - * @return the content encoding - * @throws EWSHttpException the EWS http exception - */ - public abstract String getContentEncoding() throws EWSHttpException; - - /** - * Gets the response content type. - * - * @return the response content type - * @throws EWSHttpException the EWS http exception - */ - public abstract String getResponseContentType() throws EWSHttpException; - - /** - * Gets the response code. - * - * @return the response code - * @throws EWSHttpException the EWS http exception - */ - public abstract int getResponseCode() throws EWSHttpException; - - /** - * Gets the response message. - * - * @return the response message - * @throws EWSHttpException the EWS http exception - */ - public abstract String getResponseText() throws EWSHttpException; - - /** - * Gets the response header field. - * - * @param headerName the header name - * @return the response header field - * @throws EWSHttpException the EWS http exception - */ - public abstract String getResponseHeaderField(String headerName) - throws EWSHttpException; - - /** - * Gets the request property. - * - * @return the request property - * @throws EWSHttpException the EWS http exception - */ - public abstract Map getRequestProperty() - throws EWSHttpException; - - /** - * Executes Request by sending request xml data to server. - * - * @throws EWSHttpException the EWS http exception - * @throws java.io.IOException the IO Exception - */ - public abstract int executeRequest() throws EWSHttpException, IOException; - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/MoveCopyFolderRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/MoveCopyFolderRequest.java deleted file mode 100644 index 6364b2222..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/MoveCopyFolderRequest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.FolderIdWrapperList; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Represents an abstract Move/Copy Folder request. - * - * @param The type of response - */ -abstract class MoveCopyFolderRequest extends - MoveCopyRequest { - - private static final Log LOG = LogFactory.getLog(MoveCopyFolderRequest.class); - - /** - * The folder ids. - */ - private FolderIdWrapperList folderIds = new FolderIdWrapperList(); - - /** - * Validates request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParamCollection(this.getFolderIds().iterator(), "FolderIds"); - this.getFolderIds().validate( - this.getService().getRequestedServerVersion()); - } - - /** - * Initializes a new instance of the class. - * - * @param service The service. - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - protected MoveCopyFolderRequest(ExchangeService service, - ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Writes the ids as XML. - * - * @param writer the writer - */ - @Override - protected void writeIdsToXml(EwsServiceXmlWriter writer) { - try { - this.folderIds.writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.FolderIds); - } catch (Exception e) { - LOG.error(e); - } - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.getFolderIds().getCount(); - } - - /** - * Gets the folder ids. - * - * @return The folder ids. - */ - public FolderIdWrapperList getFolderIds() { - return this.folderIds; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/MoveCopyItemRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/MoveCopyItemRequest.java deleted file mode 100644 index 5bce9990a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/MoveCopyItemRequest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.ItemIdWrapperList; - -/** - * Represents an abstract Move/Copy Item request. - * - * @param The type of the response. - */ -public abstract class MoveCopyItemRequest - extends MoveCopyRequest { - private ItemIdWrapperList itemIds = new ItemIdWrapperList(); - private Boolean newItemIds; - - /** - * Validates request. - * - * @throws Exception the exception - */ - @Override - public void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.getItemIds(), "ItemIds"); - } - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception on error - */ - protected MoveCopyItemRequest(ExchangeService service, - ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Writes the ids as XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeIdsToXml(EwsServiceXmlWriter writer) throws Exception { - this.getItemIds().writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.ItemIds); - if (this.getReturnNewItemIds() != null) { - writer.writeElementValue( - XmlNamespace.Messages, - XmlElementNames.ReturnNewItemIds, - this.getReturnNewItemIds()); - } - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.getItemIds().getCount(); - } - - /** - * Gets the item ids. - * - * @return the item ids - */ - public ItemIdWrapperList getItemIds() { - return this.itemIds; - } - - protected Boolean getReturnNewItemIds() { - return this.newItemIds; - } - - public void setReturnNewItemIds(Boolean value) { - this.newItemIds = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/MoveCopyRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/MoveCopyRequest.java deleted file mode 100644 index 07f815bf3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/MoveCopyRequest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -/** - * Represents an abstract Move/Copy request. - * - * @param The type of the service object. - * @param The type of the response. - */ -abstract class MoveCopyRequest extends - MultiResponseServiceRequest { - - /** - * The destination folder id. - */ - private FolderId destinationFolderId; - - /** - * Validates request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - EwsUtilities.validateParam(this.getDestinationFolderId(), "DestinationFolderId"); - this.getDestinationFolderId().validate( - this.getService().getRequestedServerVersion()); - } - - /** - * Initializes a new instance of the MoveCopyRequest class. - * - * @param service The Service - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - protected MoveCopyRequest(ExchangeService service, - ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Writes the ids as XML. - * - * @param writer The Writer - * @throws Exception the exception - */ - protected abstract void writeIdsToXml(EwsServiceXmlWriter writer) - throws Exception; - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.ToFolderId); - this.getDestinationFolderId().writeToXml(writer); - writer.writeEndElement(); - - this.writeIdsToXml(writer); - } - - /** - * Gets the destination folder id. - * - * @return the destination folder id - */ - public FolderId getDestinationFolderId() { - return this.destinationFolderId; - } - - /** - * Sets the destination folder id. - * - * @param destinationFolderId the new destination folder id - */ - public void setDestinationFolderId(FolderId destinationFolderId) { - this.destinationFolderId = destinationFolderId; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/MoveFolderRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/MoveFolderRequest.java deleted file mode 100644 index d17c64bba..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/MoveFolderRequest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.MoveCopyFolderResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Represents a MoveFolder request. - */ -public class MoveFolderRequest extends MoveCopyFolderRequest { - - /** - * Initializes a new instance of the MoveFolderRequest class. - * - * @param service The service. - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - public MoveFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Creates the service response. - * - * @param service The service. - * @param responseIndex Index of the response. - * @return Service response. - */ - @Override - protected MoveCopyFolderResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new MoveCopyFolderResponse(); - } - - /** - * Gets the name of the XML element. - * - * @return Xml element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.MoveFolder; - } - - /** - * Gets the name of the response XML element. - * - * @return Xml element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.MoveFolderResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return Xml element name. - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.MoveFolderResponseMessage; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/MoveItemRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/MoveItemRequest.java deleted file mode 100644 index f8fbaddb5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/MoveItemRequest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.MoveCopyItemResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * The Class MoveItemRequest. - */ -public class MoveItemRequest extends MoveCopyItemRequest { - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - public MoveItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response. - */ - @Override - protected MoveCopyItemResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new MoveCopyItemResponse(); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name, - */ - @Override public String getXmlElementName() { - return XmlElementNames.MoveItem; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name, - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.MoveItemResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name, - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.MoveItemResponseMessage; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/MultiResponseServiceRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/MultiResponseServiceRequest.java deleted file mode 100644 index 1433a0971..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/MultiResponseServiceRequest.java +++ /dev/null @@ -1,200 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.response.ServiceResponseCollection; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceResult; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.misc.IAsyncResult; - -/** - * Represents a service request that can have multiple response. - * - * @param The type of the response. - */ -public abstract class MultiResponseServiceRequest - extends SimpleServiceRequestBase> { - - /** - * The error handling mode. - */ - private ServiceErrorHandling errorHandlingMode; - - /** - * {@inheritDoc} - */ - @Override - protected ServiceResponseCollection parseResponse(EwsServiceXmlReader reader) - throws Exception { - ServiceResponseCollection serviceResponses = - new ServiceResponseCollection(); - - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.ResponseMessages); - - for (int i = 0; i < this.getExpectedResponseMessageCount(); i++) { - // Read ahead to see if we've reached the end of the response - // messages early. - reader.read(); - if (reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.ResponseMessages)) { - break; - } - - TResponse response = this.createServiceResponse( - reader.getService(), i); - - response.loadFromXml(reader, this - .getResponseMessageXmlElementName()); - - // Add the response to the list after it has been deserialized - // because the response list updates an overall result as individual - // response are added - // to it. - serviceResponses.add(response); - } - // Bug E14:131334 -- if there's a general error in batch processing, - // the server will return a single response message containing the error - // (for example, if the SavedItemFolderId is bogus in a batch CreateItem - // call). In this case, throw a ServiceResponsException. Otherwise this - // is an unexpected server error. - if (serviceResponses.getCount() < this - .getExpectedResponseMessageCount()) { - if ((serviceResponses.getCount() == 1) && - (serviceResponses.getResponseAtIndex(0).getResult() == - ServiceResult.Error)) { - throw new ServiceResponseException(serviceResponses - .getResponseAtIndex(0)); - } else { - throw new ServiceXmlDeserializationException(String.format( - "The service was expected to return %s response of type '%d', but %d response were received.", this - .getResponseMessageXmlElementName(), this - .getExpectedResponseMessageCount(), - serviceResponses.getCount())); - } - } - - reader.readEndElementIfNecessary(XmlNamespace.Messages, - XmlElementNames.ResponseMessages); - - return serviceResponses; - } - - /** - * Creates the service response. - * - * @param service The service. - * @param responseIndex Index of the response. - * @return Service response. - * @throws Exception the exception - */ - protected abstract TResponse createServiceResponse(ExchangeService service, - int responseIndex) throws Exception; - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - protected abstract String getResponseMessageXmlElementName(); - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - protected abstract int getExpectedResponseMessageCount(); - - /** - * Initializes a new instance. - * - * @param service The service. - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - protected MultiResponseServiceRequest(ExchangeService service, - ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service); - this.errorHandlingMode = errorHandlingMode; - } - - /** - * Executes this request. - * - * @return Service response collection. - * @throws Exception the exception - */ - public ServiceResponseCollection execute() throws Exception { - ServiceResponseCollection serviceResponses = internalExecute(); - - if (this.errorHandlingMode == ServiceErrorHandling.ThrowOnError) { - EwsUtilities.ewsAssert(serviceResponses.getCount() == 1, "MultiResponseServiceRequest.Execute", - "ServiceErrorHandling.ThrowOnError " + "error handling " + - "is only valid for singleton request"); - - serviceResponses.getResponseAtIndex(0).throwIfNecessary(); - } - - return serviceResponses; - } - - /** - * Ends executing this async request. - * - * @param asyncResult The async result - * @return Service response collection. - * @throws Exception on error - */ - public ServiceResponseCollection endExecute(IAsyncResult asyncResult) throws Exception { - ServiceResponseCollection serviceResponses = endInternalExecute(asyncResult); - - if (this.errorHandlingMode == ServiceErrorHandling.ThrowOnError) { - EwsUtilities.ewsAssert(serviceResponses.getCount() == 1, "MultiResponseServiceRequest.Execute", - "ServiceErrorHandling.ThrowOnError error handling is only valid for singleton request"); - - serviceResponses.getResponseAtIndex(0).throwIfNecessary(); - } - - return serviceResponses; - } - - /** - * Gets a value indicating how errors should be handled. - * - * @return A value indicating how errors should be handled. - */ - protected ServiceErrorHandling getErrorHandlingMode() { - return this.errorHandlingMode; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/PlayOnPhoneRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/PlayOnPhoneRequest.java deleted file mode 100644 index 0e8b2fce1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/PlayOnPhoneRequest.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.PlayOnPhoneResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.ItemId; - -/** - * Represents a PlayOnPhone request. - */ -public final class PlayOnPhoneRequest extends SimpleServiceRequestBase { - - /** - * The item id. - */ - private ItemId itemId; - - /** - * The dial string. - */ - private String dialString; - - /** - * Initializes a new instance of the PlayOnPhoneRequest class. - * - * @param service the service - * @throws Exception - */ - public PlayOnPhoneRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.PlayOnPhone; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.itemId.writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.ItemId); - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.DialString, dialString); - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name, - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.PlayOnPhoneResponse; - } - - /** - * {@inheritDoc} - */ - @Override - protected PlayOnPhoneResponse parseResponse(EwsServiceXmlReader reader) - throws Exception { - PlayOnPhoneResponse serviceResponse = new PlayOnPhoneResponse(this - .getService()); - serviceResponse - .loadFromXml(reader, XmlElementNames.PlayOnPhoneResponse); - return serviceResponse; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010; - } - - /** - * Executes this request. - * - * @return Service response. - * @throws Exception the exception - */ - public PlayOnPhoneResponse execute() throws Exception { - PlayOnPhoneResponse serviceResponse = internalExecute(); - serviceResponse.throwIfNecessary(); - return serviceResponse; - } - - /** - * Gets the item id of the message to play. - * - * @return the item id - */ - protected ItemId getItemId() { - return this.itemId; - } - - /** - * Sets the item id. - * - * @param itemId the new item id - */ - public void setItemId(ItemId itemId) { - this.itemId = itemId; - } - - /** - * Gets the dial string. - * - * @return the dial string - */ - protected String getDialString() { - return this.dialString; - } - - /** - * Sets the dial string. - * - * @param dialString the new dial string - */ - public void setDialString(String dialString) { - this.dialString = dialString; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/RemoveDelegateRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/RemoveDelegateRequest.java deleted file mode 100644 index 646967790..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/RemoveDelegateRequest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.DelegateManagementResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.UserId; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a RemoveDelete request. - */ -public class RemoveDelegateRequest extends - DelegateManagementRequestBase { - - /** - * The user ids. - */ - private List userIds = new ArrayList(); - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception - */ - public RemoveDelegateRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Asserts the valid. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParamCollection(this.getUserIds().iterator(), "UserIds"); - } - - /** - * Asserts the valid. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - super.writeElementsToXml(writer); - writer - .writeStartElement(XmlNamespace.Messages, - XmlElementNames.UserIds); - - for (UserId userId : this.getUserIds()) { - userId.writeToXml(writer, XmlElementNames.UserId); - } - - writer.writeEndElement(); // UserIds - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.RemoveDelegateResponse; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.RemoveDelegate; - } - - /** - * Creates the response. - * - * @return Service response - */ - @Override - protected DelegateManagementResponse createResponse() { - return new DelegateManagementResponse(false, null); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the user ids. - * - * @return the user ids - */ - public List getUserIds() { - return this.userIds; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/ResolveNamesRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/ResolveNamesRequest.java deleted file mode 100644 index 7b1fd1060..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/ResolveNamesRequest.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.ILazyMember; -import microsoft.exchange.webservices.data.core.LazyMember; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ResolveNamesResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.search.ResolveNameSearchLocation; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.FolderIdWrapperList; - -import java.util.HashMap; -import java.util.Map; - -/** - * Represents a ResolveNames request. - */ -public final class ResolveNamesRequest extends - MultiResponseServiceRequest { - - /** - * The Search scope map. - */ - private static LazyMember> - searchScopeMap = - new LazyMember>( - new ILazyMember>() { - @Override - public Map - createInstance() { - - Map map = - new HashMap(); - - map.put(ResolveNameSearchLocation.DirectoryOnly, - "ActiveDirectory"); - map.put(ResolveNameSearchLocation.DirectoryThenContacts, - "ActiveDirectoryContacts"); - map.put(ResolveNameSearchLocation.ContactsOnly, - "Contacts"); - map.put(ResolveNameSearchLocation.ContactsThenDirectory, - "ContactsActiveDirectory"); - - return map; - } - - }); - - /** - * The name to resolve. - */ - private String nameToResolve; - - /** - * The return full contact data. - */ - private boolean returnFullContactData; - - /** - * The search location. - */ - private ResolveNameSearchLocation searchLocation; - - /** - * The Contact PropertySet. * - */ - private PropertySet contactDataPropertySet; - - /** - * The parent folder ids. - */ - private FolderIdWrapperList parentFolderIds = new FolderIdWrapperList(); - - - - /** - * Asserts the valid. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateNonBlankStringParam(this. - getNameToResolve(), "NameToResolve"); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response - */ - @Override - protected ResolveNamesResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new ResolveNamesResponse(service); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.ResolveNames; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.ResolveNamesResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.ResolveNamesResponseMessage; - } - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception - */ - public ResolveNamesRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.ReturnFullContactData, - this.returnFullContactData); - - String searchScope = null; - if (searchScopeMap.getMember().containsKey(searchLocation)) { - searchScope = searchScopeMap.getMember().get(searchLocation); - } - - EwsUtilities - .ewsAssert((!(searchScope == null || searchScope.isEmpty())), - "ResolveNameRequest.WriteAttributesToXml", - "The specified search location cannot be mapped to an EWS search scope."); - - String propertySet = null; - if (this.getContactDataPropertySet() != null) { - //((PropertyBag)PropertySet.getDefaultPropertySetDictionary( ).getMember()).tryGetValue(this.contactDataPropertySet.getBasePropertySet(), propertySet); - if (PropertySet.getDefaultPropertySetMap().getMember() - .containsKey(this.getContactDataPropertySet().getBasePropertySet())) { - propertySet = PropertySet.getDefaultPropertySetMap().getMember() - .get(this.getContactDataPropertySet().getBasePropertySet()); - } - } - - if (!this.getService().getExchange2007CompatibilityMode()) { - writer.writeAttributeValue(XmlAttributeNames. - SearchScope, searchScope); - } - if (!(propertySet == null)) { - writer.writeAttributeValue(XmlAttributeNames.ContactDataShape, propertySet); - } - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.getParentFolderIds().writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.ParentFolderIds); - - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.UnresolvedEntry, this.getNameToResolve()); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the name to resolve. - * - * @return the name to resolve - */ - public String getNameToResolve() { - return this.nameToResolve; - } - - /** - * Sets the name to resolve. - * - * @param nameToResolve the new name to resolve - */ - public void setNameToResolve(String nameToResolve) { - this.nameToResolve = nameToResolve; - } - - /** - * Gets a value indicating whether to return full contact data or not. - * "true" if should return full contact data; otherwise, "false". - * - * @return the return full contact data - */ - public boolean getReturnFullContactData() { - return this.returnFullContactData; - } - - /** - * Sets the return full contact data. - * - * @param returnFullContactData the new return full contact data - */ - public void setReturnFullContactData(boolean returnFullContactData) { - this.returnFullContactData = returnFullContactData; - } - - /** - * Gets the search location. - * - * @return the search location - */ - public ResolveNameSearchLocation getSearchLocation() { - return this.searchLocation; - } - - /** - * Sets the search location. - * - * @param searchLocation the new search location - */ - public void setSearchLocation(ResolveNameSearchLocation searchLocation) { - this.searchLocation = searchLocation; - } - - /** - * Gets the parent folder ids. - * - * @return the parent folder ids - */ - public FolderIdWrapperList getParentFolderIds() { - return this.parentFolderIds; - } - - /** - * Gets or sets the PropertySet for Contact Data - *

- * The PropertySet - */ - public void setContactDataPropertySet(PropertySet propertySet) { - - - this.contactDataPropertySet = propertySet; - } - - /** - * Gets or sets the PropertySet for Contact Data - * - * @return The PropertySet - */ - public PropertySet getContactDataPropertySet() { - return this.contactDataPropertySet; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/SendItemRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/SendItemRequest.java deleted file mode 100644 index 7a7291efa..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/SendItemRequest.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -/** - * Represents a SendItem request. - */ -public final class SendItemRequest extends - MultiResponseServiceRequest { - - /** - * The item. - */ - private Iterable items; - - /** - * The saved copy destination folder id. - */ - private FolderId savedCopyDestinationFolderId; - - /** - * Asserts the valid. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.items, "Items"); - - if (this.savedCopyDestinationFolderId != null) { - this.savedCopyDestinationFolderId.validate(this.getService() - .getRequestedServerVersion()); - } - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response. - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new ServiceResponse(); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return EwsUtilities.getEnumeratedObjectCount(this.items.iterator()); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.SendItem; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.SendItemResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.SendItemResponseMessage; - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - - writer.writeAttributeValue(XmlAttributeNames.SaveItemToFolder, - this.savedCopyDestinationFolderId != null); - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) throws Exception { - writer - .writeStartElement(XmlNamespace.Messages, - XmlElementNames.ItemIds); - - for (Item item : this.getItems()) { - item.getId().writeToXml(writer, XmlElementNames.ItemId); - } - - writer.writeEndElement(); // ItemIds - - if (this.savedCopyDestinationFolderId != null) { - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.SavedItemFolderId); - this.savedCopyDestinationFolderId.writeToXml(writer); - writer.writeEndElement(); - } - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - public SendItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * Gets the item. The item. - * - * @return the item - */ - public Iterable getItems() { - return this.items; - } - - /** - * Sets the item. - * - * @param items the new item - */ - public void setItems(Iterable items) { - this.items = items; - } - - /** - * Gets the saved copy destination folder id. - * - * @return the saved copy destination folder id - */ - public FolderId getSavedCopyDestinationFolderId() { - return this.savedCopyDestinationFolderId; - } - - /** - * Sets the saved copy destination folder id. - * - * @param savedCopyDestinationFolderId the new saved copy destination folder id - */ - public void setSavedCopyDestinationFolderId( - FolderId savedCopyDestinationFolderId) { - this.savedCopyDestinationFolderId = savedCopyDestinationFolderId; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/ServiceRequestBase.java b/src/main/java/microsoft/exchange/webservices/data/core/request/ServiceRequestBase.java deleted file mode 100644 index aafd48cf6..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/ServiceRequestBase.java +++ /dev/null @@ -1,764 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeServerInfo; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.DateTimePrecision; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.TraceFlags; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.http.EWSHttpException; -import microsoft.exchange.webservices.data.core.exception.http.HttpErrorException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.core.exception.xml.XmlException; -import microsoft.exchange.webservices.data.misc.SoapFaultDetails; -import microsoft.exchange.webservices.data.security.XmlNodeType; -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.xml.stream.XMLStreamException; -import javax.xml.ws.http.HTTPException; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.GZIPInputStream; -import java.util.zip.InflaterInputStream; - -/** - * Represents an abstract service request. - */ -public abstract class ServiceRequestBase { - - private static final Log LOG = LogFactory.getLog(ServiceRequestBase.class); - - /** - * The service. - */ - private ExchangeService service; - - // Methods for subclasses to override - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - public abstract String getXmlElementName(); - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - protected abstract String getResponseXmlElementName(); - - /** - * Gets the minimum server version required to process this request. - * - * @return Exchange server version. - */ - protected abstract ExchangeVersion getMinimumRequiredServerVersion(); - - /** - * Parses the response. - * - * @param reader The reader. - * @return the Response Object. - * @throws Exception the exception - */ - protected abstract T parseResponse(EwsServiceXmlReader reader) throws Exception; - - /** - * Writes XML elements. - * - * @param writer The writer. - * @throws Exception the exception - */ - protected abstract void writeElementsToXml(EwsServiceXmlWriter writer) throws Exception; - - /** - * Validate request. - * - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - protected void validate() throws Exception { - this.service.validate(); - } - - /** - * Writes XML body. - * - * @param writer The writer. - * @throws Exception the exception - */ - protected void writeBodyToXml(EwsServiceXmlWriter writer) throws Exception { - writer.writeStartElement(XmlNamespace.Messages, this.getXmlElementName()); - - this.writeAttributesToXml(writer); - this.writeElementsToXml(writer); - - writer.writeEndElement(); // m:this.GetXmlElementName() - } - - /** - * Writes XML attribute. Subclass will override if it has XML attribute. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected void writeAttributesToXml(EwsServiceXmlWriter writer) throws ServiceXmlSerializationException { - } - - /** - * Initializes a new instance. - * - * @param service The service. - * @throws ServiceVersionException the service version exception - */ - protected ServiceRequestBase(ExchangeService service) throws ServiceVersionException { - this.service = service; - this.throwIfNotSupportedByRequestedServerVersion(); - } - - /** - * Gets the service. - * - * @return The service. - */ - public ExchangeService getService() { - return service; - } - - /** - * Throw exception if request is not supported in requested server version. - * - * @throws ServiceVersionException the service version exception - */ - protected void throwIfNotSupportedByRequestedServerVersion() throws ServiceVersionException { - if (this.service.getRequestedServerVersion().ordinal() < this.getMinimumRequiredServerVersion() - .ordinal()) { - throw new ServiceVersionException(String.format( - "The service request %s is only valid for Exchange version %s or later.", this.getXmlElementName(), - this.getMinimumRequiredServerVersion())); - } - } - - // HttpWebRequest-based implementation - - /** - * Writes XML. - * - * @param writer The writer. - * @throws Exception the exception - */ - protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { - writer.writeStartDocument(); - writer.writeStartElement(XmlNamespace.Soap, XmlElementNames.SOAPEnvelopeElementName); - writer.writeAttributeValue("xmlns", EwsUtilities.getNamespacePrefix(XmlNamespace.Soap), - EwsUtilities.getNamespaceUri(XmlNamespace.Soap)); - writer.writeAttributeValue("xmlns", EwsUtilities.EwsXmlSchemaInstanceNamespacePrefix, - EwsUtilities.EwsXmlSchemaInstanceNamespace); - writer.writeAttributeValue("xmlns", EwsUtilities.EwsMessagesNamespacePrefix, - EwsUtilities.EwsMessagesNamespace); - writer.writeAttributeValue("xmlns", EwsUtilities.EwsTypesNamespacePrefix, EwsUtilities.EwsTypesNamespace); - if (writer.isRequireWSSecurityUtilityNamespace()) { - writer.writeAttributeValue("xmlns", EwsUtilities.WSSecurityUtilityNamespacePrefix, - EwsUtilities.WSSecurityUtilityNamespace); - } - - writer.writeStartElement(XmlNamespace.Soap, XmlElementNames.SOAPHeaderElementName); - - if (this.service.getCredentials() != null) { - this.service.getCredentials().emitExtraSoapHeaderNamespaceAliases(writer.getInternalWriter()); - } - - // Emit the RequestServerVersion header - writer.writeStartElement(XmlNamespace.Types, XmlElementNames.RequestServerVersion); - writer.writeAttributeValue(XmlAttributeNames.Version, this.getRequestedServiceVersionString()); - writer.writeEndElement(); // RequestServerVersion - - /* - * if ((this.getService().getRequestedServerVersion().ordinal() == - * ExchangeVersion.Exchange2007_SP1.ordinal() || - * this.EmitTimeZoneHeader()) && - * (!this.getService().getExchange2007CompatibilityMode())) { - * writer.writeStartElement(XmlNamespace.Types, - * XmlElementNames.TimeZoneContext); - * - * this.getService().TimeZoneDefinition().WriteToXml(writer); - * - * writer.WriteEndElement(); // TimeZoneContext - * - * writer.IsTimeZoneHeaderEmitted = true; } - */ - - if (this.service.getPreferredCulture() != null) { - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.MailboxCulture, - this.service.getPreferredCulture().getDisplayName()); - } - - /** Emit the DateTimePrecision header */ - - if (this.getService().getDateTimePrecision().ordinal() != DateTimePrecision.Default.ordinal()) { - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.DateTimePrecision, - this.getService().getDateTimePrecision().toString()); - } - if (this.service.getImpersonatedUserId() != null) { - this.service.getImpersonatedUserId().writeToXml(writer); - } - - if (this.service.getCredentials() != null) { - this.service.getCredentials() - .serializeExtraSoapHeaders(writer.getInternalWriter(), this.getXmlElementName()); - } - this.service.doOnSerializeCustomSoapHeaders(writer.getInternalWriter()); - - writer.writeEndElement(); // soap:Header - - writer.writeStartElement(XmlNamespace.Soap, XmlElementNames.SOAPBodyElementName); - - this.writeBodyToXml(writer); - - writer.writeEndElement(); // soap:Body - writer.writeEndElement(); // soap:Envelope - writer.flush(); - } - - /** - * Gets st ring representation of requested server version. In order to support E12 RTM servers, - * ExchangeService has another flag indicating that we should use "Exchange2007" as the server version - * string rather than Exchange2007_SP1. - * - * @return String representation of requested server version. - */ - private String getRequestedServiceVersionString() { - if (this.service.getRequestedServerVersion() == ExchangeVersion.Exchange2007_SP1 && this.service - .getExchange2007CompatibilityMode()) { - return "Exchange2007"; - } else { - return this.service.getRequestedServerVersion().toString(); - } - } - - /** - * Gets the response stream (may be wrapped with GZip/Deflate stream to decompress content). - * - * @param request HttpWebRequest object from which response stream can be read. - * @return ResponseStream - * @throws java.io.IOException Signals that an I/O exception has occurred. - * @throws EWSHttpException the EWS http exception - */ - protected static InputStream getResponseStream(HttpWebRequest request) - throws IOException, EWSHttpException { - String contentEncoding = ""; - - if (null != request.getContentEncoding()) { - contentEncoding = request.getContentEncoding().toLowerCase(); - } - - InputStream responseStream; - - if (contentEncoding.contains("gzip")) { - responseStream = new GZIPInputStream(request.getInputStream()); - } else if (contentEncoding.contains("deflate")) { - responseStream = new InflaterInputStream(request.getInputStream()); - } else { - responseStream = request.getInputStream(); - } - return responseStream; - } - - /** - * Traces the response. - * - * @param request the response - * @param memoryStream the response content in a MemoryStream - * @throws XMLStreamException the XML stream exception - * @throws IOException signals that an I/O exception has occurred - * @throws EWSHttpException the EWS http exception - */ - protected void traceResponse(HttpWebRequest request, ByteArrayOutputStream memoryStream) - throws XMLStreamException, IOException, EWSHttpException { - - this.service.processHttpResponseHeaders(TraceFlags.EwsResponseHttpHeaders, request); - String contentType = request.getResponseContentType(); - - if (!isNullOrEmpty(contentType) && (contentType.startsWith("text/") || contentType - .startsWith("application/soap"))) { - this.service.traceXml(TraceFlags.EwsResponse, memoryStream); - } else { - this.service.traceMessage(TraceFlags.EwsResponse, "Non-textual response"); - } - - } - - /** - * Gets the response error stream. - * - * @param request the request - * @return the response error stream - * @throws EWSHttpException the EWS http exception - * @throws java.io.IOException Signals that an I/O exception has occurred. - */ - private static InputStream getResponseErrorStream(HttpWebRequest request) - throws EWSHttpException, IOException { - String contentEncoding = ""; - - if (null != request.getContentEncoding()) { - contentEncoding = request.getContentEncoding().toLowerCase(); - } - - InputStream responseStream; - - if (contentEncoding.contains("gzip")) { - responseStream = new GZIPInputStream(request.getErrorStream()); - } else if (contentEncoding.contains("deflate")) { - responseStream = new InflaterInputStream(request.getErrorStream()); - } else { - responseStream = request.getErrorStream(); - } - return responseStream; - } - - /** - * Reads the response. - * - * @param response HTTP web request - * @return response response object - * @throws Exception on error - */ - protected T readResponse(HttpWebRequest response) throws Exception { - T serviceResponse; - - if (!response.getResponseContentType().startsWith("text/xml")) { - throw new ServiceRequestException("The response received from the service didn't contain valid XML."); - } - - /** - * If tracing is enabled, we read the entire response into a - * MemoryStream so that we can pass it along to the ITraceListener. Then - * we parse the response from the MemoryStream. - */ - - try { - this.getService().processHttpResponseHeaders(TraceFlags.EwsResponseHttpHeaders, response); - - if (this.getService().isTraceEnabledFor(TraceFlags.EwsResponse)) { - ByteArrayOutputStream memoryStream = new ByteArrayOutputStream(); - InputStream serviceResponseStream = ServiceRequestBase.getResponseStream(response); - - int data = serviceResponseStream.read(); - while (data != -1) { - memoryStream.write(data); - data = serviceResponseStream.read(); - } - - this.traceResponse(response, memoryStream); - ByteArrayInputStream memoryStreamIn = new ByteArrayInputStream(memoryStream.toByteArray()); - EwsServiceXmlReader ewsXmlReader = new EwsServiceXmlReader(memoryStreamIn, this.getService()); - serviceResponse = this.readResponse(ewsXmlReader); - serviceResponseStream.close(); - memoryStream.flush(); - } else { - InputStream responseStream = ServiceRequestBase.getResponseStream(response); - EwsServiceXmlReader ewsXmlReader = new EwsServiceXmlReader(responseStream, this.getService()); - serviceResponse = this.readResponse(ewsXmlReader); - } - - return serviceResponse; - } catch (HTTPException e) { - if (e.getMessage() != null) { - this.getService().processHttpResponseHeaders(TraceFlags.EwsResponseHttpHeaders, response); - } - throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e); - } catch (IOException e) { - throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e); - } finally { // close the underlying response - response.close(); - } - } - - /** - * Reads the response. - * - * @param ewsXmlReader The XML reader. - * @return Service response. - * @throws Exception the exception - */ - protected T readResponse(EwsServiceXmlReader ewsXmlReader) throws Exception { - T serviceResponse; - this.readPreamble(ewsXmlReader); - ewsXmlReader.readStartElement(XmlNamespace.Soap, XmlElementNames.SOAPEnvelopeElementName); - this.readSoapHeader(ewsXmlReader); - ewsXmlReader.readStartElement(XmlNamespace.Soap, XmlElementNames.SOAPBodyElementName); - - ewsXmlReader.readStartElement(XmlNamespace.Messages, this.getResponseXmlElementName()); - - serviceResponse = this.parseResponse(ewsXmlReader); - - ewsXmlReader.readEndElementIfNecessary(XmlNamespace.Messages, this.getResponseXmlElementName()); - - ewsXmlReader.readEndElement(XmlNamespace.Soap, XmlElementNames.SOAPBodyElementName); - ewsXmlReader.readEndElement(XmlNamespace.Soap, XmlElementNames.SOAPEnvelopeElementName); - return serviceResponse; - } - - /** - * Reads any preamble data not part of the core response. - * - * @param ewsXmlReader The EwsServiceXmlReader. - * @throws Exception on error - */ - protected void readPreamble(EwsServiceXmlReader ewsXmlReader) throws Exception { - this.readXmlDeclaration(ewsXmlReader); - } - - /** - * Read SOAP header and extract server version. - * - * @param reader EwsServiceXmlReader - * @throws Exception the exception - */ - private void readSoapHeader(EwsServiceXmlReader reader) throws Exception { - reader.readStartElement(XmlNamespace.Soap, XmlElementNames.SOAPHeaderElementName); - do { - reader.read(); - - // Is this the ServerVersionInfo? - if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.ServerVersionInfo)) { - this.service.setServerInfo(ExchangeServerInfo.parse(reader)); - } - - // Ignore anything else inside the SOAP header - } while (!reader.isEndElement(XmlNamespace.Soap, XmlElementNames.SOAPHeaderElementName)); - } - - /** - * Processes the web exception. - * - * @param webException the web exception - * @param req HTTP Request object used to send the http request - * @throws Exception on error - */ - protected void processWebException(Exception webException, HttpWebRequest req) throws Exception { - SoapFaultDetails soapFaultDetails; - if (null != req) { - this.getService().processHttpResponseHeaders(TraceFlags.EwsResponseHttpHeaders, req); - if (500 == req.getResponseCode()) { - if (this.service.isTraceEnabledFor(TraceFlags.EwsResponse)) { - ByteArrayOutputStream memoryStream = new ByteArrayOutputStream(); - InputStream serviceResponseStream = ServiceRequestBase.getResponseErrorStream(req); - while (true) { - int data = serviceResponseStream.read(); - if (-1 == data) { - break; - } else { - memoryStream.write(data); - } - } - memoryStream.flush(); - serviceResponseStream.close(); - this.traceResponse(req, memoryStream); - ByteArrayInputStream memoryStreamIn = new ByteArrayInputStream(memoryStream.toByteArray()); - EwsServiceXmlReader reader = new EwsServiceXmlReader(memoryStreamIn, this.service); - soapFaultDetails = this.readSoapFault(reader); - memoryStream.close(); - } else { - InputStream serviceResponseStream = ServiceRequestBase.getResponseStream(req); - EwsServiceXmlReader reader = new EwsServiceXmlReader(serviceResponseStream, this.service); - soapFaultDetails = this.readSoapFault(reader); - serviceResponseStream.close(); - - } - - if (soapFaultDetails != null) { - switch (soapFaultDetails.getResponseCode()) { - case ErrorInvalidServerVersion: - throw new ServiceVersionException("Exchange Server doesn't support the requested version."); - - case ErrorSchemaValidation: - // If we're talking to an E12 server - // (8.00.xxxx.xxx), a schema - // validation error is the same as - // a version mismatch error. - // (Which only will happen if we - // send a request that's not valid - // for E12). - if ((this.service.getServerInfo() != null) && (this.service.getServerInfo().getMajorVersion() - == 8) && ( - this.service.getServerInfo().getMinorVersion() == 0)) { - throw new ServiceVersionException("Exchange Server doesn't support the requested version."); - } - - break; - - case ErrorIncorrectSchemaVersion: - // This shouldn't happen. It - // indicates that a request wasn't - // valid for the version that was specified. - EwsUtilities.ewsAssert(false, "ServiceRequestBase.ProcessWebException", - "Exchange server supports " + "requested version " - + "but request was invalid for that version"); - break; - - default: - // Other error codes will - // be reported as remote error - break; - } - - // General fall-through case: - // throw a ServiceResponseException - throw new ServiceResponseException(new ServiceResponse(soapFaultDetails)); - } - } else { - this.service.processHttpErrorResponse(req, webException); - } - } - - } - - /** - * Reads the SOAP fault. - * - * @param reader The reader. - * @return SOAP fault details. - */ - protected SoapFaultDetails readSoapFault(EwsServiceXmlReader reader) { - SoapFaultDetails soapFaultDetails = null; - - try { - this.readXmlDeclaration(reader); - - reader.read(); - if (!reader.isStartElement() || (!reader.getLocalName() - .equals(XmlElementNames.SOAPEnvelopeElementName))) { - return soapFaultDetails; - } - - // EWS can sometimes return SOAP faults using the SOAP 1.2 - // namespace. Get the - // namespace URI from the envelope element and use it for the rest - // of the parsing. - // If it's not 1.1 or 1.2, we can't continue. - XmlNamespace soapNamespace = EwsUtilities.getNamespaceFromUri(reader.getNamespaceUri()); - if (soapNamespace == XmlNamespace.NotSpecified) { - return soapFaultDetails; - } - - reader.read(); - - // EWS doesn't always return a SOAP header. If this response - // contains a header element, - // read the server version information contained in the header. - if (reader.isStartElement(soapNamespace, XmlElementNames.SOAPHeaderElementName)) { - do { - reader.read(); - - if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.ServerVersionInfo)) { - this.service.setServerInfo(ExchangeServerInfo.parse(reader)); - } - } while (!reader.isEndElement(soapNamespace, XmlElementNames.SOAPHeaderElementName)); - - // Queue up the next read - reader.read(); - } - - // Parse the fault element contained within the SOAP body. - if (reader.isStartElement(soapNamespace, XmlElementNames.SOAPBodyElementName)) { - do { - reader.read(); - - // Parse Fault element - if (reader.isStartElement(soapNamespace, XmlElementNames.SOAPFaultElementName)) { - soapFaultDetails = SoapFaultDetails.parse(reader, soapNamespace); - } - } while (!reader.isEndElement(soapNamespace, XmlElementNames.SOAPBodyElementName)); - } - - reader.readEndElement(soapNamespace, XmlElementNames.SOAPEnvelopeElementName); - } catch (Exception e) { - // If response doesn't contain a valid SOAP fault, just ignore - // exception and - // return null for SOAP fault details. - LOG.error(e); - } - - return soapFaultDetails; - } - - /** - * Validates request parameters, and emits the request to the server. - * - * @return The response returned by the server. - * @throws Exception on error - */ - protected HttpWebRequest validateAndEmitRequest() throws Exception { - this.validate(); - - HttpWebRequest request; - - if (service.getMaximumPoolingConnections() > 1) { - request = buildEwsHttpPoolingWebRequest(); - } else { - request = buildEwsHttpWebRequest(); - } - - try { - try { - return this.getEwsHttpWebResponse(request); - } catch (HttpErrorException e) { - processWebException(e, request); - - // Wrap exception if the above code block didn't throw - throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e); - } - } catch (Exception e) { - IOUtils.closeQuietly(request); - throw e; - } - } - - /** - * Builds the HttpWebRequest object for current service request with exception handling. - * - * @return An HttpWebRequest instance - * @throws Exception on error - */ - protected HttpWebRequest buildEwsHttpWebRequest() throws Exception { - HttpWebRequest request = service.prepareHttpWebRequest(); - return buildEwsHttpWebRequest(request); - } - - /** - * Builds a HttpWebRequest object from a pooling connection manager for current service request - * with exception handling. - *

- * Used for subscriptions. - *

- * - * @return A HttpWebRequest instance - * @throws Exception on error - */ - protected HttpWebRequest buildEwsHttpPoolingWebRequest() throws Exception { - HttpWebRequest request = service.prepareHttpPoolingWebRequest(); - return buildEwsHttpWebRequest(request); - } - - private HttpWebRequest buildEwsHttpWebRequest(HttpWebRequest request) throws Exception { - try { - - service.traceHttpRequestHeaders(TraceFlags.EwsRequestHttpHeaders, request); - - ByteArrayOutputStream requestStream = (ByteArrayOutputStream) request.getOutputStream(); - - EwsServiceXmlWriter writer = new EwsServiceXmlWriter(service, requestStream); - - boolean needSignature = - service.getCredentials() != null && service.getCredentials().isNeedSignature(); - writer.setRequireWSSecurityUtilityNamespace(needSignature); - - writeToXml(writer); - - if (needSignature) { - service.getCredentials().sign(requestStream); - } - - service.traceXml(TraceFlags.EwsRequest, requestStream); - - return request; - } catch (IOException e) { - // Wrap exception. - throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e); - } - } - - /** - * Gets the IEwsHttpWebRequest object from the specifiedHttpWebRequest object with exception handling - * - * @param request The specified HttpWebRequest - * @return An HttpWebResponse instance - * @throws Exception on error - */ - protected HttpWebRequest getEwsHttpWebResponse(HttpWebRequest request) throws Exception { - try { - request.executeRequest(); - - if (request.getResponseCode() >= 400) { - throw new HttpErrorException( - "The remote server returned an error: (" + request.getResponseCode() + ")" + - request.getResponseText(), request.getResponseCode()); - } - } catch (IOException e) { - // Wrap exception. - throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e); - } - - return request; - } - - /** - * Checks whether input string is null or empty. - * - * @param str The input string. - * @return true if input string is null or empty, otherwise false - */ - private boolean isNullOrEmpty(String str) { - return null == str || str.isEmpty(); - } - - /** - * Try to read the XML declaration. If it's not there, the server didn't return XML. - * - * @param reader The reader. - */ - private void readXmlDeclaration(EwsServiceXmlReader reader) throws Exception { - try { - reader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT)); - } catch (XmlException ex) { - throw new ServiceRequestException("The response received from the service didn't contain valid XML.", - ex); - } catch (ServiceXmlDeserializationException ex) { - throw new ServiceRequestException("The response received from the service didn't contain valid XML.", - ex); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/SetUserOofSettingsRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/SetUserOofSettingsRequest.java deleted file mode 100644 index 3a228295f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/SetUserOofSettingsRequest.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.availability.OofSettings; - -/** - * Represents a SetUserOofSettings request. - */ -public final class SetUserOofSettingsRequest extends SimpleServiceRequestBase { - - /** - * The smtp address. - */ - private String smtpAddress; - - /** - * The oof settings. - */ - private OofSettings oofSettings; - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.SetUserOofSettingsRequest; - } - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - - EwsUtilities.validateParam(this.getSmtpAddress(), "SmtpAddress"); - EwsUtilities.validateParam(this.getOofSettings(), "OofSettings"); - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Mailbox); - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Address, - this.getSmtpAddress()); - writer.writeEndElement(); // Mailbox - - this.getOofSettings().writeToXml(writer, - XmlElementNames.UserOofSettings); - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.SetUserOofSettingsResponse; - } - - /** - * {@inheritDoc} - */ - @Override - protected ServiceResponse parseResponse(EwsServiceXmlReader reader) - throws Exception { - ServiceResponse serviceResponse = new ServiceResponse(); - serviceResponse.loadFromXml(reader, XmlElementNames.ResponseMessage); - return serviceResponse; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception - */ - public SetUserOofSettingsRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Executes this request. - * - * @return Service response - * @throws Exception the exception - */ - public ServiceResponse execute() throws Exception { - ServiceResponse serviceResponse = internalExecute(); - serviceResponse.throwIfNecessary(); - return serviceResponse; - } - - /** - * Gets the SMTP address. - * - * @return the smtp address - */ - public String getSmtpAddress() { - return this.smtpAddress; - } - - /** - * Sets the smtp address. - * - * @param smtpAddress the new smtp address - */ - public void setSmtpAddress(String smtpAddress) { - this.smtpAddress = smtpAddress; - } - - /** - * Gets the oof settings. - * - * @return the oof settings - */ - public OofSettings getOofSettings() { - return this.oofSettings; - } - - /** - * Sets the oof settings. - * - * @param oofSettings the new oof settings - */ - public void setOofSettings(OofSettings oofSettings) { - this.oofSettings = oofSettings; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/SimpleServiceRequestBase.java b/src/main/java/microsoft/exchange/webservices/data/core/request/SimpleServiceRequestBase.java deleted file mode 100644 index 7c96e110b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/SimpleServiceRequestBase.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.enumeration.misc.TraceFlags; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceRequestException; -import microsoft.exchange.webservices.data.misc.AsyncCallback; -import microsoft.exchange.webservices.data.misc.AsyncExecutor; -import microsoft.exchange.webservices.data.misc.AsyncRequestResult; -import microsoft.exchange.webservices.data.misc.CallableMethod; -import microsoft.exchange.webservices.data.misc.IAsyncResult; - -import java.io.IOException; -import java.util.concurrent.Callable; -import java.util.concurrent.Future; - -/** - * Defines the SimpleServiceRequestBase class. - */ -public abstract class SimpleServiceRequestBase extends ServiceRequestBase { - - /** - * Initializes a new instance of the SimpleServiceRequestBase class. - */ - protected SimpleServiceRequestBase(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Executes this request. - * - * @return response object - * @throws Exception on error - */ - protected T internalExecute() throws Exception { - HttpWebRequest response = null; - - try { - response = this.validateAndEmitRequest(); - return this.readResponse(response); - } catch (IOException ex) { - // Wrap exception. - throw new ServiceRequestException(String. - format("The request failed. %s", ex.getMessage()), ex); - } catch (Exception e) { - if (response != null) { - this.getService().processHttpResponseHeaders(TraceFlags. - EwsResponseHttpHeaders, response); - } - - throw new ServiceRequestException(String.format("The request failed. %s", e.getMessage()), e); - } - } - - /** - * Ends executing this async request. - * - * @param asyncResult The async result - * @return Service response object - * @throws Exception on error - */ - protected T endInternalExecute(IAsyncResult asyncResult) throws Exception { - HttpWebRequest response = (HttpWebRequest) asyncResult.get(); - return this.readResponse(response); - } - - /** - * Begins executing this async request. - * - * @param callback The AsyncCallback delegate. - * @return An IAsyncResult that references the asynchronous request. - * @throws Exception on error - */ - public AsyncRequestResult beginExecute(AsyncCallback callback) throws Exception { - this.validate(); - - HttpWebRequest request = this.buildEwsHttpWebRequest(); - AsyncExecutor es = new AsyncExecutor(); - Callable cl = new CallableMethod(request); - Future task = es.submit(cl, callback); - es.shutdown(); - - return new AsyncRequestResult(this, request, task, null); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/SubscribeRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/SubscribeRequest.java deleted file mode 100644 index 051c356fd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/SubscribeRequest.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.SubscribeResponse; -import microsoft.exchange.webservices.data.core.enumeration.notification.EventType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.FolderIdWrapperList; -import microsoft.exchange.webservices.data.notification.SubscriptionBase; - -import javax.xml.stream.XMLStreamException; - -import java.util.ArrayList; -import java.util.List; - -/** - * The Class SubscribeRequest. - * - * @param the generic type - */ -abstract class SubscribeRequest extends - MultiResponseServiceRequest> { - - /** - * The folder ids. - */ - private FolderIdWrapperList folderIds = new FolderIdWrapperList(); - - /** - * The event types. - */ - private List eventTypes = new ArrayList(); - - /** - * The watermark. - */ - private String watermark; - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.getFolderIds(), "FolderIds"); - EwsUtilities.validateParamCollection(this.getEventTypes().iterator(), - "EventTypes"); - this.getFolderIds().validate( - this.getService().getRequestedServerVersion()); - // Check that caller isn't trying - //to subscribe to Status events. - if (this.getEventTypes().contains(EventType.Status)) { - throw new ServiceValidationException("Status events can't be subscribed to."); - } - - // If Watermark was specified, make sure it's not a blank string. - if (!(this.getWatermark() == null || - this.getWatermark().isEmpty())) { - EwsUtilities.validateNonBlankStringParam(this. - getWatermark(), "Watermark"); - } - - for (EventType eventType : this.getEventTypes()) { - EwsUtilities.validateEnumVersionValue(eventType, - this.getService().getRequestedServerVersion()); - } - - } - - /** - * Gets the name of the subscription XML element. - * - * @return XML element name - */ - protected abstract String getSubscriptionXmlElementName(); - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.Subscribe; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.SubscribeResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.SubscribeResponseMessage; - } - - /** - * Internal method to write XML elements. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected abstract void internalWriteElementsToXml( - EwsServiceXmlWriter writer) throws XMLStreamException, ServiceXmlSerializationException; - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeStartElement(XmlNamespace.Messages, this - .getSubscriptionXmlElementName()); - - if (this.getFolderIds().getCount() == 0) { - writer.writeAttributeValue(XmlAttributeNames.SubscribeToAllFolders, - true); - } - - this.getFolderIds().writeToXml(writer, XmlNamespace.Types, - XmlElementNames.FolderIds); - - writer - .writeStartElement(XmlNamespace.Types, - XmlElementNames.EventTypes); - for (EventType eventType : this.getEventTypes()) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.EventType, eventType); - } - writer.writeEndElement(); - - if (!(this.getWatermark() == null || this.getWatermark().isEmpty())) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.Watermark, this.getWatermark()); - } - - this.internalWriteElementsToXml(writer); - - writer.writeEndElement(); - } - - /** - * Instantiates a new subscribe request. - * - * @param service the service - * @throws Exception - */ - protected SubscribeRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - this.setFolderIds(new FolderIdWrapperList()); - this.setEventTypes(new ArrayList()); - } - - /** - * Gets the folder ids. - * - * @return the folder ids - */ - public FolderIdWrapperList getFolderIds() { - return this.folderIds; - } - - /** - * Sets the folder ids. - */ - private void setFolderIds(FolderIdWrapperList value) { - this.folderIds = value; - } - - /** - * Gets the event types. - * - * @return the event types - */ - public List getEventTypes() { - return this.eventTypes; - } - - /** - * set the EventTypes - */ - private void setEventTypes(List value) { - this.eventTypes = value; - } - - /** - * Gets the watermark. - * - * @return the watermark - */ - public String getWatermark() { - return this.watermark; - } - - /** - * Sets the watermark. - * - * @param watermark the new watermark - */ - public void setWatermark(String watermark) { - this.watermark = watermark; - } - - @Override - protected HttpWebRequest buildEwsHttpWebRequest() throws Exception - { - return super.buildEwsHttpPoolingWebRequest(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/SubscribeToPullNotificationsRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/SubscribeToPullNotificationsRequest.java deleted file mode 100644 index 11e9594e4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/SubscribeToPullNotificationsRequest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.SubscribeResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.notification.PullSubscription; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents a "pull" Subscribe request. - */ -public class SubscribeToPullNotificationsRequest extends - SubscribeRequest { - - /** - * The timeout. - */ - private int timeout = 30; - - /** - * Instantiates a new subscribe to pull notification request. - * - * @param service the service - * @throws Exception the exception - */ - public SubscribeToPullNotificationsRequest(ExchangeService service) - throws Exception { - - super(service); - - } - - /** - * Gets the timeout. - * - * @return the timeout - */ - public int getTimeout() { - return this.timeout; - } - - /** - * Sets the time out. - * - * @param timeout the new time out - */ - public void setTimeOut(int timeout) { - this.timeout = timeout; - } - - /** - * Validate request. - * - * @throws Exception the exception - */ - protected void validate() throws Exception { - super.validate(); - if ((this.getTimeout() < 1) || (this.getTimeout() > 1440)) { - throw new ArgumentException(String.format( - "%d is not a valid timeout value. Valid values range from 1 to 1440.", this.getTimeout())); - } - } - - /** - * Creates the service response. - * - * @param service The service. - * @param responseIndex Index of the response. - * @return Service response. - * @throws Exception the exception - */ - @Override - protected SubscribeResponse createServiceResponse( - ExchangeService service, int responseIndex) throws Exception { - return new SubscribeResponse(new PullSubscription( - service)); - } - - /** - * Gets the minimum server version required to process this request. - * - * @return Exchange server version. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the name of the subscription XML element. - * - * @return XML element name - */ - @Override - protected String getSubscriptionXmlElementName() { - return XmlElementNames.PullSubscriptionRequest; - } - - /** - * Reads response elements from XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void internalWriteElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Timeout, - this.getTimeout()); - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/SubscribeToPushNotificationsRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/SubscribeToPushNotificationsRequest.java deleted file mode 100644 index e7c30ed52..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/SubscribeToPushNotificationsRequest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.SubscribeResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.notification.PushSubscription; - -import javax.xml.stream.XMLStreamException; - -import java.net.URI; - -/** - * The Class SubscribeToPushNotificationsRequest. - */ -public class SubscribeToPushNotificationsRequest extends - SubscribeRequest { - - /** - * The frequency. - */ - private int frequency = 30; - - /** - * The url. - */ - private URI url; - - /** - * Instantiates a new subscribe to push notification request. - * - * @param service the service - * @throws Exception - */ - public SubscribeToPushNotificationsRequest(ExchangeService service) - throws Exception { - super(service); - } - - /* - * (non-Javadoc) - * - * @see microsoft.exchange.webservices.SubscribeRequest#validate() - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.getUrl(), "Url"); - if ((this.getFrequency() < 1) || (this.getFrequency() > 1440)) { - throw new ArgumentException(String.format( - "%d is not a valid frequency value. Valid values range from 1 to 1440.", this.getFrequency())); - } - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.SubscribeRequest - * #getSubscriptionXmlElementName - * () - */ - @Override - protected String getSubscriptionXmlElementName() { - return XmlElementNames.PushSubscriptionRequest; - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.SubscribeRequest - * #internalWriteElementsToXml - * (microsoft.exchange.webservices.EwsServiceXmlWriter) - */ - @Override - protected void internalWriteElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.StatusFrequency, this.getFrequency()); - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.URL, this - .getUrl().toString()); - } - - /* - * (non-Javadoc) - * - * @seemicrosoft.exchange.webservices.MultiResponseServiceRequest# - * createServiceResponse(microsoft.exchange.webservices.ExchangeService, - * int) - */ - @Override - protected SubscribeResponse createServiceResponse( - ExchangeService service, int responseIndex) throws Exception { - return new SubscribeResponse(new PushSubscription( - service)); - } - - /* - * (non-Javadoc) - * - * @seemicrosoft.exchange.webservices.ServiceRequestBase# - * getMinimumRequiredServerVersion() - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the frequency. - * - * @return the frequency - */ - public int getFrequency() { - return this.frequency; - } - - /** - * Sets the frequency. - * - * @param frequency the new frequency - */ - public void setFrequency(int frequency) { - this.frequency = frequency; - } - - /** - * Gets the url. - * - * @return the url - */ - public URI getUrl() { - return this.url; - } - - /** - * Sets the url. - * - * @param url the new url - */ - public void setUrl(URI url) { - this.url = url; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/SubscribeToStreamingNotificationsRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/SubscribeToStreamingNotificationsRequest.java deleted file mode 100644 index aa394e621..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/SubscribeToStreamingNotificationsRequest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.SubscribeResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.notification.StreamingSubscription; - -/** - * Defines the SubscribeToStreamingNotificationsRequest class. - */ -public class SubscribeToStreamingNotificationsRequest extends - SubscribeRequest { - - /** - * Initializes a new instance of the - * SubscribeToStreamingNotificationsRequest class. - * - * @param service The service - * @throws Exception - */ - public SubscribeToStreamingNotificationsRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Validate request. - * - * @throws Exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - - if (!(this.getWatermark() == null || this.getWatermark().isEmpty())) { - throw new ArgumentException( - "Watermarks cannot be used with StreamingSubscriptions."); - } - } - - - /** - * Gets the name of the subscription XML element. - * - * @return XmlElementsNames - */ - @Override - protected String getSubscriptionXmlElementName() { - return XmlElementNames.StreamingSubscriptionRequest; - } - - /** - * Internals the write elements to XML. - * - * @param writer The writer - */ - @Override - protected void internalWriteElementsToXml(EwsServiceXmlWriter writer) { - } - - /** - * Creates the service response. - * - * @param service The service - * @param responseIndex The responseIndex - * @return SubscribeResponse - * @throws Exception - */ - @Override - protected SubscribeResponse createServiceResponse(ExchangeService service, - int responseIndex) throws Exception { - return new SubscribeResponse( - new StreamingSubscription(service)); - } - - /** - * Gets the request version. - * - * @return ExchangeVersion - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010_SP1; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/SyncFolderHierarchyRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/SyncFolderHierarchyRequest.java deleted file mode 100644 index dbd5e6ebf..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/SyncFolderHierarchyRequest.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.SyncFolderHierarchyResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -/** - * Represents a SyncFolderHierarchy request. - */ -public class SyncFolderHierarchyRequest extends - MultiResponseServiceRequest { - - /** - * The property set. - */ - private PropertySet propertySet; - - /** - * The sync folder id. - */ - private FolderId syncFolderId; - - /** - * The sync state. - */ - private String syncState; - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception - */ - public SyncFolderHierarchyRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response. - */ - @Override - protected SyncFolderHierarchyResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new SyncFolderHierarchyResponse(this.getPropertySet()); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.SyncFolderHierarchy; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.SyncFolderHierarchyResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.SyncFolderHierarchyResponseMessage; - } - - /** - * Validates request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.getPropertySet(), "PropertySet"); - if (this.getSyncFolderId() != null) { - this.getSyncFolderId().validate( - this.getService().getRequestedServerVersion()); - } - - this.getPropertySet() - .validateForRequest(this, false /* summaryPropertiesOnly */); - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.getPropertySet().writeToXml(writer, ServiceObjectType.Folder); - - if (this.getSyncFolderId() != null) { - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.SyncFolderId); - this.getSyncFolderId().writeToXml(writer); - writer.writeEndElement(); - } - - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.SyncState, this.getSyncState()); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets or sets the property set. The property set. - * - * @return the property set - */ - public PropertySet getPropertySet() { - return this.propertySet; - } - - /** - * Sets the property set. - * - * @param value the new property set - */ - public void setPropertySet(PropertySet value) { - this.propertySet = value; - } - - /** - * Gets or sets the property set. The property set. - * - * @return the sync folder id - */ - public FolderId getSyncFolderId() { - return this.syncFolderId; - } - - /** - * Sets the sync folder id. - * - * @param value the new sync folder id - */ - public void setSyncFolderId(FolderId value) { - this.syncFolderId = value; - } - - /** - * Gets or sets the state of the sync. The state of the - * sync. - * - * @return the sync state - */ - public String getSyncState() { - return this.syncState; - } - - /** - * Sets the sync state. - * - * @param value the new sync state - */ - public void setSyncState(String value) { - this.syncState = value; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/SyncFolderItemsRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/SyncFolderItemsRequest.java deleted file mode 100644 index 42814b384..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/SyncFolderItemsRequest.java +++ /dev/null @@ -1,322 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.SyncFolderItemsResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType; -import microsoft.exchange.webservices.data.core.enumeration.service.SyncFolderItemsScope; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.misc.ItemIdWrapperList; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -/** - * Represents a SyncFolderItems request. - */ -public class SyncFolderItemsRequest extends - MultiResponseServiceRequest { - - /** - * The property set. - */ - private PropertySet propertySet; - - /** - * The sync folder id. - */ - private FolderId syncFolderId; - - /** - * The sync scope. - */ - private SyncFolderItemsScope syncScope; - - /** - * The sync state. - */ - private String syncState; - - /** - * The ignored item ids. - */ - private ItemIdWrapperList ignoredItemIds = new ItemIdWrapperList(); - - /** - * The max changes returned. - */ - private int maxChangesReturned = 100; - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception - */ - public SyncFolderItemsRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - } - - /** - * Creates service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response - */ - @Override - protected SyncFolderItemsResponse createServiceResponse( - ExchangeService service, int responseIndex) { - return new SyncFolderItemsResponse(this.getPropertySet()); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.SyncFolderItems; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.SyncFolderItemsResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.SyncFolderItemsResponseMessage; - } - - /** - * Validates request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.getPropertySet(), "PropertySet"); - EwsUtilities.validateParam(this.getSyncFolderId(), "SyncFolderId"); - this.getSyncFolderId().validate( - this.getService().getRequestedServerVersion()); - - // SyncFolderItemsScope enum was introduced with Exchange2010. Only - // value NormalItems is valid with previous server versions. - if (this.getService().getRequestedServerVersion().compareTo( - ExchangeVersion.Exchange2010) < 0 && - this.syncScope != SyncFolderItemsScope.NormalItems) { - throw new ServiceVersionException(String.format( - "Enumeration value %s in enumeration type %s is only valid for Exchange version %s or later.", this - .getSyncScope().toString(), this.getSyncScope() - .name(), ExchangeVersion.Exchange2010)); - } - - // SyncFolderItems can only handle summary property - this.getPropertySet() - .validateForRequest(this, true /* summaryPropertiesOnly */); - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.getPropertySet().writeToXml(writer, ServiceObjectType.Item); - - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.SyncFolderId); - this.getSyncFolderId().writeToXml(writer); - writer.writeEndElement(); - - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.SyncState, this.getSyncState()); - - this.getIgnoredItemIds().writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.Ignore); - - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.MaxChangesReturned, this - .getMaxChangesReturned()); - - if (this.getService().getRequestedServerVersion().compareTo( - ExchangeVersion.Exchange2010) >= 0) { - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.SyncScope, this.syncScope); - } - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets or sets the property set. The property set. - * - * @return the property set - */ - public PropertySet getPropertySet() { - return this.propertySet; - } - - /** - * Sets the property set. - * - * @param propertySet the new property set - */ - public void setPropertySet(PropertySet propertySet) { - this.propertySet = propertySet; - } - - /** - * Gets the sync folder id. The sync folder id. - * - * @return the sync folder id - */ - public FolderId getSyncFolderId() { - return this.syncFolderId; - } - - /** - * Sets the sync folder id. - * - * @param syncFolderId the new sync folder id - */ - public void setSyncFolderId(FolderId syncFolderId) { - this.syncFolderId = syncFolderId; - } - - /** - * Gets the scope of the sync. The scope of the - * sync. - * - * @return the sync scope - */ - public SyncFolderItemsScope getSyncScope() { - return this.syncScope; - } - - /** - * Sets the sync scope. - * - * @param syncScope the new sync scope - */ - public void setSyncScope(SyncFolderItemsScope syncScope) { - this.syncScope = syncScope; - } - - /** - * Gets the state of the sync. The state of the - * sync. - * - * @return the sync state - */ - public String getSyncState() { - return this.syncState; - } - - /** - * Sets the sync state. - * - * @param syncState the new sync state - */ - public void setSyncState(String syncState) { - this.syncState = syncState; - } - - /** - * Gets the list of ignored item ids. The ignored item ids. - * - * @return the ignored item ids - */ - public ItemIdWrapperList getIgnoredItemIds() { - return this.ignoredItemIds; - } - - /** - * Gets the maximum number of changes returned by SyncFolderItems. - * Values must be between 1 and 512. Default is 100. - * - * @return the max changes returned - */ - public int getMaxChangesReturned() { - - return this.maxChangesReturned; - } - - /** - * Sets the max changes returned. - * - * @param maxChangesReturned the new max changes returned - * @throws ArgumentException the argument exception - */ - public void setMaxChangesReturned(int maxChangesReturned) - throws ArgumentException { - if (maxChangesReturned >= 1 && maxChangesReturned <= 512) { - this.maxChangesReturned = maxChangesReturned; - } else { - throw new ArgumentException("MaxChangesReturned must be between 1 and 512."); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/UnsubscribeRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/UnsubscribeRequest.java deleted file mode 100644 index 6ec44556c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/UnsubscribeRequest.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * The Class UnsubscribeRequest. - */ -public class UnsubscribeRequest extends MultiResponseServiceRequest { - - /** - * The subscription id. - */ - private String subscriptionId; - - /** - * Instantiates a new unsubscribe request. - * - * @param service the service - * @throws Exception - */ - public UnsubscribeRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - } - - /** - * Creates service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response. - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new ServiceResponse(); - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } - - /** - * Gets the name of the XML element. - * - * @return Xml element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.Unsubscribe; - } - - /** - * Gets the name of the response XML element. - * - * @return Xml element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.UnsubscribeResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return Xml element name. - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.UnsubscribeResponseMessage; - } - - /** - * Validate the request. - * - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - @Override - protected void validate() throws ServiceLocalException, Exception { - super.validate(); - EwsUtilities.validateNonBlankStringParam(this. - getSubscriptionId(), "SubscriptionId"); - - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.SubscriptionId, this.getSubscriptionId()); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the subscription id. - * - * @return the subscription id - */ - public String getSubscriptionId() { - return this.subscriptionId; - } - - /** - * Sets the subscription id. - * - * @param subscriptionId the new subscription id - */ - public void setSubscriptionId(String subscriptionId) { - this.subscriptionId = subscriptionId; - } - @Override - protected HttpWebRequest buildEwsHttpWebRequest() throws Exception - { - return super.buildEwsHttpPoolingWebRequest(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateDelegateRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateDelegateRequest.java deleted file mode 100644 index 968fe62c9..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateDelegateRequest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.DelegateManagementResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.MeetingRequestsDeliveryScope; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.DelegateUser; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents an UpdateDelegate request. - */ -public class UpdateDelegateRequest extends - DelegateManagementRequestBase { - - /** - * The delegate users. - */ - private List delegateUsers = new ArrayList(); - - /** - * The meeting request delivery scope. - */ - private MeetingRequestsDeliveryScope meetingRequestsDeliveryScope; - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception - */ - public UpdateDelegateRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParamCollection(this.getDelegateUsers().iterator(), "DelegateUsers"); - for (DelegateUser delegateUser : this.getDelegateUsers()) { - delegateUser.validateUpdateDelegate(); - } - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - super.writeElementsToXml(writer); - - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.DelegateUsers); - - for (DelegateUser delegateUser : this.getDelegateUsers()) { - delegateUser.writeToXml(writer, XmlElementNames.DelegateUser); - } - - writer.writeEndElement(); // DelegateUsers - - if (this.getMeetingRequestsDeliveryScope() != null) { - writer.writeElementValue(XmlNamespace.Messages, - XmlElementNames.DeliverMeetingRequests, this - .getMeetingRequestsDeliveryScope()); - } - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.UpdateDelegateResponse; - } - - /** - * Creates the response. - * - * @return Response object. - */ - @Override - protected DelegateManagementResponse createResponse() { - return new DelegateManagementResponse(true, this.delegateUsers); - } - - /** - * Gets the name of the XML element. - * - * @return Xml element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.UpdateDelegate; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the meeting request delivery scope. - * - * @return the meeting request delivery scope - */ - public MeetingRequestsDeliveryScope getMeetingRequestsDeliveryScope() { - return this.meetingRequestsDeliveryScope; - } - - /** - * Sets the meeting request delivery scope. - * - * @param value the new meeting request delivery scope - */ - public void setMeetingRequestsDeliveryScope( - MeetingRequestsDeliveryScope value) { - this.meetingRequestsDeliveryScope = value; - } - - /** - * Gets the delegate users. - * - * @return the delegate users - */ - public List getDelegateUsers() { - return this.delegateUsers; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateFolderRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateFolderRequest.java deleted file mode 100644 index e0cfa8a77..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateFolderRequest.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.response.UpdateFolderResponse; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -import java.util.ArrayList; - -/** - * Represents an UpdateFolder request. - */ -public final class UpdateFolderRequest extends - MultiResponseServiceRequest { - - /** - * The folder. - */ - private ArrayList folders = new ArrayList(); - - /** - * Initializes a new instance of the UpdateFolderRequest class. - * - * @param service The Servcie - * @param errorHandlingMode Indicates how errors should be handled. - * @throws Exception - */ - public UpdateFolderRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /** - * validates request. - * - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - @Override - protected void validate() throws ServiceLocalException, Exception { - super.validate(); - EwsUtilities.validateParamCollection(this.getFolders().iterator(), "Folders"); - for (int i = 0; i < this.getFolders().size(); i++) { - Folder folder = this.getFolders().get(i); - - if ((folder == null) || folder.isNew()) { - throw new IllegalArgumentException(String.format("Folders[%d] is either null or does not have an Id.", i)); - } - - folder.validate(); - } - } - - /** - * Creates the service response. - * - * @param session The session - * @param responseIndex Index of the response. - * @return Service response. - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService session, - int responseIndex) { - return new UpdateFolderResponse(this.getFolders().get(responseIndex)); - } - - /** - * Gets the name of the XML element. - * - * @return Xml element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.UpdateFolder; - } - - /** - * Gets the name of the response XML element. - * - * @return Xml element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.UpdateFolderResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return Xml element name. - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.UpdateFolderResponseMessage; - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.getFolders().size(); - } - - /** - * Writes to xml. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.FolderChanges); - - for (Folder folder : this.folders) { - folder.writeToXmlForUpdate(writer); - } - - writer.writeEndElement(); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the folder. - * - * @return the folder - */ - public ArrayList getFolders() { - return this.folders; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateInboxRulesRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateInboxRulesRequest.java deleted file mode 100644 index bba576eb2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateInboxRulesRequest.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.UpdateInboxRulesResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceResult; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.remote.UpdateInboxRulesException; -import microsoft.exchange.webservices.data.property.complex.RuleOperation; - -/** - * Represents a UpdateInboxRulesRequest request. - */ -public final class UpdateInboxRulesRequest extends SimpleServiceRequestBase { - /** - * The smtp address of the mailbox from which to get the inbox rules. - */ - private String mailboxSmtpAddress; - - /** - * Remove OutlookRuleBlob or not. - */ - private boolean removeOutlookRuleBlob; - - /** - * InboxRule operation collection. - */ - private Iterable inboxRuleOperations; - - /** - * Initializes a new instance of the - * class. - * - * @param service The service. - */ - public UpdateInboxRulesRequest(ExchangeService service) - throws Exception { - super(service); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.UpdateInboxRules; - } - - /** - * Writes XML elements. - * - * @param writer The writer. - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - if (!(mailboxSmtpAddress == null || mailboxSmtpAddress.isEmpty())) { - writer.writeElementValue( - XmlNamespace.Messages, - XmlElementNames.MailboxSmtpAddress, - this.mailboxSmtpAddress); - } - - writer.writeElementValue( - XmlNamespace.Messages, - XmlElementNames.RemoveOutlookRuleBlob, - this.removeOutlookRuleBlob); - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.Operations); - for (RuleOperation operation : this.inboxRuleOperations) { - operation.writeToXml(writer, operation.getXmlElementName()); - } - writer.writeEndElement(); - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name. - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.UpdateInboxRulesResponse; - } - - /** - * {@inheritDoc} - */ - @Override - protected UpdateInboxRulesResponse parseResponse(EwsServiceXmlReader reader) - throws Exception { - UpdateInboxRulesResponse response = new UpdateInboxRulesResponse(); - response.loadFromXml(reader, XmlElementNames.UpdateInboxRulesResponse); - return response; - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010_SP1; - } - - /** - * Validate request. - */ - @Override - protected void validate() throws Exception { - if (this.inboxRuleOperations == null) { - throw new IllegalArgumentException( - "RuleOperations cannot be null." + "Operations"); - } - - int operationCount = 0; - for (RuleOperation operation : this.inboxRuleOperations) { - EwsUtilities.validateParam(operation, "RuleOperation"); - operationCount++; - } - - if (operationCount == 0) { - throw new IllegalArgumentException( - "RuleOperations cannot be empty." + "Operations"); - } - - this.getService().validate(); - } - - /** - * Executes this request. - * - * @return Service response. - * @throws Exception on error - */ - public UpdateInboxRulesResponse execute() throws Exception { - UpdateInboxRulesResponse serviceResponse = internalExecute(); - if (serviceResponse.getResult() == ServiceResult.Error) { - throw new UpdateInboxRulesException(serviceResponse, - this.inboxRuleOperations); - } - return serviceResponse; - } - - /** - * Gets the address of the mailbox in which to update the inbox rules. - */ - protected String getMailboxSmtpAddress() { - return this.mailboxSmtpAddress; - } - - /** - * Sets the address of the mailbox in which to update the inbox rules. - */ - public void setMailboxSmtpAddress(String value) { - this.mailboxSmtpAddress = value; - } - - /** - * Gets a value indicating whether or not to - * remove OutlookRuleBlob from the rule collection. - */ - protected boolean getRemoveOutlookRuleBlob() { - return this.removeOutlookRuleBlob; - } - - /** - * Sets a value indicating whether or not to - * remove OutlookRuleBlob from the rule collection. - */ - public void setRemoveOutlookRuleBlob(boolean value) { - this.removeOutlookRuleBlob = value; - } - - - /** - * Gets the RuleOperation collection. - */ - protected Iterable getInboxRuleOperations() { - return this.inboxRuleOperations; - } - - /** - * Sets the RuleOperation collection. - */ - public void setInboxRuleOperations(Iterable value) { - this.inboxRuleOperations = value; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateItemRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateItemRequest.java deleted file mode 100644 index 063f1e0a5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateItemRequest.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.UpdateItemResponse; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.service.ConflictResolutionMode; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition; -import microsoft.exchange.webservices.data.core.enumeration.service.SendInvitationsOrCancellationsMode; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -import java.util.ArrayList; -import java.util.List; - -/** - * The Class UpdateItemRequest. - */ -public final class UpdateItemRequest extends - MultiResponseServiceRequest { - - /** - * The item. - */ - private List items = new ArrayList(); - - /** - * The saved item destination folder. - */ - private FolderId savedItemsDestinationFolder; - - /** - * The conflict resolution mode. - */ - private ConflictResolutionMode conflictResolutionMode; - - /** - * The message disposition. - */ - private MessageDisposition messageDisposition; - - /** - * The send invitations or cancellations mode. - */ - private SendInvitationsOrCancellationsMode - sendInvitationsOrCancellationsMode; - - /** - * Instantiates a new update item request. - * - * @param service the service - * @param errorHandlingMode the error handling mode - * @throws Exception - */ - public UpdateItemRequest(ExchangeService service, ServiceErrorHandling errorHandlingMode) - throws Exception { - super(service, errorHandlingMode); - } - - /* - * (non-Javadoc) - * - * @see microsoft.exchange.webservices.ServiceRequestBase#validate() - */ - @Override - protected void validate() throws ServiceLocalException, Exception { - super.validate(); - EwsUtilities.validateParamCollection(this.getItems().iterator(), "Items"); - for (int i = 0; i < this.getItems().size(); i++) { - if ((this.getItems().get(i) == null) || - this.getItems().get(i).isNew()) { - throw new ArgumentException(String.format("Items[%d] is either null or does not have an Id.", i)); - } - } - - if (this.savedItemsDestinationFolder != null) { - this.savedItemsDestinationFolder.validate(this.getService() - .getRequestedServerVersion()); - } - - // Validate each item. - for (Item item : this.getItems()) { - item.validate(); - } - } - - /* - * (non-Javadoc) - * - * @seemicrosoft.exchange.webservices.MultiResponseServiceRequest# - * createServiceResponse(microsoft.exchange.webservices.ExchangeService, - * int) - */ - @Override - protected UpdateItemResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new UpdateItemResponse(this.getItems().get(responseIndex)); - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.ServiceRequestBase#getXmlElementName() - */ - @Override public String getXmlElementName() { - return XmlElementNames.UpdateItem; - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.ServiceRequestBase - * #getResponseXmlElementName - * () - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.UpdateItemResponse; - } - - /* - * (non-Javadoc) - * - * @seemicrosoft.exchange.webservices.MultiResponseServiceRequest# - * getResponseMessageXmlElementName() - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.UpdateItemResponseMessage; - } - - /* - * (non-Javadoc) - * - * @seemicrosoft.exchange.webservices.MultiResponseServiceRequest# - * getExpectedResponseMessageCount() - */ - @Override - protected int getExpectedResponseMessageCount() { - return this.items.size(); - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.ServiceRequestBase#writeAttributesToXml - * (microsoft.exchange.webservices.EwsServiceXmlWriter) - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - - if (this.messageDisposition != null) { - writer.writeAttributeValue(XmlAttributeNames.MessageDisposition, - this.messageDisposition); - } - - writer.writeAttributeValue(XmlAttributeNames.ConflictResolution, - this.conflictResolutionMode); - - if (this.sendInvitationsOrCancellationsMode != null) { - writer.writeAttributeValue( - XmlAttributeNames.SendMeetingInvitationsOrCancellations, - this.sendInvitationsOrCancellationsMode); - } - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.ServiceRequestBase#writeElementsToXml( - * microsoft.exchange.webservices.EwsServiceXmlWriter) - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - if (this.savedItemsDestinationFolder != null) { - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.SavedItemFolderId); - this.savedItemsDestinationFolder.writeToXml(writer); - writer.writeEndElement(); - } - - writer.writeStartElement(XmlNamespace.Messages, - XmlElementNames.ItemChanges); - - for (Item item : this.items) { - item.writeToXmlForUpdate(writer); - } - - writer.writeEndElement(); - } - - /* - * (non-Javadoc) - * - * @seemicrosoft.exchange.webservices.ServiceRequestBase# - * getMinimumRequiredServerVersion() - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the message disposition. - * - * @return the message disposition - */ - public MessageDisposition getMessageDisposition() { - return this.messageDisposition; - } - - /** - * Sets the message disposition. - * - * @param value the new message disposition - */ - public void setMessageDisposition(MessageDisposition value) { - this.messageDisposition = value; - } - - /** - * Gets the conflict resolution mode. - * - * @return the conflict resolution mode - */ - public ConflictResolutionMode getConflictResolutionMode() { - return this.conflictResolutionMode; - } - - /** - * Sets the conflict resolution mode. - * - * @param value the new conflict resolution mode - */ - public void setConflictResolutionMode(ConflictResolutionMode value) { - this.conflictResolutionMode = value; - } - - /** - * Gets the send invitations or cancellations mode. - * - * @return the send invitations or cancellations mode - */ - public SendInvitationsOrCancellationsMode - getSendInvitationsOrCancellationsMode() { - return this.sendInvitationsOrCancellationsMode; - } - - /** - * Sets the send invitations or cancellations mode. - * - * @param value the new send invitations or cancellations mode - */ - public void setSendInvitationsOrCancellationsMode( - SendInvitationsOrCancellationsMode value) { - this.sendInvitationsOrCancellationsMode = value; - } - - /** - * Gets the item. - * - * @return the item - */ - public List getItems() { - return this.items; - } - - /** - * Gets the saved item destination folder. - * - * @return the saved item destination folder - */ - public FolderId getSavedItemsDestinationFolder() { - return this.savedItemsDestinationFolder; - } - - /** - * Sets the saved item destination folder. - * - * @param value the new saved item destination folder - */ - public void setSavedItemsDestinationFolder(FolderId value) { - this.savedItemsDestinationFolder = value; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateUserConfigurationRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateUserConfigurationRequest.java deleted file mode 100644 index a64310e91..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/request/UpdateUserConfigurationRequest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.request; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.response.ServiceResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.UserConfiguration; - -/** - * Represents a UpdateUserConfiguration request. - */ -public class UpdateUserConfigurationRequest extends - MultiResponseServiceRequest { - - /** - * The user configuration. - */ - protected UserConfiguration userConfiguration; - - /** - * Validate request. - * - * @throws Exception the exception - */ - @Override - protected void validate() throws Exception { - super.validate(); - EwsUtilities.validateParam(this.userConfiguration, "userConfiguration"); - } - - /** - * Creates the service response. - * - * @param service the service - * @param responseIndex the response index - * @return Service response. - */ - @Override - protected ServiceResponse createServiceResponse(ExchangeService service, - int responseIndex) { - return new ServiceResponse(); - } - - /** - * Gets the request version. - * - * @return Earliest Exchange version in which this request is supported. - */ - @Override - protected ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010; - } - - /** - * Gets the expected response message count. - * - * @return Number of expected response messages. - */ - @Override - protected int getExpectedResponseMessageCount() { - return 1; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override public String getXmlElementName() { - return XmlElementNames.UpdateUserConfiguration; - } - - /** - * Gets the name of the response XML element. - * - * @return XML element name - */ - @Override - protected String getResponseXmlElementName() { - return XmlElementNames.UpdateUserConfigurationResponse; - } - - /** - * Gets the name of the response message XML element. - * - * @return XML element name - */ - @Override - protected String getResponseMessageXmlElementName() { - return XmlElementNames.UpdateUserConfigurationResponseMessage; - } - - /** - * Writes XML elements. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - // Write UserConfiguation element - this.userConfiguration.writeToXml(writer, XmlNamespace.Messages, - XmlElementNames.UserConfiguration); - } - - /** - * Initializes a new instance of the class. - * - * @param service the service - * @throws Exception on error - */ - public UpdateUserConfigurationRequest(ExchangeService service) - throws Exception { - super(service, ServiceErrorHandling.ThrowOnError); - } - - /** - * Gets the user configuration. - * - * @return the user configuration - */ - public UserConfiguration getUserConfiguration() { - return this.userConfiguration; - } - - /** - * Sets the user configuration. - * - * @param userConfiguration the new user configuration - */ - public void setUserConfiguration(UserConfiguration userConfiguration) { - this.userConfiguration = userConfiguration; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/AttendeeAvailability.java b/src/main/java/microsoft/exchange/webservices/data/core/response/AttendeeAvailability.java deleted file mode 100644 index d888d551f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/AttendeeAvailability.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.availability.FreeBusyViewType; -import microsoft.exchange.webservices.data.core.enumeration.property.LegacyFreeBusyStatus; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.availability.CalendarEvent; -import microsoft.exchange.webservices.data.property.complex.availability.WorkingHours; - -import java.util.ArrayList; -import java.util.Collection; - -/** - * Represents the availability of an individual attendee. - */ -public final class AttendeeAvailability extends ServiceResponse { - - /** - * The calendar events. - */ - private Collection calendarEvents = - new ArrayList(); - - /** - * The merged free busy status. - */ - private Collection mergedFreeBusyStatus = - new ArrayList(); - - /** - * The view type. - */ - private FreeBusyViewType viewType; - - /** - * The working hours. - */ - private WorkingHours workingHours; - - /** - * Initializes a new instance of the AttendeeAvailability class. - */ - public AttendeeAvailability() { - super(); - } - - /** - * Loads the free busy view from XML. - * - * @param reader the reader - * @param viewType the view type - * @throws Exception the exception - */ - public void loadFreeBusyViewFromXml(EwsServiceXmlReader reader, FreeBusyViewType viewType) throws Exception { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.FreeBusyView); - - String viewTypeString = reader.readElementValue(XmlNamespace.Types, - XmlElementNames.FreeBusyViewType); - - for (Object o : FreeBusyViewType.class.getEnumConstants()) { - if (o.toString().equals(viewTypeString)) { - this.viewType = (FreeBusyViewType) o; - break; - } - } - do { - reader.read(); - - if (reader.isStartElement()) { - if (reader.getLocalName() - .equals(XmlElementNames.MergedFreeBusy)) { - String mergedFreeBusy = reader.readElementValue(); - - for (int i = 0; i < mergedFreeBusy.length(); i++) { - - Byte b = Byte.parseByte(mergedFreeBusy.charAt(i) + ""); - for (LegacyFreeBusyStatus legacyStatus : LegacyFreeBusyStatus.values()) { - if (b == legacyStatus.getBusyStatus()) { - this.mergedFreeBusyStatus.add(legacyStatus); - break; - } - } - - } - - } else if (reader.getLocalName().equals( - XmlElementNames.CalendarEventArray)) { - do { - reader.read(); - - if (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.CalendarEvent)) { - CalendarEvent calendarEvent = new CalendarEvent(); - - calendarEvent.loadFromXml(reader, - XmlElementNames.CalendarEvent); - - this.calendarEvents.add(calendarEvent); - } - } while (!reader.isEndElement(XmlNamespace.Types, - XmlElementNames.CalendarEventArray)); - - } else if (reader.getLocalName().equals( - XmlElementNames.WorkingHours)) { - this.workingHours = new WorkingHours(); - this.workingHours - .loadFromXml(reader, reader.getLocalName()); - - break; - } - } - } while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.FreeBusyView)); - } - - /** - * Gets a collection of calendar events for the attendee. - * - * @return the calendar events - */ - public Collection getCalendarEvents() { - return this.calendarEvents; - } - - /** - * Gets a collection of merged free/busy status for the attendee. - * - * @return the merged free busy status - */ - public Collection getMergedFreeBusyStatus() { - return mergedFreeBusyStatus; - } - - /** - * Gets the free/busy view type that wes retrieved for the attendee. - * - * @return the view type - */ - public FreeBusyViewType getViewType() { - return viewType; - } - - /** - * Gets the working hours of the attendee. - * - * @return the working hours - */ - public WorkingHours getWorkingHours() { - return workingHours; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/ConvertIdResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/ConvertIdResponse.java deleted file mode 100644 index a752f2c2d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/ConvertIdResponse.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.misc.id.AlternateId; -import microsoft.exchange.webservices.data.misc.id.AlternateIdBase; -import microsoft.exchange.webservices.data.misc.id.AlternatePublicFolderId; -import microsoft.exchange.webservices.data.misc.id.AlternatePublicFolderItemId; - -/** - * Represents the response to an individual Id conversion operation. - */ -public final class ConvertIdResponse extends ServiceResponse { - - /** - * The converted id. - */ - private AlternateIdBase convertedId; - - /** - * Initializes a new instance of the class. - */ - public ConvertIdResponse() { - super(); - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws InstantiationException the instantiation exception - * @throws IllegalAccessException the illegal access exception - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws InstantiationException, IllegalAccessException, ServiceLocalException, Exception { - super.readElementsFromXml(reader); - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.AlternateId); - String alternateIdClass = reader.readAttributeValue( - XmlNamespace.XmlSchemaInstance, XmlAttributeNames.Type); - - int aliasSeparatorIndex = alternateIdClass.indexOf(':'); - - if (aliasSeparatorIndex > -1) { - alternateIdClass = alternateIdClass - .substring(aliasSeparatorIndex + 1); - } - - // Alternate Id classes are responsible fro reading the AlternateId end - // element when necessary - if (alternateIdClass.equals(AlternateId.SchemaTypeName)) { - this.convertedId = new AlternateId(); - } else if (alternateIdClass - .equals(AlternatePublicFolderId.SchemaTypeName)) { - this.convertedId = new AlternatePublicFolderId(); - } else if (alternateIdClass - .equals(AlternatePublicFolderItemId.SchemaTypeName)) { - this.convertedId = new AlternatePublicFolderItemId(); - } else { - EwsUtilities - .ewsAssert(false, "ConvertIdResponse.ReadElementsFromXml", - String.format("Unknown alternate Id class: %s", alternateIdClass)); - } - - this.convertedId.loadAttributesFromXml(reader); - reader.readEndElement(XmlNamespace.Messages, - XmlElementNames.AlternateId); - } - - /** - * Reads response elements from XML. - * - * @return the converted id - */ - public AlternateIdBase getConvertedId() { - return this.convertedId; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/CreateAttachmentResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/CreateAttachmentResponse.java deleted file mode 100644 index 5883138a0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/CreateAttachmentResponse.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.Attachment; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -/** - * Represents the response to an individual attachment creation operation. - */ -public final class CreateAttachmentResponse extends ServiceResponse { - - /** - * The attachment. - */ - private Attachment attachment; - - /** - * Initializes a new instance of the CreateAttachmentResponse class. - * - * @param attachment the attachment - */ - public CreateAttachmentResponse(Attachment attachment) { - super(); - EwsUtilities.ewsAssert(attachment != null, "CreateAttachmentResponse.ctor", "attachment is null"); - - this.attachment = attachment; - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.Attachments); - - // reader.read(XmlNodeType.START_ELEMENT); - XmlNodeType x = new XmlNodeType(XmlNodeType.START_ELEMENT); - reader.read(x); - this.attachment.loadFromXml(reader, reader.getLocalName()); - - reader.readEndElement(XmlNamespace.Messages, - XmlElementNames.Attachments); - } - - /** - * Gets the attachment that was created. - * - * @return the attachment - */ - public Attachment getAttachment() { - return this.attachment; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/CreateFolderResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/CreateFolderResponse.java deleted file mode 100644 index 6b2934e56..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/CreateFolderResponse.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceResult; - -import java.util.List; - -/** - * Represents the response to an individual folder creation operation. - */ -public final class CreateFolderResponse extends ServiceResponse implements - IGetObjectInstanceDelegate { - - /** - * The folder. - */ - private Folder folder; - - /** - * Initializes a new instance of the CreateFolderResponse class. - * - * @param folder The folder. - */ - public CreateFolderResponse(Folder folder) { - super(); - this.folder = folder; - } - - /** - * Gets the object instance. - * - * @param service The service. - * @param xmlElementName Name of the XML element. - * @return Folder - * @throws Exception the exception - */ - private Folder getObjectInstance(ExchangeService service, - String xmlElementName) throws Exception { - if (this.folder != null) { - return this.folder; - } else { - return EwsUtilities.createEwsObjectFromXmlElementName(Folder.class, service, xmlElementName); - } - } - - /** - * Reads response elements from XML. - * - * @param reader The reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - - List folders = reader.readServiceObjectsCollectionFromXml( - XmlElementNames.Folders, this, false, /* clearPropertyBag */ - null, /* requestedPropertySet */ - false); /* summaryPropertiesOnly */ - - this.folder = folders.get(0); - } - - /** - * Gets the object instance delegate. - * - * @param service the service - * @param xmlElementName the xml element name - * @return the object instance delegate - * @throws Exception the exception - */ - @Override - public ServiceObject getObjectInstanceDelegate(ExchangeService service, - String xmlElementName) throws Exception { - return this.getObjectInstance(service, xmlElementName); - } - - /** - * Clears the change log of the created folder if the creation succeeded. - */ - @Override - protected void loaded() { - if (this.getResult() == ServiceResult.Success) { - this.folder.clearChangeLog(); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/CreateItemResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/CreateItemResponse.java deleted file mode 100644 index 8e9f4f9c5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/CreateItemResponse.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceResult; - -/** - * Represents the response to an individual item creation operation. - */ -public final class CreateItemResponse extends CreateItemResponseBase { - - /** - * The item. - */ - private Item item; - - /** - * Gets Item instance. - * - * @param service The service. - * @param xmlElementName Name of the XML element. - * @return the object instance - */ - @Override - protected Item getObjectInstance(ExchangeService service, - String xmlElementName) { - return this.item; - } - - /** - * Initializes a new instance. - * - * @param item The item. - */ - public CreateItemResponse(Item item) { - super(); - this.item = item; - } - - /** - * Clears the change log of the created folder if the creation succeeded. - */ - @Override - protected void loaded() { - if (this.getResult() == ServiceResult.Success) { - this.item.clearChangeLog(); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/CreateItemResponseBase.java b/src/main/java/microsoft/exchange/webservices/data/core/response/CreateItemResponseBase.java deleted file mode 100644 index 9a24ffae3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/CreateItemResponseBase.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; - -import java.util.List; - -/** - * Represents the base response class for item creation operations. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -abstract class CreateItemResponseBase extends ServiceResponse implements - IGetObjectInstanceDelegate { - - /** - * The item. - */ - private List items; - - /** - * Gets Item instance. - * - * @param service The service. - * @param xmlElementName Name of the XML element. - * @return Item. - * @throws InstantiationException the instantiation exception - * @throws IllegalAccessException the illegal access exception - * @throws Exception the exception - */ - protected abstract Item getObjectInstance(ExchangeService service, - String xmlElementName) throws InstantiationException, - IllegalAccessException, Exception; - - /** - * Gets the object instance delegate. - * - * @param service accepts ExchangeService - * @param xmlElementName accepts String - * @return object - * @throws Exception throws Exception - */ - public ServiceObject getObjectInstanceDelegate(ExchangeService service, - String xmlElementName) throws Exception { - return this.getObjectInstance(service, xmlElementName); - } - - /** - * Initializes a new instance. - */ - protected CreateItemResponseBase() { - super(); - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - this.items = reader.readServiceObjectsCollectionFromXml( - XmlElementNames.Items, this, false, /* clearPropertyBag */ - null, /* requestedPropertySet */ - false); /* summaryPropertiesOnly */ - } - - /** - * Gets the item. - * - * @return List of item. - */ - public List getItems() { - return items; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/CreateResponseObjectResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/CreateResponseObjectResponse.java deleted file mode 100644 index 369baf4a7..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/CreateResponseObjectResponse.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Represents response to generic Create request. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) public final class CreateResponseObjectResponse extends CreateItemResponseBase { - - private static final Log LOG = LogFactory.getLog(CreateResponseObjectResponse.class); - - /** - * Gets Item instance. - * - * @param service The service. - * @param xmlElementName Name of the XML element. - * @return Item. - * @throws Exception the exception - */ - @Override - protected Item getObjectInstance(ExchangeService service, - String xmlElementName) throws Exception { - try { - return EwsUtilities.createEwsObjectFromXmlElementName(Item.class, service, xmlElementName); - } catch (InstantiationException e) { - LOG.error(e); - return null; - } catch (IllegalAccessException e) { - LOG.error(e); - return null; - } - } - - /** - * Initializes a new instance of the CreateResponseObjectResponse class. - */ - public CreateResponseObjectResponse() { - super(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/DelegateManagementResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/DelegateManagementResponse.java deleted file mode 100644 index 8f0a27ad1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/DelegateManagementResponse.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.error.ServiceError; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.DelegateUser; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * Represents the response to a delegate managent-related operation. - */ -public class DelegateManagementResponse extends ServiceResponse { - - /** - * The read delegate users. - */ - private boolean readDelegateUsers; - - /** - * The delegate users. - */ - private List delegateUsers; - - /** - * The delegate user response. - */ - private Collection delegateUserResponses; - - /** - * Initializes a new instance of the class. - * - * @param readDelegateUsers the read delegate users - * @param delegateUsers the delegate users - */ - public DelegateManagementResponse(boolean readDelegateUsers, List delegateUsers) { - super(); - this.readDelegateUsers = readDelegateUsers; - this.delegateUsers = delegateUsers; - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - if (this.getErrorCode() == ServiceError.NoError) { - this.delegateUserResponses = new ArrayList(); - - reader.read(); - - if (reader.isStartElement(XmlNamespace.Messages, - XmlElementNames.ResponseMessages)) { - int delegateUserIndex = 0; - do { - reader.read(); - if (reader.isStartElement(XmlNamespace.Messages, - XmlElementNames.DelegateUserResponseMessageType)) { - DelegateUser delegateUser = null; - if (this.readDelegateUsers && - (this.delegateUsers != null)) { - delegateUser = this.delegateUsers - .get(delegateUserIndex); - } - - DelegateUserResponse delegateUserResponse = - new DelegateUserResponse( - readDelegateUsers, delegateUser); - delegateUserResponse - .loadFromXml( - reader, - XmlElementNames. - DelegateUserResponseMessageType); - this.delegateUserResponses.add(delegateUserResponse); - - delegateUserIndex++; - } - } while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.ResponseMessages)); - } - } - } - - /** - * Gets a collection of response for each of the delegate users concerned - * by the operation. - * - * @return the delegate user response - */ - public Collection getDelegateUserResponses() { - return this.delegateUserResponses; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/DelegateUserResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/DelegateUserResponse.java deleted file mode 100644 index 80bb24942..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/DelegateUserResponse.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.DelegateUser; - -/** - * Represents the response to an individual delegate user manipulation (add, - * remove, update) operation. - */ -public final class DelegateUserResponse extends ServiceResponse { - - /** - * The read delegate user. - */ - private boolean readDelegateUser; - - /** - * The delegate user. - */ - private DelegateUser delegateUser; - - /** - * Initializes a new instance of the class. - * - * @param readDelegateUser the read delegate user - * @param delegateUser the delegate user - */ - protected DelegateUserResponse(boolean readDelegateUser, - DelegateUser delegateUser) { - super(); - this.readDelegateUser = readDelegateUser; - this.delegateUser = delegateUser; - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - if (this.readDelegateUser) { - if (this.delegateUser == null) { - this.delegateUser = new DelegateUser(); - } - - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.DelegateUser); - - this.delegateUser.loadFromXml(reader, XmlNamespace.Messages, reader - .getLocalName()); - } - } - - /** - * The delegate user that was involved in the operation. - * - * @return the delegate user - */ - public DelegateUser getDelegateUser() { - return this.delegateUser; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/DeleteAttachmentResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/DeleteAttachmentResponse.java deleted file mode 100644 index a22deb0ad..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/DeleteAttachmentResponse.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.Attachment; - -/** - * Represents the response to an individual attachment deletion operation. - */ -public final class DeleteAttachmentResponse extends ServiceResponse { - - /** - * The attachment. - */ - private Attachment attachment; - - /** - * Initializes a new instance of the DeleteAttachmentResponse class. - * - * @param attachment the attachment - */ - public DeleteAttachmentResponse(Attachment attachment) { - super(); - EwsUtilities.ewsAssert(attachment != null, "DeleteAttachmentResponse.ctor", "attachment is null"); - - this.attachment = attachment; - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws ServiceLocalException, Exception { - super.readElementsFromXml(reader); - - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.RootItemId); - - String changeKey = reader - .readAttributeValue(XmlAttributeNames.RootItemChangeKey); - if (!(null == changeKey || changeKey.isEmpty())) { - this.attachment.getOwner().getRootItemId().setChangeKey(changeKey); - } - reader.readEndElement(XmlNamespace.Messages, - XmlElementNames.RootItemId); - } - - /** - * Gets the attachment that was deleted. - * - * @return the attachment - */ - public Attachment getAttachment() { - return this.attachment; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/ExecuteDiagnosticMethodResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/ExecuteDiagnosticMethodResponse.java deleted file mode 100644 index f67322ab0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/ExecuteDiagnosticMethodResponse.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.events.Attribute; -import javax.xml.stream.events.Namespace; -import javax.xml.stream.events.StartElement; -import javax.xml.stream.events.XMLEvent; - -import java.util.Iterator; - - -/** - * Represents the response to a ExecuteDiagnosticMethod operation - */ -public final class ExecuteDiagnosticMethodResponse extends ServiceResponse { - - - /** - * Initializes a new instance of the ExecuteDiagnosticMethodResponse class. - * - * @param service The service - */ - public ExecuteDiagnosticMethodResponse(ExchangeService service) { - super(); - EwsUtilities.ewsAssert(service != null, "ExecuteDiagnosticMethodResponse.ctor", "service is null"); - } - - /** - * Reads response elements from XML. - * - * @throws Exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.ReturnValue); - - XMLEventReader returnValueReader = reader.getXmlReaderForNode(); - //this.returnValue = (Document) new SafeXmlDocument(); - { - this.returnValue = retriveDocument(returnValueReader); - } - - reader.skipCurrentElement(); - reader.readEndElementIfNecessary(XmlNamespace.Messages, - XmlElementNames.ReturnValue); - } - - - /** - * @return document - * @throws javax.xml.parsers.ParserConfigurationException - */ - public Document retriveDocument(XMLEventReader xmlEventReader) - throws ParserConfigurationException { - DocumentBuilderFactory dbfInstance = DocumentBuilderFactory - .newInstance(); - DocumentBuilder documentBuilder = dbfInstance.newDocumentBuilder(); - Document document = documentBuilder.newDocument(); - - Element currentElement = document.getDocumentElement(); - - while (xmlEventReader.hasNext()) { - XMLEvent xmleve = (XMLEvent) xmlEventReader.next(); - - if (xmleve.getEventType() == XmlNodeType.END_ELEMENT) { - Node node = currentElement.getParentNode(); - if (node instanceof Document) { - currentElement = ((Document) node).getDocumentElement(); - } else { - currentElement = (Element) currentElement.getParentNode(); - } - } - - if (xmleve.getEventType() == XmlNodeType.START_ELEMENT) { - // startElement((StartElement) xmleve,doc); - StartElement ele = (StartElement) xmleve; - Element element = null; - element = document.createElementNS(ele.getName() - .getNamespaceURI(), ele.getName().getLocalPart()); - - Iterator ite = ele.getAttributes(); - - while (ite.hasNext()) { - Attribute attr = ite.next(); - element.setAttribute(attr.getName().getLocalPart(), - attr.getValue()); - } - - String xmlns = EwsUtilities.WSTrustFebruary2005Namespace;//"http://schemas.xmlsoap.org/wsdl/"; - ite = ele.getNamespaces(); - while (ite.hasNext()) { - Namespace ns = (Namespace) ite.next(); - String name = ns.getPrefix(); - if (!name.isEmpty()) { - element.setAttributeNS(xmlns, name, - ns.getNamespaceURI()); - } else { - xmlns = ns.getNamespaceURI(); - } - } - - if (currentElement == null) { - document.appendChild(element); - } else { - currentElement.appendChild(element); - } - - currentElement = element; - element.setUserData("location", ele.getLocation(), null); - } - } - return document; - } - - private Document returnValue; - - /** - * Gets the return value. - */ - public Document getReturnValue() { - return returnValue; - } - - /** - * Sets the return value. - */ - private void setReturnValue(Document value) { - returnValue = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/ExpandGroupResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/ExpandGroupResponse.java deleted file mode 100644 index cc6f22f3b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/ExpandGroupResponse.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.misc.ExpandGroupResults; - -/** - * Represents the response to a group expansion operation. - */ -public final class ExpandGroupResponse extends ServiceResponse { - - /** - * AD or store group members. - */ - private ExpandGroupResults members = new ExpandGroupResults(); - - /** - * Initializes a new instance of the class. - */ - public ExpandGroupResponse() { - super(); - } - - /** - * Gets a list of the group's members. - * - * @return the members - */ - public ExpandGroupResults getMembers() { - return this.members; - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - this.getMembers().loadFromXml(reader); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/FindConversationResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/FindConversationResponse.java deleted file mode 100644 index 2e70ed9ad..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/FindConversationResponse.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.item.Conversation; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * Represents the response to a Conversation search operation. - */ -public final class FindConversationResponse extends ServiceResponse { - List conversations = new ArrayList(); - - /** - * Initializes a new instance of the FindConversationResponse class. - */ - public FindConversationResponse() { - super(); - } - - /** - * Gets the results of the operation. - */ - public Collection getConversations() { - - return this.conversations; - - } - - /** - * Read Conversations from XML. - * - * @param reader The reader. - * @throws Exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - EwsUtilities.ewsAssert(conversations != null, "FindConversationResponse.ReadElementsFromXml", - "conversations is null."); - - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.Conversations); - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - Conversation item = EwsUtilities. - createEwsObjectFromXmlElementName(Conversation.class, - reader.getService(), reader.getLocalName()); - - if (item == null) { - reader.skipCurrentElement(); - } else { - item.loadFromXml( - reader, - true, /* clearPropertyBag */ - null, - false /* summaryPropertiesOnly */); - - conversations.add(item); - } - } - } - while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.Conversations)); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/FindFolderResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/FindFolderResponse.java deleted file mode 100644 index ede9f343c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/FindFolderResponse.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.search.FindFoldersResults; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -/** - * Represents the response to a folder search operation. - */ -public final class FindFolderResponse extends ServiceResponse { - - /** - * The results. - */ - private FindFoldersResults results = new FindFoldersResults(); - - /** - * The property set. - */ - private PropertySet propertySet; - - /** - * Reads response elements from XML. - * - * @param reader The reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.RootFolder); - - this.results.setTotalCount(reader.readAttributeValue(Integer.class, - XmlAttributeNames.TotalItemsInView)); - this.results.setMoreAvailable(!reader.readAttributeValue(Boolean.class, - XmlAttributeNames.IncludesLastItemInRange)); - - // Ignore IndexedPagingOffset attribute if MoreAvailable is false. - this.results.setNextPageOffset(results.isMoreAvailable() ? reader - .readNullableAttributeValue(Integer.class, - XmlAttributeNames.IndexedPagingOffset) : null); - - reader.readStartElement(XmlNamespace.Types, XmlElementNames.Folders); - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) { - Folder folder = EwsUtilities - .createEwsObjectFromXmlElementName(Folder.class, reader.getService(), reader.getLocalName()); - - if (folder == null) { - reader.skipCurrentElement(); - } else { - folder.loadFromXml(reader, true, /* clearPropertyBag */ - this.propertySet, true /* summaryPropertiesOnly */); - - this.results.getFolders().add(folder); - } - } - } while (!reader.isEndElement(XmlNamespace.Types, - XmlElementNames.Folders)); - } else { - reader.read(); - } - - reader - .readEndElement(XmlNamespace.Messages, - XmlElementNames.RootFolder); - } - - /** - * Initializes a new instance of the FindFolderResponse class. - * - * @param propertySet The property set from, the request. - */ - public FindFolderResponse(PropertySet propertySet) { - super(); - this.propertySet = propertySet; - - EwsUtilities.ewsAssert(this.propertySet != null, "FindFolderResponse.ctor", - "PropertySet should not be null"); - } - - /** - * Gets the results of the search operation. - * - * @return the results - */ - public FindFoldersResults getResults() { - return this.results; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/FindItemResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/FindItemResponse.java deleted file mode 100644 index 10fb77d2a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/FindItemResponse.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.search.FindItemsResults; -import microsoft.exchange.webservices.data.search.GroupedFindItemsResults; -import microsoft.exchange.webservices.data.search.ItemGroup; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import javax.xml.stream.XMLStreamException; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents the response to a item search operation. - * - * @param The type of item that the opeartion returned. - */ -public final class FindItemResponse - extends ServiceResponse { - - /** - * The results. - */ - private FindItemsResults results; - - /** - * The is grouped. - */ - private boolean isGrouped; - - /** - * The grouped find results. - */ - private GroupedFindItemsResults groupedFindResults; - - /** - * The property set. - */ - private PropertySet propertySet; - - /** - * Initializes a new instance of the FindItemResponse class. - * - * @param isGrouped if set to true if grouped. - * @param propertySet The property Set - */ - public FindItemResponse(boolean isGrouped, PropertySet propertySet) { - super(); - this.isGrouped = isGrouped; - this.propertySet = propertySet; - - EwsUtilities - .ewsAssert(this.propertySet != null, "FindItemResponse.ctor", "PropertySet should not be null"); - } - - /** - * Reads response elements from XML. - * - * @param reader ,The reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.RootFolder); - - int totalItemsInView = reader.readAttributeValue(Integer.class, - XmlAttributeNames.TotalItemsInView); - boolean moreItemsAvailable = !reader.readAttributeValue(Boolean.class, - XmlAttributeNames.IncludesLastItemInRange); - - // Ignore IndexedPagingOffset attribute if moreItemsAvailable is false. - Integer nextPageOffset = moreItemsAvailable ? reader - .readNullableAttributeValue(Integer.class, - XmlAttributeNames.IndexedPagingOffset) : null; - - if (!this.isGrouped) { - this.results = new FindItemsResults(); - this.results.setTotalCount(totalItemsInView); - this.results.setNextPageOffset(nextPageOffset); - this.results.setMoreAvailable(moreItemsAvailable); - internalReadItemsFromXml(reader, this.propertySet, this.results - .getItems()); - } else { - this.groupedFindResults = new GroupedFindItemsResults(); - this.groupedFindResults.setTotalCount(totalItemsInView); - this.groupedFindResults.setNextPageOffset(nextPageOffset); - this.groupedFindResults.setMoreAvailable(moreItemsAvailable); - - reader.readStartElement(XmlNamespace.Types, XmlElementNames.Groups); - - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.GroupedItems)) { - String groupIndex = reader.readElementValue( - XmlNamespace.Types, XmlElementNames.GroupIndex); - - ArrayList itemList = new ArrayList(); - internalReadItemsFromXml(reader, this.propertySet, - itemList); - - reader.readEndElement(XmlNamespace.Types, - XmlElementNames.GroupedItems); - - this.groupedFindResults.getItemGroups().add( - new ItemGroup(groupIndex, itemList)); - } - } while (!reader.isEndElement(XmlNamespace.Types, - XmlElementNames.Groups)); - } else { - reader.read(); - } - } - - reader - .readEndElement(XmlNamespace.Messages, - XmlElementNames.RootFolder); - } - - /** - * Read item from XML. - * - * @param reader the reader - * @param propertySet the property set - * @param destinationList the list in which to add the read item - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlDeserializationException the service xml deserialization exception - * @throws Exception the exception - */ - private void internalReadItemsFromXml(EwsServiceXmlReader reader, - PropertySet propertySet, List destinationList) - throws XMLStreamException, ServiceXmlDeserializationException, - Exception { - EwsUtilities.ewsAssert(destinationList != null, "FindItemResponse.InternalReadItemsFromXml", - "destinationList is null."); - - reader.readStartElement(XmlNamespace.Types, XmlElementNames.Items); - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) { - Item item = EwsUtilities.createEwsObjectFromXmlElementName( - Item.class, reader.getService(), reader - .getLocalName()); - - if (item == null) { - reader.skipCurrentElement(); - } else { - item.loadFromXml(reader, true, /* clearPropertyBag */ - propertySet, true /* summaryPropertiesOnly */); - - destinationList.add((TItem) item); - } - } - } while (!reader.isEndElement(XmlNamespace.Types, - XmlElementNames.Items)); - } else { - reader.read(); - } - - } - - /** - * Gets a grouped list of item matching the specified search criteria that - * were found in Exchange. ItemGroups is null if the search operation did - * not specify grouping options. - * - * @return the grouped find results - */ - public GroupedFindItemsResults getGroupedFindResults() { - return groupedFindResults; - } - - /** - * Gets the results of the search operation. - * - * @return the results - */ - public FindItemsResults getResults() { - return results; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetAttachmentResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetAttachmentResponse.java deleted file mode 100644 index 09de5159c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetAttachmentResponse.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.Attachment; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -/** - * Represents the response to an individual attachment retrieval request. - */ -public final class GetAttachmentResponse extends ServiceResponse { - - /** - * The attachment. - */ - private Attachment attachment; - - /** - * Initializes a new instance of the GetAttachmentResponse class. - * - * @param attachment the attachment - */ - public GetAttachmentResponse(Attachment attachment) { - super(); - EwsUtilities.ewsAssert(attachment != null, "GetAttachmentResponse.ctor", "attachment is null"); - - this.attachment = attachment; - } - - /** - * Reads response elements from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.Attachments); - if (!reader.isEmptyElement()) { - XmlNodeType x = new XmlNodeType(XmlNodeType.START_ELEMENT); - reader.read(x); - - this.attachment.loadFromXml(reader, reader.getLocalName()); - - reader.readEndElement(XmlNamespace.Messages, - XmlElementNames.Attachments); - } else { - reader.read(); - } - } - - /** - * Gets the attachment that was retrieved. - * - * @return the attachment - */ - protected Attachment getAttachment() { - return this.attachment; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetDelegateResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetDelegateResponse.java deleted file mode 100644 index b4ba8dd13..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetDelegateResponse.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.MeetingRequestsDeliveryScope; -import microsoft.exchange.webservices.data.core.enumeration.misc.error.ServiceError; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -/** - * The Class GetDelegateResponse. - */ -public final class GetDelegateResponse extends DelegateManagementResponse { - - /** - * Represents the response to a delegate user retrieval operation. - */ - private MeetingRequestsDeliveryScope meetingRequestsDeliveryScope = - MeetingRequestsDeliveryScope.NoForward; - - /** - * Initializes a new instance of the class. - * - * @param readDelegateUsers the read delegate users - */ - public GetDelegateResponse(boolean readDelegateUsers) { - super(readDelegateUsers, null); - } - - /** - * Reads response elements from XML - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - - if (this.getErrorCode() == ServiceError.NoError) { - // This is a hack. If there were no response messages, the reader - // will already be on the - // DeliverMeetingRequests start element, so we don't need to read - // it. - if (this.getDelegateUserResponses().size() > 0) { - reader.read(); - } - if (reader.isStartElement(XmlNamespace.Messages, XmlElementNames.DeliverMeetingRequests)) { - this.meetingRequestsDeliveryScope = reader - .readElementValue(MeetingRequestsDeliveryScope.class); - } - } - } - - /** - * Gets a value indicating if and how meeting request are delivered to - * delegates. - * - * @return the meeting request delivery scope - */ - public MeetingRequestsDeliveryScope getMeetingRequestsDeliveryScope() { - return this.meetingRequestsDeliveryScope; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetEventsResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetEventsResponse.java deleted file mode 100644 index e9e490e27..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetEventsResponse.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.notification.GetEventsResults; - -/** - * Represents the response to a subscription event retrieval operation. - */ -public final class GetEventsResponse extends ServiceResponse { - - /** - * The results. - */ - private GetEventsResults results = new GetEventsResults(); - - /** - * Initializes a new instance. - */ - public GetEventsResponse() { - super(); - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - this.results.loadFromXml(reader); - } - - /** - * gets the results. - * - * @return the results. - */ - public GetEventsResults getResults() { - return results; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetFolderResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetFolderResponse.java deleted file mode 100644 index a838a080c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetFolderResponse.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.folder.Folder; - -import java.util.List; - -/** - * Represents the response to an individual folder retrieval operation. - */ -public final class GetFolderResponse extends ServiceResponse implements - IGetObjectInstanceDelegate { - - /** - * The folder. - */ - private Folder folder; - - /** - * The property set. - */ - private PropertySet propertySet; - - /** - * Initializes a new instance of the GetFolderResponse class. - * - * @param folder The folder. - * @param propertySet The property set from the request. - */ - public GetFolderResponse(Folder folder, PropertySet propertySet) { - super(); - this.folder = folder; - this.propertySet = propertySet; - EwsUtilities - .ewsAssert(this.propertySet != null, "GetFolderResponse.ctor", "PropertySet should not be null"); - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - List folders = reader.readServiceObjectsCollectionFromXml( - XmlElementNames.Folders, this, true, /* clearPropertyBag */ - this.propertySet, /* requestedPropertySet */ - false); /* summaryPropertiesOnly */ - this.folder = folders.get(0); - } - - /** - * Gets the object instance delegate. - * - * @param service the service - * @param xmlElementName the xml element name - * @return the object instance delegate - * @throws Exception the exception - */ - @Override - public ServiceObject getObjectInstanceDelegate(ExchangeService service, - String xmlElementName) throws Exception { - return this.getObjectInstance(service, xmlElementName); - } - - /** - * Gets the folder instance. - * - * @param service The service. - * @param xmlElementName Name of the XML element. - * @return folder - * @throws Exception the exception - */ - private Folder getObjectInstance(ExchangeService service, - String xmlElementName) throws Exception { - if (this.getFolder() != null) { - return this.getFolder(); - } else { - return EwsUtilities.createEwsObjectFromXmlElementName(Folder.class, - service, xmlElementName); - } - } - - /** - * Gets the folder that was retrieved. - * - * @return folder - */ - public Folder getFolder() { - return this.folder; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetInboxRulesResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetInboxRulesResponse.java deleted file mode 100644 index f7e4f4086..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetInboxRulesResponse.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.RuleCollection; - -/** - * Represents the response to a GetInboxRules operation. - */ -public final class GetInboxRulesResponse extends ServiceResponse { - /** - * Rule collection. - */ - private RuleCollection ruleCollection; - - /** - * Initializes a new instance of the {@link GetInboxRulesResponse} class. - */ - public GetInboxRulesResponse() { - super(); - this.ruleCollection = new RuleCollection(); - } - - /** - * Reads response elements from XML. - * - * @param reader The reader. - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - reader.read(); - this.ruleCollection.setOutlookRuleBlobExists(reader. - readElementValue(Boolean.class, - XmlNamespace.Messages, - XmlElementNames.OutlookRuleBlobExists)); - reader.read(); - if (reader.isStartElement(XmlNamespace.NotSpecified, XmlElementNames.InboxRules)) { - this.ruleCollection.loadFromXml(reader, - XmlNamespace.NotSpecified, - XmlElementNames.InboxRules); - } - } - - /** - * Gets the rule collection in the response. - */ - public RuleCollection getRules() { - return this.ruleCollection; - } -} - diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetItemResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetItemResponse.java deleted file mode 100644 index 3bbfd7c82..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetItemResponse.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Item; - -import java.util.List; - -/** - * Represents a response to an individual item retrieval operation. - */ -public final class GetItemResponse extends ServiceResponse implements - IGetObjectInstanceDelegate { - - /** - * The item. - */ - private Item item; - - /** - * The property set. - */ - private PropertySet propertySet; - - /** - * Initializes a new instance of the class. - * - * @param item the item - * @param propertySet the property set - */ - public GetItemResponse(Item item, PropertySet propertySet) { - super(); - this.item = item; - this.propertySet = propertySet; - EwsUtilities.ewsAssert(this.propertySet != null, "GetItemResponse.ctor", "PropertySet should not be null"); - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws InstantiationException the instantiation exception - * @throws IllegalAccessException the illegal access exception - * @throws Exception the exception - */ - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws InstantiationException, IllegalAccessException, Exception { - super.readElementsFromXml(reader); - - List items = reader.readServiceObjectsCollectionFromXml( - XmlElementNames.Items, this, - true, /* clearPropertyBag */ - this.propertySet, /* requestedPropertySet */ - false); /* summaryPropertiesOnly */ - - this.item = items.get(0); - } - - /** - * Gets Item instance. - * - * @param service the service - * @param xmlElementName the xml element name - * @return Item - * @throws Exception the exception - */ - private Item getObjectInstance(ExchangeService service, - String xmlElementName) throws Exception { - if (this.getItem() != null) { - return this.getItem(); - } else { - return EwsUtilities.createEwsObjectFromXmlElementName(Item.class, - service, xmlElementName); - - } - } - - /** - * Gets the item that was retrieved. - * - * @return the item - */ - public Item getItem() { - return this.item; - } - - /** - * Gets the object instance delegate. - * - * @param service accepts ExchangeService - * @param xmlElementName accepts String - * @return Name - * @throws Exception throws exception - */ - @Override - public ServiceObject getObjectInstanceDelegate(ExchangeService service, - String xmlElementName) throws Exception { - return getObjectInstance(service, xmlElementName); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetPasswordExpirationDateResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetPasswordExpirationDateResponse.java deleted file mode 100644 index 3697f433d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetPasswordExpirationDateResponse.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -import java.util.Date; - -public class GetPasswordExpirationDateResponse extends ServiceResponse { - private Date passwordExpirationDate; - - /** - * Initializes a new instance of the GetPasswordExpirationDateResponse class. - */ - public GetPasswordExpirationDateResponse() { - super(); - } - - /** - * Reads response elements from XML - * - * @param reader The Reader - */ - protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { - super.readElementsFromXml(reader); - this.passwordExpirationDate = reader.readElementValueAsDateTime( - XmlNamespace.NotSpecified, - XmlElementNames.PasswordExpirationDate); - - } - - /** - * Get password expiration date. - * - * @return Password expiration date. - */ - public Date getPasswordExpirationDate() { - return this.passwordExpirationDate; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetPhoneCallResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetPhoneCallResponse.java deleted file mode 100644 index 776fbfdb8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetPhoneCallResponse.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.messaging.PhoneCall; - -/** - * Represents the response to a GetPhoneCall operation. - */ -public final class GetPhoneCallResponse extends ServiceResponse { - - /** - * The phone call. - */ - private PhoneCall phoneCall; - - /** - * Initializes a new instance of the GetPhoneCallResponse class. - * - * @param service the service - */ - public GetPhoneCallResponse(ExchangeService service) { - super(); - EwsUtilities.ewsAssert(service != null, "GetPhoneCallResponse.ctor", "service is null"); - - this.phoneCall = new PhoneCall(service); - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.PhoneCallInformation); - this.phoneCall.loadFromXml(reader, XmlNamespace.Messages, - XmlElementNames.PhoneCallInformation); - reader.readEndElementIfNecessary(XmlNamespace.Messages, - XmlElementNames.PhoneCallInformation); - } - - /** - * Gets the phone call. - * - * @return the phone call - */ - public PhoneCall getPhoneCall() { - return phoneCall; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetRoomListsResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetRoomListsResponse.java deleted file mode 100644 index 9b70e7b09..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetRoomListsResponse.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; -import microsoft.exchange.webservices.data.property.complex.EmailAddressCollection; - -/** - * Represents the response to a GetRoomLists operation. - */ -public final class GetRoomListsResponse extends ServiceResponse { - - /** - * The room lists. - */ - private EmailAddressCollection roomLists = new EmailAddressCollection(); - - /** - * Represents the response to a GetRoomLists operation. - */ - public GetRoomListsResponse() { - super(); - } - - /** - * Gets all room list returned. - * - * @return the room lists - */ - public EmailAddressCollection getRoomLists() { - return this.roomLists; - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - this.roomLists.clear(); - super.readElementsFromXml(reader); - - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.RoomLists); - - if (!reader.isEmptyElement()) { - // Because we don't have an element for count of returned object, - // we have to test the element to determine if it is return object - // or EndElement - reader.read(); - while (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.Address)) { - EmailAddress emailAddress = new EmailAddress(); - emailAddress.loadFromXml(reader, XmlElementNames.Address); - this.roomLists.add(emailAddress); - reader.read(); - } - reader.ensureCurrentNodeIsEndElement(XmlNamespace.Messages, - XmlElementNames.RoomLists); - } else { - reader.read(); - } - return; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetRoomsResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetRoomsResponse.java deleted file mode 100644 index 7a5d31e1e..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetRoomsResponse.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; - -import java.util.ArrayList; -import java.util.Collection; - -/** - * Represents the response to a GetRooms operation. - */ -public final class GetRoomsResponse extends ServiceResponse { - - /** - * The rooms. - */ - private Collection rooms = new ArrayList(); - - /** - * Initializes a new instance of the class. - */ - public GetRoomsResponse() { - super(); - } - - /** - * Gets collection for all rooms returned. - * - * @return the rooms - */ - public Collection getRooms() { - return this.rooms; - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - this.rooms.clear(); - super.readElementsFromXml(reader); - - reader.readStartElement(XmlNamespace.Messages, XmlElementNames.Rooms); - - if (!reader.isEmptyElement()) { - // Because we don't have an element for count of returned object, - // we have to test the element to determine if it is StartElement of - // return object or EndElement - reader.read(); - while (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.Room)) { - reader.read(); // skip the start - - EmailAddress emailAddress = new EmailAddress(); - emailAddress.loadFromXml(reader, XmlElementNames.RoomId); - this.rooms.add(emailAddress); - - reader.readEndElement(XmlNamespace.Types, XmlElementNames.Room); - reader.read(); - } - - reader.ensureCurrentNodeIsEndElement(XmlNamespace.Messages, - XmlElementNames.Rooms); - } else { - reader.read(); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetServerTimeZonesResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetServerTimeZonesResponse.java deleted file mode 100644 index f9cb672fe..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetServerTimeZonesResponse.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition; - -import java.util.ArrayList; -import java.util.Collection; - -/** - * Represents the response to a GetServerTimeZones request. - */ -public class GetServerTimeZonesResponse extends ServiceResponse { - - /** - * The time zones. - */ - private Collection timeZones = - new ArrayList(); - - /** - * Initializes a new instance of the class. - */ - public GetServerTimeZonesResponse() { - super(); - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { - super.readElementsFromXml(reader); - - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.TimeZoneDefinitions); - - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.TimeZoneDefinition)) { - TimeZoneDefinition timeZoneDefinition = - new TimeZoneDefinition(); - timeZoneDefinition.loadFromXml(reader); - - this.timeZones.add(timeZoneDefinition); - } - } while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.TimeZoneDefinitions)); - } else { - reader.read(); - } - } - - /** - * Reads response elements from XML. - * - * @return the time zones - */ - public Collection getTimeZones() { - return this.timeZones; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetStreamingEventsResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetStreamingEventsResponse.java deleted file mode 100644 index 7e50f9bbb..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetStreamingEventsResponse.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.request.HangingServiceRequestBase; -import microsoft.exchange.webservices.data.core.enumeration.misc.HangingRequestDisconnectReason; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.notification.GetStreamingEventsResults; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents the response to a subscription event retrieval operation. - */ -public final class GetStreamingEventsResponse extends ServiceResponse { - - private GetStreamingEventsResults results = new GetStreamingEventsResults(); - private HangingServiceRequestBase request; - - - /** - * Enumeration of ConnectionStatus that can be returned by the server. - */ - private enum ConnectionStatus { - /** - * Simple heartbeat - */ - OK, - - /** - * Server is closing the connection. - */ - Closed - } - - /** - * Initializes a new instance of the GetStreamingEventsResponse class. - * - * @param request The request - * Request to disconnect when we get a close message. - */ - public GetStreamingEventsResponse(HangingServiceRequestBase request) { - super(); - List string = new ArrayList(); - this.setErrorSubscriptionIds(string); - this.request = request; - } - - /** - * Reads response elements from XML. - * - * @throws Exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - - reader.read(); - - if (reader.getLocalName().equals(XmlElementNames.Notifications)) { - this.results.loadFromXml(reader); - } else if (reader.getLocalName().equals(XmlElementNames.ConnectionStatus)) { - String connectionStatus = reader.readElementValue(XmlNamespace. - Messages, XmlElementNames.ConnectionStatus); - - if (connectionStatus.equals(ConnectionStatus.Closed.toString())) { - this.request.disconnect( - HangingRequestDisconnectReason.Clean, null); - } - } - } - - /** - * Loads extra error details from XML - * - * @throws Exception - */ - @Override - protected boolean loadExtraErrorDetailsFromXml(EwsServiceXmlReader reader, - String xmlElementName) throws Exception { - boolean baseReturnVal = super. - loadExtraErrorDetailsFromXml(reader, xmlElementName); - - if (reader.isStartElement(XmlNamespace.Messages, XmlElementNames.ErrorSubscriptionIds)) { - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT && - reader.getLocalName().equals(XmlElementNames.SubscriptionId)) { - this.getErrorSubscriptionIds().add( - reader.readElementValue(XmlNamespace.Messages, - XmlElementNames.SubscriptionId)); - } - } - while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.ErrorSubscriptionIds)); - - return true; - } else { - return baseReturnVal; - } - } - - /** - * Gets event results from subscription. - */ - public GetStreamingEventsResults getResults() { - return this.results; - } - - private List errorSubscriptionIds; - - /** - * Gets the error subscription ids. - */ - public List getErrorSubscriptionIds() { - return this.errorSubscriptionIds; - } - - /** - * Sets the error subscription ids. - */ - private void setErrorSubscriptionIds(List value) { - this.errorSubscriptionIds = value; - } - - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetUserConfigurationResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetUserConfigurationResponse.java deleted file mode 100644 index 46ae9e222..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetUserConfigurationResponse.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.misc.UserConfiguration; - -/** - * Represents a response to a GetUserConfiguration request. - */ -public final class GetUserConfigurationResponse extends ServiceResponse { - - /** - * The user configuration. - */ - private UserConfiguration userConfiguration; - - /** - * Initializes a new instance of the class. - * - * @param userConfiguration the user configuration - */ - public GetUserConfigurationResponse(UserConfiguration userConfiguration) { - super(); - EwsUtilities.ewsAssert(userConfiguration != null, "GetUserConfigurationResponse.ctor", - "userConfiguration is null"); - - this.userConfiguration = userConfiguration; - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { - super.readElementsFromXml(reader); - this.userConfiguration.loadFromXml(reader); - } - - /** - * Gets the user configuration that was created. - * - * @return the user configuration - */ - public UserConfiguration getUserConfiguration() { - return this.userConfiguration; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/GetUserOofSettingsResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/GetUserOofSettingsResponse.java deleted file mode 100644 index ed0f89124..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/GetUserOofSettingsResponse.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.property.complex.availability.OofSettings; - -/** - * Represents response to GetUserOofSettings request. - */ -public class GetUserOofSettingsResponse extends ServiceResponse { - - /** - * The oof settings. - */ - private OofSettings oofSettings; - - /** - * Initializes a new instance of the class. - */ - public GetUserOofSettingsResponse() { - super(); - } - - /** - * Gets the OOF settings. - * - * @return the oof settings - */ - public OofSettings getOofSettings() { - return this.oofSettings; - } - - /** - * Sets the oof settings. - * - * @param value the new oof settings - */ - public void setOofSettings(OofSettings value) { - this.oofSettings = value; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/IGetObjectInstanceDelegate.java b/src/main/java/microsoft/exchange/webservices/data/core/response/IGetObjectInstanceDelegate.java deleted file mode 100644 index c6daf40b2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/IGetObjectInstanceDelegate.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.service.ServiceObject; - -/** - * The Interface GetObjectInstanceDelegateInterface. - * - * @param the generic type - */ -public interface IGetObjectInstanceDelegate { - - /** - * Gets the object instance delegate. - * - * @param service the service - * @param xmlElementName the xml element name - * @return the object instance delegate - * @throws Exception the exception - */ - T getObjectInstanceDelegate(ExchangeService service, String xmlElementName) - throws Exception; -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/MoveCopyFolderResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/MoveCopyFolderResponse.java deleted file mode 100644 index b0aeb5228..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/MoveCopyFolderResponse.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.List; - -/** - * Represents the base response class for individual folder move and copy - * operations. - */ -public final class MoveCopyFolderResponse extends ServiceResponse implements - IGetObjectInstanceDelegate { - - private static final Log LOG = LogFactory.getLog(MoveCopyFolderResponse.class); - - /** - * The folder. - */ - private Folder folder; - - /** - * Initializes a new instance of the MoveCopyFolderResponse class. - */ - public MoveCopyFolderResponse() { - super(); - } - - /** - * Gets Folder instance. - * - * @param service The service. - * @param xmlElementName Name of the XML element. - * @return folder - * @throws Exception the exception - */ - private Folder getObjectInstance(ExchangeService service, - String xmlElementName) throws Exception { - return EwsUtilities.createEwsObjectFromXmlElementName(Folder.class, service, xmlElementName); - } - - /** - * Reads response elements from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - - List folders; - try { - folders = reader.readServiceObjectsCollectionFromXml( - - XmlElementNames.Folders, this, false,/* clearPropertyBag */ - null, /* requestedPropertySet */ - false); /* summaryPropertiesOnly */ - - this.folder = folders.get(0); - } catch (ServiceLocalException e) { - LOG.error(e); - } - - } - - /** - * Gets the new (moved or copied) folder. - * - * @return the folder - */ - public Folder getFolder() { - return folder; - } - - /** - * Gets the object instance delegate. - * - * @param service accepts ExchangeService - * @param xmlElementName accepts String - * @return Object - * @throws Exception throws Exception - */ - @Override - public ServiceObject getObjectInstanceDelegate(ExchangeService service, - String xmlElementName) throws Exception { - return this.getObjectInstance(service, xmlElementName); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/MoveCopyItemResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/MoveCopyItemResponse.java deleted file mode 100644 index 5d336d54d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/MoveCopyItemResponse.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Item; - -import java.util.List; - -/** - * Represents a response to a Move or Copy operation. - */ -public final class MoveCopyItemResponse extends ServiceResponse implements - IGetObjectInstanceDelegate { - - /** - * The item. - */ - private Item item; - - /** - * Represents a response to a Move or Copy operation. - */ - public MoveCopyItemResponse() { - super(); - } - - /** - * Gets Item instance. - * - * @param service the service - * @param xmlElementName the xml element name - * @return the object instance - * @throws Exception the exception - */ - private Item getObjectInstance(ExchangeService service, - String xmlElementName) throws Exception { - return EwsUtilities.createEwsObjectFromXmlElementName(Item.class, service, xmlElementName); - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - List items = reader.readServiceObjectsCollectionFromXml( - XmlElementNames.Items, this, false, /* clearPropertyBag */ - null, /* requestedPropertySet */ - false); /* summaryPropertiesOnly */ - - // We only receive the copied or moved item if the copy or move - // operation was within - // a single mailbox. No item is returned if the operation is - // cross-mailbox, from a - // mailbox to a public folder or from a public folder to a mailbox. - if (items.size() > 0) { - this.item = items.get(0); - } - } - - /** - * Gets the object instance delegate. - * - * @param service the service - * @param xmlElementName the xml element name - * @return the object instance delegate - * @throws Exception the exception - */ - @Override - public ServiceObject getObjectInstanceDelegate(ExchangeService service, - String xmlElementName) throws Exception { - return this.getObjectInstance(service, xmlElementName); - } - - /** - * Gets the copied or moved item. Item is null if the copy or move - * operation was between two mailboxes or between a mailbox and a public - * folder. - * - * @return the item - */ - public Item getItem() { - return this.item; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/PlayOnPhoneResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/PlayOnPhoneResponse.java deleted file mode 100644 index b2ed47f84..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/PlayOnPhoneResponse.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.messaging.PhoneCallId; - -/** - * Represents the response to a PlayOnPhone operation. - */ -public final class PlayOnPhoneResponse extends ServiceResponse { - - /** - * The phone call id. - */ - private PhoneCallId phoneCallId; - - /** - * Initializes a new instance of the PlayOnPhoneResponse class. - * - * @param service the service - */ - public PlayOnPhoneResponse(ExchangeService service) { - super(); - EwsUtilities.ewsAssert(service != null, "PlayOnPhoneResponse.ctor", "service is null"); - - this.phoneCallId = new PhoneCallId(); - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.PhoneCallId); - this.phoneCallId.loadFromXml(reader, XmlNamespace.Messages, - XmlElementNames.PhoneCallId); - reader.readEndElementIfNecessary(XmlNamespace.Messages, - XmlElementNames.PhoneCallId); - } - - /** - * Gets the Id of the phone call. - * - * @return the phone call id - */ - public PhoneCallId getPhoneCallId() { - return phoneCallId; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/ResolveNamesResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/ResolveNamesResponse.java deleted file mode 100644 index bc93a2563..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/ResolveNamesResponse.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.enumeration.misc.error.ServiceError; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException; -import microsoft.exchange.webservices.data.misc.NameResolutionCollection; - -/** - * Represents the response to a name resolution operation. - */ -public final class ResolveNamesResponse extends ServiceResponse { - - /** - * The resolutions. - */ - private NameResolutionCollection resolutions; - - /** - * Initializes a new instance of the class. - * - * @param service the service - */ - public ResolveNamesResponse(ExchangeService service) { - super(); - EwsUtilities.ewsAssert(service != null, "ResolveNamesResponse.ctor", "service is null"); - - this.resolutions = new NameResolutionCollection(service); - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - this.resolutions.loadFromXml(reader); - } - - /** - * Override base implementation so that API does not throw when name - * resolution fails to find a match. EWS returns an error in this case but - * the API will just return an empty NameResolutionCollection. - * - * @throws ServiceResponseException the service response exception - */ - @Override - protected void internalThrowIfNecessary() throws ServiceResponseException { - if (this.getErrorCode() != ServiceError.ErrorNameResolutionNoResults) { - super.internalThrowIfNecessary(); - } - } - - /** - * Gets a list of name resolution suggestions. - * - * @return the resolutions - */ - public NameResolutionCollection getResolutions() { - return this.resolutions; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/ServiceResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/ServiceResponse.java deleted file mode 100644 index 53b3f1e4d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/ServiceResponse.java +++ /dev/null @@ -1,358 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.misc.error.ServiceError; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceResult; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException; -import microsoft.exchange.webservices.data.misc.SoapFaultDetails; -import microsoft.exchange.webservices.data.property.definition.ExtendedPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.IndexedPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinitionBase; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -/** - * Represents the standard response to an Exchange Web Services operation. - */ -public class ServiceResponse { - - /** - * The result. - */ - private ServiceResult result; - - /** - * The error code. - */ - private ServiceError errorCode; - - /** - * The error message. - */ - private String errorMessage; - - /** - * The error details. - */ - private Map errorDetails = new HashMap(); - - /** - * The error property. - */ - private Collection errorProperties = - new ArrayList(); - - /** - * Initializes a new instance. - */ - public ServiceResponse() { - } - - /** - * Initializes a new instance. - * - * @param soapFaultDetails The SOAP fault details. - */ - public ServiceResponse(SoapFaultDetails soapFaultDetails) { - this.result = ServiceResult.Error; - this.errorCode = soapFaultDetails.getResponseCode(); - this.errorMessage = soapFaultDetails.getFaultString(); - this.errorDetails = soapFaultDetails.getErrorDetails(); - } - - /** - * Loads response from XML. - * - * @param reader the reader - * @param xmlElementName the xml element name - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader, String xmlElementName) - throws Exception { - if (!reader.isStartElement(XmlNamespace.Messages, xmlElementName)) { - reader.readStartElement(XmlNamespace.Messages, xmlElementName); - } - - this.result = reader.readAttributeValue(ServiceResult.class, - XmlAttributeNames.ResponseClass); - - if (this.result == ServiceResult.Success || - this.result == ServiceResult.Warning) { - if (this.result == ServiceResult.Warning) { - this.errorMessage = reader.readElementValue( - XmlNamespace.Messages, XmlElementNames.MessageText); - } - - this.errorCode = reader.readElementValue(ServiceError.class, - XmlNamespace.Messages, XmlElementNames.ResponseCode); - - if (this.result == ServiceResult.Warning) { - reader.readElementValue(int.class, XmlNamespace.Messages, - XmlElementNames.DescriptiveLinkKey); - } - - // Bug E14:212308 -- If batch processing stopped, EWS returns an - // empty element. Skip over it. - if (this.getBatchProcessingStopped()) { - do { - reader.read(); - } while (!reader.isEndElement(XmlNamespace.Messages, - xmlElementName)); - } else { - - this.readElementsFromXml(reader); - //read end tag if it is an empty element. - if (reader.isEmptyElement()) { - reader.read(); - } - reader.readEndElementIfNecessary(XmlNamespace. - Messages, xmlElementName); - } - } else { - this.errorMessage = reader.readElementValue(XmlNamespace.Messages, - XmlElementNames.MessageText); - this.errorCode = reader.readElementValue(ServiceError.class, - XmlNamespace.Messages, XmlElementNames.ResponseCode); - reader.readElementValue(int.class, XmlNamespace.Messages, - XmlElementNames.DescriptiveLinkKey); - - while (!reader.isEndElement(XmlNamespace. - Messages, xmlElementName)) { - reader.read(); - - if (reader.isStartElement()) { - if (!this.loadExtraErrorDetailsFromXml(reader, reader.getLocalName())) { - reader.skipCurrentElement(); - } - - } - } - } - - this.mapErrorCodeToErrorMessage(); - - this.loaded(); - } - - /** - * Parses the message XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - protected void parseMessageXml(EwsServiceXmlReader reader) - throws Exception { - do { - reader.read(); - if (reader.isStartElement()) { - if (reader.getLocalName().equals(XmlElementNames.Value)) { - this.errorDetails.put(reader - .readAttributeValue(XmlAttributeNames.Name), reader - .readElementValue()); - } else if (reader.getLocalName().equals( - XmlElementNames.FieldURI)) { - this.errorProperties - .add(ServiceObjectSchema - .findPropertyDefinition(reader.readAttributeValue(XmlAttributeNames. - FieldURI))); - } else if (reader.getLocalName().equals( - XmlElementNames.IndexedFieldURI)) { - this.errorProperties - .add(new IndexedPropertyDefinition( - reader - .readAttributeValue(XmlAttributeNames. - FieldURI), - reader - .readAttributeValue(XmlAttributeNames. - FieldIndex))); - } else if (reader.getLocalName().equals( - XmlElementNames.ExtendedFieldURI)) { - ExtendedPropertyDefinition extendedPropDef = - new ExtendedPropertyDefinition(); - extendedPropDef.loadFromXml(reader); - this.errorProperties.add(extendedPropDef); - } - } - } while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.MessageXml)); - } - - - - /** - * Called when the response has been loaded from XML. - */ - protected void loaded() { - } - - /** - * Called after the response has been loaded from XML in order to map error - * codes to "better" error messages. - */ - protected void mapErrorCodeToErrorMessage() { - // Bug E14:69560 -- Use a better error message when an item cannot be - // updated because its changeKey is old. - if (this.getErrorCode() == ServiceError.ErrorIrresolvableConflict) { - this.setErrorMessage( - "The operation can't be performed because the item is out of date. Reload the item and try again."); - } - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { - } - - /** - * Loads extra error details from XML - * - * @param reader The reader. - * @param xmlElementName The current element name of the extra error details. - * @return True if the expected extra details is loaded; - * False if the element name does not match the expected element. - */ - protected boolean loadExtraErrorDetailsFromXml(EwsServiceXmlReader reader, - String xmlElementName) throws Exception { - if (reader.isStartElement(XmlNamespace.Messages, XmlElementNames.MessageXml) && - !reader.isEmptyElement()) { - this.parseMessageXml(reader); - - return true; - } else { - return false; - } - } - - /** - * Throws a ServiceResponseException if this response has its Result - * property set to Error. - * - * @throws ServiceResponseException the service response exception - */ - public void throwIfNecessary() throws ServiceResponseException { - this.internalThrowIfNecessary(); - } - - /** - * Internal method that throws a ServiceResponseException if this response - * has its Result property set to Error. - * - * @throws ServiceResponseException the service response exception - */ - protected void internalThrowIfNecessary() throws ServiceResponseException { - if (this.result == ServiceResult.Error) { - throw new ServiceResponseException(this); - } - } - - /** - * Gets a value indicating whether a batch request stopped processing before - * the end. - * - * @return A value indicating whether a batch request stopped processing - * before the end. - */ - protected boolean getBatchProcessingStopped() { - return (this.result == ServiceResult.Warning) - && (this.errorCode == ServiceError.ErrorBatchProcessingStopped); - } - - /** - * Gets the result associated with this response. - * - * @return The result associated with this response. - */ - public ServiceResult getResult() { - return result; - } - - /** - * Gets the error code associated with this response. - * - * @return The error code associated with this response. - */ - public ServiceError getErrorCode() { - return errorCode; - } - - /** - * Gets a detailed error message associated with the response. If Result - * is set to Success, ErrorMessage returns null. ErrorMessage is localized - * according to the PreferredCulture property of the ExchangeService object - * that was used to call the method that generated the response. - * - * @return the error message - */ - public String getErrorMessage() { - return errorMessage; - } - - /** - * Sets a detailed error message associated with the response. - * - * @param errorMessage The error message associated with the response. - */ - protected void setErrorMessage(String errorMessage) { - this.errorMessage = errorMessage; - } - - /** - * Gets error details associated with the response. If Result is set to - * Success, ErrorDetailsDictionary returns null. Error details will only - * available for some error codes. For example, when error code is - * ErrorRecurrenceHasNoOccurrence, the ErrorDetailsDictionary will contain - * keys for EffectiveStartDate and EffectiveEndDate. - * - * @return The error details dictionary. - */ - public Map getErrorDetails() { - return errorDetails; - } - - /** - * Gets information about property errors associated with the response. If - * Result is set to Success, ErrorProperties returns null. ErrorProperties - * is only available for some error codes. For example, when the error code - * is ErrorInvalidPropertyForOperation, ErrorProperties will contain the - * definition of the property that was invalid for the request. - * - * @return the error property - */ - public Collection getErrorProperties() { - return this.errorProperties; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/ServiceResponseCollection.java b/src/main/java/microsoft/exchange/webservices/data/core/response/ServiceResponseCollection.java deleted file mode 100644 index 60f3f1bb8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/ServiceResponseCollection.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceResult; - -import java.util.Enumeration; -import java.util.Iterator; -import java.util.Vector; - -/** - * Represents a strongly typed list of service response. - * - * @param The type of response stored in the list. - */ -public final class ServiceResponseCollection - implements Iterable { - - /** - * The response. - */ - private Vector responses = new Vector(); - - /** - * The overall result. - */ - private ServiceResult overallResult = ServiceResult.Success; - - /** - * Initializes a new instance. - */ - public ServiceResponseCollection() { - - } - - /** - * Adds specified response. - * - * @param response The response. - */ - public void add(TResponse response) { - EwsUtilities.ewsAssert(response != null, "EwsResponseList.Add", "response is null"); - if (response.getResult().ordinal() > this.overallResult.ordinal()) { - this.overallResult = response.getResult(); - } - this.responses.add(response); - } - - /** - * Gets the total number of response in the list. - * - * @return total number of response in the list. - */ - public int getCount() { - return this.responses.size(); - } - - /** - * Gets the response at the specified index. - * - * @param index The zero-based index of the response to get. - * @return The response at the specified index. - * @throws IndexOutOfBoundsException the index out of bounds exception - */ - public TResponse getResponseAtIndex(int index) - throws IndexOutOfBoundsException { - if (index < 0 || index >= this.getCount()) { - throw new IndexOutOfBoundsException("Index out of Range"); - } - return this.responses.get(index); - } - - /** - * Gets a value indicating the overall result of the request that - * generated this response collection. If all of the response have their - * Result property set to Success, OverallResult returns Success. If at - * least one response has its Result property set to Warning and all other - * response have their Result property set to Success, OverallResult - * returns Warning. If at least one response has a its Result set to Error, - * OverallResult returns Error. - * - * @return the overall result - */ - public ServiceResult getOverallResult() { - return this.overallResult; - } - - /** - * Returns an iterator over a set of elements of type T. - * - * @return an Iterator. - */ - @Override - public Iterator iterator() { - return responses.iterator(); - } - - /** - * Gets the enumerator. - * - * @return the enumerator - */ - public Enumeration getEnumerator() { - return this.responses.elements(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/SubscribeResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/SubscribeResponse.java deleted file mode 100644 index b2f409586..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/SubscribeResponse.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.notification.SubscriptionBase; - -/** - * Represents the base response class to subscription creation operations. - * - * @param Subscription type - */ -public final class SubscribeResponse extends ServiceResponse { - - /** - * The subscription. - */ - private TSubscription subscription; - - /** - * Initializes a new instance of the SubscribeResponse<TSubscription - * class. - * - * @param subscription The Subscription - */ - public SubscribeResponse(TSubscription subscription) { - super(); - EwsUtilities.ewsAssert(subscription != null, "SubscribeResponse.ctor", "subscription is null"); - this.subscription = subscription; - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { - super.readElementsFromXml(reader); - this.subscription.loadFromXml(reader); - } - - /** - * Gets the subscription. - * - * @return the subscription - */ - public TSubscription getSubscription() { - return this.subscription; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/SuggestionsResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/SuggestionsResponse.java deleted file mode 100644 index 5bcae6c7c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/SuggestionsResponse.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.availability.Suggestion; - -import java.util.ArrayList; -import java.util.Collection; - -/** - * Represents the base response class to subscription creation operations. - */ -public final class SuggestionsResponse extends ServiceResponse { - - /** - * The day suggestions. - */ - private Collection daySuggestions = new ArrayList(); - - /** - * Initializes a new instance of the SuggestionsResponse class. - */ - public SuggestionsResponse() { - super(); - } - - /** - * Loads the suggested days from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void loadSuggestedDaysFromXml(EwsServiceXmlReader reader) - throws Exception { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.SuggestionDayResultArray); - - do { - reader.read(); - - if (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.SuggestionDayResult)) { - Suggestion daySuggestion = new Suggestion(); - - daySuggestion.loadFromXml(reader, reader.getLocalName()); - - this.daySuggestions.add(daySuggestion); - } - } while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.SuggestionDayResultArray)); - } - - /** - * Gets a list of suggested days. - * - * @return the suggestions - */ - public Collection getSuggestions() { - return this.daySuggestions; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/SyncFolderHierarchyResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/SyncFolderHierarchyResponse.java deleted file mode 100644 index b4decb8ac..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/SyncFolderHierarchyResponse.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.sync.FolderChange; - -/** - * Represents the response to a folder synchronization operation. - */ -public final class SyncFolderHierarchyResponse extends - SyncResponse { - - /** - * Represents the response to a folder synchronization operation. - * - * @param propertySet the property set - */ - public SyncFolderHierarchyResponse(PropertySet propertySet) { - super(propertySet); - } - - /** - * Gets the name of the includes last in range XML element. - * - * @return XML element name. - */ - @Override - protected String getIncludesLastInRangeXmlElementName() { - return XmlElementNames.IncludesLastFolderInRange; - } - - /** - * Creates a folder change instance. - * - * @return FolderChange instance - */ - @Override - protected FolderChange createChangeInstance() { - return new FolderChange(); - } - - /** - * Gets a value indicating whether this request returns full or summary property. - * "true" if summary property only; otherwise, "false". - * - * @return the summary property only - */ - @Override - protected boolean getSummaryPropertiesOnly() { - return false; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/SyncFolderItemsResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/SyncFolderItemsResponse.java deleted file mode 100644 index 458e203a2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/SyncFolderItemsResponse.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.sync.ItemChange; - -/** - * Represents the response to a folder item synchronization operation. - */ -public final class SyncFolderItemsResponse extends - SyncResponse { - - /** - * Initializes a new instance of the class. - * - * @param propertySet the property set - */ - public SyncFolderItemsResponse(PropertySet propertySet) { - super(propertySet); - } - - /** - * Gets the name of the includes last in range XML element. - * - * @return XML element name. - */ - @Override - protected String getIncludesLastInRangeXmlElementName() { - return XmlElementNames.IncludesLastItemInRange; - } - - /** - * Creates an item change instance. - * - * @return ItemChange instance - */ - @Override - protected ItemChange createChangeInstance() { - return new ItemChange(); - } - - /** - * Gets a value indicating whether this request returns full or summary property. - * "true" if summary property only; otherwise, "false". - * - * @return the summary property only - */ - @Override - protected boolean getSummaryPropertiesOnly() { - return true; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/SyncResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/SyncResponse.java deleted file mode 100644 index 731e1e878..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/SyncResponse.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.sync.ChangeType; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.sync.Change; -import microsoft.exchange.webservices.data.sync.ChangeCollection; -import microsoft.exchange.webservices.data.sync.ItemChange; - -/** - * Represents the base response class for synchronuization operations. - * - * @param ServiceObject type. - * @param Change type. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class SyncResponse extends ServiceResponse { - - /** - * The changes. - */ - private ChangeCollection changes = new ChangeCollection(); - - /** - * The property set. - */ - private PropertySet propertySet; - - /** - * Initializes a new instance of the class. - * - * @param propertySet the property set - */ - protected SyncResponse(PropertySet propertySet) { - super(); - this.propertySet = propertySet; - EwsUtilities.ewsAssert(this.propertySet != null, "SyncResponse.ctor", "PropertySet should not be null"); - } - - /** - * Gets the name of the includes last in range XML element. - * - * @return XML element name. - */ - protected abstract String getIncludesLastInRangeXmlElementName(); - - /** - * Creates the change instance. - * - * @return TChange instance - */ - protected abstract TChange createChangeInstance(); - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws ServiceLocalException, Exception { - this.changes.setSyncState(reader.readElementValue( - XmlNamespace.Messages, XmlElementNames.SyncState)); - this.changes.setMoreChangesAvailable(!reader.readElementValue( - Boolean.class, XmlNamespace.Messages, this - .getIncludesLastInRangeXmlElementName())); - - reader.readStartElement(XmlNamespace.Messages, XmlElementNames.Changes); - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.isStartElement()) { - TChange change = this.createChangeInstance(); - - if (reader.getLocalName().equals(XmlElementNames.Create)) { - change.setChangeType(ChangeType.Create); - } else if (reader.getLocalName().equals( - XmlElementNames.Update)) { - change.setChangeType(ChangeType.Update); - } else if (reader.getLocalName().equals( - XmlElementNames.Delete)) { - change.setChangeType(ChangeType.Delete); - } else if (reader.getLocalName().equals( - XmlElementNames.ReadFlagChange)) { - change.setChangeType(ChangeType.ReadFlagChange); - } else { - reader.skipCurrentElement(); - } - - if (change != null) { - reader.read(); - reader.ensureCurrentNodeIsStartElement(); - - if (change.getChangeType().equals(ChangeType.Delete) - || change.getChangeType().equals( - ChangeType.ReadFlagChange)) { - change.setId(change.createId()); - change.getId().loadFromXml(reader, - change.getId().getXmlElementName()); - - if (change.getChangeType().equals( - ChangeType.ReadFlagChange)) { - reader.read(); - reader.ensureCurrentNodeIsStartElement(); - ItemChange itemChange = null; - if (change instanceof ItemChange) { - itemChange = (ItemChange) change; - } - EwsUtilities - .ewsAssert(itemChange != null, "SyncResponse." + "ReadElementsFromXml", - "ReadFlagChange is only " + "valid on ItemChange"); - - itemChange.setIsRead(reader.readElementValue( - Boolean.class, XmlNamespace.Types, - XmlElementNames.IsRead)); - } - } else { - - change.setServiceObject(EwsUtilities - .createEwsObjectFromXmlElementName(null, - reader.getService(), reader - .getLocalName())); - - change.getServiceObject().loadFromXml(reader, - true, /* clearPropertyBag */ - this.propertySet, this.getSummaryPropertiesOnly()); - } - - reader.readEndElementIfNecessary(XmlNamespace.Types, - change.getChangeType().toString()); - - this.changes.add(change); - } - } - } while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.Changes)); - } else { - reader.read(); - } - } - - /** - * Gets a list of changes that occurred on the synchronized folder. - * - * @return the changes - */ - public ChangeCollection getChanges() { - return this.changes; - } - - /** - * Gets a value indicating whether this request returns full or summary - * property. - * - * @return the summary property only - */ - protected abstract boolean getSummaryPropertiesOnly(); - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/UpdateFolderResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/UpdateFolderResponse.java deleted file mode 100644 index 6d5e3a2cb..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/UpdateFolderResponse.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceResult; - -/** - * Represents response to UpdateFolder request. - */ -public final class UpdateFolderResponse extends ServiceResponse implements - IGetObjectInstanceDelegate { - - /** - * The folder. - */ - private Folder folder; - - /** - * Initializes a new instance of the UpdateFolderResponse class. - * - * @param folder The folder - */ - public UpdateFolderResponse(Folder folder) { - super(); - EwsUtilities.ewsAssert(folder != null, "UpdateFolderResponse.ctor", "folder is null"); - - this.folder = folder; - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readElementsFromXml(reader); - - reader.readServiceObjectsCollectionFromXml(XmlElementNames.Folders, - this, false, /* clearPropertyBag */ - null, /* requestedPropertySet */ - false); /* summaryPropertiesOnly */ - } - - /** - * Clears the change log of the updated folder if the update succeeded. - */ - @Override - protected void loaded() { - if (this.getResult() == ServiceResult.Success) { - this.folder.clearChangeLog(); - } - } - - /** - * Gets Folder instance. - * - * @param session The session - * @param xmlElementName Name of the XML element. - * @return Folder - */ - private Folder getObjectInstance(ExchangeService session, - String xmlElementName) { - return this.folder; - } - - /** - * Gets the object instance delegate. - * - * @param service accepts ExchangeService - * @param xmlElementName accepts String - * @return Object - * @throws Exception throws Exception - */ - @Override - public ServiceObject getObjectInstanceDelegate(ExchangeService service, - String xmlElementName) throws Exception { - return this.getObjectInstance(service, xmlElementName); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/UpdateInboxRulesResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/UpdateInboxRulesResponse.java deleted file mode 100644 index 0b4e368e3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/UpdateInboxRulesResponse.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.RuleOperationErrorCollection; - -/** - * Represents the response to a UpdateInboxRulesResponse operation. - */ -public final class UpdateInboxRulesResponse extends ServiceResponse { - - /** - * Rule operation error collection. - */ - private RuleOperationErrorCollection errors; - - /** - * Initializes a new instance of the UpdateInboxRulesResponse class. - */ - public UpdateInboxRulesResponse() { - super(); - this.errors = new RuleOperationErrorCollection(); - } - - /** - * Loads extra error details from XML - * - * @param reader The reader. - * @param xmlElementName The current element name of the extra error details. - * @return True if the expected extra details is loaded, - * False if the element name does not match the expected element. - * @throws Exception - */ - @Override - protected boolean loadExtraErrorDetailsFromXml(EwsServiceXmlReader reader, - String xmlElementName) throws Exception { - if (xmlElementName.equals(XmlElementNames.MessageXml)) { - return super.loadExtraErrorDetailsFromXml(reader, xmlElementName); - } else if (xmlElementName.equals(XmlElementNames.RuleOperationErrors)) { - this.getErrors().loadFromXml(reader, - XmlNamespace.Messages, xmlElementName); - return true; - } else { - return false; - } - } - - /** - * Gets the rule operation errors in the response. - */ - public RuleOperationErrorCollection getErrors() { - return this.errors; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/response/UpdateItemResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/response/UpdateItemResponse.java deleted file mode 100644 index a30847fce..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/response/UpdateItemResponse.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.response; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceResult; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -/** - * The Class UpdateItemResponse. - */ -public final class UpdateItemResponse extends ServiceResponse implements - IGetObjectInstanceDelegate { - - /** - * Represents the response to an individual item update operation. - */ - private Item item; - - /** - * The returned item. - */ - private Item returnedItem; - - /** - * The conflict count. - */ - private int conflictCount; - - /** - * Initializes a new instance of the class. - * - * @param item the item - */ - public UpdateItemResponse(Item item) { - super(); - EwsUtilities.ewsAssert(item != null, "UpdateItemResponse.ctor", "item is null"); - this.item = item; - } - - /** - * Reads response elements from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception { - super.readElementsFromXml(reader); - - reader.readServiceObjectsCollectionFromXml(XmlElementNames.Items, this, - false, null, false); - - if (!reader.getService().getExchange2007CompatibilityMode()) { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.ConflictResults); - this.conflictCount = reader.readElementValue(Integer.class, - XmlNamespace.Types, XmlElementNames.Count); - reader.readEndElement(XmlNamespace.Messages, - XmlElementNames.ConflictResults); - } - - // If UpdateItem returned an item that has the same Id as the item that - // is being updated, this is a "normal" UpdateItem operation, and we - // need - // to update the ChangeKey of the item being updated with the one that - // was - // returned. Also set returnedItem to indicate that no new item was - // returned. - // - // Otherwise, this in a "special" UpdateItem operation, such as a - // recurring - // task marked as complete (the returned item in that case is the - // one-off - // task that represents the completed instance). - // - // Note that there can be no returned item at all, as in an UpdateItem - // call - // with MessageDisposition set to SendOnly or SendAndSaveCopy. - if (this.returnedItem != null) { - if (this.item.getId().getUniqueId().equals( - this.returnedItem.getId().getUniqueId())) { - this.item.getId().setChangeKey( - this.returnedItem.getId().getChangeKey()); - this.returnedItem = null; - } - } - } - - /* - * (non-Javadoc) - * - * @seemicrosoft.exchange.webservices.GetObjectInstanceDelegateInterface# - * getObjectInstanceDelegate(microsoft.exchange.webservices.ExchangeService, - * java.lang.String) - */ - public ServiceObject getObjectInstanceDelegate(ExchangeService service, - String xmlElementName) throws Exception { - return this.getObjectInstance(service, xmlElementName); - } - - /** - * Clears the change log of the created folder if the creation succeeded. - */ - @Override - protected void loaded() { - if (this.getResult() == ServiceResult.Success) { - this.item.clearChangeLog(); - } - } - - /** - * Gets Item instance. - * - * @param service the service - * @param xmlElementName the xml element name - * @return Item - * @throws Exception the exception - */ - private Item getObjectInstance(ExchangeService service, - String xmlElementName) throws Exception { - this.returnedItem = EwsUtilities.createEwsObjectFromXmlElementName( - Item.class, service, xmlElementName); - return this.returnedItem; - } - - /** - * Gets the item that was returned by the update operation. ReturnedItem - * is set only when a recurring Task is marked as complete or when its - * recurrence pattern changes. - * - * @return the returned item - */ - public Item getReturnedItem() { - return this.returnedItem; - } - - /** - * Gets the number of property conflicts that were resolved during the - * update operation. - * - * @return the conflict count - */ - public int getConflictCount() { - return this.conflictCount; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/ICreateServiceObjectWithAttachmentParam.java b/src/main/java/microsoft/exchange/webservices/data/core/service/ICreateServiceObjectWithAttachmentParam.java deleted file mode 100644 index 4f1400ac1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/ICreateServiceObjectWithAttachmentParam.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service; - -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; - -/** - * The Interface ICreateServiceObjectWithAttachmentParam. - */ -public interface ICreateServiceObjectWithAttachmentParam { - - /** - * Creates the service object with attachment param. - * - * @param itemAttachment the item attachment - * @param isNew the is new - * @return the object - * @throws Exception the exception - */ - Object createServiceObjectWithAttachmentParam( - ItemAttachment itemAttachment, boolean isNew) throws Exception; - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/ICreateServiceObjectWithServiceParam.java b/src/main/java/microsoft/exchange/webservices/data/core/service/ICreateServiceObjectWithServiceParam.java deleted file mode 100644 index 26c4978cf..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/ICreateServiceObjectWithServiceParam.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service; - -import microsoft.exchange.webservices.data.core.ExchangeService; - -/** - * The Interface ICreateServiceObjectWithServiceParam. - */ -public interface ICreateServiceObjectWithServiceParam { - - /** - * Creates the service object with service param. - * - * @param srv the srv - * @return the object - * @throws Exception the exception - */ - Object createServiceObjectWithServiceParam(ExchangeService srv) - throws Exception; -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/ServiceObject.java b/src/main/java/microsoft/exchange/webservices/data/core/service/ServiceObject.java deleted file mode 100644 index 2c4d87ccc..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/ServiceObject.java +++ /dev/null @@ -1,629 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertyBag; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence; -import microsoft.exchange.webservices.data.core.exception.misc.InvalidOperationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.complex.ExtendedProperty; -import microsoft.exchange.webservices.data.property.complex.ExtendedPropertyCollection; -import microsoft.exchange.webservices.data.property.complex.IServiceObjectChangedDelegate; -import microsoft.exchange.webservices.data.property.complex.ServiceId; -import microsoft.exchange.webservices.data.property.definition.ExtendedPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinitionBase; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * Represents the base abstract class for all item and folder types. - */ -public abstract class ServiceObject { - - /** - * The lock object. - */ - private Object lockObject = new Object(); - - /** - * The service. - */ - private ExchangeService service; - - /** - * The property bag. - */ - private PropertyBag propertyBag; - - /** - * The xml element name. - */ - private String xmlElementName; - - /** - * Triggers dispatch of the change event. - */ - public void changed() { - - for (IServiceObjectChangedDelegate change : this.onChange) { - change.serviceObjectChanged(this); - } - } - - /** - * Throws exception if this is a new service object. - * - * @throws InvalidOperationException the invalid operation exception - * @throws ServiceLocalException the service local exception - */ - public void throwIfThisIsNew() throws InvalidOperationException, - ServiceLocalException { - if (this.isNew()) { - throw new InvalidOperationException( - "This operation can't be performed because this service object doesn't have an Id."); - } - } - - /** - * Throws exception if this is not a new service object. - * - * @throws InvalidOperationException the invalid operation exception - * @throws ServiceLocalException the service local exception - */ - protected void throwIfThisIsNotNew() throws InvalidOperationException, - ServiceLocalException { - if (!this.isNew()) { - throw new InvalidOperationException( - "This operation can't be performed because this service object already has an ID. To update this service object, use the Update() method instead."); - } - } - - // / This methods lets subclasses of ServiceObject override the default - // mechanism - // / by which the XML element name associated with their type is retrieved. - - /** - * This methods lets subclasses of ServiceObject override the default - * mechanism by which the XML element name associated with their type is - * retrieved. - * - * @return String - */ - protected String getXmlElementNameOverride() { - return null; - } - - /** - * GetXmlElementName retrieves the XmlElementName of this type based on the - * EwsObjectDefinition attribute that decorates it, if present. - * - * @return The XML element name associated with this type. - */ - public String getXmlElementName() { - if (this.isNullOrEmpty(this.xmlElementName)) { - this.xmlElementName = this.getXmlElementNameOverride(); - if (this.isNullOrEmpty(this.xmlElementName)) { - synchronized (this.lockObject) { - - ServiceObjectDefinition annotation = this.getClass() - .getAnnotation(ServiceObjectDefinition.class); - if (null != annotation) { - this.xmlElementName = annotation.xmlElementName(); - } - } - } - } - EwsUtilities - .ewsAssert(!isNullOrEmpty(this.xmlElementName), "EwsObject.GetXmlElementName", String - .format("The class %s does not have an " + "associated XML element name.", - this.getClass().getName())); - - return this.xmlElementName; - } - - /** - * Gets the name of the change XML element. - * - * @return the change xml element name - */ - public String getChangeXmlElementName() { - return XmlElementNames.ItemChange; - } - - /** - * Gets the name of the set field XML element. - * - * @return String - */ - public String getSetFieldXmlElementName() { - return XmlElementNames.SetItemField; - } - - /** - * Gets the name of the delete field XML element. - * - * @return String - */ - public String getDeleteFieldXmlElementName() { - return XmlElementNames.DeleteItemField; - } - - /** - * Gets a value indicating whether a time zone SOAP header should be emitted - * in a CreateItem or UpdateItem request so this item can be property saved - * or updated. - * - * @param isUpdateOperation the is update operation - * @return boolean - * @throws ServiceLocalException - * @throws Exception - */ - protected boolean getIsTimeZoneHeaderRequired(boolean isUpdateOperation) - throws ServiceLocalException, Exception { - return false; - } - - /** - * Determines whether property defined with - * ScopedDateTimePropertyDefinition require custom time zone scoping. - * - * @return boolean - */ - protected boolean getIsCustomDateTimeScopingRequired() { - return false; - } - - /** - * The property bag holding property values for this object. - * - * @return the property bag - */ - public PropertyBag getPropertyBag() { - return this.propertyBag; - } - - /** - * Internal constructor. - * - * @param service the service - * @throws Exception the exception - */ - protected ServiceObject(ExchangeService service) throws Exception { - EwsUtilities.validateParam(service, "service"); - EwsUtilities.validateServiceObjectVersion(this, service - .getRequestedServerVersion()); - this.service = service; - this.propertyBag = new PropertyBag(this); - } - - /** - * Gets the schema associated with this type of object. - * - * @return ServiceObjectSchema - */ - public ServiceObjectSchema schema() { - return this.getSchema(); - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return the schema - */ - public abstract ServiceObjectSchema getSchema(); - - /** - * Gets the minimum required server version. - * - * @return the minimum required server version - */ - public abstract ExchangeVersion getMinimumRequiredServerVersion(); - - /** - * Loads service object from XML. - * - * @param reader the reader - * @param clearPropertyBag the clear property bag - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader, boolean clearPropertyBag) throws Exception { - - this.getPropertyBag().loadFromXml(reader, clearPropertyBag, - null, // propertySet - false); // summaryPropertiesOnly - - } - - // / Validates this instance. - - /** - * Validate. - * - * @throws Exception the exception - */ - protected void validate() throws Exception { - this.getPropertyBag().validate(); - } - - // / Loads service object from XML. - - /** - * Load from xml. - * - * @param reader the reader - * @param clearPropertyBag the clear property bag - * @param requestedPropertySet the requested property set - * @param summaryPropertiesOnly the summary property only - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader, boolean clearPropertyBag, - PropertySet requestedPropertySet, boolean summaryPropertiesOnly) throws Exception { - - this.getPropertyBag().loadFromXml(reader, clearPropertyBag, - requestedPropertySet, summaryPropertiesOnly); - - } - - // Clears the object's change log. - - /** - * Clear change log. - */ - public void clearChangeLog() { - this.getPropertyBag().clearChangeLog(); - } - - // / Writes service object as XML. - - /** - * Write to xml. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer) throws Exception { - this.getPropertyBag().writeToXml(writer); - } - - // Writes service object for update as XML. - - /** - * Write to xml for update. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeToXmlForUpdate(EwsServiceXmlWriter writer) - throws Exception { - this.getPropertyBag().writeToXmlForUpdate(writer); - } - - // / Loads the specified set of property on the object. - - /** - * Internal load. - * - * @param propertySet the property set - * @throws Exception the exception - */ - protected abstract void internalLoad(PropertySet propertySet) - throws Exception; - - // / Deletes the object. - - /** - * Internal delete. - * - * @param deleteMode the delete mode - * @param sendCancellationsMode the send cancellations mode - * @param affectedTaskOccurrences the affected task occurrences - * @throws Exception the exception - */ - protected abstract void internalDelete(DeleteMode deleteMode, - SendCancellationsMode sendCancellationsMode, - AffectedTaskOccurrence affectedTaskOccurrences) throws Exception; - - // / Loads the specified set of property. Calling this method results in a - // call to EWS. - - /** - * Load. - * - * @param propertySet the property set - * @throws Exception the exception - */ - public void load(PropertySet propertySet) throws Exception { - this.internalLoad(propertySet); - } - - // Loads the first class property. Calling this method results in a call - // to EWS. - - /** - * Load. - * - * @throws Exception the exception - */ - public void load() throws Exception { - this.internalLoad(PropertySet.getFirstClassProperties()); - } - - /** - * Gets the value of specified property in this instance. - * - * @param propertyDefinition Definition of the property to get. - * @return The value of specified property in this instance. - * @throws Exception the exception - */ - public Object getObjectFromPropertyDefinition( - PropertyDefinitionBase propertyDefinition) throws Exception { - PropertyDefinition propDef = (PropertyDefinition) propertyDefinition; - - if (propDef != null) { - return this.getPropertyBag().getObjectFromPropertyDefinition(propDef); - } else { - // E14:226103 -- Other subclasses of PropertyDefinitionBase are not supported. - throw new UnsupportedOperationException(String.format( - "This operation isn't supported for property definition type %s.", - propertyDefinition.getType().getName())); - } - } - - /** - * Try to get the value of a specified extended property in this instance. - * - * @param propertyDefinition the property definition - * @param propertyValue the property value - * @return true, if successful - * @throws Exception the exception - */ - protected boolean tryGetExtendedProperty(Class cls, - ExtendedPropertyDefinition propertyDefinition, - OutParam propertyValue) throws Exception { - ExtendedPropertyCollection propertyCollection = this - .getExtendedProperties(); - - if ((propertyCollection != null) && - propertyCollection.tryGetValue(cls, propertyDefinition, propertyValue)) { - return true; - } else { - propertyValue.setParam(null); - return false; - } - } - - /** - * Try to get the value of a specified property in this instance. - * - * @param propertyDefinition The property definition. - * @param propertyValue The property value - * @return True if property retrieved, false otherwise. - * @throws Exception - */ - public boolean tryGetProperty(PropertyDefinitionBase propertyDefinition, OutParam propertyValue) - throws Exception { - return this.tryGetProperty(Object.class, propertyDefinition, propertyValue); - } - - /** - * Try to get the value of a specified property in this instance. - * - * @param propertyDefinition the property definition - * @param propertyValue the property value - * @return true, if successful - * @throws Exception the exception - */ - public boolean tryGetProperty(Class cls, PropertyDefinitionBase propertyDefinition, - OutParam propertyValue) throws Exception { - - PropertyDefinition propDef = (PropertyDefinition) propertyDefinition; - if (propDef != null) { - return this.getPropertyBag().tryGetPropertyType(cls, propDef, propertyValue); - } else { - // E14:226103 -- Other subclasses of PropertyDefinitionBase are not supported. - throw new UnsupportedOperationException(String.format( - "This operation isn't supported for property definition type %s.", - propertyDefinition.getType().getName())); - } - } - - /** - * Gets the collection of loaded property definitions. - * - * @return the loaded property definitions - * @throws Exception the exception - */ - public Collection getLoadedPropertyDefinitions() - throws Exception { - - Collection propDefs = - new ArrayList(); - for (PropertyDefinition propDef : this.getPropertyBag().getProperties() - .keySet()) { - propDefs.add(propDef); - } - - if (this.getExtendedProperties() != null) { - for (ExtendedProperty extProp : getExtendedProperties()) { - propDefs.add(extProp.getPropertyDefinition()); - } - } - - return propDefs; - } - - /** - * Gets the service. - * - * @return the service - */ - public ExchangeService getService() { - return service; - } - - /** - * Sets the service. - * - * @param service the new service - */ - protected void setService(ExchangeService service) { - this.service = service; - } - - // / The property definition for the Id of this object. - - /** - * Gets the id property definition. - * - * @return the id property definition - */ - public PropertyDefinition getIdPropertyDefinition() { - return null; - } - - // / The unique Id of this object. - - /** - * Gets the id. - * - * @return the id - * @throws ServiceLocalException the service local exception - */ - public ServiceId getId() throws ServiceLocalException { - PropertyDefinition idPropertyDefinition = this - .getIdPropertyDefinition(); - - OutParam serviceId = new OutParam(); - - if (idPropertyDefinition != null) { - this.getPropertyBag().tryGetValue(idPropertyDefinition, serviceId); - } - - return (ServiceId) serviceId.getParam(); - } - - // / Indicates whether this object is a real store item, or if it's a local - // object - // / that has yet to be saved. - - /** - * Checks if is new. - * - * @return true, if is new - * @throws ServiceLocalException the service local exception - */ - public boolean isNew() throws ServiceLocalException { - - ServiceId id = this.getId(); - - return id == null ? true : !id.isValid(); - - } - - // / Gets a value indicating whether the object has been modified and should - // be saved. - - /** - * Checks if is dirty. - * - * @return true, if is dirty - */ - public boolean isDirty() { - return this.getPropertyBag().getIsDirty(); - - } - - // Gets the extended property collection. - - /** - * Gets the extended property. - * - * @return the extended property - * @throws Exception the exception - */ - protected ExtendedPropertyCollection getExtendedProperties() - throws Exception { - return null; - } - - /** - * Checks is the string is null or empty. - * - * @param namespacePrefix the namespace prefix - * @return true, if is null or empty - */ - private boolean isNullOrEmpty(String namespacePrefix) { - return (namespacePrefix == null || namespacePrefix.isEmpty()); - - } - - /** - * The on change. - */ - private List onChange = - new ArrayList(); - - /** - * Adds the service object changed event. - * - * @param change the change - */ - public void addServiceObjectChangedEvent( - IServiceObjectChangedDelegate change) { - this.onChange.add(change); - } - - /** - * Removes the service object changed event. - * - * @param change the change - */ - public void removeServiceObjectChangedEvent( - IServiceObjectChangedDelegate change) { - this.onChange.remove(change); - } - - /** - * Clear service object changed event. - */ - public void clearServiceObjectChangedEvent() { - this.onChange.clear(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/ServiceObjectInfo.java b/src/main/java/microsoft/exchange/webservices/data/core/service/ServiceObjectInfo.java deleted file mode 100644 index 20dd1936f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/ServiceObjectInfo.java +++ /dev/null @@ -1,430 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.folder.CalendarFolder; -import microsoft.exchange.webservices.data.core.service.folder.ContactsFolder; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.service.folder.SearchFolder; -import microsoft.exchange.webservices.data.core.service.folder.TasksFolder; -import microsoft.exchange.webservices.data.core.service.item.Appointment; -import microsoft.exchange.webservices.data.core.service.item.Contact; -import microsoft.exchange.webservices.data.core.service.item.ContactGroup; -import microsoft.exchange.webservices.data.core.service.item.Conversation; -import microsoft.exchange.webservices.data.core.service.item.EmailMessage; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.item.MeetingCancellation; -import microsoft.exchange.webservices.data.core.service.item.MeetingMessage; -import microsoft.exchange.webservices.data.core.service.item.MeetingRequest; -import microsoft.exchange.webservices.data.core.service.item.MeetingResponse; -import microsoft.exchange.webservices.data.core.service.item.PostItem; -import microsoft.exchange.webservices.data.core.service.item.Task; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * ServiceObjectInfo contains metadata on how to map from an element name to a - * ServiceObject type as well as how to map from a ServiceObject type to - * appropriate constructors. - */ -public class ServiceObjectInfo { - - /** - * The service object constructors with attachment param. - */ - private Map, ICreateServiceObjectWithAttachmentParam> - serviceObjectConstructorsWithAttachmentParam; - - /** - * The service object constructors with service param. - */ - private Map, ICreateServiceObjectWithServiceParam> - serviceObjectConstructorsWithServiceParam; - - /** - * The xml element name to service object class map. - */ - private Map> xmlElementNameToServiceObjectClassMap; - - /** - * Default constructor. - */ - public ServiceObjectInfo() { - this.xmlElementNameToServiceObjectClassMap = - new HashMap>(); - this.serviceObjectConstructorsWithServiceParam = - new HashMap, ICreateServiceObjectWithServiceParam>(); - this.serviceObjectConstructorsWithAttachmentParam = - new HashMap, ICreateServiceObjectWithAttachmentParam>(); - - this.initializeServiceObjectClassMap(); - } - - /** - * Initializes the service object class map. If you add a new ServiceObject - * subclass that can be returned by the Server, add the type to the class - * map as well as associated delegate(s) to call the constructor(s). - */ - private void initializeServiceObjectClassMap() { - // Appointment - this.addServiceObjectType(XmlElementNames.CalendarItem, - Appointment.class, new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new Appointment(srv); - } - }, new ICreateServiceObjectWithAttachmentParam() { - public Object createServiceObjectWithAttachmentParam( - ItemAttachment itemAttachment, boolean isNew) - throws Exception { - return new Appointment(itemAttachment, isNew); - } - }); - - // CalendarFolder - this.addServiceObjectType(XmlElementNames.CalendarFolder, - CalendarFolder.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new CalendarFolder(srv); - } - }, null); - - // Contact - this.addServiceObjectType(XmlElementNames.Contact, Contact.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new Contact(srv); - } - }, new ICreateServiceObjectWithAttachmentParam() { - public Object createServiceObjectWithAttachmentParam( - ItemAttachment itemAttachment, boolean isNew) - throws Exception { - return new Contact(itemAttachment); - } - }); - - // ContactsFolder - this.addServiceObjectType(XmlElementNames.ContactsFolder, - ContactsFolder.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new ContactsFolder(srv); - } - }, null); - - // ContactGroup - this.addServiceObjectType(XmlElementNames.DistributionList, - ContactGroup.class, new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new ContactGroup(srv); - } - }, new ICreateServiceObjectWithAttachmentParam() { - public Object createServiceObjectWithAttachmentParam( - ItemAttachment itemAttachment, boolean isNew) - throws Exception { - return new ContactGroup(itemAttachment); - } - }); - - // Conversation - this.addServiceObjectType(XmlElementNames.Conversation, - Conversation.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new Conversation(srv); - } - }, null); - - // EmailMessage - this.addServiceObjectType(XmlElementNames.Message, EmailMessage.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new EmailMessage(srv); - } - }, new ICreateServiceObjectWithAttachmentParam() { - public Object createServiceObjectWithAttachmentParam( - ItemAttachment itemAttachment, boolean isNew) - throws Exception { - return new EmailMessage(itemAttachment); - } - }); - - // Folder - this.addServiceObjectType(XmlElementNames.Folder, Folder.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new Folder(srv); - } - }, null); - - // Item - this.addServiceObjectType(XmlElementNames.Item, Item.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new Item(srv); - } - }, new ICreateServiceObjectWithAttachmentParam() { - public Object createServiceObjectWithAttachmentParam( - ItemAttachment itemAttachment, boolean isNew) - throws Exception { - return new Item(itemAttachment); - } - }); - - // MeetingCancellation - this.addServiceObjectType(XmlElementNames.MeetingCancellation, - MeetingCancellation.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new MeetingCancellation(srv); - } - }, new ICreateServiceObjectWithAttachmentParam() { - public Object createServiceObjectWithAttachmentParam( - ItemAttachment itemAttachment, boolean isNew) - throws Exception { - return new MeetingCancellation(itemAttachment); - } - }); - - // MeetingMessage - this.addServiceObjectType(XmlElementNames.MeetingMessage, - MeetingMessage.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new MeetingMessage(srv); - } - }, new ICreateServiceObjectWithAttachmentParam() { - public Object createServiceObjectWithAttachmentParam( - ItemAttachment itemAttachment, boolean isNew) - throws Exception { - return new MeetingMessage(itemAttachment); - } - }); - - // MeetingRequest - this.addServiceObjectType(XmlElementNames.MeetingRequest, - MeetingRequest.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new MeetingRequest(srv); - } - }, new ICreateServiceObjectWithAttachmentParam() { - public Object createServiceObjectWithAttachmentParam( - ItemAttachment itemAttachment, boolean isNew) - throws Exception { - return new MeetingRequest(itemAttachment); - } - }); - - // MeetingResponse - this.addServiceObjectType(XmlElementNames.MeetingResponse, - MeetingResponse.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new MeetingResponse(srv); - } - }, new ICreateServiceObjectWithAttachmentParam() { - public Object createServiceObjectWithAttachmentParam( - ItemAttachment itemAttachment, boolean isNew) - throws Exception { - return new MeetingResponse(itemAttachment); - } - }); - - // PostItem - this.addServiceObjectType(XmlElementNames.PostItem, PostItem.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new PostItem(srv); - } - }, new ICreateServiceObjectWithAttachmentParam() { - public Object createServiceObjectWithAttachmentParam( - ItemAttachment itemAttachment, boolean isNew) - throws Exception { - return new PostItem(itemAttachment); - } - }); - - // SearchFolder - this.addServiceObjectType(XmlElementNames.SearchFolder, - SearchFolder.class, new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new SearchFolder(srv); - } - }, null); - - // Task - this.addServiceObjectType(XmlElementNames.Task, Task.class, - new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new Task(srv); - } - }, new ICreateServiceObjectWithAttachmentParam() { - public Object createServiceObjectWithAttachmentParam( - ItemAttachment itemAttachment, boolean isNew) - throws Exception { - return new Task(itemAttachment); - } - }); - - // TasksFolder - this.addServiceObjectType(XmlElementNames.TasksFolder, - TasksFolder.class, new ICreateServiceObjectWithServiceParam() { - public Object createServiceObjectWithServiceParam( - ExchangeService srv) throws Exception { - return new TasksFolder(srv); - } - }, null); - } - - /** - * Adds specified type of service object to map. - * - * @param xmlElementName the xml element name - * @param cls the cls - * @param createServiceObjectWithServiceParam the create service object with service param - * @param createServiceObjectWithAttachmentParam the create service object with attachment param - */ - private void addServiceObjectType( - String xmlElementName, - Class cls, - ICreateServiceObjectWithServiceParam createServiceObjectWithServiceParam, - ICreateServiceObjectWithAttachmentParam createServiceObjectWithAttachmentParam) { - this.xmlElementNameToServiceObjectClassMap.put(xmlElementName, cls); - this.serviceObjectConstructorsWithServiceParam.put(cls, - createServiceObjectWithServiceParam); - if (createServiceObjectWithAttachmentParam != null) { - this.serviceObjectConstructorsWithAttachmentParam.put(cls, - createServiceObjectWithAttachmentParam); - } - } - - /** - * Return Dictionary that maps from element name to ServiceObject Type. - * - * @return the xml element name to service object class map - */ - public Map> getXmlElementNameToServiceObjectClassMap() { - return this.xmlElementNameToServiceObjectClassMap; - } - - /** - * Return Dictionary that maps from ServiceObject Type to - * CreateServiceObjectWithServiceParam delegate with ExchangeService - * parameter. - * - * @return the service object constructors with service param - */ - public Map, ICreateServiceObjectWithServiceParam> - getServiceObjectConstructorsWithServiceParam() { - return this.serviceObjectConstructorsWithServiceParam; - } - - /** - * Return Dictionary that maps from ServiceObject Type to - * CreateServiceObjectWithAttachmentParam delegate with ItemAttachment - * parameter. - * - * @return the service object constructors with attachment param - */ - public Map, ICreateServiceObjectWithAttachmentParam> - getServiceObjectConstructorsWithAttachmentParam() { - return this.serviceObjectConstructorsWithAttachmentParam; - } - - /** - * Set event to happen when property changed. - * - * @param change change event - */ - protected void addOnChangeEvent( - ICreateServiceObjectWithAttachmentParam change) { - onChangeList.add(change); - } - - /** - * Remove the event from happening when property changed. - * - * @param change change event - */ - protected void removeChangeEvent( - ICreateServiceObjectWithAttachmentParam change) { - onChangeList.remove(change); - } - - /** - * The on change list. - */ - private List onChangeList = - new ArrayList(); - - /** - * The on change list1. - */ - private List onChangeList1 = - new ArrayList(); - - /** - * Set event to happen when property changed. - * - * @param change change event - */ - protected void addOnChangeEvent( - ICreateServiceObjectWithServiceParam change) { - onChangeList1.add(change); - } - - /** - * Remove the event from happening when property changed. - * - * @param change change event - */ - protected void removeChangeEvent( - ICreateServiceObjectWithServiceParam change) { - onChangeList1.remove(change); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/folder/CalendarFolder.java b/src/main/java/microsoft/exchange/webservices/data/core/service/folder/CalendarFolder.java deleted file mode 100644 index 199377618..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/folder/CalendarFolder.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.folder; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.FindItemResponse; -import microsoft.exchange.webservices.data.core.response.ServiceResponseCollection; -import microsoft.exchange.webservices.data.core.service.item.Appointment; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.search.CalendarView; -import microsoft.exchange.webservices.data.search.FindItemsResults; -import microsoft.exchange.webservices.data.search.filter.SearchFilter; - -/** - * Represents a folder containing appointments. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.CalendarFolder) -public class CalendarFolder extends Folder { - - /** - * Binds to an existing calendar folder and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @param propertySet the property set - * @return A CalendarFolder instance representing the calendar folder - * corresponding to the specified Id - * @throws Exception the exception - */ - public static CalendarFolder bind(ExchangeService service, FolderId id, - PropertySet propertySet) throws Exception { - return service.bindToFolder(CalendarFolder.class, id, propertySet); - } - - /** - * Binds to an existing calendar folder and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @return A CalendarFolder instance representing the calendar folder - * corresponding to the specified Id - * @throws Exception the exception - */ - public static CalendarFolder bind(ExchangeService service, FolderId id) - throws Exception { - return CalendarFolder.bind(service, id, PropertySet - .getFirstClassProperties()); - } - - /** - * Binds to an existing calendar folder and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service the service - * @param name the name - * @param propertySet the property set - * @return A CalendarFolder instance representing the calendar folder with - * the specified name. - * @throws Exception the exception - */ - public static CalendarFolder bind(ExchangeService service, - WellKnownFolderName name, PropertySet - propertySet) throws Exception { - return CalendarFolder.bind(service, new FolderId(name), propertySet); - } - - /** - * Binds to an existing calendar folder and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service the service - * @param name the name - * @return A CalendarFolder instance representing the calendar folder with - * the specified name. - * @throws Exception the exception - */ - public static CalendarFolder bind(ExchangeService service, - WellKnownFolderName name) throws Exception { - return CalendarFolder.bind(service, new FolderId(name), PropertySet - .getFirstClassProperties()); - } - - /** - * Initializes an unsaved local instance of "CalendarFolder". To bind to an - * existing calendar folder, use CalendarFolder.Bind() instead. Calling this - * method results in a call to EWS. - * - * @param service the service - * @throws Exception the exception - */ - public CalendarFolder(ExchangeService service) throws Exception { - super(service); - } - - /** - * Obtains a list of appointments by searching the contents of this folder - * and performing recurrence expansion for recurring appointments. Calling - * this method results in a call to EWS. - * - * @param view the view - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindItemsResults findAppointments(CalendarView view) - throws Exception { - EwsUtilities.validateParam(view, "view"); - - ServiceResponseCollection> responses = - this.internalFindItems((SearchFilter) null, view, null - /* groupBy */); - - return responses.getResponseAtIndex(0).getResults(); - } - - /** - * Obtains a list of appointments by searching the contents of this folder - * and performing recurrence expansion. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/folder/ContactsFolder.java b/src/main/java/microsoft/exchange/webservices/data/core/service/folder/ContactsFolder.java deleted file mode 100644 index f0e66b8a4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/folder/ContactsFolder.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.folder; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -/** - * Represents a folder containing contacts. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.ContactsFolder) -public class ContactsFolder extends Folder { - - /** - * Initializes an unsaved local instance of the class.To bind to an - * existing contacts folder, use ContactsFolder.Bind() instead. - * - * @param service the service - * @throws Exception the exception - */ - public ContactsFolder(ExchangeService service) throws Exception { - super(service); - } - - /** - * Binds to an existing contacts folder and loads the specified set of - * property. - * - * @param service the service - * @param id the id - * @param propertySet the property set - * @return A ContactsFolder instance representing the contacts folder - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static ContactsFolder bind(ExchangeService service, FolderId id, - PropertySet propertySet) throws Exception { - return service.bindToFolder(ContactsFolder.class, id, propertySet); - } - - /** - * Binds to an existing contacts folder and loads its first class - * property. - * - * @param service the service - * @param id the id - * @return A ContactsFolder instance representing the contacts folder - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static ContactsFolder bind(ExchangeService service, FolderId id) - throws Exception { - return ContactsFolder.bind(service, id, PropertySet - .getFirstClassProperties()); - } - - /** - * Binds to an existing contacts folder and loads the specified set of - * property. - * - * @param service the service - * @param name the name - * @param propertySet the property set - * @return A ContactsFolder instance representing the contacts folder - * corresponding to the specified name. - * @throws Exception the exception - */ - public static ContactsFolder bind(ExchangeService service, - WellKnownFolderName name, PropertySet propertySet) - throws Exception { - return ContactsFolder.bind(service, new FolderId(name), propertySet); - } - - /** - * Binds to an existing contacts folder and loads its first class - * property. - * - * @param service the service - * @param name the name - * @return A ContactsFolder instance representing the contacts folder - * corresponding to the specified name. - * @throws Exception the exception - */ - public static ContactsFolder bind(ExchangeService service, - WellKnownFolderName name) throws Exception { - return ContactsFolder.bind(service, new FolderId(name), PropertySet - .getFirstClassProperties()); - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/folder/Folder.java b/src/main/java/microsoft/exchange/webservices/data/core/service/folder/Folder.java deleted file mode 100644 index 77849c1f2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/folder/Folder.java +++ /dev/null @@ -1,782 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.folder; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.FindItemResponse; -import microsoft.exchange.webservices.data.core.response.ServiceResponseCollection; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.schema.FolderSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.enumeration.service.EffectiveRights; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.core.exception.misc.InvalidOperationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.ExtendedPropertyCollection; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.FolderPermissionCollection; -import microsoft.exchange.webservices.data.property.complex.ManagedFolderInformation; -import microsoft.exchange.webservices.data.property.definition.ExtendedPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; -import microsoft.exchange.webservices.data.search.FindFoldersResults; -import microsoft.exchange.webservices.data.search.FindItemsResults; -import microsoft.exchange.webservices.data.search.FolderView; -import microsoft.exchange.webservices.data.search.GroupedFindItemsResults; -import microsoft.exchange.webservices.data.search.Grouping; -import microsoft.exchange.webservices.data.search.ItemView; -import microsoft.exchange.webservices.data.search.ViewBase; -import microsoft.exchange.webservices.data.search.filter.SearchFilter; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.ArrayList; -import java.util.EnumSet; - -/** - * Represents a generic folder. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.Folder) -public class Folder extends ServiceObject { - - private static final Log LOG = LogFactory.getLog(Folder.class); - - /** - * Initializes an unsaved local instance of {@link Folder}. - * - * @param service EWS service to which this object belongs - * @throws Exception the exception - */ - public Folder(ExchangeService service) throws Exception { - super(service); - } - - /** - * Binds to an existing folder, whatever its actual type is, and loads the - * specified set of property. Calling this method results in a call to - * EWS. - * - * @param service The service to use to bind to the folder. - * @param id The Id of the folder to bind to. - * @param propertySet The set of property to load. - * @return A Folder instance representing the folder corresponding to the - * specified Id. - * @throws Exception the exception - */ - public static Folder bind(ExchangeService service, FolderId id, - PropertySet propertySet) throws Exception { - return service.bindToFolder(Folder.class, id, propertySet); - } - - /** - * Binds to an existing folder, whatever its actual type is, and loads the - * specified set of property. Calling this method results in a call to - * EWS. - * - * @param service , The service to use to bind to the folder. - * @param id , The Id of the folder to bind to. - * @return A Folder instance representing the folder corresponding to the - * specified Id. - * @throws Exception the exception - */ - public static Folder bind(ExchangeService service, FolderId id) - throws Exception { - return Folder.bind(service, id, PropertySet.getFirstClassProperties()); - } - - /** - * Binds to an existing folder, whatever its actual type is, and loads the - * specified set of property. Calling this method results in a call to - * EWS. - * - * @param service The service to use to bind to the folder. - * @param name The name of the folder to bind to. - * @param propertySet The set of property to load. - * @return A Folder instance representing the folder corresponding to the - * specified Id. - * @throws Exception the exception - */ - public static Folder bind(ExchangeService service, - WellKnownFolderName name, PropertySet propertySet) - throws Exception { - return Folder.bind(service, new FolderId(name), propertySet); - } - - /** - * Binds to an existing folder, whatever its actual type is, and loads the - * specified set of property. Calling this method results in a call to - * EWS. - * - * @param service The service to use to bind to the folder. - * @param name The name of the folder to bind to. - * @return the folder - * @throws Exception the exception - */ - public static Folder bind(ExchangeService service, WellKnownFolderName name) - throws Exception { - return Folder.bind(service, new FolderId(name), PropertySet - .getFirstClassProperties()); - } - - /** - * Validates this instance. - * - * @throws Exception the exception - */ - @Override public void validate() throws Exception { - super.validate(); - - // Validate folder permissions - try { - if (this.getPropertyBag().contains(FolderSchema.Permissions)) { - this.getPermissions().validate(); - } - } catch (ServiceLocalException e) { - LOG.error(e); - } - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return FolderSchema.Instance; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the name of the change XML element. - * - * @return Xml element name - */ - @Override public String getChangeXmlElementName() { - return XmlElementNames.FolderChange; - } - - /** - * Gets the name of the set field XML element. - * - * @return Xml element name - */ - @Override public String getSetFieldXmlElementName() { - return XmlElementNames.SetFolderField; - } - - /** - * Gets the name of the delete field XML element. - * - * @return Xml element name - */ - @Override public String getDeleteFieldXmlElementName() { - return XmlElementNames.DeleteFolderField; - } - - /** - * Loads the specified set of property on the object. - * - * @param propertySet The property to load. - * @throws Exception the exception - */ - @Override - protected void internalLoad(PropertySet propertySet) throws Exception { - this.throwIfThisIsNew(); - - this.getService().loadPropertiesForFolder(this, propertySet); - } - - /** - * Deletes the object. - * - * @param deleteMode the delete mode - * @param sendCancellationsMode Indicates whether meeting cancellation messages should be - * sent. - * @param affectedTaskOccurrences Indicate which occurrence of a recurring task should be - * deleted. - * @throws Exception the exception - */ - @Override - protected void internalDelete(DeleteMode deleteMode, - SendCancellationsMode sendCancellationsMode, - AffectedTaskOccurrence affectedTaskOccurrences) throws Exception { - try { - this.throwIfThisIsNew(); - } catch (InvalidOperationException e) { - LOG.error(e); - } - - this.getService().deleteFolder(this.getId(), deleteMode); - } - - /** - * Deletes the folder. Calling this method results in a call to EWS. - * - * @param deleteMode the delete mode - * @throws Exception the exception - */ - public void delete(DeleteMode deleteMode) throws Exception { - this.internalDelete(deleteMode, null, null); - } - - /** - * Empties the folder. Calling this method results in a call to EWS. - * - * @param deletemode the delete mode - * @param deleteSubFolders Indicates whether sub-folder should also be deleted. - * @throws Exception - */ - public void empty(DeleteMode deletemode, boolean deleteSubFolders) - throws Exception { - this.throwIfThisIsNew(); - this.getService().emptyFolder(this.getId(), - deletemode, deleteSubFolders); - } - - /** - * Saves this folder in a specific folder. Calling this method results in a - * call to EWS. - * - * @param parentFolderId The Id of the folder in which to save this folder. - * @throws Exception the exception - */ - public void save(FolderId parentFolderId) throws Exception { - this.throwIfThisIsNotNew(); - - EwsUtilities.validateParam(parentFolderId, "parentFolderId"); - - if (this.isDirty()) { - this.getService().createFolder(this, parentFolderId); - } - } - - /** - * Saves this folder in a specific folder. Calling this method results in a - * call to EWS. - * - * @param parentFolderName The name of the folder in which to save this folder. - * @throws Exception the exception - */ - public void save(WellKnownFolderName parentFolderName) throws Exception { - this.save(new FolderId(parentFolderName)); - } - - /** - * Applies the local changes that have been made to this folder. Calling - * this method results in a call to EWS. - * - * @throws Exception the exception - */ - public void update() throws Exception { - if (this.isDirty()) { - if (this.getPropertyBag().getIsUpdateCallNecessary()) { - this.getService().updateFolder(this); - } - } - } - - /** - * Copies this folder into a specific folder. Calling this method results in - * a call to EWS. - * - * @param destinationFolderId The Id of the folder in which to copy this folder. - * @return A Folder representing the copy of this folder. - * @throws Exception the exception - */ - public Folder copy(FolderId destinationFolderId) throws Exception { - this.throwIfThisIsNew(); - - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - - return this.getService().copyFolder(this.getId(), destinationFolderId); - } - - /** - * Copies this folder into the specified folder. Calling this method results - * in a call to EWS. - * - * @param destinationFolderName The name of the folder in which to copy this folder. - * @return A Folder representing the copy of this folder. - * @throws Exception the exception - */ - public Folder copy(WellKnownFolderName destinationFolderName) - throws Exception { - return this.copy(new FolderId(destinationFolderName)); - } - - /** - * Moves this folder to a specific folder. Calling this method results in a - * call to EWS. - * - * @param destinationFolderId The Id of the folder in which to move this folder. - * @return A new folder representing this folder in its new location. After - * Move completes, this folder does not exist anymore. - * @throws Exception the exception - */ - public Folder move(FolderId destinationFolderId) throws Exception { - this.throwIfThisIsNew(); - - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - - return this.getService().moveFolder(this.getId(), destinationFolderId); - } - - /** - * Moves this folder to a specific folder. Calling this method results in a - * call to EWS. - * - * @param destinationFolderName The name of the folder in which to move this folder. - * @return A new folder representing this folder in its new location. After - * Move completes, this folder does not exist anymore. - * @throws Exception the exception - */ - public Folder move(WellKnownFolderName destinationFolderName) - throws Exception { - return this.move(new FolderId(destinationFolderName)); - } - - /** - * Find item. - * - * @param The type of the item. - * @param queryString query string to be used for indexed search - * @param view The view controlling the number of item returned. - * @param groupBy The group by. - * @return FindItems response collection. - * @throws Exception the exception - */ - ServiceResponseCollection> - internalFindItems(String queryString, - ViewBase view, Grouping groupBy) - throws Exception { - ArrayList folderIdArry = new ArrayList(); - folderIdArry.add(this.getId()); - - this.throwIfThisIsNew(); - return this.getService().findItems(folderIdArry, - null, /* searchFilter */ - queryString, view, groupBy, ServiceErrorHandling.ThrowOnError); - - } - - /** - * Find item. - * - * @param The type of the item. - * @param searchFilter The search filter. Available search filter classes include - * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection - * @param view The view controlling the number of item returned. - * @param groupBy The group by. - * @return FindItems response collection. - * @throws Exception the exception - */ - ServiceResponseCollection> - internalFindItems(SearchFilter searchFilter, - ViewBase view, Grouping groupBy) - throws Exception { - ArrayList folderIdArry = new ArrayList(); - folderIdArry.add(this.getId()); - this.throwIfThisIsNew(); - - return this.getService().findItems(folderIdArry, searchFilter, - null, /* queryString */ - view, groupBy, ServiceErrorHandling.ThrowOnError); - } - - /** - * Find item. - * - * @param searchFilter The search filter. Available search filter classes include - * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection - * @param view The view controlling the number of item returned. - * @return FindItems results collection. - * @throws Exception the exception - */ - public FindItemsResults findItems(SearchFilter searchFilter, - ItemView view) throws Exception { - EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); - - ServiceResponseCollection> responses = this - .internalFindItems(searchFilter, view, null /* groupBy */); - - return responses.getResponseAtIndex(0).getResults(); - } - - /** - * Find item. - * - * @param queryString query string to be used for indexed search - * @param view The view controlling the number of item returned. - * @return FindItems results collection. - * @throws Exception the exception - */ - public FindItemsResults findItems(String queryString, ItemView view) - throws Exception { - EwsUtilities.validateParamAllowNull(queryString, "queryString"); - - ServiceResponseCollection> responses = this - .internalFindItems(queryString, view, null /* groupBy */); - - return responses.getResponseAtIndex(0).getResults(); - } - - /** - * Find item. - * - * @param view The view controlling the number of item returned. - * @return FindItems results collection. - * @throws Exception the exception - */ - public FindItemsResults findItems(ItemView view) throws Exception { - ServiceResponseCollection> responses = this - .internalFindItems((SearchFilter) null, view, - null /* groupBy */); - - return responses.getResponseAtIndex(0).getResults(); - } - - /** - * Find item. - * - * @param searchFilter The search filter. Available search filter classes include - * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection - * @param view The view controlling the number of item returned. - * @param groupBy The group by. - * @return A collection of grouped item representing the contents of this - * folder. - * @throws Exception the exception - */ - public GroupedFindItemsResults findItems(SearchFilter searchFilter, - ItemView view, Grouping groupBy) throws Exception { - EwsUtilities.validateParam(groupBy, "groupBy"); - EwsUtilities.validateParamAllowNull(searchFilter, "searchFilter"); - - ServiceResponseCollection> responses = this - .internalFindItems(searchFilter, view, groupBy); - - return responses.getResponseAtIndex(0).getGroupedFindResults(); - } - - /** - * Find item. - * - * @param queryString query string to be used for indexed search - * @param view The view controlling the number of item returned. - * @param groupBy The group by. - * @return A collection of grouped item representing the contents of this - * folder. - * @throws Exception the exception - */ - public GroupedFindItemsResults findItems(String queryString, - ItemView view, Grouping groupBy) throws Exception { - EwsUtilities.validateParam(groupBy, "groupBy"); - - ServiceResponseCollection> responses = this - .internalFindItems(queryString, view, groupBy); - - return responses.getResponseAtIndex(0).getGroupedFindResults(); - } - - /** - * Obtains a list of folder by searching the sub-folder of this folder. - * Calling this method results in a call to EWS. - * - * @param view The view controlling the number of folder returned. - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindFoldersResults findFolders(FolderView view) throws Exception { - this.throwIfThisIsNew(); - - return this.getService().findFolders(this.getId(), view); - } - - /** - * Obtains a list of folder by searching the sub-folder of this folder. - * Calling this method results in a call to EWS. - * - * @param searchFilter The search filter. Available search filter classes include - * SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection - * @param view The view controlling the number of folder returned. - * @return An object representing the results of the search operation. - * @throws Exception the exception - */ - public FindFoldersResults findFolders(SearchFilter searchFilter, - FolderView view) throws Exception { - this.throwIfThisIsNew(); - - return this.getService().findFolders(this.getId(), searchFilter, view); - } - - /** - * Obtains a grouped list of item by searching the contents of this folder. - * Calling this method results in a call to EWS. - * - * @param view The view controlling the number of folder returned. - * @param groupBy The grouping criteria. - * @return A collection of grouped item representing the contents of this - * folder. - * @throws Exception the exception - */ - public GroupedFindItemsResults findItems(ItemView view, - Grouping groupBy) throws Exception { - EwsUtilities.validateParam(groupBy, "groupBy"); - - return this.findItems((SearchFilter) null, view, groupBy); - } - - /** - * Get the property definition for the Id property. - * - * @return the id property definition - */ - @Override public PropertyDefinition getIdPropertyDefinition() { - return FolderSchema.Id; - } - - /** - * Sets the extended property. - * - * @param extendedPropertyDefinition The extended property definition. - * @param value The value. - * @throws Exception the exception - */ - public void setExtendedProperty( - ExtendedPropertyDefinition extendedPropertyDefinition, Object value) - throws Exception { - this.getExtendedProperties().setExtendedProperty( - extendedPropertyDefinition, value); - } - - /** - * Removes an extended property. - * - * @param extendedPropertyDefinition The extended property definition. - * @return True if property was removed. - * @throws Exception the exception - */ - public boolean removeExtendedProperty( - ExtendedPropertyDefinition extendedPropertyDefinition) - throws Exception { - return this.getExtendedProperties().removeExtendedProperty( - extendedPropertyDefinition); - } - - /** - * True if property was removed. - * - * @return Extended property collection. - * @throws Exception the exception - */ - @Override - protected ExtendedPropertyCollection getExtendedProperties() - throws Exception { - return this.getExtendedPropertiesForService(); - } - - /** - * Gets the Id of the folder. - * - * @return the id - */ - public FolderId getId() { - try { - return getPropertyBag().getObjectFromPropertyDefinition( - getIdPropertyDefinition()); - } catch (ServiceLocalException e) { - LOG.error(e); - return null; - } - } - - /** - * Gets the Id of this folder's parent folder. - * - * @return the parent folder id - * @throws ServiceLocalException the service local exception - */ - public FolderId getParentFolderId() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - FolderSchema.ParentFolderId); - } - - /** - * Gets the number of child folder this folder has. - * - * @return the child folder count - * @throws NumberFormatException the number format exception - * @throws ServiceLocalException the service local exception - */ - public int getChildFolderCount() throws NumberFormatException, - ServiceLocalException { - return (Integer.parseInt(this.getPropertyBag() - .getObjectFromPropertyDefinition(FolderSchema.ChildFolderCount) - .toString())); - } - - /** - * Gets the display name of the folder. - * - * @return the display name - * @throws ServiceLocalException the service local exception - */ - public String getDisplayName() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - FolderSchema.DisplayName); - } - - /** - * Sets the display name of the folder. - * - * @param value Name of the folder - * @throws Exception the exception - */ - public void setDisplayName(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - FolderSchema.DisplayName, value); - } - - /** - * Gets the custom class name of this folder. - * - * @return the folder class - * @throws ServiceLocalException the service local exception - */ - public String getFolderClass() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - FolderSchema.FolderClass); - } - - /** - * Sets the custom class name of this folder. - * - * @param value name of the folder - * @throws Exception the exception - */ - public void setFolderClass(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - FolderSchema.FolderClass, value); - } - - /** - * Gets the total number of item contained in the folder. - * - * @return the total count - * @throws NumberFormatException the number format exception - * @throws ServiceLocalException the service local exception - */ - public int getTotalCount() throws NumberFormatException, - ServiceLocalException { - return (Integer.parseInt(this.getPropertyBag() - .getObjectFromPropertyDefinition(FolderSchema.TotalCount) - .toString())); - } - - /** - * Gets a list of extended property associated with the folder. - * - * @return the extended property for service - * @throws ServiceLocalException the service local exception - */ - // changed the name of method as another method with same name exists - public ExtendedPropertyCollection getExtendedPropertiesForService() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ServiceObjectSchema.extendedProperties); - } - - /** - * Gets the Email Lifecycle Management (ELC) information associated with the - * folder. - * - * @return the managed folder information - * @throws ServiceLocalException the service local exception - */ - public ManagedFolderInformation getManagedFolderInformation() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - FolderSchema.ManagedFolderInformation); - } - - /** - * Gets a value indicating the effective rights the current authenticated - * user has on the folder. - * - * @return the effective rights - * @throws ServiceLocalException the service local exception - */ - public EnumSet getEffectiveRights() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - FolderSchema.EffectiveRights); - } - - /** - * Gets a list of permissions for the folder. - * - * @return the permissions - * @throws ServiceLocalException the service local exception - */ - public FolderPermissionCollection getPermissions() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - FolderSchema.Permissions); - } - - /** - * Gets the number of unread item in the folder. - * - * @return the unread count - * @throws NumberFormatException the number format exception - * @throws ServiceLocalException the service local exception - */ - public int getUnreadCount() throws NumberFormatException, - ServiceLocalException { - return (Integer.parseInt(this.getPropertyBag() - .getObjectFromPropertyDefinition(FolderSchema.UnreadCount) - .toString())); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/folder/SearchFolder.java b/src/main/java/microsoft/exchange/webservices/data/core/service/folder/SearchFolder.java deleted file mode 100644 index ee205c3fe..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/folder/SearchFolder.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.folder; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.schema.SearchFolderSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.SearchFolderParameters; - -/** - * Represents a search folder. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.SearchFolder, returnedByServer = true) -public class SearchFolder extends Folder { - - /** - * Binds to an existing search folder and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @param propertySet the property set - * @return A SearchFolder instance representing the search folder - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static SearchFolder bind(ExchangeService service, FolderId id, - PropertySet propertySet) throws Exception { - return service.bindToFolder(SearchFolder.class, id, propertySet); - } - - /** - * Binds to an existing search folder and loads its first class property. - * Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @return A SearchFolder instance representing the search folder - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static SearchFolder bind(ExchangeService service, FolderId id) - throws Exception { - return SearchFolder.bind(service, id, PropertySet - .getFirstClassProperties()); - } - - /** - * Binds to an existing search folder and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service the service - * @param name the name - * @param propertySet the property set - * @return A SearchFolder instance representing the search folder with the - * specified name. - * @throws Exception the exception - */ - public static SearchFolder bind(ExchangeService service, - WellKnownFolderName name, PropertySet propertySet) - throws Exception { - return SearchFolder.bind(service, new FolderId(name), propertySet); - } - - /** - * Binds to an existing search folder and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service the service - * @param name the name - * @return A SearchFolder instance representing the search folder with the - * specified name. - * @throws Exception the exception - */ - public static SearchFolder bind(ExchangeService service, - WellKnownFolderName name) throws Exception { - return SearchFolder.bind(service, new FolderId(name), PropertySet - .getFirstClassProperties()); - } - - /** - * Initializes an unsaved local instance of the class. To bind to an - * existing search folder, use SearchFolder.Bind() instead. - * - * @param service the service - * @throws Exception the exception - */ - public SearchFolder(ExchangeService service) throws Exception { - super(service); - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return SearchFolderSchema.Instance; - } - - /** - * Validates this instance. - * - * @throws Exception the exception - */ - @Override public void validate() throws Exception { - super.validate(); - if (this.getSearchParameters() != null) { - this.getSearchParameters().validate(); - } - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the search parameters associated with the search folder. - * - * @return the search parameters - * @throws Exception the exception - */ - public SearchFolderParameters getSearchParameters() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - SearchFolderSchema.SearchParameters); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/folder/TasksFolder.java b/src/main/java/microsoft/exchange/webservices/data/core/service/folder/TasksFolder.java deleted file mode 100644 index bf336ec3f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/folder/TasksFolder.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.folder; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -/** - * Represents a folder containing task item. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.TasksFolder) -public class TasksFolder extends Folder { - - /** - * Initializes an unsaved local instance of the class. - * - * @param service the service - * @throws Exception the exception - */ - public TasksFolder(ExchangeService service) throws Exception { - super(service); - } - - /** - * Binds to an existing tasks folder and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @param propertySet the property set - * @return A TasksFolder instance representing the task folder corresponding - * to the specified Id. - * @throws Exception the exception - */ - public static TasksFolder bind(ExchangeService service, FolderId id, - PropertySet propertySet) throws Exception { - return service.bindToFolder(TasksFolder.class, id, propertySet); - } - - /** - * Binds to an existing tasks folder and loads its first class property. - * Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @return A TasksFolder instance representing the task folder corresponding - * to the specified Id. - * @throws Exception the exception - */ - public static TasksFolder bind(ExchangeService service, FolderId id) - throws Exception { - return TasksFolder.bind(service, id, PropertySet - .getFirstClassProperties()); - } - - /** - * Binds to an existing tasks folder and loads specified set of property. - * Calling this method results in a call to EWS. - * - * @param service the service - * @param name the name - * @param propertySet the property set - * @return A TasksFolder instance representing the tasks folder with the - * specified name. - * @throws Exception the exception - */ - public static TasksFolder bind(ExchangeService service, - WellKnownFolderName name, PropertySet propertySet) - throws Exception { - return TasksFolder.bind(service, new FolderId(name), propertySet); - } - - /** - * Binds to an existing tasks folder and loads its first class property. - * Calling this method results in a call to EWS. - * - * @param service the service - * @param name the name - * @return A TasksFolder instance representing the tasks folder with the - * specified name. - * @throws Exception the exception - */ - public static TasksFolder bind(ExchangeService service, - WellKnownFolderName name) throws Exception { - return TasksFolder.bind(service, new FolderId(name), PropertySet - .getFirstClassProperties()); - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/Appointment.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/Appointment.java deleted file mode 100644 index 74a40149b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/Appointment.java +++ /dev/null @@ -1,1266 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.attribute.Attachable; -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.response.AcceptMeetingInvitationMessage; -import microsoft.exchange.webservices.data.core.service.response.CancelMeetingMessage; -import microsoft.exchange.webservices.data.core.service.response.DeclineMeetingInvitationMessage; -import microsoft.exchange.webservices.data.core.service.response.ResponseMessage; -import microsoft.exchange.webservices.data.core.service.schema.AppointmentSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AppointmentType; -import microsoft.exchange.webservices.data.core.enumeration.service.ConflictResolutionMode; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.LegacyFreeBusyStatus; -import microsoft.exchange.webservices.data.core.enumeration.property.MeetingResponseType; -import microsoft.exchange.webservices.data.core.enumeration.service.ResponseMessageType; -import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode; -import microsoft.exchange.webservices.data.core.enumeration.service.SendInvitationsMode; -import microsoft.exchange.webservices.data.core.enumeration.service.SendInvitationsOrCancellationsMode; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.misc.CalendarActionResults; -import microsoft.exchange.webservices.data.misc.TimeSpan; -import microsoft.exchange.webservices.data.property.complex.AppointmentOccurrenceId; -import microsoft.exchange.webservices.data.property.complex.AttendeeCollection; -import microsoft.exchange.webservices.data.property.complex.DeletedOccurrenceInfoCollection; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; -import microsoft.exchange.webservices.data.property.complex.ItemCollection; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.MessageBody; -import microsoft.exchange.webservices.data.property.complex.OccurrenceInfo; -import microsoft.exchange.webservices.data.property.complex.OccurrenceInfoCollection; -import microsoft.exchange.webservices.data.property.complex.RecurringAppointmentMasterId; -import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence; -import microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition; - -import java.util.Arrays; -import java.util.Date; - -/** - * Represents an appointment or a meeting. Properties available on appointments - * are defined in the AppointmentSchema class. - */ -@Attachable -@ServiceObjectDefinition(xmlElementName = XmlElementNames.CalendarItem) -public class Appointment extends Item implements ICalendarActionProvider { - - /** - * Initializes an unsaved local instance of Appointment". To bind to an - * existing appointment, use Appointment.Bind() instead. - * - * @param service The ExchangeService instance to which this appointmtnt is - * bound. - * @throws Exception the exception - */ - public Appointment(ExchangeService service) throws Exception { - super(service); - } - - /** - * Initializes a new instance of Appointment. - * - * @param parentAttachment the parent attachment - * @param isNew If true, attachment is new. - * @throws Exception the exception - */ - public Appointment(ItemAttachment parentAttachment, boolean isNew) - throws Exception { - // If we're running against Exchange 2007, we need to explicitly preset - // the StartTimeZone property since Exchange 2007 will otherwise scope - // start and end to UTC. - super(parentAttachment); - } - - /** - * Binds to an existing appointment and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @param propertySet the property set - * @return An Appointment instance representing the appointment - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static Appointment bind(ExchangeService service, ItemId id, - PropertySet propertySet) throws Exception { - return service.bindToItem(Appointment.class, id, propertySet); - } - - /** - * Binds to an existing appointment and loads its first class property. - * Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @return An Appointment instance representing the appointment - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static Appointment bind(ExchangeService service, ItemId id) - throws Exception { - return Appointment.bind(service, id, PropertySet.FirstClassProperties); - } - - /** - * Binds to an existing appointment and loads its first class property. - * Calling this method results in a call to EWS. - * - * @param service the service - * @param recurringMasterId the recurring master id - * @param occurenceIndex the occurence index - * @return An Appointment instance representing the appointment - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static Appointment bindToOccurrence(ExchangeService service, - ItemId recurringMasterId, int occurenceIndex) throws Exception { - return Appointment.bindToOccurrence(service, recurringMasterId, - occurenceIndex, PropertySet.FirstClassProperties); - } - - /** - * Binds to an existing appointment and loads its first class property. - * Calling this method results in a call to EWS. - * - * @param service the service - * @param recurringMasterId the recurring master id - * @param occurenceIndex the occurence index - * @param propertySet the property set - * @return An Appointment instance representing the appointment - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static Appointment bindToOccurrence(ExchangeService service, - ItemId recurringMasterId, int occurenceIndex, - PropertySet propertySet) throws Exception { - AppointmentOccurrenceId occurenceId = new AppointmentOccurrenceId( - recurringMasterId.getUniqueId(), occurenceIndex); - return Appointment.bind(service, occurenceId, propertySet); - } - - /** - * Binds to the master appointment of a recurring series and loads its first - * class property. Calling this method results in a call to EWS. - * - * @param service the service - * @param occurrenceId the occurrence id - * @return An Appointment instance representing the appointment - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static Appointment bindToRecurringMaster(ExchangeService service, - ItemId occurrenceId) throws Exception { - return Appointment.bindToRecurringMaster(service, occurrenceId, - PropertySet.FirstClassProperties); - } - - /** - * Binds to the master appointment of a recurring series and loads its first - * class property. Calling this method results in a call to EWS. - * - * @param service the service - * @param occurrenceId the occurrence id - * @param propertySet the property set - * @return An Appointment instance representing the appointment - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static Appointment bindToRecurringMaster(ExchangeService service, - ItemId occurrenceId, PropertySet propertySet) throws Exception { - RecurringAppointmentMasterId recurringMasterId = - new RecurringAppointmentMasterId( - occurrenceId.getUniqueId()); - return Appointment.bind(service, recurringMasterId, propertySet); - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object - */ - @Override public ServiceObjectSchema getSchema() { - return AppointmentSchema.Instance; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Determines whether property defined with - * ScopedDateTimePropertyDefinition require custom time zone scoping. - * - * @return if this item type requires custom scoping for scoped date/time - * property; otherwise, . - */ - @Override - protected boolean getIsCustomDateTimeScopingRequired() { - return true; - } - - /** - * Validates this instance. - * - * @throws Exception - */ - @Override public void validate() throws Exception { - super.validate(); - - // PS # 250452: Make sure that if we're - //on the Exchange2007_SP1 schema version, - // if any of the following - // property are set or updated: - // o Start - // o End - // o IsAllDayEvent - // o Recurrence - // ... then, we must send the MeetingTimeZone element - // (which is generated from StartTimeZone for - // Exchange2007_SP1 request (see - //StartTimeZonePropertyDefinition.cs). - // If the StartTimeZone isn't - // in the property bag, then throw, because clients must - // supply the proper time zone - either by - // loading it from a currently-existing appointment, - //or by setting it directly. - // Otherwise, to dirty - // the StartTimeZone property, we just set it to its current value. - if ((this.getService().getRequestedServerVersion() == ExchangeVersion.Exchange2007_SP1) && - !(this.getService().getExchange2007CompatibilityMode())) { - if (this.getPropertyBag().isPropertyUpdated(AppointmentSchema.Start) || - this.getPropertyBag().isPropertyUpdated(AppointmentSchema.End) || - this.getPropertyBag().isPropertyUpdated(AppointmentSchema.IsAllDayEvent) || - this.getPropertyBag().isPropertyUpdated(AppointmentSchema.Recurrence)) { - // If the property isn't in the property bag, throw.... - if (!this.getPropertyBag().contains(AppointmentSchema.StartTimeZone)) { - throw new ServiceLocalException("StartTimeZone required when setting the Start, End, IsAllDayEvent, " - + "or Recurrence property. You must load or assign this property " - + "before attempting to update the appointment."); - //getStartTimeZoneRequired()); - } - - // Otherwise, set the time zone to its current value to - // force it to be sent with the request. - this.setStartTimeZone(this.getStartTimeZone()); - } - } - } - - /** - * Creates a reply response to the organizer and/or attendees of the - * meeting. - * - * @param replyAll the reply all - * @return A ResponseMessage representing the reply response that can - * subsequently be modified and sent. - * @throws Exception the exception - */ - public ResponseMessage createReply(boolean replyAll) throws Exception { - this.throwIfThisIsNew(); - - return new ResponseMessage(this, - replyAll ? ResponseMessageType.ReplyAll : - ResponseMessageType.Reply); - } - - /** - * Replies to the organizer and/or the attendees of the meeting. Calling - * this method results in a call to EWS. - * - * @param bodyPrefix the body prefix - * @param replyAll the reply all - * @throws Exception the exception - */ - public void reply(MessageBody bodyPrefix, boolean replyAll) - throws Exception { - ResponseMessage responseMessage = this.createReply(replyAll); - - responseMessage.setBodyPrefix(bodyPrefix); - responseMessage.sendAndSaveCopy(); - } - - /** - * Creates a forward message from this appointment. - * - * @return A ResponseMessage representing the forward response that can - * subsequently be modified and sent. - * @throws Exception the exception - */ - public ResponseMessage createForward() throws Exception { - this.throwIfThisIsNew(); - return new ResponseMessage(this, ResponseMessageType.Forward); - } - - /** - * Forwards the appointment. Calling this method results in a call to EWS. - * - * @param bodyPrefix the body prefix - * @param toRecipients the to recipients - * @throws Exception the exception - */ - public void forward(MessageBody bodyPrefix, EmailAddress... toRecipients) - throws Exception { - if (null != toRecipients) { - forward(bodyPrefix, Arrays.asList(toRecipients)); - } - } - - /** - * Forwards the appointment. Calling this method results in a call to EWS. - * - * @param bodyPrefix the body prefix - * @param toRecipients the to recipients - * @throws Exception the exception - */ - public void forward(MessageBody bodyPrefix, - Iterable toRecipients) throws Exception { - ResponseMessage responseMessage = this.createForward(); - - responseMessage.setBodyPrefix(bodyPrefix); - responseMessage.getToRecipients() - .addEmailRange(toRecipients.iterator()); - - responseMessage.sendAndSaveCopy(); - } - - /** - * Saves this appointment in the specified folder. Calling this method - * results in at least one call to EWS. Mutliple calls to EWS might be made - * if attachments have been added. - * - * @param destinationFolderName the destination folder name - * @param sendInvitationsMode the send invitations mode - * @throws Exception the exception - */ - public void save(WellKnownFolderName destinationFolderName, - SendInvitationsMode sendInvitationsMode) throws Exception { - this.internalCreate(new FolderId(destinationFolderName), null, - sendInvitationsMode); - } - - /** - * Saves this appointment in the specified folder. Calling this method - * results in at least one call to EWS. Mutliple calls to EWS might be made - * if attachments have been added. - * - * @param destinationFolderId the destination folder id - * @param sendInvitationsMode the send invitations mode - * @throws Exception the exception - */ - public void save(FolderId destinationFolderId, - SendInvitationsMode sendInvitationsMode) throws Exception { - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - - this.internalCreate(destinationFolderId, null, sendInvitationsMode); - } - - /** - * Saves this appointment in the Calendar folder. Calling this method - * results in at least one call to EWS. Mutliple calls to EWS might be made - * if attachments have been added. - * - * @param sendInvitationsMode the send invitations mode - * @throws Exception the exception - */ - public void save(SendInvitationsMode sendInvitationsMode) throws Exception { - this.internalCreate(null, null, sendInvitationsMode); - } - - /** - * Applies the local changes that have been made to this appointment. - * Calling this method results in at least one call to EWS. Mutliple calls - * to EWS might be made if attachments have been added or removed. - * - * @param conflictResolutionMode the conflict resolution mode - * @param sendInvitationsOrCancellationsMode the send invitations or cancellations mode - * @throws Exception the exception - */ - public void update( - ConflictResolutionMode conflictResolutionMode, - SendInvitationsOrCancellationsMode - sendInvitationsOrCancellationsMode) - throws Exception { - this.internalUpdate(null, conflictResolutionMode, null, - sendInvitationsOrCancellationsMode); - } - - /** - * Deletes this appointment. Calling this method results in a call to EWS. - * - * @param deleteMode the delete mode - * @param sendCancellationsMode the send cancellations mode - * @throws Exception the exception - */ - public void delete(DeleteMode deleteMode, - SendCancellationsMode sendCancellationsMode) throws Exception { - this.internalDelete(deleteMode, sendCancellationsMode, null); - } - - /** - * Creates a local meeting acceptance message that can be customized and - * sent. - * - * @param tentative the tentative - * @return An AcceptMeetingInvitationMessage representing the meeting - * acceptance message. - * @throws Exception the exception - */ - public AcceptMeetingInvitationMessage createAcceptMessage(boolean tentative) - throws Exception { - return new AcceptMeetingInvitationMessage(this, tentative); - } - - /** - * Creates a local meeting acceptance message that can be customized and - * sent. - * - * @return A CancelMeetingMessage representing the meeting cancellation - * message. - * @throws Exception the exception - */ - public CancelMeetingMessage createCancelMeetingMessage() throws Exception { - return new CancelMeetingMessage(this); - } - - /** - * Creates a local meeting declination message that can be customized and - * sent. - * - * @return A DeclineMeetingInvitation representing the meeting declination - * message. - * @throws Exception the exception - */ - public DeclineMeetingInvitationMessage createDeclineMessage() - throws Exception { - return new DeclineMeetingInvitationMessage(this); - } - - /** - * Accepts the meeting. Calling this method results in a call to EWS. - * - * @param sendResponse the send response - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - public CalendarActionResults accept(boolean sendResponse) throws Exception { - return this.internalAccept(false, sendResponse); - } - - /** - * Tentatively accepts the meeting. Calling this method results in a call to - * EWS. - * - * @param sendResponse the send response - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - public CalendarActionResults acceptTentatively(boolean sendResponse) - throws Exception { - return this.internalAccept(true, sendResponse); - } - - /** - * Accepts the meeting. - * - * @param tentative the tentative - * @param sendResponse the send response - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - protected CalendarActionResults internalAccept(boolean tentative, - boolean sendResponse) throws Exception { - AcceptMeetingInvitationMessage accept = this - .createAcceptMessage(tentative); - - if (sendResponse) { - return accept.calendarSendAndSaveCopy(); - } else { - return accept.calendarSave(); - } - } - - /** - * Cancels the meeting and sends cancellation messages to all attendees. - * Calling this method results in a call to EWS. - * - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - public CalendarActionResults cancelMeeting() throws Exception { - return this.createCancelMeetingMessage().calendarSendAndSaveCopy(); - } - - /** - * Cancels the meeting and sends cancellation messages to all attendees. - * Calling this method results in a call to EWS. - * - * @param cancellationMessageText the cancellation message text - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - public CalendarActionResults cancelMeeting(String cancellationMessageText) - throws Exception { - CancelMeetingMessage cancelMsg = this.createCancelMeetingMessage(); - cancelMsg.setBody(new MessageBody(cancellationMessageText)); - return cancelMsg.calendarSendAndSaveCopy(); - } - - /** - * Declines the meeting invitation. Calling this method results in a call to - * EWS. - * - * @param sendResponse the send response - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - public CalendarActionResults decline(boolean - sendResponse) throws Exception { - DeclineMeetingInvitationMessage decline = this.createDeclineMessage(); - - if (sendResponse) { - return decline.calendarSendAndSaveCopy(); - } else { - return decline.calendarSave(); - } - } - - /** - * Gets the default setting for sending cancellations on Delete. - * - * @return If Delete() is called on Appointment, we want to send - * cancellations and save a copy. - */ - @Override - protected SendCancellationsMode getDefaultSendCancellationsMode() { - return SendCancellationsMode.SendToAllAndSaveCopy; - } - - /** - * Gets the default settings for sending invitations on Save. - * - * @return the default send invitations mode - */ - @Override - protected SendInvitationsMode getDefaultSendInvitationsMode() { - return SendInvitationsMode.SendToAllAndSaveCopy; - } - - /** - * Gets the default settings for sending invitations on Save. - * - * @return the default send invitations or cancellations mode - */ - @Override - protected SendInvitationsOrCancellationsMode - getDefaultSendInvitationsOrCancellationsMode() { - return SendInvitationsOrCancellationsMode.SendToAllAndSaveCopy; - } - - // Properties - - /** - * Gets the start time of the appointment. - * - * @return the start - * @throws ServiceLocalException the service local exception - */ - public Date getStart() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.Start); - } - - /** - * Sets the start. - * - * @param value the new start - * @throws Exception the exception - */ - public void setStart(Date value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.Start, value); - } - - /** - * Gets or sets the end time of the appointment. - * - * @return the end - * @throws ServiceLocalException the service local exception - */ - public Date getEnd() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.End); - } - - /** - * Sets the end. - * - * @param value the new end - * @throws Exception the exception - */ - public void setEnd(Date value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.End, value); - } - - /** - * Gets the original start time of this appointment. - * - * @return the original start - * @throws ServiceLocalException the service local exception - */ - public Date getOriginalStart() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.OriginalStart); - } - - /** - * Gets a value indicating whether this appointment is an all day - * event. - * - * @return the checks if is all day event - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsAllDayEvent() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.IsAllDayEvent); - } - - /** - * Sets the checks if is all day event. - * - * @param value the new checks if is all day event - * @throws Exception the exception - */ - public void setIsAllDayEvent(Boolean value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.IsAllDayEvent, value); - } - - /** - * Gets a value indicating the free/busy status of the owner of this - * appointment. - * - * @return the legacy free busy status - * @throws ServiceLocalException the service local exception - */ - public LegacyFreeBusyStatus getLegacyFreeBusyStatus() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.LegacyFreeBusyStatus); - } - - /** - * Sets the legacy free busy status. - * - * @param value the new legacy free busy status - * @throws Exception the exception - */ - public void setLegacyFreeBusyStatus(LegacyFreeBusyStatus value) - throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.LegacyFreeBusyStatus, value); - } - - /** - * Gets the location of this appointment. - * - * @return the location - * @throws ServiceLocalException the service local exception - */ - public String getLocation() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.Location); - } - - /** - * Sets the location. - * - * @param value the new location - * @throws Exception the exception - */ - public void setLocation(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.Location, value); - } - - /** - * Gets a text indicating when this appointment occurs. The text returned by - * When is localized using the Exchange Server culture or using the culture - * specified in the PreferredCulture property of the ExchangeService object - * this appointment is bound to. - * - * @return the when - * @throws ServiceLocalException the service local exception - */ - public String getWhen() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.When); - } - - /** - * Gets a value indicating whether the appointment is a meeting. - * - * @return the checks if is meeting - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsMeeting() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.IsMeeting); - } - - /** - * Gets a value indicating whether the appointment has been cancelled. - * - * @return the checks if is cancelled - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsCancelled() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.IsCancelled); - } - - /** - * Gets a value indicating whether the appointment is recurring. - * - * @return the checks if is recurring - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsRecurring() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.IsRecurring); - } - - /** - * Gets a value indicating whether the meeting request has already been - * sent. - * - * @return the meeting request was sent - * @throws ServiceLocalException the service local exception - */ - public Boolean getMeetingRequestWasSent() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.MeetingRequestWasSent); - } - - /** - * Gets a value indicating whether response are requested when - * invitations are sent for this meeting. - * - * @return the checks if is response requested - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsResponseRequested() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.IsResponseRequested); - } - - /** - * Sets the checks if is response requested. - * - * @param value the new checks if is response requested - * @throws Exception the exception - */ - public void setIsResponseRequested(Boolean value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.IsResponseRequested, value); - } - - /** - * Gets a value indicating the type of this appointment. - * - * @return the appointment type - * @throws ServiceLocalException the service local exception - */ - public AppointmentType getAppointmentType() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.AppointmentType); - } - - /** - * Gets a value indicating what was the last response of the user that - * loaded this meeting. - * - * @return the my response type - * @throws ServiceLocalException the service local exception - */ - public MeetingResponseType getMyResponseType() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.MyResponseType); - } - - /** - * Gets the organizer of this meeting. The Organizer property is read-only - * and is only relevant for attendees. The organizer of a meeting is - * automatically set to the user that created the meeting. - * - * @return the organizer - * @throws ServiceLocalException the service local exception - */ - public EmailAddress getOrganizer() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.Organizer); - } - - /** - * Gets a list of required attendees for this meeting. - * - * @return the required attendees - * @throws ServiceLocalException the service local exception - */ - public AttendeeCollection getRequiredAttendees() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.RequiredAttendees); - } - - /** - * Gets a list of optional attendeed for this meeting. - * - * @return the optional attendees - * @throws ServiceLocalException the service local exception - */ - public AttendeeCollection getOptionalAttendees() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.OptionalAttendees); - } - - /** - * Gets a list of resources for this meeting. - * - * @return the resources - * @throws ServiceLocalException the service local exception - */ - public AttendeeCollection getResources() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.Resources); - } - - /** - * Gets the number of calendar entries that conflict with this appointment - * in the authenticated user's calendar. - * - * @return the conflicting meeting count - * @throws ServiceLocalException the service local exception - */ - public Integer getConflictingMeetingCount() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.ConflictingMeetingCount); - } - - /** - * Gets the number of calendar entries that are adjacent to this appointment - * in the authenticated user's calendar. - * - * @return the adjacent meeting count - * @throws ServiceLocalException the service local exception - */ - public Integer getAdjacentMeetingCount() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.AdjacentMeetingCount); - } - - /** - * Gets a list of meetings that conflict with this appointment in the - * authenticated user's calendar. - * - * @return the conflicting meetings - * @throws ServiceLocalException the service local exception - */ - public ItemCollection getConflictingMeetings() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.ConflictingMeetings); - } - - /** - * Gets a list of meetings that conflict with this appointment in the - * authenticated user's calendar. - * - * @return the adjacent meetings - * @throws ServiceLocalException the service local exception - */ - public ItemCollection getAdjacentMeetings() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.AdjacentMeetings); - } - - /** - * Gets the duration of this appointment. - * - * @return the duration - * @throws ServiceLocalException the service local exception - */ - public TimeSpan getDuration() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.Duration); - } - - /** - * Gets the name of the time zone this appointment is defined in. - * - * @return the time zone - * @throws ServiceLocalException the service local exception - */ - public String getTimeZone() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.TimeZone); - } - - /** - * Gets the time when the attendee replied to the meeting request. - * - * @return the appointment reply time - * @throws ServiceLocalException the service local exception - */ - public Date getAppointmentReplyTime() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.AppointmentReplyTime); - } - - /** - * Gets the sequence number of this appointment. - * - * @return the appointment sequence number - * @throws ServiceLocalException the service local exception - */ - public Integer getAppointmentSequenceNumber() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.AppointmentSequenceNumber); - } - - /** - * Gets the state of this appointment. - * - * @return the appointment state - * @throws ServiceLocalException the service local exception - */ - public Integer getAppointmentState() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.AppointmentState); - } - - /** - * Gets the recurrence pattern for this appointment. Available - * recurrence pattern classes include Recurrence.DailyPattern, - * Recurrence.MonthlyPattern and Recurrence.YearlyPattern. - * - * @return the recurrence - * @throws ServiceLocalException the service local exception - */ - public Recurrence getRecurrence() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.Recurrence); - } - - /** - * Sets the recurrence. - * - * @param value the new recurrence - * @throws Exception the exception - */ - public void setRecurrence(Recurrence value) throws Exception { - if (value != null) { - if (value.isRegenerationPattern()) { - throw new ServiceLocalException("Regeneration pattern can only be used with Task item."); - } - } - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.Recurrence, value); - } - - /** - * Gets an OccurrenceInfo identifying the first occurrence of this meeting. - * - * @return the first occurrence - * @throws ServiceLocalException the service local exception - */ - public OccurrenceInfo getFirstOccurrence() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.FirstOccurrence); - } - - /** - * Gets an OccurrenceInfo identifying the first occurrence of this meeting. - * - * @return the last occurrence - * @throws ServiceLocalException the service local exception - */ - public OccurrenceInfo getLastOccurrence() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.LastOccurrence); - } - - /** - * Gets a list of modified occurrences for this meeting. - * - * @return the modified occurrences - * @throws ServiceLocalException the service local exception - */ - public OccurrenceInfoCollection getModifiedOccurrences() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.ModifiedOccurrences); - } - - /** - * Gets a list of deleted occurrences for this meeting. - * - * @return the deleted occurrences - * @throws ServiceLocalException the service local exception - */ - public DeletedOccurrenceInfoCollection getDeletedOccurrences() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.DeletedOccurrences); - } - - /** - * Gets the start time zone. - * - * @return the start time zone - * @throws ServiceLocalException the service local exception - */ - public TimeZoneDefinition getStartTimeZone() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.StartTimeZone); - } - - /** - * Sets the start time zone. - * - * @param value the new start time zone - * @throws Exception the exception - */ - public void setStartTimeZone(TimeZoneDefinition value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.StartTimeZone, value); - - } - - /** - * Gets the start time zone. - * - * @return the start time zone - * @throws ServiceLocalException the service local exception - */ - public TimeZoneDefinition getEndTimeZone() throws ServiceLocalException { - return getPropertyBag() - .getObjectFromPropertyDefinition(AppointmentSchema.EndTimeZone); - } - - /** - * Sets the start time zone. - * - * @param value the new end time zone - * @throws Exception the exception - */ - public void setEndTimeZone(TimeZoneDefinition value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.EndTimeZone, value); - - } - - /** - * Gets the type of conferencing that will be used during the - * meeting. - * - * @return the conference type - * @throws ServiceLocalException the service local exception - */ - public Integer getConferenceType() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.ConferenceType); - } - - /** - * Sets the conference type. - * - * @param value the new conference type - * @throws Exception the exception - */ - public void setConferenceType(Integer value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.ConferenceType, value); - } - - /** - * Gets a value indicating whether new time proposals are allowed - * for attendees of this meeting. - * - * @return the allow new time proposal - * @throws ServiceLocalException the service local exception - */ - public Boolean getAllowNewTimeProposal() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.AllowNewTimeProposal); - } - - /** - * Sets the allow new time proposal. - * - * @param value the new allow new time proposal - * @throws Exception the exception - */ - public void setAllowNewTimeProposal(Boolean value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.AllowNewTimeProposal, value); - } - - /** - * Gets a value indicating whether this is an online meeting. - * - * @return the checks if is online meeting - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsOnlineMeeting() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.IsOnlineMeeting); - } - - /** - * Sets the checks if is online meeting. - * - * @param value the new checks if is online meeting - * @throws Exception the exception - */ - public void setIsOnlineMeeting(Boolean value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.IsOnlineMeeting, value); - } - - /** - * Gets the URL of the meeting workspace. A meeting workspace is a - * shared Web site for planning meetings and tracking results. - * - * @return the meeting workspace url - * @throws ServiceLocalException the service local exception - */ - public String getMeetingWorkspaceUrl() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.MeetingWorkspaceUrl); - } - - /** - * Sets the meeting workspace url. - * - * @param value the new meeting workspace url - * @throws Exception the exception - */ - public void setMeetingWorkspaceUrl(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.MeetingWorkspaceUrl, value); - } - - /** - * Gets the URL of the Microsoft NetShow online meeting. - * - * @return the net show url - * @throws ServiceLocalException the service local exception - */ - public String getNetShowUrl() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.NetShowUrl); - } - - /** - * Sets the net show url. - * - * @param value the new net show url - * @throws Exception the exception - */ - public void setNetShowUrl(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.NetShowUrl, value); - } - - /** - * Gets the ICalendar Uid. - * - * @return the i cal uid - * @throws ServiceLocalException the service local exception - */ - public String getICalUid() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.ICalUid); - } - - /** - * Sets the ICalendar Uid. - * - * @param value the i cal uid - * @throws Exception - *///this.PropertyBag[AppointmentSchema.ICalUid] = value; - public void setICalUid(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - AppointmentSchema.ICalUid, value); - } - - /** - * Gets the ICalendar RecurrenceId. - * - * @return the i cal recurrence id - * @throws ServiceLocalException the service local exception - */ - public Date getICalRecurrenceId() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.ICalRecurrenceId); - } - - /** - * Gets the ICalendar DateTimeStamp. - * - * @return the i cal date time stamp - * @throws ServiceLocalException the service local exception - */ - public Date getICalDateTimeStamp() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.ICalDateTimeStamp); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/Contact.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/Contact.java deleted file mode 100644 index 402e39c20..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/Contact.java +++ /dev/null @@ -1,995 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.attribute.Attachable; -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.schema.ContactSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.service.ContactSource; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.FileAsMapping; -import microsoft.exchange.webservices.data.core.enumeration.property.PhysicalAddressIndex; -import microsoft.exchange.webservices.data.core.exception.service.local.PropertyException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.complex.Attachment; -import microsoft.exchange.webservices.data.property.complex.ByteArrayArray; -import microsoft.exchange.webservices.data.property.complex.CompleteName; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; -import microsoft.exchange.webservices.data.property.complex.EmailAddressCollection; -import microsoft.exchange.webservices.data.property.complex.EmailAddressDictionary; -import microsoft.exchange.webservices.data.property.complex.FileAttachment; -import microsoft.exchange.webservices.data.property.complex.ImAddressDictionary; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.PhoneNumberDictionary; -import microsoft.exchange.webservices.data.property.complex.PhysicalAddressDictionary; -import microsoft.exchange.webservices.data.property.complex.StringList; - -import java.io.File; -import java.io.InputStream; -import java.util.Date; - -/** - * Represents a contact. Properties available on contacts are defined in the - * ContactSchema class. - */ -@Attachable -@ServiceObjectDefinition(xmlElementName = XmlElementNames.Contact, returnedByServer = true) -public class Contact extends Item { - - /** - * The Contact picture name. - */ - private final String ContactPictureName = "ContactPicture.jpg"; - - /** - * Initializes an unsaved local instance of {@link Contact}. - * To bind to an existing contact, use Contact.Bind() instead. - * - * @param service the service - * @throws Exception the exception - */ - public Contact(ExchangeService service) throws Exception { - super(service); - } - - /** - * Initializes a new instance of the {@link Contact} class. - * - * @param parentAttachment the parent attachment - * @throws Exception the exception - */ - public Contact(ItemAttachment parentAttachment) throws Exception { - super(parentAttachment); - } - - /** - * Binds to an existing contact and loads the specified set of property. - * Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @param propertySet the property set - * @return A Contact instance representing the contact corresponding to the - * specified Id. - * @throws Exception the exception - */ - public static Contact bind(ExchangeService service, ItemId id, - PropertySet propertySet) throws Exception { - return service.bindToItem(Contact.class, id, propertySet); - } - - /** - * Binds to an existing contact and loads its first class property. - * Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @return A Contact instance representing the contact corresponding to the - * specified Id. - * @throws Exception the exception - */ - public static Contact bind(ExchangeService service, ItemId id) - throws Exception { - return Contact.bind(service, id, PropertySet.getFirstClassProperties()); - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return ContactSchema.Instance; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Sets the contact's picture using the specified byte array. - * - * @param content the new contact picture - * @throws Exception the exception - */ - public void setContactPicture(byte[] content) throws Exception { - EwsUtilities.validateMethodVersion(this.getService(), ExchangeVersion.Exchange2010, "SetContactPicture"); - - internalRemoveContactPicture(); - FileAttachment fileAttachment = getAttachments().addFileAttachment( - ContactPictureName, content); - fileAttachment.setIsContactPhoto(true); - } - - /** - * Sets the contact's picture using the specified stream. - * - * @param contentStream the new contact picture - * @throws Exception the exception - */ - public void setContactPicture(InputStream contentStream) throws Exception { - EwsUtilities.validateMethodVersion(this.getService(), - ExchangeVersion.Exchange2010, "SetContactPicture"); - - internalRemoveContactPicture(); - FileAttachment fileAttachment = getAttachments().addFileAttachment( - ContactPictureName, contentStream); - fileAttachment.setIsContactPhoto(true); - } - - /** - * Sets the contact's picture using the specified file. - * - * @param fileName the new contact picture - * @throws Exception the exception - */ - public void setContactPicture(String fileName) throws Exception { - EwsUtilities.validateMethodVersion(this.getService(), - ExchangeVersion.Exchange2010, "SetContactPicture"); - - internalRemoveContactPicture(); - FileAttachment fileAttachment = getAttachments().addFileAttachment( - new File(fileName).getName(), fileName); - fileAttachment.setIsContactPhoto(true); - } - - /** - * Retrieves the file attachment that holds the contact's picture. - * - * @return The file attachment that holds the contact's picture. - * @throws ServiceLocalException the service local exception - */ - public FileAttachment getContactPictureAttachment() - throws ServiceLocalException { - EwsUtilities.validateMethodVersion(this.getService(), - ExchangeVersion.Exchange2010, "GetContactPictureAttachment"); - - if (!this.getPropertyBag().isPropertyLoaded(ContactSchema.Attachments)) { - throw new PropertyException("The attachment collection must be loaded."); - } - - for (Attachment fileAttachment : this.getAttachments()) { - if (fileAttachment instanceof FileAttachment) { - if (((FileAttachment) fileAttachment).isContactPhoto()) { - return (FileAttachment) fileAttachment; - } - } - } - return null; - } - - /** - * Removes the picture from local attachment collection. - * - * @throws Exception the exception - */ - private void internalRemoveContactPicture() throws Exception { - // Iterates in reverse order to remove file attachments that have - // IsContactPhoto set to true. - for (int index = this.getAttachments().getCount() - 1; index >= 0; index--) { - FileAttachment fileAttachment = (FileAttachment) this - .getAttachments().getPropertyAtIndex(index); - if (fileAttachment != null) { - if (fileAttachment.isContactPhoto()) { - this.getAttachments().remove(fileAttachment); - } - } - } - - } - - /** - * Removes the contact's picture. - * - * @throws Exception the exception - */ - public void removeContactPicture() throws Exception { - EwsUtilities.validateMethodVersion(this.getService(), - ExchangeVersion.Exchange2010, "RemoveContactPicture"); - - if (!this.getPropertyBag().isPropertyLoaded(ContactSchema.Attachments)) { - throw new PropertyException("The attachment collection must be loaded."); - } - - internalRemoveContactPicture(); - } - - /** - * Validates this instance. - * - * @throws ServiceVersionException the service version exception - * @throws Exception the exception - */ - @Override public void validate() throws ServiceVersionException, Exception { - super.validate(); - - Object fileAsMapping; - OutParam outParam = new OutParam(); - if (this.tryGetProperty(ContactSchema.FileAsMapping, outParam)) { - fileAsMapping = outParam.getParam(); - // FileAsMapping is extended by 5 new values in 2010 mode. Validate - // that they are used according the version. - EwsUtilities.validateEnumVersionValue( - (FileAsMapping) fileAsMapping, this.getService() - .getRequestedServerVersion()); - } - } - - /** - * Gets the name under which this contact is filed as. FileAs can be - * manually set or can be automatically calculated based on the value of the - * FileAsMapping property. - * - * @return the file as - * @throws ServiceLocalException the service local exception - */ - public String getFileAs() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.FileAs); - - } - - /** - * Sets the file as. - * - * @param value the new file as - * @throws Exception the exception - */ - public void setFileAs(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.FileAs, value); - } - - /** - * Gets a value indicating how the FileAs property should be - * automatically calculated. - * - * @return the file as mapping - * @throws ServiceLocalException the service local exception - */ - public FileAsMapping getFileAsMapping() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.FileAsMapping); - } - - /** - * Sets the file as. - * - * @param value the new file as - * @throws Exception the exception - */ - public void setFileAs(FileAsMapping value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.FileAsMapping, value); - } - - /** - * Gets the display name of the contact. - * - * @return the display name - * @throws ServiceLocalException the service local exception - */ - public String getDisplayName() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.DisplayName); - } - - /** - * Sets the display name. - * - * @param value the new display name - * @throws Exception the exception - */ - public void setDisplayName(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.DisplayName, value); - } - - /** - * Gets the given name of the contact. - * - * @return the given name - * @throws ServiceLocalException the service local exception - */ - public String getGivenName() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.GivenName); - } - - /** - * Sets the given name. - * - * @param value the new given name - * @throws Exception the exception - */ - public void setGivenName(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.GivenName, value); - } - - /** - * Gets the initials of the contact. - * - * @return the initials - * @throws ServiceLocalException the service local exception - */ - public String getInitials() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.Initials); - } - - /** - * Sets the initials. - * - * @param value the new initials - * @throws Exception the exception - */ - public void setInitials(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.Initials, value); - } - - /** - * Gets the middle name of the contact. - * - * @return the middle name - * @throws ServiceLocalException the service local exception - */ - public String getMiddleName() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.MiddleName); - } - - /** - * Sets the middle name. - * - * @param value the new middle name - * @throws Exception the exception - */ - public void setMiddleName(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.MiddleName, value); - } - - /** - * Gets the nick name of the contact. - * - * @return the nick name - * @throws ServiceLocalException the service local exception - */ - public String getNickName() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.NickName); - } - - /** - * Sets the nick name. - * - * @param value the new nick name - * @throws Exception the exception - */ - public void setNickName(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.NickName, value); - } - - /** - * Gets the complete name of the contact. - * - * @return the complete name - * @throws ServiceLocalException the service local exception - */ - public CompleteName getCompleteName() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.CompleteName); - } - - /** - * Gets the company name of the contact. - * - * @return the company name - * @throws ServiceLocalException the service local exception - */ - public String getCompanyName() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.CompanyName); - } - - /** - * Sets the company name. - * - * @param value the new company name - * @throws Exception the exception - */ - public void setCompanyName(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.CompanyName, value); - } - - /** - * Gets an indexed list of e-mail addresses for the contact. For example, to - * set the first e-mail address, use the following syntax: - * EmailAddresses[EmailAddressKey.EmailAddress1] = "john.doe@contoso.com" - * - * @return the email addresses - * @throws ServiceLocalException the service local exception - */ - public EmailAddressDictionary getEmailAddresses() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.EmailAddresses); - } - - /** - * Gets an indexed list of physical addresses for the contact. For example, - * to set the first business address, use the following syntax: - * physical[PhysicalAddressKey.Business] = new PhysicalAddressEntry() - * - * @return the physical addresses - * @throws ServiceLocalException the service local exception - */ - public PhysicalAddressDictionary getPhysicalAddresses() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.PhysicalAddresses); - } - - /** - * Gets an indexed list of phone numbers for the contact. For example, to - * set the home phone number, use the following syntax: - * PhoneNumbers[PhoneNumberKey.HomePhone] = "phone number" - * - * @return the phone numbers - * @throws ServiceLocalException the service local exception - */ - public PhoneNumberDictionary getPhoneNumbers() - throws ServiceLocalException { - return getPropertyBag() - .getObjectFromPropertyDefinition(ContactSchema.PhoneNumbers); - } - - /** - * Gets the contact's assistant name. - * - * @return the assistant name - * @throws ServiceLocalException the service local exception - */ - public String getAssistantName() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.AssistantName); - } - - /** - * Sets the assistant name. - * - * @param value the new assistant name - * @throws Exception the exception - */ - public void setAssistantName(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.AssistantName, value); - } - - /** - * Gets the contact's assistant name. - * - * @return the birthday - * @throws ServiceLocalException the service local exception - */ - public Date getBirthday() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.Birthday); - - } - - /** - * Sets the birthday. - * - * @param value the new birthday - * @throws Exception the exception - */ - public void setBirthday(Date value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.Birthday, value); - } - - /** - * Gets the business home page of the contact. - * - * @return the business home page - * @throws ServiceLocalException the service local exception - */ - public String getBusinessHomePage() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.BusinessHomePage); - - } - - /** - * Sets the business home page. - * - * @param value the new business home page - * @throws Exception the exception - */ - public void setBusinessHomePage(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.BusinessHomePage, value); - } - - /** - * Gets a list of children for the contact. - * - * @return the children - * @throws ServiceLocalException the service local exception - */ - public StringList getChildren() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.Children); - } - - /** - * Sets the children. - * - * @param value the new children - * @throws Exception the exception - */ - public void setChildren(StringList value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.Children, value); - } - - /** - * Gets a list of companies for the contact. - * - * @return the companies - * @throws ServiceLocalException the service local exception - */ - public StringList getCompanies() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.Companies); - } - - /** - * Sets the companies. - * - * @param value the new companies - * @throws Exception the exception - */ - public void setCompanies(StringList value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.Companies, value); - } - - /** - * Gets the source of the contact. - * - * @return the contact source - * @throws ServiceLocalException the service local exception - */ - public ContactSource getContactSource() throws ServiceLocalException { - return getPropertyBag() - .getObjectFromPropertyDefinition(ContactSchema.ContactSource); - } - - /** - * Gets the department of the contact. - * - * @return the department - * @throws ServiceLocalException the service local exception - */ - public String getDepartment() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.Department); - } - - /** - * Sets the department. - * - * @param value the new department - * @throws Exception the exception - */ - public void setDepartment(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.Department, value); - } - - /** - * Gets the generation of the contact. - * - * @return the generation - * @throws ServiceLocalException the service local exception - */ - public String getGeneration() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.Generation); - } - - /** - * Sets the generation. - * - * @param value the new generation - * @throws Exception the exception - */ - public void setGeneration(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.Generation, value); - } - - /** - * Gets an indexed list of Instant Messaging addresses for the contact. For - * example, to set the first IM address, use the following syntax: - * ImAddresses[ImAddressKey.ImAddress1] = "john.doe@contoso.com" - * - * @return the im addresses - * @throws ServiceLocalException the service local exception - */ - public ImAddressDictionary getImAddresses() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.ImAddresses); - } - - /** - * Gets the contact's job title. - * - * @return the job title - * @throws ServiceLocalException the service local exception - */ - public String getJobTitle() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.JobTitle); - } - - /** - * Sets the job title. - * - * @param value the new job title - * @throws Exception the exception - */ - public void setJobTitle(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.JobTitle, value); - } - - /** - * Gets the name of the contact's manager. - * - * @return the manager - * @throws ServiceLocalException the service local exception - */ - public String getManager() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.Manager); - } - - /** - * Sets the manager. - * - * @param value the new manager - * @throws Exception the exception - */ - public void setManager(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.Manager, value); - } - - /** - * Gets the mileage for the contact. - * - * @return the mileage - * @throws ServiceLocalException the service local exception - */ - public String getMileage() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.Mileage); - } - - /** - * Sets the mileage. - * - * @param value the new mileage - * @throws Exception the exception - */ - public void setMileage(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.Mileage, value); - } - - /** - * Gets the location of the contact's office. - * - * @return the office location - * @throws ServiceLocalException the service local exception - */ - public String getOfficeLocation() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.OfficeLocation); - } - - /** - * Sets the office location. - * - * @param value the new office location - * @throws Exception the exception - */ - public void setOfficeLocation(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.OfficeLocation, value); - } - - /** - * Gets the index of the contact's postal address. When set, - * PostalAddressIndex refers to an entry in the PhysicalAddresses indexed - * list. - * - * @return the postal address index - * @throws ServiceLocalException the service local exception - */ - public PhysicalAddressIndex getPostalAddressIndex() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.PostalAddressIndex); - } - - /** - * Sets the postal address index. - * - * @param value the new postal address index - * @throws Exception the exception - */ - public void setPostalAddressIndex(PhysicalAddressIndex value) - throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.PostalAddressIndex, value); - } - - /** - * Gets the contact's profession. - * - * @return the profession - * @throws ServiceLocalException the service local exception - */ - public String getProfession() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.Profession); - } - - /** - * Sets the profession. - * - * @param value the new profession - * @throws Exception the exception - */ - public void setProfession(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.Profession, value); - } - - /** - * Gets the name of the contact's spouse. - * - * @return the spouse name - * @throws ServiceLocalException the service local exception - */ - public String getSpouseName() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.SpouseName); - } - - /** - * Sets the spouse name. - * - * @param value the new spouse name - * @throws Exception the exception - */ - public void setSpouseName(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.SpouseName, value); - } - - /** - * Gets the surname of the contact. - * - * @return the surname - * @throws ServiceLocalException the service local exception - */ - public String getSurname() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.Surname); - } - - /** - * Sets the surname. - * - * @param value the new surname - * @throws Exception the exception - */ - public void setSurname(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.Surname, value); - } - - /** - * Gets the date of the contact's wedding anniversary. - * - * @return the wedding anniversary - * @throws ServiceLocalException the service local exception - */ - public Date getWeddingAnniversary() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.WeddingAnniversary); - } - - /** - * Sets the wedding anniversary. - * - * @param value the new wedding anniversary - * @throws Exception the exception - */ - public void setWeddingAnniversary(Date value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.WeddingAnniversary, value); - } - - /** - * Gets a value indicating whether this contact has a picture associated - * with it. - * - * @return the checks for picture - * @throws ServiceLocalException the service local exception - */ - public Boolean getHasPicture() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ContactSchema.HasPicture); - } - - /** - * Gets the funn phonetic name from the directory - */ - public String getPhoneticFullName() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.PhoneticFullName); - } - - /** - * Gets the funn phonetic name from the directory - */ - public String getPhoneticFirstName() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.PhoneticFirstName); - } - - /** - * Gets the phonetic last name from the directory - * - * @throws ServiceLocalException - */ - public String getPhoneticLastName() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.PhoneticLastName); - } - - /** - * Gets the Alias from the directory - * - * @throws ServiceLocalException - */ - public String getAlias() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.Alias); - } - - /** - * Get the Notes from the directory - * - * @throws ServiceLocalException - */ - public String getNotes() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.Notes); - } - - /** - * Gets the Photo from the directory - * - * @throws ServiceLocalException - */ - public byte[] getDirectoryPhoto() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.Photo); - } - - /** - * Gets the User SMIME certificate from the directory - * - * @throws ServiceLocalException - */ - public byte[][] getUserSMIMECertificate() throws ServiceLocalException { - ByteArrayArray array = this.getPropertyBag() - .getObjectFromPropertyDefinition(ContactSchema.UserSMIMECertificate); - return array.getContent(); - } - - /** - * Gets the MSExchange certificate from the directory - * - * @throws ServiceLocalException - */ - public byte[][] getMSExchangeCertificate() throws ServiceLocalException { - ByteArrayArray array = getPropertyBag() - .getObjectFromPropertyDefinition(ContactSchema.MSExchangeCertificate); - return array.getContent(); - } - - /** - * Gets the DirectoryID as Guid or DN string - * - * @throws ServiceLocalException - */ - public String getDirectoryId() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.DirectoryId); - } - - /** - * Gets the manager mailbox information - * - * @throws ServiceLocalException - */ - public EmailAddress getManagerMailbox() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ContactSchema.ManagerMailbox); - } - - /** - * Get the direct reports mailbox information - * - * @throws ServiceLocalException - */ - public EmailAddressCollection getDirectReports() throws ServiceLocalException { - return getPropertyBag() - .getObjectFromPropertyDefinition(ContactSchema.DirectReports); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/ContactGroup.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/ContactGroup.java deleted file mode 100644 index 92bc73333..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/ContactGroup.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.attribute.RequiredServerVersion; -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.schema.ContactGroupSchema; -import microsoft.exchange.webservices.data.core.service.schema.ContactSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceObjectPropertyException; -import microsoft.exchange.webservices.data.property.complex.GroupMemberCollection; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; -import microsoft.exchange.webservices.data.property.complex.ItemId; - -/** - * Represents a Contact Group. Properties available on contact groups are - * defined in the ContactGroupSchema class. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.DistributionList, returnedByServer = true) -public class ContactGroup extends Item { - - /** - * Initializes an unsaved local instance of the class. - * - * @param service the service - * @throws Exception the exception - */ - public ContactGroup(ExchangeService service) throws Exception { - super(service); - } - - /** - * Initializes an new instance of the class. - * - * @param parentAttachment the parent attachment - * @throws Exception the exception - */ - public ContactGroup(ItemAttachment parentAttachment) throws Exception { - super(parentAttachment); - } - - /** - * Gets the name under which this contact group is filed as. - * - * @return the file as - * @throws Exception the exception - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010) - public String getFileAs() throws Exception { - return (String) this - .getObjectFromPropertyDefinition(ContactSchema.FileAs); - } - - /** - * Gets the display name of the contact group. - * - * @return the display name - * @throws Exception the exception - */ - public String getDisplayName() throws Exception { - return (String) this - .getObjectFromPropertyDefinition(ContactSchema.DisplayName); - } - - /** - * Sets the display name. - * - * @param value the new display name - * @throws Exception the exception - */ - public void setDisplayName(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ContactSchema.DisplayName, value); - } - - /** - * Gets the members of the contact group. - * - * @return the members - * @throws Exception the exception - */ - @RequiredServerVersion(version = ExchangeVersion.Exchange2010) - public GroupMemberCollection getMembers() throws Exception { - return (GroupMemberCollection) this - .getObjectFromPropertyDefinition(ContactGroupSchema.Members); - - } - - /** - * Binds to an existing contact group and loads the specified set of - * property.Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @param propertySet the property set - * @return A ContactGroup instance representing the contact group - * corresponding to the specified Id - * @throws Exception the exception - */ - public static ContactGroup bind(ExchangeService service, ItemId id, - PropertySet propertySet) throws Exception { - return service.bindToItem(ContactGroup.class, id, propertySet); - } - - /** - * Binds to an existing contact group and loads the specified set of - * property.Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @return A ContactGroup instance representing the contact group - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static ContactGroup bind(ExchangeService service, ItemId id) - throws Exception { - return ContactGroup.bind(service, id, PropertySet - .getFirstClassProperties()); - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return ContactGroupSchema.Instance; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Sets the subject. - * - * @param subject the new subject - * @throws ServiceObjectPropertyException the service object property exception - */ - @Override - public void setSubject(String subject) - throws ServiceObjectPropertyException { - // Set is disabled in client API even though it is implemented in - // protocol for Item.Subject. - // Setting Subject out of sync with DisplayName breaks interop with OLK. - // See E14:70417, 65663, 6529. - throw new ServiceObjectPropertyException("This property is read-only and can't be set.", - ContactGroupSchema.Subject); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/Conversation.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/Conversation.java deleted file mode 100644 index eb70e10f7..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/Conversation.java +++ /dev/null @@ -1,891 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.schema.ConversationSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence; -import microsoft.exchange.webservices.data.core.enumeration.service.ConversationFlagStatus; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.Importance; -import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.complex.ConversationId; -import microsoft.exchange.webservices.data.property.complex.ExtendedPropertyCollection; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ItemIdCollection; -import microsoft.exchange.webservices.data.property.complex.StringList; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; - -/** - * Represents a collection of Conversation related property. - * Properties available on this object are defined - * in the ConversationSchema class. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.Conversation) -public class Conversation extends ServiceObject { - - /** - * Initializes an unsaved local instance of Conversation. - * - * @param service The service - * The ExchangeService object to which the item will be bound. - * @throws Exception - */ - public Conversation(ExchangeService service) throws Exception { - super(service); - } - - /** - * Internal method to return the schema associated with this type of object - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return ConversationSchema.Instance; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which - * this service object type is supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2010_SP1; - } - - /** - * The property definition for the Id of this object. - * - * @return A PropertyDefinition instance. - */ - @Override public PropertyDefinition getIdPropertyDefinition() { - return ConversationSchema.Id; - } - - /** - * This method is not supported in this object. - * Loads the specified set of property on the object. - * - * @param propertySet The propertySet - * The property to load. - */ - @Override - protected void internalLoad(PropertySet propertySet) { - throw new UnsupportedOperationException(); - } - - /** - * This is not supported in this object. - * Deletes the object. - * - * @param deleteMode The deleteMode - * The deletion mode. - * @param sendCancellationsMode The sendCancellationsMode - * Indicates whether meeting cancellation messages should be sent. - * @param affectedTaskOccurrences The affectedTaskOccurrences - * Indicate which occurrence of a recurring task should be deleted. - */ - @Override - protected void internalDelete(DeleteMode deleteMode, - SendCancellationsMode sendCancellationsMode, - AffectedTaskOccurrence affectedTaskOccurrences) { - throw new UnsupportedOperationException(); - } - - /** - * This method is not supported in this object. - * Gets the name of the change XML element. - * - * @return XML element name - */ - @Override public String getChangeXmlElementName() { - throw new UnsupportedOperationException(); - } - - /** - * This method is not supported in this object. - * Gets the name of the delete field XML element. - * - * @return XML element name - */ - @Override public String getDeleteFieldXmlElementName() { - throw new UnsupportedOperationException(); - } - - /** - * This method is not supported in this object. - * Gets the name of the set field XML element. - * - * @return XML element name - */ - @Override public String getSetFieldXmlElementName() { - throw new UnsupportedOperationException(); - } - - /** - * This method is not supported in this object. - * Gets a value indicating whether a time zone - * SOAP header should be emitted in a CreateItem - * or UpdateItem request so this item can be property saved or updated. - * - * @param isUpdateOperation Indicates whether - * the operation being petrformed is an update operation. - * @return true if a time zone SOAP header - * should be emitted; otherwise, false. - */ - @Override - protected boolean getIsTimeZoneHeaderRequired(boolean isUpdateOperation) { - throw new UnsupportedOperationException(); - } - - /** - * This method is not supported in this object. - * Gets the extended property collection. - * - * @return Extended property collection. - */ - @Override - protected ExtendedPropertyCollection getExtendedProperties() { - throw new UnsupportedOperationException(); - } - - /** - * Sets up a conversation so that any item - * received within that conversation is always categorized. - * Calling this method results in a call to EWS. - * - * @param categories The categories that should be stamped on item in the conversation. - * @param processSynchronously Indicates whether the method should - * return only once enabling this rule and stamping existing item - * in the conversation is completely done. - * If processSynchronously is false, the method returns immediately. - * @throws Exception - * @throws IndexOutOfBoundsException - * @throws ServiceResponseException - */ - public void enableAlwaysCategorizeItems(Iterable categories, - boolean processSynchronously) throws ServiceResponseException, - IndexOutOfBoundsException, Exception { - - ArrayList convArry = new ArrayList(); - convArry.add(this.getId()); - - this.getService().enableAlwaysCategorizeItemsInConversations( - convArry, - categories, - processSynchronously).getResponseAtIndex(0).throwIfNecessary(); - } - - /** - * Sets up a conversation so that any item - * received within that conversation is no longer categorized. - * Calling this method results in a call to EWS. - * - * @param processSynchronously Indicates whether the method should - * return only once disabling this rule and - * removing the categories from existing item - * in the conversation is completely done. If processSynchronously - * is false, the method returns immediately. - * @throws Exception - * @throws IndexOutOfBoundsException - * @throws ServiceResponseException - */ - public void disableAlwaysCategorizeItems(boolean processSynchronously) - throws ServiceResponseException, IndexOutOfBoundsException, Exception { - ArrayList convArry = new ArrayList(); - convArry.add(this.getId()); - this.getService().disableAlwaysCategorizeItemsInConversations( - convArry, processSynchronously). - getResponseAtIndex(0).throwIfNecessary(); - } - - /** - * Sets up a conversation so that any item received - * within that conversation is always moved to Deleted Items folder. - * Calling this method results in a call to EWS. - * - * @param processSynchronously Indicates whether the method should - * return only once enabling this rule and deleting existing item - * in the conversation is completely done. If processSynchronously - * is false, the method returns immediately. - * @throws Exception - * @throws IndexOutOfBoundsException - * @throws ServiceResponseException - */ - public void enableAlwaysDeleteItems(boolean processSynchronously) - throws ServiceResponseException, IndexOutOfBoundsException, Exception { - ArrayList convArry = new ArrayList(); - convArry.add(this.getId()); - this.getService().enableAlwaysDeleteItemsInConversations( - convArry, - processSynchronously).getResponseAtIndex(0).throwIfNecessary(); - } - - /** - * Sets up a conversation so that any item received within that - * conversation is no longer moved to Deleted Items folder. - * Calling this method results in a call to EWS. - * - * @param processSynchronously Indicates whether the method should return - * only once disabling this rule and restoring the item - * in the conversation is completely done. If processSynchronously - * is false, the method returns immediately. - * @throws Exception - * @throws IndexOutOfBoundsException - * @throws ServiceResponseException - */ - public void disableAlwaysDeleteItems(boolean processSynchronously) - throws ServiceResponseException, IndexOutOfBoundsException, Exception { - ArrayList convArry = new ArrayList(); - convArry.add(this.getId()); - this.getService().disableAlwaysDeleteItemsInConversations( - convArry, - processSynchronously).getResponseAtIndex(0).throwIfNecessary(); - } - - /** - * Sets up a conversation so that any item received within - * that conversation is always moved to a specific folder. - * Calling this method results in a call to EWS. - * - * @param destinationFolderId The Id of the folder to which conversation item should be moved. - * @param processSynchronously Indicates whether the method should return only - * once enabling this rule - * and moving existing item in the conversation is completely done. - * If processSynchronously is false, the method returns immediately. - * @throws Exception - * @throws IndexOutOfBoundsException - * @throws ServiceResponseException - */ - public void enableAlwaysMoveItems(FolderId destinationFolderId, - boolean processSynchronously) throws ServiceResponseException, - IndexOutOfBoundsException, Exception { - ArrayList convArry = new ArrayList(); - convArry.add(this.getId()); - this.getService().enableAlwaysMoveItemsInConversations( - convArry, - destinationFolderId, - processSynchronously).getResponseAtIndex(0).throwIfNecessary(); - } - - /** - * Sets up a conversation so that any item received within - * that conversation is no longer moved to a specific - * folder. Calling this method results in a call to EWS. - * - * @param processSynchronously Indicates whether the method should return only - * once disabling this - * rule is completely done. If processSynchronously - * is false, the method returns immediately. - * @throws Exception - * @throws IndexOutOfBoundsException - * @throws ServiceResponseException - */ - public void disableAlwaysMoveItemsInConversation(boolean processSynchronously) - throws ServiceResponseException, IndexOutOfBoundsException, Exception { - ArrayList convArry = new ArrayList(); - convArry.add(this.getId()); - this.getService().disableAlwaysMoveItemsInConversations( - convArry, - processSynchronously).getResponseAtIndex(0).throwIfNecessary(); - } - - /** - * Deletes item in the specified conversation. - * Calling this method results in a call to EWS. - * - * @param contextFolderId The Id of the folder item must belong - * to in order to be deleted. If contextFolderId is - * null, item across the entire mailbox are deleted. - * @param deleteMode The deletion mode. - * @throws Exception - * @throws IndexOutOfBoundsException - * @throws ServiceResponseException - */ - public void deleteItems(FolderId contextFolderId, DeleteMode deleteMode) - throws ServiceResponseException, IndexOutOfBoundsException, Exception { - HashMap m = new HashMap(); - m.put(this.getId(), this.getGlobalLastDeliveryTime()); - - List> f = new ArrayList>(); - f.add(m); - - this.getService().deleteItemsInConversations( - f, - contextFolderId, - deleteMode).getResponseAtIndex(0).throwIfNecessary(); - } - - - /** - * Moves item in the specified conversation to a specific folder. - * Calling this method results in a call to EWS. - * - * @param contextFolderId The Id of the folder item must belong to - * in order to be moved. If contextFolderId is null, - * item across the entire mailbox are moved. - * @param destinationFolderId The Id of the destination folder. - * @throws Exception - * @throws IndexOutOfBoundsException - * @throws ServiceResponseException - */ - public void moveItemsInConversation( - FolderId contextFolderId, - FolderId destinationFolderId) throws ServiceResponseException, - IndexOutOfBoundsException, Exception { - HashMap m = new HashMap(); - m.put(this.getId(), this.getGlobalLastDeliveryTime()); - - List> f = new ArrayList>(); - f.add(m); - - this.getService().moveItemsInConversations( - f, contextFolderId, destinationFolderId). - getResponseAtIndex(0).throwIfNecessary(); - } - - /** - * Copies item in the specified conversation to a specific folder. - * Calling this method results in a call to EWS. - * - * @param contextFolderId The Id of the folder item must belong to in - * order to be copied. If contextFolderId - * is null, item across the entire mailbox are copied. - * @param destinationFolderId The Id of the destination folder. - * @throws Exception - * @throws IndexOutOfBoundsException - * @throws ServiceResponseException - */ - public void copyItemsInConversation( - FolderId contextFolderId, - FolderId destinationFolderId) throws ServiceResponseException, - IndexOutOfBoundsException, Exception { - HashMap m = new HashMap(); - m.put(this.getId(), this.getGlobalLastDeliveryTime()); - - List> f = new ArrayList>(); - f.add(m); - - this.getService().copyItemsInConversations( - f, contextFolderId, destinationFolderId). - getResponseAtIndex(0).throwIfNecessary(); - } - - /** - * Sets the read state of item in the specified conversation. - * Calling this method results in a call to EWS. - * - * @param contextFolderId The Id of the folder item must - * belong to in order for their read state to - * be set. If contextFolderId is null, the read states of - * item across the entire mailbox are set. - * @param isRead if set to true, conversation item are marked as read; - * otherwise they are marked as unread. - * @throws Exception - * @throws IndexOutOfBoundsException - * @throws ServiceResponseException - */ - public void setReadStateForItemsInConversation( - FolderId contextFolderId, - boolean isRead) throws ServiceResponseException, - IndexOutOfBoundsException, Exception { - HashMap m = new HashMap(); - m.put(this.getId(), this.getGlobalLastDeliveryTime()); - - List> f = new ArrayList>(); - f.add(m); - - this.getService().setReadStateForItemsInConversations( - f, contextFolderId, isRead). - getResponseAtIndex(0).throwIfNecessary(); - } - - /** - * Gets the Id of this Conversation. - * - * @return Id - * @throws ServiceLocalException - */ - public ConversationId getId() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - getIdPropertyDefinition()); - } - - /** - * Gets the topic of this Conversation. - * - * @return value - * @throws ArgumentException - */ - public String getTopic() throws ArgumentException { - String returnValue = ""; - - /**This property need not be present hence the - * property bag may not contain it. - *Check for the presence of this property before accessing it. - */ - if (this.getPropertyBag().contains(ConversationSchema.Topic)) { - OutParam out = new OutParam(); - this.getPropertyBag().tryGetPropertyType(String.class, - ConversationSchema.Topic, - out); - returnValue = out.getParam(); - } - - return returnValue; - } - - /** - * Gets a list of all the people who have received - * messages in this conversation in the current folder only. - * - * @return String - * @throws Exception - */ - public StringList getUniqueRecipients() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.UniqueRecipients); - } - - /** - * Gets a list of all the people who have received - * messages in this conversation across all folder in the mailbox. - * - * @return String - * @throws Exception - */ - public StringList getGlobalUniqueRecipients() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.GlobalUniqueRecipients); - } - - /** - * Gets a list of all the people who have sent messages - * that are currently unread in this conversation in - * the current folder only. - * - * @return unreadSenders - * @throws ArgumentException - */ - public StringList getUniqueUnreadSenders() throws ArgumentException { - StringList unreadSenders = null; - - /**This property need not be present hence - * the property bag may not contain it. - *Check for the presence of this property before accessing it. - */ - if (this.getPropertyBag().contains(ConversationSchema.UniqueUnreadSenders)) { - OutParam out = new OutParam(); - this.getPropertyBag().tryGetPropertyType(StringList.class, - ConversationSchema.UniqueUnreadSenders, - out); - unreadSenders = out.getParam(); - } - - return unreadSenders; - } - - - /** - * Gets a list of all the people who have sent - * messages that are currently unread in this - * conversation across all folder in the mailbox. - * - * @return unreadSenders - * @throws ArgumentException - */ - public StringList getGlobalUniqueUnreadSenders() throws ArgumentException { - StringList unreadSenders = null; - - // This property need not be present hence - //the property bag may not contain it. - // Check for the presence of this property before accessing it. - if (this.getPropertyBag().contains(ConversationSchema.GlobalUniqueUnreadSenders)) { - OutParam out = new OutParam(); - this.getPropertyBag().tryGetPropertyType(StringList.class, - ConversationSchema.GlobalUniqueUnreadSenders, - out); - unreadSenders = out.getParam(); - } - - return unreadSenders; - } - - /** - * Gets a list of all the people who have sent - * messages in this conversation in the current folder only. - * - * @return String - * @throws Exception - */ - public StringList getUniqueSenders() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.UniqueSenders); - } - - /** - * Gets a list of all the people who have sent messages - * in this conversation across all folder in the mailbox. - * - * @return String - * @throws Exception - */ - public StringList getGlobalUniqueSenders() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.GlobalUniqueSenders); - } - - /** - * Gets the delivery time of the message that was last - * received in this conversation in the current folder only. - * - * @return Date - * @throws Exception - */ - public Date getLastDeliveryTime() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.LastDeliveryTime); - } - - /** - * Gets the delivery time of the message that was last - * received in this conversation across all folder in the mailbox. - * - * @return Date - * @throws Exception - */ - public Date getGlobalLastDeliveryTime() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.GlobalLastDeliveryTime); - } - - /** - * Gets a list summarizing the categories stamped on - * messages in this conversation, in the current folder only. - * - * @return value - * @throws ArgumentException - */ - public StringList getCategories() throws ArgumentException { - StringList returnValue = null; - - /**This property need not be present hence - * the property bag may not contain it. - * Check for the presence of this property before accessing it. - */ - if (this.getPropertyBag().contains(ConversationSchema.Categories)) { - OutParam out = new OutParam(); - this.getPropertyBag().tryGetPropertyType(StringList.class, - ConversationSchema.Categories, - out); - returnValue = out.getParam(); - } - return returnValue; - } - - /** - * Gets a list summarizing the categories stamped on - * messages in this conversation, across all folder in the mailbox. - * - * @return returnValue - * @throws ArgumentException - */ - public StringList getGlobalCategories() throws ArgumentException { - StringList returnValue = null; - - // This property need not be present hence the - //property bag may not contain it. - // Check for the presence of this property before accessing it. - if (this.getPropertyBag().contains(ConversationSchema.GlobalCategories)) { - OutParam out = new OutParam(); - this.getPropertyBag().tryGetPropertyType(StringList.class, - ConversationSchema.GlobalCategories, - out); - returnValue = out.getParam(); - } - return returnValue; - } - - /** - * Gets the flag status for this conversation, calculated - * by aggregating individual messages flag status in the current folder. - * - * @return returnValue - * @throws ArgumentException - */ - public ConversationFlagStatus getFlagStatus() throws ArgumentException { - ConversationFlagStatus returnValue = ConversationFlagStatus.NotFlagged; - - // This property need not be present hence the - //property bag may not contain it. - // Check for the presence of this property before accessing it. - if (this.getPropertyBag().contains(ConversationSchema.FlagStatus)) { - OutParam out = new OutParam(); - this.getPropertyBag().tryGetPropertyType( - ConversationFlagStatus.class, - ConversationSchema.FlagStatus, - out); - returnValue = out.getParam(); - } - - return returnValue; - } - - /** - * Gets the flag status for this conversation, calculated by aggregating - * individual messages flag status across all folder in the mailbox. - * - * @return returnValue - * @throws ArgumentException - */ - public ConversationFlagStatus getGlobalFlagStatus() - throws ArgumentException { - ConversationFlagStatus returnValue = ConversationFlagStatus.NotFlagged; - - // This property need not be present hence the - //property bag may not contain it. - // Check for the presence of this property before accessing it. - if (this.getPropertyBag().contains(ConversationSchema.GlobalFlagStatus)) { - OutParam out = new OutParam(); - this.getPropertyBag().tryGetPropertyType( - ConversationFlagStatus.class, - ConversationSchema.GlobalFlagStatus, - out); - returnValue = out.getParam(); - } - - return returnValue; - } - - /** - * Gets a value indicating if at least one message in this - * conversation, in the current folder only, has an attachment. - * - * @return Value - * @throws ServiceLocalException - */ - public boolean getHasAttachments() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ConversationSchema.HasAttachments); - } - - /** - * Gets a value indicating if at least one message - * in this conversation, across all folder in the mailbox, - * has an attachment. - * - * @return boolean - * @throws ServiceLocalException - */ - public boolean getGlobalHasAttachments() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.GlobalHasAttachments); - } - - /** - * Gets the total number of messages in this conversation - * in the current folder only. - * - * @return integer - * @throws ServiceLocalException - */ - public int getMessageCount() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.MessageCount); - } - - /** - * Gets the total number of messages in this - * conversation across all folder in the mailbox. - * - * @return integer - * @throws ServiceLocalException - */ - public int getGlobalMessageCount() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.GlobalMessageCount); - } - - /** - * Gets the total number of unread messages in this - * conversation in the current folder only. - * - * @return returnValue - * @throws ArgumentException - */ - public int getUnreadCount() throws ArgumentException { - int returnValue = 0; - - /**This property need not be present hence the - * property bag may not contain it. - * Check for the presence of this property before accessing it. - */ - if (this.getPropertyBag().contains(ConversationSchema.UnreadCount)) { - OutParam out = new OutParam(); - this.getPropertyBag().tryGetPropertyType(Integer.class, - ConversationSchema.UnreadCount, - out); - returnValue = out.getParam().intValue(); - } - - return returnValue; - } - - /** - * Gets the total number of unread messages in this - * conversation across all folder in the mailbox. - * - * @return returnValue - * @throws ArgumentException - */ - public int getGlobalUnreadCount() throws ArgumentException { - int returnValue = 0; - - if (this.getPropertyBag().contains(ConversationSchema.GlobalUnreadCount)) { - OutParam out = new OutParam(); - this.getPropertyBag().tryGetPropertyType(Integer.class, - ConversationSchema.GlobalUnreadCount, - out); - returnValue = out.getParam().intValue(); - } - return returnValue; - - } - - - /** - * Gets the size of this conversation, calculated by - * adding the sizes of all messages in the conversation in - * the current folder only. - * - * @return integer - * @throws ServiceLocalException - */ - public int getSize() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.Size); - } - - /** - * Gets the size of this conversation, calculated by - * adding the sizes of all messages in the conversation - * across all folder in the mailbox. - * - * @return integer - * @throws ServiceLocalException - */ - public int getGlobalSize() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.GlobalSize); - } - - /** - * Gets a list summarizing the classes of the item - * in this conversation, in the current folder only. - * - * @return string - * @throws Exception - */ - public StringList getItemClasses() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.ItemClasses); - } - - /** - * Gets a list summarizing the classes of the item - * in this conversation, across all folder in the mailbox. - * - * @return string - * @throws Exception - */ - public StringList getGlobalItemClasses() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.GlobalItemClasses); - } - - /** - * Gets the importance of this conversation, calculated by - * aggregating individual messages importance in the current folder only. - * - * @return important - * @throws Exception - */ - public Importance getImportance() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.Importance); - } - - /** - * Gets the importance of this conversation, calculated by - * aggregating individual messages importance across all - * folder in the mailbox. - * - * @return important - * @throws Exception - */ - public Importance getGlobalImportance() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.GlobalImportance); - } - - /** - * Gets the Ids of the messages in this conversation, - * in the current folder only. - * - * @return Id - * @throws Exception - */ - public ItemIdCollection getItemIds() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.ItemIds); - } - - /** - * Gets the Ids of the messages in this conversation, - * across all folder in the mailbox. - * - * @return Id - * @throws Exception - */ - public ItemIdCollection getGlobalItemIds() throws Exception { - return getPropertyBag().getObjectFromPropertyDefinition( - ConversationSchema.GlobalItemIds); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/EmailMessage.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/EmailMessage.java deleted file mode 100644 index 00ff93df0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/EmailMessage.java +++ /dev/null @@ -1,603 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.attribute.Attachable; -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.response.ResponseMessage; -import microsoft.exchange.webservices.data.core.service.response.SuppressReadReceipt; -import microsoft.exchange.webservices.data.core.service.schema.EmailMessageSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.service.ConflictResolutionMode; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition; -import microsoft.exchange.webservices.data.core.enumeration.service.ResponseMessageType; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; -import microsoft.exchange.webservices.data.property.complex.EmailAddressCollection; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.MessageBody; - -import java.util.Arrays; - -/** - * Represents an e-mail message. Properties available on e-mail messages are - * defined in the EmailMessageSchema class. - */ -@Attachable -@ServiceObjectDefinition(xmlElementName = XmlElementNames.Message) -public class EmailMessage extends Item { - - /** - * Initializes an unsaved local instance of EmailMessage. To bind to an - * existing e-mail message, use EmailMessage.Bind() instead. - * - * @param service The ExchangeService object to which the e-mail message will be - * bound. - * @throws Exception the exception - */ - public EmailMessage(ExchangeService service) throws Exception { - super(service); - } - - /** - * Initializes a new instance of the "EmailMessage" class. - * - * @param parentAttachment The parent attachment. - * @throws Exception the exception - */ - public EmailMessage(ItemAttachment parentAttachment) throws Exception { - super(parentAttachment); - } - - /** - * Binds to an existing e-mail message and loads the specified set of - * property.Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @param propertySet the property set - * @return An EmailMessage instance representing the e-mail message - * corresponding to the specified Id - * @throws Exception the exception - */ - public static EmailMessage bind(ExchangeService service, ItemId id, - PropertySet propertySet) throws Exception { - return service.bindToItem(EmailMessage.class, id, propertySet); - - } - - /** - * Binds to an existing e-mail message and loads its first class - * property.Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @return An EmailMessage instance representing the e-mail message - * corresponding to the specified Id - * @throws Exception the exception - */ - public static EmailMessage bind(ExchangeService service, ItemId id) - throws Exception { - return EmailMessage.bind(service, id, PropertySet - .getFirstClassProperties()); - } - - /** - * Method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return EmailMessageSchema.Instance; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Send message. - * - * @param parentFolderId The parent folder id. - * @param messageDisposition The message disposition. - * @throws Exception the exception - */ - private void internalSend(FolderId parentFolderId, - MessageDisposition messageDisposition) throws Exception { - this.throwIfThisIsAttachment(); - - if (this.isNew()) { - if ((this.getAttachments().getCount() == 0) || - (messageDisposition == MessageDisposition.SaveOnly)) { - this.internalCreate(parentFolderId, messageDisposition, null); - } else { - // Bug E14:80316 -- If the message has attachments, save as a - // draft (and add attachments) before sending. - this.internalCreate(null, // null means use the Drafts folder in - // the mailbox of the authenticated - // user. - MessageDisposition.SaveOnly, null); - - this.getService().sendItem(this, parentFolderId); - } - } else if (this.isDirty()) { - // Validate and save attachments before sending. - this.getAttachments().validate(); - this.getAttachments().save(); - - if (this.getPropertyBag().getIsUpdateCallNecessary()) { - this.internalUpdate(parentFolderId, - ConflictResolutionMode.AutoResolve, messageDisposition, - null); - } else { - this.getService().sendItem(this, parentFolderId); - } - } else { - this.getService().sendItem(this, parentFolderId); - } - - // this.internalCreate(parentFolderId, messageDisposition, null); - } - - /** - * Creates a reply response to the message. - * - * @param replyAll the reply all - * @return A ResponseMessage representing the reply response that can - * subsequently be modified and sent. - * @throws Exception the exception - */ - public ResponseMessage createReply(boolean replyAll) throws Exception { - this.throwIfThisIsNew(); - - return new ResponseMessage(this, - replyAll ? ResponseMessageType.ReplyAll : - ResponseMessageType.Reply); - } - - /** - * Creates a forward response to the message. - * - * @return A ResponseMessage representing the forward response that can - * subsequently be modified and sent. - * @throws Exception the exception - */ - public ResponseMessage createForward() throws Exception { - this.throwIfThisIsNew(); - return new ResponseMessage(this, ResponseMessageType.Forward); - } - - /** - * Replies to the message. Calling this method results in a call to EWS. - * - * @param bodyPrefix the body prefix - * @param replyAll the reply all - * @throws Exception the exception - */ - public void reply(MessageBody bodyPrefix, boolean replyAll) - throws Exception { - ResponseMessage responseMessage = this.createReply(replyAll); - responseMessage.setBodyPrefix(bodyPrefix); - responseMessage.sendAndSaveCopy(); - } - - /** - * Forwards the message. Calling this method results in a call to EWS. - * - * @param bodyPrefix the body prefix - * @param toRecipients the to recipients - * @throws Exception the exception - */ - public void forward(MessageBody bodyPrefix, EmailAddress... toRecipients) - throws Exception { - if (null != toRecipients) { - forward(bodyPrefix, Arrays.asList(toRecipients)); - } - } - - /** - * Forwards the message. Calling this method results in a call to EWS. - * - * @param bodyPrefix the body prefix - * @param toRecipients the to recipients - * @throws Exception the exception - */ - public void forward(MessageBody bodyPrefix, - Iterable toRecipients) throws Exception { - ResponseMessage responseMessage = this.createForward(); - - responseMessage.setBodyPrefix(bodyPrefix); - responseMessage.getToRecipients() - .addEmailRange(toRecipients.iterator()); - - responseMessage.sendAndSaveCopy(); - } - - /** - * Sends this e-mail message. Calling this method results in at least one - * call to EWS. - * - * @throws Exception the exception - */ - public void send() throws Exception { - internalSend(null, MessageDisposition.SendOnly); - } - - /** - * Sends this e-mail message and saves a copy of it in the specified - * folder. SendAndSaveCopy does not work if the message has unsaved - * attachments. In that case, the message must first be saved and then sent. - * Calling this method results in a call to EWS. - * - * @param destinationFolderId the destination folder id - * @throws Exception the exception - */ - public void sendAndSaveCopy(FolderId destinationFolderId) throws Exception { - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - this.internalSend(destinationFolderId, - MessageDisposition.SendAndSaveCopy); - } - - /** - * Sends this e-mail message and saves a copy of it in the specified - * folder. SendAndSaveCopy does not work if the message has unsaved - * attachments. In that case, the message must first be saved and then sent. - * Calling this method results in a call to EWS. - * - * @param destinationFolderName the destination folder name - * @throws Exception the exception - */ - public void sendAndSaveCopy(WellKnownFolderName destinationFolderName) - throws Exception { - this.internalSend(new FolderId(destinationFolderName), - MessageDisposition.SendAndSaveCopy); - } - - /** - * Sends this e-mail message and saves a copy of it in the Sent Items - * folder. SendAndSaveCopy does not work if the message has unsaved - * attachments. In that case, the message must first be saved and then sent. - * Calling this method results in a call to EWS. - * - * @throws Exception the exception - */ - public void sendAndSaveCopy() throws Exception { - this.internalSend(new FolderId(WellKnownFolderName.SentItems), - MessageDisposition.SendAndSaveCopy); - } - - /** - * Suppresses the read receipt on the message. Calling this method results - * in a call to EWS. - * - * @throws Exception the exception - */ - public void suppressReadReceipt() throws Exception { - this.throwIfThisIsNew(); - new SuppressReadReceipt(this).internalCreate(null, null); - } - - /** - * Gets the list of To recipients for the e-mail message. - * - * @return The list of To recipients for the e-mail message. - * @throws ServiceLocalException the service local exception - */ - public EmailAddressCollection getToRecipients() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.ToRecipients); - } - - /** - * Gets the list of Bcc recipients for the e-mail message. - * - * @return the bcc recipients - * @throws ServiceLocalException the service local exception - */ - public EmailAddressCollection getBccRecipients() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.BccRecipients); - } - - /** - * Gets the list of Cc recipients for the e-mail message. - * - * @return the cc recipients - * @throws ServiceLocalException the service local exception - */ - public EmailAddressCollection getCcRecipients() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.CcRecipients); - } - - /** - * Gets the conversation topic of the e-mail message. - * - * @return the conversation topic - * @throws ServiceLocalException the service local exception - */ - public String getConversationTopic() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.ConversationTopic); - } - - /** - * Gets the conversation index of the e-mail message. - * - * @return the conversation index - * @throws ServiceLocalException the service local exception - */ - public byte[] getConversationIndex() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.ConversationIndex); - } - - /** - * Gets the "on behalf" sender of the e-mail message. - * - * @return the from - * @throws ServiceLocalException the service local exception - */ - public EmailAddress getFrom() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.From); - } - - /** - * Sets the from. - * - * @param value the new from - * @throws Exception the exception - */ - public void setFrom(EmailAddress value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.From, value); - } - - /** - * Gets a value indicating whether this is an associated message. - * - * @return the checks if is associated - * @throws ServiceLocalException the service local exception - */ - public boolean getIsAssociated() throws ServiceLocalException { - return super.getIsAssociated(); - } - - // The "new" keyword is used to expose the setter only on Message types, - // because - // EWS only supports creation of FAI Message types. IsAssociated is a - // readonly - // property of the Item type but it is used by the CreateItem web method for - // creating - // associated messages. - - /** - * Sets the checks if is associated. - * - * @param value the new checks if is associated - * @throws Exception the exception - */ - public void setIsAssociated(boolean value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.IsAssociated, value); - } - - /** - * Gets a value indicating whether a read receipt is requested for - * the e-mail message. - * - * @return the checks if is delivery receipt requested - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsDeliveryReceiptRequested() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.IsDeliveryReceiptRequested); - } - - /** - * Sets the checks if is delivery receipt requested. - * - * @param value the new checks if is delivery receipt requested - * @throws Exception the exception - */ - public void setIsDeliveryReceiptRequested(Boolean value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.IsDeliveryReceiptRequested, value); - } - - /** - * Gets a value indicating whether the e-mail message is read. - * - * @return the checks if is read - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsRead() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.IsRead); - } - - /** - * Sets the checks if is read. - * - * @param value the new checks if is read - * @throws Exception the exception - */ - public void setIsRead(Boolean value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.IsRead, value); - } - - /** - * Gets a value indicating whether a read receipt is requested for - * the e-mail message. - * - * @return the checks if is read receipt requested - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsReadReceiptRequested() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.IsReadReceiptRequested); - } - - /** - * Sets the checks if is read receipt requested. - * - * @param value the new checks if is read receipt requested - * @throws Exception the exception - */ - public void setIsReadReceiptRequested(Boolean value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.IsReadReceiptRequested, value); - } - - /** - * Gets a value indicating whether a response is requested for the - * e-mail message. - * - * @return the checks if is response requested - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsResponseRequested() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.IsResponseRequested); - } - - /** - * Sets the checks if is response requested. - * - * @param value the new checks if is response requested - * @throws Exception the exception - */ - public void setIsResponseRequested(Boolean value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.IsResponseRequested, value); - } - - /** - * Gets the Internat Message Id of the e-mail message. - * - * @return the internet message id - * @throws ServiceLocalException the service local exception - */ - public String getInternetMessageId() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.InternetMessageId); - } - - /** - * Gets the references of the e-mail message. - * - * @return the references - * @throws ServiceLocalException the service local exception - */ - public String getReferences() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.References); - } - - /** - * Sets the references. - * - * @param value the new references - * @throws Exception the exception - */ - public void setReferences(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.References, value); - } - - /** - * Gets a list of e-mail addresses to which replies should be addressed. - * - * @return the reply to - * @throws ServiceLocalException the service local exception - */ - public EmailAddressCollection getReplyTo() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.ReplyTo); - } - - /** - * Gets the sender of the e-mail message. - * - * @return the sender - * @throws ServiceLocalException the service local exception - */ - public EmailAddress getSender() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.Sender); - } - - /** - * Sets the sender. - * - * @param value the new sender - * @throws Exception the exception - */ - public void setSender(EmailAddress value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.Sender, value); - } - - /** - * Gets the ReceivedBy property of the e-mail message. - * - * @return the received by - * @throws ServiceLocalException the service local exception - */ - public EmailAddress getReceivedBy() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.ReceivedBy); - } - - /** - * Gets the ReceivedRepresenting property of the e-mail message. - * - * @return the received representing - * @throws ServiceLocalException the service local exception - */ - public EmailAddress getReceivedRepresenting() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.ReceivedRepresenting); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/ICalendarActionProvider.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/ICalendarActionProvider.java deleted file mode 100644 index f1a850949..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/ICalendarActionProvider.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.core.service.response.AcceptMeetingInvitationMessage; -import microsoft.exchange.webservices.data.core.service.response.DeclineMeetingInvitationMessage; -import microsoft.exchange.webservices.data.misc.CalendarActionResults; - -/** - * Interface defintion of a group of methods that are common to item that - * return CalendarActionResults. - */ -public interface ICalendarActionProvider { - - /** - * Implements the Accept method. - * - * @param sendResponse Indicates whether to send a response to the organizer. - * @return A CalendarActionResults object containing the various item that - * were created or modified as a result of this operation. - * @throws Exception the exception - */ - CalendarActionResults accept(boolean sendResponse) throws Exception; - - /** - * Implements the AcceptTentatively method. - * - * @param sendResponse Indicates whether to send a response to the organizer. - * @return A CalendarActionResults object containing the various item that - * were created or modified as a result of this operation. - * @throws Exception the exception - */ - CalendarActionResults acceptTentatively(boolean sendResponse) - throws Exception; - - /** - * Implements the Decline method. - * - * @param sendResponse Indicates whether to send a response to the organizer. - * @return A CalendarActionResults object containing the various item that - * were created or modified as a result of this operation. - * @throws Exception the exception - */ - CalendarActionResults decline(boolean sendResponse) throws Exception; - - /** - * Implements the CreateAcceptMessage method. - * - * @param tentative Indicates whether the new AcceptMeetingInvitationMessage - * should represent a Tentative accept response (as opposed to an - * Accept response). - * @return A new AcceptMeetingInvitationMessage. - * @throws Exception the exception - */ - AcceptMeetingInvitationMessage createAcceptMessage(boolean tentative) - throws Exception; - - /** - * Implements the DeclineMeetingInvitationMessage method. - * - * @return A new DeclineMeetingInvitationMessage. - * @throws Exception the exception - */ - DeclineMeetingInvitationMessage createDeclineMessage() throws Exception; - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/Item.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/Item.java deleted file mode 100644 index bf23473cf..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/Item.java +++ /dev/null @@ -1,1190 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.attribute.Attachable; -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.schema.ItemSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence; -import microsoft.exchange.webservices.data.core.enumeration.service.ConflictResolutionMode; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.enumeration.service.EffectiveRights; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.Importance; -import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition; -import microsoft.exchange.webservices.data.core.enumeration.service.ResponseActions; -import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode; -import microsoft.exchange.webservices.data.core.enumeration.service.SendInvitationsMode; -import microsoft.exchange.webservices.data.core.enumeration.service.SendInvitationsOrCancellationsMode; -import microsoft.exchange.webservices.data.core.enumeration.property.Sensitivity; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ServiceErrorHandling; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.core.exception.misc.InvalidOperationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException; -import microsoft.exchange.webservices.data.property.complex.Attachment; -import microsoft.exchange.webservices.data.property.complex.AttachmentCollection; -import microsoft.exchange.webservices.data.property.complex.ConversationId; -import microsoft.exchange.webservices.data.property.complex.ExtendedPropertyCollection; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.InternetMessageHeaderCollection; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.MessageBody; -import microsoft.exchange.webservices.data.property.complex.MimeContent; -import microsoft.exchange.webservices.data.property.complex.StringList; -import microsoft.exchange.webservices.data.property.complex.UniqueBody; -import microsoft.exchange.webservices.data.property.definition.ExtendedPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import java.util.ArrayList; -import java.util.Date; -import java.util.EnumSet; -import java.util.ListIterator; - -/** - * Represents a generic item. Properties available on item are defined in the - * ItemSchema class. - */ -@Attachable -@ServiceObjectDefinition(xmlElementName = XmlElementNames.Item) -public class Item extends ServiceObject { - - /** - * The parent attachment. - */ - private ItemAttachment parentAttachment; - - /** - * Initializes an unsaved local instance of . To bind to - * an existing item, use Item.Bind() instead. - * - * @param service the service - * @throws Exception the exception - */ - public Item(ExchangeService service) throws Exception { - super(service); - } - - /** - * Initializes a new instance of the item class. - * - * @param parentAttachment The parent attachment. - * @throws Exception the exception - */ - public Item(final ItemAttachment parentAttachment) throws Exception { - this(parentAttachment.getOwner().getService()); - this.parentAttachment = parentAttachment; - } - - /** - * Binds to an existing item, whatever its actual type is, and loads the - * specified set of property. Calling this method results in a call to - * EWS. - * - * @param service The service to use to bind to the item. - * @param id The Id of the item to bind to. - * @param propertySet The set of property to load. - * @return An Item instance representing the item corresponding to the - * specified Id. - * @throws Exception the exception - */ - public static Item bind(ExchangeService service, ItemId id, - PropertySet propertySet) throws Exception { - return service.bindToItem(Item.class, id, propertySet); - } - - /** - * Binds to an existing item, whatever its actual type is, and loads the - * specified set of property. Calling this method results in a call to - * EWS. - * - * @param service The service to use to bind to the item. - * @param id The Id of the item to bind to. - * @return An Item instance representing the item corresponding to the - * specified Id. - * @throws Exception the exception - */ - public static Item bind(ExchangeService service, ItemId id) - throws Exception { - return Item.bind(service, id, PropertySet.getFirstClassProperties()); - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return ItemSchema.getInstance(); - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Throws exception if this is attachment. - * - * @throws InvalidOperationException the invalid operation exception - */ - protected void throwIfThisIsAttachment() throws InvalidOperationException { - if (this.isAttachment()) { - throw new InvalidOperationException("This operation isn't supported on attachments."); - } - } - - /** - * The property definition for the Id of this object. - * - * @return A PropertyDefinition instance. - */ - public PropertyDefinition getIdPropertyDefinition() { - return ItemSchema.Id; - } - - /** - * The property definition for the Id of this object. - * - * @param propertySet the property set - * @throws Exception the exception - */ - @Override - protected void internalLoad(PropertySet propertySet) throws Exception { - this.throwIfThisIsNew(); - this.throwIfThisIsAttachment(); - - ArrayList itemArry = new ArrayList(); - itemArry.add(this); - this.getService().internalLoadPropertiesForItems(itemArry, propertySet, - ServiceErrorHandling.ThrowOnError); - } - - /** - * Deletes the object. - * - * @param deleteMode the delete mode - * @param sendCancellationsMode the send cancellations mode - * @param affectedTaskOccurrences the affected task occurrences - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - @Override - protected void internalDelete(DeleteMode deleteMode, - SendCancellationsMode sendCancellationsMode, - AffectedTaskOccurrence affectedTaskOccurrences) - throws ServiceLocalException, Exception { - this.throwIfThisIsNew(); - this.throwIfThisIsAttachment(); - - // If sendCancellationsMode is null, use the default value that's - // appropriate for item type. - if (sendCancellationsMode == null) { - sendCancellationsMode = this.getDefaultSendCancellationsMode(); - } - - // If affectedTaskOccurrences is null, use the default value that's - // appropriate for item type. - if (affectedTaskOccurrences == null) { - affectedTaskOccurrences = this.getDefaultAffectedTaskOccurrences(); - } - - this.getService().deleteItem(this.getId(), deleteMode, - sendCancellationsMode, affectedTaskOccurrences); - } - - /** - * Create item. - * - * @param parentFolderId the parent folder id - * @param messageDisposition the message disposition - * @param sendInvitationsMode the send invitations mode - * @throws Exception the exception - */ - protected void internalCreate(FolderId parentFolderId, - MessageDisposition messageDisposition, - SendInvitationsMode sendInvitationsMode) throws Exception { - this.throwIfThisIsNotNew(); - this.throwIfThisIsAttachment(); - - if (this.isNew() || this.isDirty()) { - this.getService().createItem( - this, - parentFolderId, - messageDisposition, - sendInvitationsMode != null ? sendInvitationsMode : this - .getDefaultSendInvitationsMode()); - - this.getAttachments().save(); - } - } - - /** - * Update item. - * - * @param parentFolderId the parent folder id - * @param conflictResolutionMode the conflict resolution mode - * @param messageDisposition the message disposition - * @param sendInvitationsOrCancellationsMode the send invitations or cancellations mode - * @return Updated item. - * @throws ServiceResponseException the service response exception - * @throws Exception the exception - */ - protected Item internalUpdate( - FolderId parentFolderId, - ConflictResolutionMode conflictResolutionMode, - MessageDisposition messageDisposition, - SendInvitationsOrCancellationsMode sendInvitationsOrCancellationsMode) - throws ServiceResponseException, Exception { - this.throwIfThisIsNew(); - this.throwIfThisIsAttachment(); - - Item returnedItem = null; - - if (this.isDirty() && this.getPropertyBag().getIsUpdateCallNecessary()) { - returnedItem = this - .getService() - .updateItem( - this, - parentFolderId, - conflictResolutionMode, - messageDisposition, - sendInvitationsOrCancellationsMode != null ? sendInvitationsOrCancellationsMode - : this - .getDefaultSendInvitationsOrCancellationsMode()); - } - if (this.hasUnprocessedAttachmentChanges()) { - // Validation of the item and its attachments occurs in - // UpdateItems. - // If we didn't update the item we still need to validate - // attachments. - this.getAttachments().validate(); - this.getAttachments().save(); - - } - - return returnedItem; - } - - /** - * Gets a value indicating whether this instance has unprocessed attachment - * collection changes. - * - * @throws ServiceLocalException - */ - public boolean hasUnprocessedAttachmentChanges() - throws ServiceLocalException { - return this.getAttachments().hasUnprocessedChanges(); - - } - - /** - * Gets the parent attachment of this item. - * - * @return the parent attachment - */ - public ItemAttachment getParentAttachment() { - return this.parentAttachment; - } - - /** - * Gets Id of the root item for this item. - * - * @return the root item id - * @throws ServiceLocalException the service local exception - */ - public ItemId getRootItemId() throws ServiceLocalException { - - if (this.isAttachment()) { - return this.getParentAttachment().getOwner().getRootItemId(); - } else { - return this.getId(); - } - } - - /** - * Deletes the item. Calling this method results in a call to EWS. - * - * @param deleteMode the delete mode - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - public void delete(DeleteMode deleteMode) throws ServiceLocalException, - Exception { - this.internalDelete(deleteMode, null, null); - } - - /** - * Saves this item in a specific folder. Calling this method results in at - * least one call to EWS. Mutliple calls to EWS might be made if attachments - * have been added. - * - * @param parentFolderId the parent folder id - * @throws Exception the exception - */ - public void save(FolderId parentFolderId) throws Exception { - EwsUtilities.validateParam(parentFolderId, "parentFolderId"); - this.internalCreate(parentFolderId, MessageDisposition.SaveOnly, null); - } - - /** - * Saves this item in a specific folder. Calling this method results in at - * least one call to EWS. Mutliple calls to EWS might be made if attachments - * have been added. - * - * @param parentFolderName the parent folder name - * @throws Exception the exception - */ - public void save(WellKnownFolderName parentFolderName) throws Exception { - this.internalCreate(new FolderId(parentFolderName), - MessageDisposition.SaveOnly, null); - } - - /** - * Saves this item in the default folder based on the item's type (for - * example, an e-mail message is saved to the Drafts folder). Calling this - * method results in at least one call to EWS. Mutliple calls to EWS might - * be made if attachments have been added. - * - * @throws Exception the exception - */ - public void save() throws Exception { - this.internalCreate(null, MessageDisposition.SaveOnly, null); - } - - /** - * Applies the local changes that have been made to this item. Calling this - * method results in at least one call to EWS. Mutliple calls to EWS might - * be made if attachments have been added or removed. - * - * @param conflictResolutionMode the conflict resolution mode - * @throws ServiceResponseException the service response exception - * @throws Exception the exception - */ - public void update(ConflictResolutionMode conflictResolutionMode) - throws ServiceResponseException, Exception { - this.internalUpdate(null /* parentFolder */, conflictResolutionMode, - MessageDisposition.SaveOnly, null); - } - - /** - * Creates a copy of this item in the specified folder. Calling this method - * results in a call to EWS. Copy returns null if the copy operation is - * across two mailboxes or between a mailbox and a public folder. - * - * @param destinationFolderId the destination folder id - * @return The copy of this item. - * @throws Exception the exception - */ - public Item copy(FolderId destinationFolderId) throws Exception { - - this.throwIfThisIsNew(); - this.throwIfThisIsAttachment(); - - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - - return this.getService().copyItem(this.getId(), destinationFolderId); - } - - /** - * Creates a copy of this item in the specified folder. Calling this method - * results in a call to EWS. Copy returns null if the copy operation is - * across two mailboxes or between a mailbox and a public folder. - * - * @param destinationFolderName the destination folder name - * @return The copy of this item. - * @throws Exception the exception - */ - public Item copy(WellKnownFolderName destinationFolderName) - throws Exception { - return this.copy(new FolderId(destinationFolderName)); - } - - /** - * Moves this item to a the specified folder. Calling this method results in - * a call to EWS. Move returns null if the move operation is across two - * mailboxes or between a mailbox and a public folder. - * - * @param destinationFolderId the destination folder id - * @return The moved copy of this item. - * @throws Exception the exception - */ - public Item move(FolderId destinationFolderId) throws Exception { - this.throwIfThisIsNew(); - this.throwIfThisIsAttachment(); - - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - - return this.getService().moveItem(this.getId(), destinationFolderId); - } - - /** - * Moves this item to a the specified folder. Calling this method results in - * a call to EWS. Move returns null if the move operation is across two - * mailboxes or between a mailbox and a public folder. - * - * @param destinationFolderName the destination folder name - * @return The moved copy of this item. - * @throws Exception the exception - */ - public Item move(WellKnownFolderName destinationFolderName) - throws Exception { - return this.move(new FolderId(destinationFolderName)); - } - - /** - * Sets the extended property. - * - * @param extendedPropertyDefinition the extended property definition - * @param value the value - * @throws Exception the exception - */ - public void setExtendedProperty( - ExtendedPropertyDefinition extendedPropertyDefinition, Object value) - throws Exception { - this.getExtendedProperties().setExtendedProperty( - extendedPropertyDefinition, value); - } - - /** - * Removes an extended property. - * - * @param extendedPropertyDefinition the extended property definition - * @return True if property was removed. - * @throws Exception the exception - */ - public boolean removeExtendedProperty( - ExtendedPropertyDefinition extendedPropertyDefinition) - throws Exception { - return this.getExtendedProperties().removeExtendedProperty( - extendedPropertyDefinition); - } - - /** - * Validates this instance. - * - * @throws Exception the exception - */ - @Override public void validate() throws Exception { - super.validate(); - this.getAttachments().validate(); - } - - /** - * Gets a value indicating whether a time zone SOAP header should be emitted - * in a CreateItem or UpdateItem request so this item can be property saved - * or updated. - * - * @param isUpdateOperation Indicates whether the operation being petrformed is an update - * operation. - * @return true if a time zone SOAP header should be emitted; - * otherwise,false - */ - public boolean getIsTimeZoneHeaderRequired(boolean isUpdateOperation) - throws Exception { - // Starting E14SP2, attachment will be sent along with CreateItem - // request. - // if the attachment used to require the Timezone header, CreateItem - // request should do so too. - // - - if (!isUpdateOperation - && (this.getService().getRequestedServerVersion().ordinal() >= ExchangeVersion.Exchange2010_SP2 - .ordinal())) { - - ListIterator items = this.getAttachments().getItems() - .listIterator(); - - while (items.hasNext()) { - - ItemAttachment itemAttachment = (ItemAttachment) items.next(); - - if ((itemAttachment.getItem() != null) - && itemAttachment - .getItem() - .getIsTimeZoneHeaderRequired(false /* isUpdateOperation */)) { - return true; - } - } - } - - /* - * for (ItemAttachment itemAttachment : - * this.getAttachments().OfType().getc) { if - * ((itemAttachment.Item != null) && - * itemAttachment.Item.GetIsTimeZoneHeaderRequired(false /* // - * isUpdateOperation )) { return true; } } - */ - - return super.getIsTimeZoneHeaderRequired(isUpdateOperation); - } - - // region Properties - - /** - * Gets a value indicating whether the item is an attachment. - * - * @return true, if is attachment - */ - public boolean isAttachment() { - return this.parentAttachment != null; - } - - /** - * Gets a value indicating whether this object is a real store item, or if - * it's a local object that has yet to be saved. - * - * @return the checks if is new - * @throws ServiceLocalException the service local exception - */ - public boolean getIsNew() throws ServiceLocalException { - - // Item attachments don't have an Id, need to check whether the - // parentAttachment is new or not. - if (this.isAttachment()) { - return this.getParentAttachment().isNew(); - } else { - return super.isNew(); - } - } - - /** - * Gets the Id of this item. - * - * @return the id - * @throws ServiceLocalException the service local exception - */ - public ItemId getId() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - getIdPropertyDefinition()); - } - - /** - * Get the MIME content of this item. - * - * @return the mime content - * @throws ServiceLocalException the service local exception - */ - public MimeContent getMimeContent() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.MimeContent); - } - - /** - * Sets the mime content. - * - * @param value the new mime content - * @throws Exception the exception - */ - public void setMimeContent(MimeContent value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.MimeContent, value); - } - - /** - * Gets the Id of the parent folder of this item. - * - * @return the parent folder id - * @throws ServiceLocalException the service local exception - */ - public FolderId getParentFolderId() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.ParentFolderId); - } - - /** - * Gets the sensitivity of this item. - * - * @return the sensitivity - * @throws ServiceLocalException the service local exception - */ - public Sensitivity getSensitivity() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.Sensitivity); - } - - /** - * Sets the sensitivity. - * - * @param value the new sensitivity - * @throws Exception the exception - */ - public void setSensitivity(Sensitivity value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.Sensitivity, value); - } - - /** - * Gets a list of the attachments to this item. - * - * @return the attachments - * @throws ServiceLocalException the service local exception - */ - public AttachmentCollection getAttachments() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.Attachments); - } - - /** - * Gets the time when this item was received. - * - * @return the date time received - * @throws ServiceLocalException the service local exception - */ - public Date getDateTimeReceived() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.DateTimeReceived); - } - - /** - * Gets the size of this item. - * - * @return the size - * @throws ServiceLocalException the service local exception - */ - public int getSize() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.Size); - } - - /** - * Gets the list of categories associated with this item. - * - * @return the categories - * @throws ServiceLocalException the service local exception - */ - public StringList getCategories() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.Categories); - } - - /** - * Sets the categories. - * - * @param value the new categories - * @throws Exception the exception - */ - public void setCategories(StringList value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.Categories, value); - } - - /** - * Gets the culture associated with this item. - * - * @return the culture - * @throws ServiceLocalException the service local exception - */ - public String getCulture() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.Culture); - } - - /** - * Sets the culture. - * - * @param value the new culture - * @throws Exception the exception - */ - public void setCulture(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.Culture, value); - } - - /** - * Gets the importance of this item. - * - * @return the importance - * @throws ServiceLocalException the service local exception - */ - public Importance getImportance() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.Importance); - } - - /** - * Sets the importance. - * - * @param value the new importance - * @throws Exception the exception - */ - public void setImportance(Importance value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.Importance, value); - } - - /** - * Gets the In-Reply-To reference of this item. - * - * @return the in reply to - * @throws ServiceLocalException the service local exception - */ - public String getInReplyTo() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.InReplyTo); - } - - /** - * Sets the in reply to. - * - * @param value the new in reply to - * @throws Exception the exception - */ - public void setInReplyTo(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.InReplyTo, value); - } - - /** - * Gets a value indicating whether the message has been submitted to be - * sent. - * - * @return the checks if is submitted - * @throws ServiceLocalException the service local exception - */ - public boolean getIsSubmitted() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.IsSubmitted); - } - - /** - * Gets a value indicating whether the message has been submitted to be - * sent. - * - * @return the checks if is associated - * @throws ServiceLocalException the service local exception - */ - public boolean getIsAssociated() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.IsAssociated); - } - - /** - * Gets a value indicating whether the message has been submitted to be - * sent. - * - * @return the checks if is draft - * @throws ServiceLocalException the service local exception - */ - public boolean getIsDraft() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.IsDraft); - } - - /** - * Gets a value indicating whether the item has been sent by the current - * authenticated user. - * - * @return the checks if is from me - * @throws ServiceLocalException the service local exception - */ - public boolean getIsFromMe() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.IsFromMe); - } - - /** - * Gets a value indicating whether the item is a resend of another item. - * - * @return the checks if is resend - * @throws ServiceLocalException the service local exception - */ - public boolean getIsResend() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.IsResend); - } - - /** - * Gets a value indicating whether the item has been modified since it was - * created. - * - * @return the checks if is unmodified - * @throws ServiceLocalException the service local exception - */ - public boolean getIsUnmodified() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.IsUnmodified); - } - - /** - * Gets a list of Internet headers for this item. - * - * @return the internet message headers - * @throws ServiceLocalException the service local exception - */ - public InternetMessageHeaderCollection getInternetMessageHeaders() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.InternetMessageHeaders); - } - - /** - * Gets the date and time this item was sent. - * - * @return the date time sent - * @throws ServiceLocalException the service local exception - */ - public Date getDateTimeSent() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.DateTimeSent); - } - - /** - * Gets the date and time this item was created. - * - * @return the date time created - * @throws ServiceLocalException the service local exception - */ - public Date getDateTimeCreated() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.DateTimeCreated); - } - - /** - * Gets a value indicating which response actions are allowed on this item. - * Examples of response actions are Reply and Forward. - * - * @return the allowed response actions - * @throws ServiceLocalException the service local exception - */ - public EnumSet getAllowedResponseActions() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.AllowedResponseActions); - } - - /** - * Gets the date and time when the reminder is due for this item. - * - * @return the reminder due by - * @throws ServiceLocalException the service local exception - */ - public Date getReminderDueBy() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.ReminderDueBy); - } - - /** - * Sets the reminder due by. - * - * @param value the new reminder due by - * @throws Exception the exception - */ - public void setReminderDueBy(Date value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.ReminderDueBy, value); - } - - /** - * Gets a value indicating whether a reminder is set for this item. - * - * @return the checks if is reminder set - * @throws ServiceLocalException the service local exception - */ - public boolean getIsReminderSet() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.IsReminderSet); - } - - /** - * Sets the checks if is reminder set. - * - * @param value the new checks if is reminder set - * @throws Exception the exception - */ - public void setIsReminderSet(Boolean value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.IsReminderSet, value); - } - - /** - * Gets the number of minutes before the start of this item when the - * reminder should be triggered. - * - * @return the reminder minutes before start - * @throws ServiceLocalException the service local exception - */ - public int getReminderMinutesBeforeStart() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.ReminderMinutesBeforeStart); - } - - /** - * Sets the reminder minutes before start. - * - * @param value the new reminder minutes before start - * @throws Exception the exception - */ - public void setReminderMinutesBeforeStart(int value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.ReminderMinutesBeforeStart, value); - } - - /** - * Gets a text summarizing the Cc receipients of this item. - * - * @return the display cc - * @throws ServiceLocalException the service local exception - */ - public String getDisplayCc() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.DisplayCc); - } - - /** - * Gets a text summarizing the To recipients of this item. - * - * @return the display to - * @throws ServiceLocalException the service local exception - */ - public String getDisplayTo() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.DisplayTo); - } - - /** - * Gets a value indicating whether the item has attachments. - * - * @return the checks for attachments - * @throws ServiceLocalException the service local exception - */ - public boolean getHasAttachments() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.HasAttachments); - } - - /** - * Gets the body of this item. - * - * @return MessageBody - * @throws ServiceLocalException the service local exception - */ - public MessageBody getBody() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(ItemSchema.Body); - } - - /** - * Sets the body. - * - * @param value the new body - * @throws Exception the exception - */ - public void setBody(MessageBody value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition(ItemSchema.Body, - value); - } - - /** - * Gets the custom class name of this item. - * - * @return the item class - * @throws ServiceLocalException the service local exception - */ - public String getItemClass() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.ItemClass); - } - - /** - * Sets the item class. - * - * @param value the new item class - * @throws Exception the exception - */ - public void setItemClass(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.ItemClass, value); - } - - /** - * Sets the subject. - * - * @param subject the new subject - * @throws Exception the exception - */ - public void setSubject(String subject) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.Subject, subject); - } - - /** - * Gets the subject. - * - * @return the subject - * @throws ServiceLocalException the service local exception - */ - public String getSubject() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.Subject); - } - - /** - * Gets the query string that should be appended to the Exchange Web client - * URL to open this item using the appropriate read form in a web browser. - * - * @return the web client read form query string - * @throws ServiceLocalException the service local exception - */ - public String getWebClientReadFormQueryString() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.WebClientReadFormQueryString); - } - - /** - * Gets the query string that should be appended to the Exchange Web client - * URL to open this item using the appropriate read form in a web browser. - * - * @return the web client edit form query string - * @throws ServiceLocalException the service local exception - */ - public String getWebClientEditFormQueryString() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.WebClientEditFormQueryString); - } - - /** - * Gets a list of extended property defined on this item. - * - * @return the extended property - * @throws ServiceLocalException the service local exception - */ - @Override - public ExtendedPropertyCollection getExtendedProperties() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ServiceObjectSchema.extendedProperties); - } - - /** - * Gets a value indicating the effective rights the current authenticated - * user has on this item. - * - * @return the effective rights - * @throws ServiceLocalException the service local exception - */ - public EnumSet getEffectiveRights() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.EffectiveRights); - } - - /** - * Gets the name of the user who last modified this item. - * - * @return the last modified name - * @throws ServiceLocalException the service local exception - */ - public String getLastModifiedName() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.LastModifiedName); - } - - /** - * Gets the date and time this item was last modified. - * - * @return the last modified time - * @throws ServiceLocalException the service local exception - */ - public Date getLastModifiedTime() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.LastModifiedTime); - } - - /** - * Gets the Id of the conversation this item is part of. - * - * @return the conversation id - * @throws ServiceLocalException the service local exception - */ - public ConversationId getConversationId() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.ConversationId); - } - - /** - * Gets the body part that is unique to the conversation this item is part - * of. - * - * @return the unique body - * @throws ServiceLocalException the service local exception - */ - public UniqueBody getUniqueBody() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - ItemSchema.UniqueBody); - } - - /** - * Gets the default setting for how to treat affected task occurrences on - * Delete. Subclasses will override this for different default behavior. - * - * @return the default affected task occurrences - */ - protected AffectedTaskOccurrence getDefaultAffectedTaskOccurrences() { - return null; - } - - /** - * Gets the default setting for sending cancellations on Delete. Subclasses - * will override this for different default behavior. - * - * @return the default send cancellations mode - */ - protected SendCancellationsMode getDefaultSendCancellationsMode() { - return null; - } - - /** - * Gets the default settings for sending invitations on Save. Subclasses - * will override this for different default behavior. - * - * @return the default send invitations mode - */ - protected SendInvitationsMode getDefaultSendInvitationsMode() { - return null; - } - - /** - * Gets the default settings for sending invitations or cancellations on - * Update. Subclasses will override this for different default behavior. - * - * @return the default send invitations or cancellations mode - */ - protected SendInvitationsOrCancellationsMode getDefaultSendInvitationsOrCancellationsMode() { - return null; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/MeetingCancellation.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/MeetingCancellation.java deleted file mode 100644 index 8c6eb5b71..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/MeetingCancellation.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.response.RemoveFromCalendar; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.misc.CalendarActionResults; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Represents a meeting cancellation message. Properties available on meeting - * messages are defined in the MeetingMessageSchema class. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.MeetingCancellation) -public class MeetingCancellation extends MeetingMessage { - - private static final Log LOG = LogFactory.getLog(MeetingCancellation.class); - - /** - * Initializes a new instance of the class. - * - * @param parentAttachment The parent attachment. - * @throws Exception the exception - */ - public MeetingCancellation(ItemAttachment parentAttachment) - throws Exception { - super(parentAttachment); - } - - /** - * Initializes a new instance of the class. - * - * @param service EWS service to which this object belongs. - * @throws Exception the exception - */ - public MeetingCancellation(ExchangeService service) throws Exception { - super(service); - } - - /** - * Binds to an existing meeting cancellation message and loads the specified - * set of property. Calling this method results in a call to EWS. - * - * @param service The service to use to bind to the meeting cancellation - * message. - * @param id The Id of the meeting cancellation message to bind to. - * @param propertySet The set of property to load. - * @return A MeetingCancellation instance representing the meeting - * cancellation message corresponding to the specified Id. - */ - public static MeetingCancellation bind(ExchangeService service, ItemId id, - PropertySet propertySet) { - try { - return service.bindToItem(MeetingCancellation.class, id, - propertySet); - } catch (Exception e) { - LOG.error(e); - return null; - } - } - - /** - * Binds to an existing meeting cancellation message and loads the specified - * set of property. Calling this method results in a call to EWS. - * - * @param service The service to use to bind to the meeting cancellation - * message. - * @param id The Id of the meeting cancellation message to bind to. - * @return A MeetingCancellation instance representing the meeting - * cancellation message corresponding to the specified Id. - */ - public static MeetingCancellation bind(ExchangeService service, ItemId id) { - return MeetingCancellation.bind(service, id, PropertySet - .getFirstClassProperties()); - } - - /** - * Removes the meeting associated with the cancellation message from the - * user's calendar. - * - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - public CalendarActionResults removeMeetingFromCalendar() - throws ServiceLocalException, Exception { - return new CalendarActionResults(new RemoveFromCalendar(this) - .internalCreate(null, null)); - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/MeetingMessage.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/MeetingMessage.java deleted file mode 100644 index 801922a3c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/MeetingMessage.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.schema.MeetingMessageSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.MeetingResponseType; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; -import microsoft.exchange.webservices.data.property.complex.ItemId; - -import java.util.Date; - -/** - * Represents a meeting-related message. Properties available on meeting - * messages are defined in the MeetingMessageSchema class. - */ - -@ServiceObjectDefinition(xmlElementName = XmlElementNames.MeetingMessage) -@EditorBrowsable(state = EditorBrowsableState.Never) -public class MeetingMessage extends EmailMessage { - - /** - * Initializes a new instance of the "MeetingMessage" class. - * - * @param parentAttachment the parent attachment - * @throws Exception the exception - */ - public MeetingMessage(ItemAttachment parentAttachment) throws Exception { - super(parentAttachment); - } - - /** - * Initializes a new instance of the "MeetingMessage" class. - * - * @param service EWS service to which this object belongs. - * @throws Exception the exception - */ - public MeetingMessage(ExchangeService service) throws Exception { - super(service); - } - - /** - * Binds to an existing meeting message and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service The service to use to bind to the meeting message. - * @param id The Id of the meeting message to bind to. - * @param propertySet The set of property to load. - * @return A MeetingMessage instance representing the meeting message - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static MeetingMessage bind(ExchangeService service, ItemId id, - PropertySet propertySet) throws Exception { - return (MeetingMessage) service.bindToItem(id, propertySet); - } - - /** - * Binds to an existing meeting message and loads its first class - * property. Calling this method results in a call to EWS. - * - * @param service The service to use to bind to the meeting message. - * @param id The Id of the meeting message to bind to. - * @return A MeetingMessage instance representing the meeting message - * corresponding to the specified Id. - * @throws Exception the exception - */ - public static MeetingMessage bind(ExchangeService service, ItemId id) - throws Exception { - return MeetingMessage.bind(service, id, PropertySet - .getFirstClassProperties()); - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return MeetingMessageSchema.getInstance(); - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the associated appointment ID. - * - * @return the associated appointment ID. - * @throws ServiceLocalException the service local exception - */ - public ItemId getAssociatedAppointmentId() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - MeetingMessageSchema.AssociatedAppointmentId); - } - - /** - * Gets whether the meeting message has been processed. - * - * @return whether the meeting message has been processed. - * @throws ServiceLocalException the service local exception - */ - public Boolean getHasBeenProcessed() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - MeetingMessageSchema.HasBeenProcessed); - } - - /** - * Gets the response type indicated by this meeting message. - * - * @return the response type indicated by this meeting message. - * @throws ServiceLocalException the service local exception - */ - public MeetingResponseType getResponseType() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - MeetingMessageSchema.ResponseType); - } - - /** - * Gets the ICalendar Uid. - * - * @return the ical uid - * @throws ServiceLocalException the service local exception - */ - public String getICalUid() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - MeetingMessageSchema.ICalUid); - } - - /** - * Gets the ICalendar RecurrenceId. - * - * @return the ical recurrence id - * @throws ServiceLocalException the service local exception - */ - public Date getICalRecurrenceId() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - MeetingMessageSchema.ICalRecurrenceId); - } - - /** - * Gets the ICalendar DateTimeStamp. - * - * @return the ical date time stamp - * @throws ServiceLocalException the service local exception - */ - public Date getICalDateTimeStamp() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - MeetingMessageSchema.ICalDateTimeStamp); - } - - /** - * Gets the IsDelegated property. - * - * @return True if delegated; false otherwise. - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsDelegated() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - MeetingMessageSchema.IsDelegated); - } - - /** - * Gets the IsOutOfDate property. - * - * @return True if out of date; false otherwise. - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsOutOfDate() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - MeetingMessageSchema.IsOutOfDate); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/MeetingRequest.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/MeetingRequest.java deleted file mode 100644 index f8c8b5a82..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/MeetingRequest.java +++ /dev/null @@ -1,723 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.response.AcceptMeetingInvitationMessage; -import microsoft.exchange.webservices.data.core.service.response.DeclineMeetingInvitationMessage; -import microsoft.exchange.webservices.data.core.service.schema.AppointmentSchema; -import microsoft.exchange.webservices.data.core.service.schema.MeetingRequestSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AppointmentType; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.LegacyFreeBusyStatus; -import microsoft.exchange.webservices.data.core.enumeration.service.MeetingRequestType; -import microsoft.exchange.webservices.data.core.enumeration.property.MeetingResponseType; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.misc.CalendarActionResults; -import microsoft.exchange.webservices.data.misc.TimeSpan; -import microsoft.exchange.webservices.data.property.complex.AttendeeCollection; -import microsoft.exchange.webservices.data.property.complex.DeletedOccurrenceInfoCollection; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; -import microsoft.exchange.webservices.data.property.complex.ItemCollection; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.OccurrenceInfo; -import microsoft.exchange.webservices.data.property.complex.OccurrenceInfoCollection; -import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence; -import microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.Date; - -/** - * Represents a meeting request that an attendee can accept - * or decline. Properties available on meeting - * request are defined in the MeetingRequestSchema class. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.MeetingRequest) -public class MeetingRequest extends MeetingMessage implements ICalendarActionProvider { - - private static final Log LOG = LogFactory.getLog(MeetingRequest.class); - - /** - * Initializes a new instance of the class. - * - * @param parentAttachment The parent attachment - * @throws Exception throws Exception - */ - public MeetingRequest(ItemAttachment parentAttachment) throws Exception { - super(parentAttachment); - } - - /** - * Initializes a new instance of the class. - * - * @param service EWS service to which this object belongs. - * @throws Exception throws Exception - */ - public MeetingRequest(ExchangeService service) throws Exception { - super(service); - } - - /** - * Binds to an existing meeting response and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service The service to use to bind to the meeting request. - * @param id The Id of the meeting request to bind to. - * @param propertySet The set of property to load. - * @return A MeetingResponse instance representing the meeting request - * corresponding to the specified Id. - */ - public static MeetingRequest bind(ExchangeService service, ItemId id, - PropertySet propertySet) { - try { - return service.bindToItem(MeetingRequest.class, id, propertySet); - } catch (Exception e) { - LOG.error(e); - return null; - } - } - - /** - * Binds to an existing meeting response and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service The service to use to bind to the meeting request. - * @param id The Id of the meeting request to bind to. - * @return A MeetingResponse instance representing the meeting request - * corresponding to the specified Id. - */ - public static MeetingRequest bind(ExchangeService service, ItemId id) { - return MeetingRequest.bind(service, id, PropertySet - .getFirstClassProperties()); - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return MeetingRequestSchema.Instance; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Creates a local meeting acceptance message that can be customized and - * sent. - * - * @param tentative Specifies whether the meeting will be tentatively accepted. - * @return An AcceptMeetingInvitationMessage representing the meeting - * acceptance message. - */ - public AcceptMeetingInvitationMessage createAcceptMessage(boolean - tentative) { - try { - return new AcceptMeetingInvitationMessage(this, tentative); - } catch (Exception e) { - LOG.error(e); - return null; - } - } - - /** - * Creates a local meeting declination message that can be customized and - * sent. - * - * @return A DeclineMeetingInvitation representing the meeting declination - * message. - */ - public DeclineMeetingInvitationMessage createDeclineMessage() { - try { - return new DeclineMeetingInvitationMessage(this); - } catch (Exception e) { - LOG.error(e); - return null; - } - } - - /** - * Accepts the meeting. Calling this method results in a call to EWS. - * - * @param sendResponse Indicates whether to send a response to the organizer. - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception throws Exception - */ - public CalendarActionResults accept(boolean sendResponse) throws Exception { - return this.internalAccept(false, sendResponse); - } - - /** - * Tentatively accepts the meeting. Calling this method results in a call to - * EWS. - * - * @param sendResponse Indicates whether to send a response to the organizer. - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception throws Exception - */ - public CalendarActionResults acceptTentatively(boolean sendResponse) - throws Exception { - return this.internalAccept(true, sendResponse); - } - - /** - * Accepts the meeting. - * - * @param tentative True if tentative accept. - * @param sendResponse Indicates whether to send a response to the organizer. - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception throws Exception - */ - protected CalendarActionResults internalAccept(boolean tentative, - boolean sendResponse) throws Exception { - AcceptMeetingInvitationMessage accept = this - .createAcceptMessage(tentative); - - if (sendResponse) { - return accept.calendarSendAndSaveCopy(); - } else { - return accept.calendarSave(); - - } - } - - /** - * Declines the meeting invitation. Calling this method results in a call to - * EWS. - * - * @param sendResponse Indicates whether to send a response to the organizer. - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception throws Exception - */ - public CalendarActionResults decline(boolean sendResponse) - throws Exception { - DeclineMeetingInvitationMessage decline = this.createDeclineMessage(); - - if (sendResponse) { - return decline.calendarSendAndSaveCopy(); - } else { - return decline.calendarSave(); - } - } - - /** - * Gets the type of this meeting request. - * - * @return the meeting request type - * @throws ServiceLocalException the service local exception - */ - public MeetingRequestType getMeetingRequestType() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - MeetingRequestSchema.MeetingRequestType); - } - - /** - * Gets the a value representing the intended free/busy status of the - * meeting. - * - * @return the intended free busy status - * @throws ServiceLocalException the service local exception - */ - public LegacyFreeBusyStatus getIntendedFreeBusyStatus() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - MeetingRequestSchema.IntendedFreeBusyStatus); - } - - /** - * Gets the start time of the appointment. - * - * @return the start - * @throws ServiceLocalException the service local exception - */ - public Date getStart() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.Start); - } - - /** - * Gets the end time of the appointment. - * - * @return the end - * @throws ServiceLocalException the service local exception - */ - public Date getEnd() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.End); - } - - /** - * Gets the original start time of the appointment. - * - * @return the original start - * @throws ServiceLocalException the service local exception - */ - public Date getOriginalStart() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.OriginalStart); - } - - /** - * Gets a value indicating whether this appointment is an all day event. - * - * @return the checks if is all day event - * @throws ServiceLocalException the service local exception - */ - public boolean getIsAllDayEvent() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.IsAllDayEvent) != null; - } - - /** - * Gets a value indicating the free/busy status of the owner of this - * appointment. - * - * @return the legacy free busy status - * @throws ServiceLocalException the service local exception - */ - public LegacyFreeBusyStatus legacyFreeBusyStatus() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.LegacyFreeBusyStatus); - } - - /** - * Gets the location of this appointment. - * - * @return the location - * @throws ServiceLocalException the service local exception - */ - public String getLocation() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.Location); - } - - /** - * Gets a text indicating when this appointment occurs. The text returned by - * When is localized using the Exchange Server culture or using the culture - * specified in the PreferredCulture property of the ExchangeService object - * this appointment is bound to. - * - * @return the when - * @throws ServiceLocalException the service local exception - */ - public String getWhen() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.When); - } - - /** - * Gets a value indicating whether the appointment is a meeting. - * - * @return the checks if is meeting - * @throws ServiceLocalException the service local exception - */ - public boolean getIsMeeting() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.IsMeeting) != null; - } - - /** - * Gets a value indicating whether the appointment has been cancelled. - * - * @return the checks if is cancelled - * @throws ServiceLocalException the service local exception - */ - public boolean getIsCancelled() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.IsCancelled) != null; - } - - /** - * Gets a value indicating whether the appointment is recurring. - * - * @return the checks if is recurring - * @throws ServiceLocalException the service local exception - */ - public boolean getIsRecurring() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.IsRecurring) != null; - } - - /** - * Gets a value indicating whether the meeting request has already been - * sent. - * - * @return the meeting request was sent - * @throws ServiceLocalException the service local exception - */ - public boolean getMeetingRequestWasSent() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.MeetingRequestWasSent) != null; - } - - /** - * Gets a value indicating the type of this appointment. - * - * @return the appointment type - * @throws ServiceLocalException the service local exception - */ - public AppointmentType getAppointmentType() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.AppointmentType); - } - - /** - * Gets a value indicating what was the last response of the user that - * loaded this meeting. - * - * @return the my response type - * @throws ServiceLocalException the service local exception - */ - public MeetingResponseType getMyResponseType() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.MyResponseType); - } - - /** - * Gets the organizer of this meeting. - * - * @return the organizer - * @throws ServiceLocalException the service local exception - */ - public EmailAddress getOrganizer() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.Organizer); - } - - /** - * Gets a list of required attendees for this meeting. - * - * @return the required attendees - * @throws ServiceLocalException the service local exception - */ - public AttendeeCollection getRequiredAttendees() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.RequiredAttendees); - } - - /** - * Gets a list of optional attendeed for this meeting. - * - * @return the optional attendees - * @throws ServiceLocalException the service local exception - */ - public AttendeeCollection getOptionalAttendees() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.OptionalAttendees); - } - - /** - * Gets a list of resources for this meeting. - * - * @return the resources - * @throws ServiceLocalException the service local exception - */ - public AttendeeCollection getResources() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.Resources); - } - - /** - * Gets the number of calendar entries that conflict with - * this appointment in the authenticated user's calendar. - * - * @return the conflicting meeting count - * @throws NumberFormatException the number format exception - * @throws ServiceLocalException the service local exception - */ - public int getConflictingMeetingCount() throws NumberFormatException, - ServiceLocalException { - return (Integer.parseInt(this.getPropertyBag() - .getObjectFromPropertyDefinition( - AppointmentSchema.ConflictingMeetingCount).toString())); - } - - /** - * Gets the number of calendar entries that are adjacent to - * this appointment in the authenticated user's calendar. - * - * @return the adjacent meeting count - * @throws NumberFormatException the number format exception - * @throws ServiceLocalException the service local exception - */ - public int getAdjacentMeetingCount() throws NumberFormatException, - ServiceLocalException { - return (Integer.parseInt(this.getPropertyBag() - .getObjectFromPropertyDefinition( - AppointmentSchema.AdjacentMeetingCount).toString())); - } - - /** - * Gets a list of meetings that conflict with - * this appointment in the authenticated user's calendar. - * - * @return the conflicting meetings - * @throws ServiceLocalException the service local exception - */ - public ItemCollection getConflictingMeetings() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.ConflictingMeetings); - } - - /** - * Gets a list of meetings that are adjacent with this - * appointment in the authenticated user's calendar. - * - * @return the adjacent meetings - * @throws ServiceLocalException the service local exception - */ - public ItemCollection getAdjacentMeetings() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.AdjacentMeetings); - } - - /** - * Gets the duration of this appointment. - * - * @return the duration - * @throws ServiceLocalException the service local exception - */ - public TimeSpan getDuration() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.Duration); - } - - /** - * Gets the name of the time zone this appointment is defined in. - * - * @return the time zone - * @throws ServiceLocalException the service local exception - */ - public String getTimeZone() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.TimeZone); - } - - /** - * Gets the time when the attendee replied to the meeting request. - * - * @return the appointment reply time - * @throws ServiceLocalException the service local exception - */ - public Date getAppointmentReplyTime() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.AppointmentReplyTime); - } - - /** - * Gets the sequence number of this appointment. - * - * @return the appointment sequence number - * @throws NumberFormatException the number format exception - * @throws ServiceLocalException the service local exception - */ - public int getAppointmentSequenceNumber() throws NumberFormatException, - ServiceLocalException { - return (Integer - .parseInt(this.getPropertyBag() - .getObjectFromPropertyDefinition( - AppointmentSchema.AppointmentSequenceNumber) - .toString())); - } - - /** - * Gets the state of this appointment. - * - * @return the appointment state - * @throws NumberFormatException the number format exception - * @throws ServiceLocalException the service local exception - */ - public int getAppointmentState() throws NumberFormatException, - ServiceLocalException { - return (Integer.parseInt(this.getPropertyBag() - .getObjectFromPropertyDefinition( - AppointmentSchema.AppointmentState).toString())); - } - - /** - * Gets the recurrence pattern for this meeting request. - * - * @return the recurrence - * @throws ServiceLocalException the service local exception - */ - public Recurrence getRecurrence() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.Recurrence); - } - - /** - * Gets an OccurrenceInfo identifying the first occurrence of this meeting. - * - * @return the first occurrence - * @throws ServiceLocalException the service local exception - */ - public OccurrenceInfo getFirstOccurrence() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.FirstOccurrence); - } - - /** - * Gets an OccurrenceInfo identifying the last occurrence of this meeting. - * - * @return the last occurrence - * @throws ServiceLocalException the service local exception - */ - public OccurrenceInfo getLastOccurrence() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.FirstOccurrence); - } - - /** - * Gets a list of modified occurrences for this meeting. - * - * @return the modified occurrences - * @throws ServiceLocalException the service local exception - */ - public OccurrenceInfoCollection getModifiedOccurrences() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.ModifiedOccurrences); - } - - /** - * Gets a list of deleted occurrences for this meeting. - * - * @return the deleted occurrences - * @throws ServiceLocalException the service local exception - */ - public DeletedOccurrenceInfoCollection getDeletedOccurrences() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.DeletedOccurrences); - } - - /** - * Gets time zone of the start property of this meeting request. - * - * @return the start time zone - * @throws ServiceLocalException the service local exception - */ - public TimeZoneDefinition getStartTimeZone() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.StartTimeZone); - } - - /** - * Gets time zone of the end property of this meeting request. - * - * @return the end time zone - * @throws ServiceLocalException the service local exception - */ - public TimeZoneDefinition getEndTimeZone() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.EndTimeZone); - } - - /** - * Gets the type of conferencing that will be used during the meeting. - * - * @return the conference type - * @throws NumberFormatException the number format exception - * @throws ServiceLocalException the service local exception - */ - public int getConferenceType() throws NumberFormatException, - ServiceLocalException { - return (Integer.parseInt(this.getPropertyBag() - .getObjectFromPropertyDefinition( - AppointmentSchema.ConferenceType).toString())); - } - - /** - * Gets a value indicating whether new time - * proposals are allowed for attendees of this meeting. - * - * @return the allow new time proposal - * @throws ServiceLocalException the service local exception - */ - public boolean getAllowNewTimeProposal() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.AllowNewTimeProposal); - } - - /** - * Gets a value indicating whether this is an online meeting. - * - * @return the checks if is online meeting - * @throws ServiceLocalException the service local exception - */ - public boolean getIsOnlineMeeting() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.IsOnlineMeeting); - } - - /** - * Gets the URL of the meeting workspace. A meeting - * workspace is a shared Web site for - * planning meetings and tracking results. - * - * @return the meeting workspace url - * @throws ServiceLocalException the service local exception - */ - public String getMeetingWorkspaceUrl() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.MeetingWorkspaceUrl); - } - - /** - * Gets the URL of the Microsoft NetShow online meeting. - * - * @return the net show url - * @throws ServiceLocalException the service local exception - */ - public String getNetShowUrl() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - AppointmentSchema.NetShowUrl); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/MeetingResponse.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/MeetingResponse.java deleted file mode 100644 index 72823478b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/MeetingResponse.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Represents a response to a meeting request. Properties available on meeting - * messages are defined in the MeetingMessageSchema class. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.MeetingResponse) -public class MeetingResponse extends MeetingMessage { - - private static final Log LOG = LogFactory.getLog(MeetingResponse.class); - - /** - * Initializes a new instance of the class. - * - * @param parentAttachment The parentAttachment - * @throws Exception the exception - */ - public MeetingResponse(ItemAttachment parentAttachment) - throws Exception { - super(parentAttachment); - } - - /** - * Initializes a new instance of the class. - * - * @param service EWS service to which this object belongs. - * @throws Exception the exception - */ - public MeetingResponse(ExchangeService service) throws Exception { - super(service); - } - - /** - * Binds to an existing meeting response and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service The service to use to bind to the meeting response. - * @param id The Id of the meeting response to bind to. - * @param propertySet The set of property to load. - * @return A MeetingResponse instance representing the meeting response - * corresponding to the specified Id. - */ - public static MeetingResponse bind(ExchangeService service, ItemId id, - PropertySet propertySet) { - try { - return service.bindToItem(MeetingResponse.class, id, propertySet); - } catch (Exception e) { - LOG.error(e); - return null; - } - } - - /** - * Binds to an existing meeting response and loads the specified set of - * property. Calling this method results in a call to EWS. - * - * @param service The service to use to bind to the meeting response. - * @param id The Id of the meeting response to bind to. - * @return A MeetingResponse instance representing the meeting response - * corresponding to the specified Id. - */ - public static MeetingResponse bind(ExchangeService service, ItemId id) { - return MeetingResponse.bind(service, id, PropertySet - .getFirstClassProperties()); - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/PostItem.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/PostItem.java deleted file mode 100644 index 535c470b3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/PostItem.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.attribute.Attachable; -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.response.PostReply; -import microsoft.exchange.webservices.data.core.service.response.ResponseMessage; -import microsoft.exchange.webservices.data.core.service.schema.EmailMessageSchema; -import microsoft.exchange.webservices.data.core.service.schema.PostItemSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.ResponseMessageType; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.MessageBody; - -import java.util.Arrays; -import java.util.Date; - -/** - * Represents a post item. Properties available on post item are defined in the - * PostItemSchema class. - */ -@Attachable -@ServiceObjectDefinition(xmlElementName = XmlElementNames.PostItem) -public final class PostItem extends Item { - - /** - * Initializes an unsaved local instance of PostItem.To bind to an existing - * post item, use PostItem.Bind() instead. - * - * @param service the service - * @throws Exception the exception - */ - public PostItem(ExchangeService service) throws Exception { - super(service); - } - - /** - * Initializes a new instance of the class. - * - * @param parentAttachment the parent attachment - * @throws Exception the exception - */ - public PostItem(ItemAttachment parentAttachment) throws Exception { - super(parentAttachment); - } - - /** - * Binds to an existing post item and loads the specified set of property. - * Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @param propertySet the property set - * @return An PostItem instance representing the post item corresponding to - * the specified Id. - * @throws Exception the exception - */ - public static PostItem bind(ExchangeService service, ItemId id, - PropertySet propertySet) throws Exception { - return service.bindToItem(PostItem.class, id, propertySet); - } - - /** - * Binds to an existing post item and loads its first class property. - * calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @return An PostItem instance representing the post item corresponding to - * the specified Id. - * @throws Exception the exception - */ - public static PostItem bind(ExchangeService service, ItemId id) - throws Exception { - return PostItem - .bind(service, id, PropertySet.getFirstClassProperties()); - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return PostItemSchema.Instance; - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Creates a post reply to this post item. - * - * @return A PostReply that can be modified and saved. - * @throws Exception the exception - */ - public PostReply createPostReply() throws Exception { - this.throwIfThisIsNew(); - return new PostReply(this); - } - - /** - * Posts a reply to this post item. Calling this method results in a call to - * EWS. - * - * @param bodyPrefix the body prefix - * @throws Exception the exception - */ - public void postReply(MessageBody bodyPrefix) throws Exception { - PostReply postReply = this.createPostReply(); - postReply.setBodyPrefix(bodyPrefix); - postReply.save(); - } - - /** - * Creates a e-mail reply response to the post item. - * - * @param replyAll the reply all - * @return A ResponseMessage representing the e-mail reply response that can - * subsequently be modified and sent. - * @throws Exception the exception - */ - public ResponseMessage createReply(boolean replyAll) throws Exception { - this.throwIfThisIsNew(); - return new ResponseMessage(this, - replyAll ? ResponseMessageType.ReplyAll : - ResponseMessageType.Reply); - } - - /** - * Replies to the post item. Calling this method results in a call to EWS. - * - * @param bodyPrefix the body prefix - * @param replyAll the reply all - * @throws Exception the exception - */ - public void reply(MessageBody bodyPrefix, boolean replyAll) - throws Exception { - ResponseMessage responseMessage = this.createReply(replyAll); - responseMessage.setBodyPrefix(bodyPrefix); - responseMessage.sendAndSaveCopy(); - } - - /** - * Creates a forward response to the post item. - * - * @return A ResponseMessage representing the forward response that can - * subsequently be modified and sent. - * @throws Exception the exception - */ - public ResponseMessage createForward() throws Exception { - this.throwIfThisIsNew(); - return new ResponseMessage(this, ResponseMessageType.Forward); - } - - /** - * Forwards the post item. Calling this method results in a call to EWS. - * - * @param bodyPrefix the body prefix - * @param toRecipients the to recipients - * @throws Exception the exception - */ - public void forward(MessageBody bodyPrefix, EmailAddress... toRecipients) - throws Exception { - forward(bodyPrefix, Arrays.asList(toRecipients)); - } - - /** - * Forwards the post item. Calling this method results in a call to EWS. - * - * @param bodyPrefix the body prefix - * @param toRecipients the to recipients - * @throws Exception the exception - */ - public void forward(MessageBody bodyPrefix, - Iterable toRecipients) throws Exception { - ResponseMessage responseMessage = this.createForward(); - responseMessage.setBodyPrefix(bodyPrefix); - responseMessage.getToRecipients() - .addEmailRange(toRecipients.iterator()); - - responseMessage.sendAndSaveCopy(); - } - - // Properties - - /** - * Gets the conversation index of the post item. - * - * @return the conversation index - * @throws ServiceLocalException the service local exception - */ - public byte[] getConversationIndex() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.ConversationIndex); - } - - /** - * Gets the conversation topic of the post item. - * - * @return the conversation topic - * @throws ServiceLocalException the service local exception - */ - public String getConversationTopic() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.ConversationTopic); - } - - /** - * Gets the "on behalf" poster of the post item. - * - * @return the from - * @throws ServiceLocalException the service local exception - */ - public EmailAddress getFrom() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.From); - } - - /** - * Sets the from. - * - * @param value the new from - * @throws Exception the exception - */ - public void setFrom(EmailAddress value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.From, value); - } - - /** - * Gets the Internet message Id of the post item. - * - * @return the internet message id - * @throws ServiceLocalException the service local exception - */ - public String getInternetMessageId() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.InternetMessageId); - } - - /** - * Gets a value indicating whether the post item is read. - * - * @return the checks if is read - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsRead() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.IsRead); - } - - /** - * Sets the checks if is read. - * - * @param value the new checks if is read - * @throws Exception the exception - */ - public void setIsRead(Boolean value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.IsRead, value); - } - - /** - * Gets the the date and time when the post item was posted. - * - * @return the posted time - * @throws ServiceLocalException the service local exception - */ - public Date getPostedTime() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - PostItemSchema.PostedTime); - } - - /** - * Gets the references of the post item. - * - * @return the references - * @throws ServiceLocalException the service local exception - */ - public String getReferences() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.References); - } - - /** - * Sets the checks if is read. - * - * @param value the new checks if is read - * @throws Exception the exception - */ - public void setIsRead(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.References, value); - } - - /** - * Gets the sender (poster) of the post item. - * - * @return the sender - * @throws ServiceLocalException the service local exception - */ - public EmailAddress getSender() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - EmailMessageSchema.Sender); - } - - /** - * Sets the sender. - * - * @param value the new sender - * @throws Exception the exception - */ - public void setSender(EmailAddress value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.Sender, value); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/item/Task.java b/src/main/java/microsoft/exchange/webservices/data/core/service/item/Task.java deleted file mode 100644 index 9183ded03..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/item/Task.java +++ /dev/null @@ -1,595 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.item; - -import microsoft.exchange.webservices.data.attribute.Attachable; -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.service.schema.TaskSchema; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence; -import microsoft.exchange.webservices.data.core.enumeration.service.ConflictResolutionMode; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition; -import microsoft.exchange.webservices.data.core.enumeration.property.TaskDelegationState; -import microsoft.exchange.webservices.data.core.enumeration.service.TaskMode; -import microsoft.exchange.webservices.data.core.enumeration.service.TaskStatus; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException; -import microsoft.exchange.webservices.data.property.complex.ItemAttachment; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.StringList; -import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence; - -import java.util.Date; - -/** - * Represents a Task item. Properties available on tasks are defined in the - * TaskSchema class. - */ -@Attachable -@ServiceObjectDefinition(xmlElementName = XmlElementNames.Task) -public class Task extends Item { - - private static final double PERCENT_MIN = 0.0D; - private static final double PERCENT_MAX = 100.0D; - - - /** - * Initializes an unsaved local instance of Task.To bind to an existing - * task, use Task.Bind() instead. - * - * @param service the service - * @throws Exception the exception - */ - public Task(ExchangeService service) throws Exception { - super(service); - } - - /** - * Initializes a new instance of the class. - * - * @param parentAttachment the parent attachment - * @throws Exception the exception - */ - public Task(ItemAttachment parentAttachment) throws Exception { - super(parentAttachment); - } - - /** - * Binds to an existing task and loads the specified set of property. - * Calling this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @param propertySet the property set - * @return A Task instance representing the task corresponding to the - * specified Id. - * @throws Exception the exception - */ - public static Task bind(ExchangeService service, ItemId id, - PropertySet propertySet) throws Exception { - return service.bindToItem(Task.class, id, propertySet); - } - - /** - * Binds to an existing task and loads its first class property. Calling - * this method results in a call to EWS. - * - * @param service the service - * @param id the id - * @return A Task instance representing the task corresponding to the - * specified Id. - * @throws Exception the exception - */ - public static Task bind(ExchangeService service, ItemId id) - throws Exception { - return Task.bind(service, id, PropertySet.getFirstClassProperties()); - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return TaskSchema.Instance; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets a value indicating whether a time zone SOAP header should be - * emitted in a CreateItem or UpdateItem request so this item can be - * property saved or updated. - * - * @param isUpdateOperation the is update operation - * @return if a time zone SOAP header should be emitted; otherwise, . - */ - @Override public boolean getIsTimeZoneHeaderRequired(boolean isUpdateOperation) { - return true; - } - - /** - * Deletes the current occurrence of a recurring task. After the current - * occurrence isdeleted, the task represents the next occurrence. Developers - * should call Load to retrieve the new property values of the task. Calling - * this method results in a call to EWS. - * - * @param deleteMode the delete mode - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - public void deleteCurrentOccurrence(DeleteMode deleteMode) - throws ServiceLocalException, Exception { - this.internalDelete(deleteMode, null, - AffectedTaskOccurrence.SpecifiedOccurrenceOnly); - } - - /** - * Applies the local changes that have been made to this task. Calling - * this method results in at least one call to EWS. Mutliple calls to EWS - * might be made if attachments have been added or removed. - * - * @param conflictResolutionMode the conflict resolution mode - * @return A Task object representing the completed occurrence if the task - * is recurring and the update marks it as completed; or a Task - * object representing the current occurrence if the task is - * recurring and the uypdate changed its recurrence pattern; or null - * in every other case. - * @throws ServiceResponseException the service response exception - * @throws Exception the exception - */ - public Task updateTask(ConflictResolutionMode conflictResolutionMode) - throws ServiceResponseException, Exception { - return (Task) this.internalUpdate(null /* parentFolder */, - conflictResolutionMode, MessageDisposition.SaveOnly, null); - } - - // Properties - - /** - * Gets the actual amount of time that is spent on the task. - * - * @return the actual work - * @throws ServiceLocalException the service local exception - */ - public Integer getActualWork() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.ActualWork); - } - - /** - * Sets the checks if is read. - * - * @param value the new checks if is read - * @throws Exception the exception - */ - public void setActualWork(Integer value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - TaskSchema.ActualWork, value); - } - - /** - * Gets the date and time the task was assigned. - * - * @return the assigned time - * @throws ServiceLocalException the service local exception - */ - public Date getAssignedTime() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.AssignedTime); - } - - /** - * Gets the billing information of the task. - * - * @return the billing information - * @throws ServiceLocalException the service local exception - */ - public String getBillingInformation() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.BillingInformation); - } - - /** - * Sets the billing information. - * - * @param value the new billing information - * @throws Exception the exception - */ - public void setBillingInformation(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - TaskSchema.BillingInformation, value); - } - - /** - * Gets the number of times the task has changed since it was created. - * - * @return the change count - * @throws ServiceLocalException the service local exception - */ - public Integer getChangeCount() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.ChangeCount); - } - - /** - * Gets a list of companies associated with the task. - * - * @return the companies - * @throws ServiceLocalException the service local exception - */ - public StringList getCompanies() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.Companies); - } - - /** - * Sets the companies. - * - * @param value the new companies - * @throws Exception the exception - */ - public void setCompanies(StringList value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - TaskSchema.Companies, value); - } - - /** - * Gets the date and time on which the task was completed. - * - * @return the complete date - * @throws ServiceLocalException the service local exception - */ - public Date getCompleteDate() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.CompleteDate); - } - - /** - * Sets the complete date. - * - * @param value the new complete date - * @throws Exception the exception - */ - public void setCompleteDate(Date value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - TaskSchema.CompleteDate, value); - } - - /** - * Gets a list of contacts associated with the task. - * - * @return the contacts - * @throws ServiceLocalException the service local exception - */ - public StringList getContacts() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.Contacts); - } - - /** - * Sets the contacts. - * - * @param value the new contacts - * @throws Exception the exception - */ - public void setContacts(StringList value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - TaskSchema.Contacts, value); - } - - /** - * Gets the current delegation state of the task. - * - * @return the delegation state - * @throws ServiceLocalException the service local exception - */ - public TaskDelegationState getDelegationState() - throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.DelegationState); - } - - /** - * Gets the name of the delegator of this task. - * - * @return the delegator - * @throws ServiceLocalException the service local exception - */ - public String getDelegator() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.Delegator); - } - - /** - * Gets a list of contacts associated with the task. - * - * @return the due date - * @throws ServiceLocalException the service local exception - */ - public Date getDueDate() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.DueDate); - } - - /** - * Sets the due date. - * - * @param value the new due date - * @throws Exception the exception - */ - public void setDueDate(Date value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - TaskSchema.DueDate, value); - } - - /** - * Gets a value indicating the mode of the task. - * - * @return the mode - * @throws ServiceLocalException the service local exception - */ - public TaskMode getMode() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(TaskSchema.Mode); - } - - /** - * Gets a value indicating whether the task is complete. - * - * @return the checks if is complete - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsComplete() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.IsComplete); - } - - /** - * Gets a value indicating whether the task is recurring. - * - * @return the checks if is recurring - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsRecurring() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.IsRecurring); - } - - /** - * Gets a value indicating whether the task is a team task. - * - * @return the checks if is team task - * @throws ServiceLocalException the service local exception - */ - public Boolean getIsTeamTask() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.IsTeamTask); - } - - /** - * Gets the mileage of the task. - * - * @return the mileage - * @throws ServiceLocalException the service local exception - */ - public String getMileage() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.Mileage); - } - - /** - * Sets the mileage. - * - * @param value the new mileage - * @throws Exception the exception - */ - public void setMileage(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - TaskSchema.Mileage, value); - } - - /** - * Gets the name of the owner of the task. - * - * @return the owner - * @throws ServiceLocalException the service local exception - */ - public String getOwner() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.Owner); - } - - /** - * Gets the completion percentage of the task. - * PercentComplete must be between - * 0 and 100. - * - * @return the percent complete - * @throws ServiceLocalException the service local exception - */ - public Double getPercentComplete() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.PercentComplete); - } - - /** - * Sets the completion percentage of the task. - * PercentComplete must be between - * 0.0 and 100.0 . - * - * @param value the new percent complete - * @throws Exception the exception - * @deprecated use Double parameter instead - */ - @Deprecated - public void setPercentComplete(String value) throws Exception { - setPercentComplete(Double.valueOf(value)); - } - - /** - * Sets the completion percentage of the task. - * PercentComplete must be between - * 0.0 and 100.0 . - * - * @param value the new percent complete - * @throws Exception the exception - */ - public void setPercentComplete(Double value) throws Exception { - if (value == null || Double.isNaN(value) || value < PERCENT_MIN || value > PERCENT_MAX) { - throw new IllegalArgumentException( - String.format("%s must be between %f and %f", - String.valueOf(value), PERCENT_MIN, PERCENT_MAX)); - } - this.getPropertyBag().setObjectFromPropertyDefinition( - TaskSchema.PercentComplete, value); - } - - /** - * Gets the recurrence pattern for this task. Available recurrence - * pattern classes include Recurrence.DailyPattern, - * Recurrence.MonthlyPattern and Recurrence.YearlyPattern. - * - * @return the recurrence - * @throws ServiceLocalException the service local exception - */ - public Recurrence getRecurrence() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.Recurrence); - } - - /** - * Sets the recurrence. - * - * @param value the new recurrence - * @throws Exception the exception - */ - public void setRecurrence(Recurrence value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - TaskSchema.Recurrence, value); - } - - /** - * Gets the date and time on which the task starts. - * - * @return the start date - * @throws ServiceLocalException the service local exception - */ - public Date getStartDate() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.StartDate); - } - - /** - * Sets the start date. - * - * @param value the new start date - * @throws Exception the exception - */ - public void setStartDate(Date value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - TaskSchema.StartDate, value); - } - - /** - * Gets the status of the task. - * - * @return the status - * @throws ServiceLocalException the service local exception - */ - public TaskStatus getStatus() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition(TaskSchema.Status); - } - - /** - * Sets the status. - * - * @param value the new status - * @throws Exception the exception - */ - public void setStatus(TaskStatus value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - TaskSchema.Status, value); - } - - /** - * Gets a string representing the status of the task, localized according to - * the PreferredCulture property of the ExchangeService object the task is - * bound to. - * - * @return the status description - * @throws ServiceLocalException the service local exception - */ - public String getStatusDescription() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.StatusDescription); - } - - /** - * Gets the total amount of work spent on the task. - * - * @return the total work - * @throws ServiceLocalException the service local exception - */ - public Integer getTotalWork() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - TaskSchema.TotalWork); - } - - /** - * Sets the total work. - * - * @param value the new total work - * @throws Exception the exception - */ - public void setTotalWork(Integer value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - TaskSchema.TotalWork, value); - } - - /** - * Gets the default setting for how to treat affected task occurrences on - * Delete. AffectedTaskOccurrence.AllOccurrences: All affected Task - * occurrences will be deleted. - * - * @return the default affected task occurrences - */ - @Override - protected AffectedTaskOccurrence getDefaultAffectedTaskOccurrences() { - return AffectedTaskOccurrence.AllOccurrences; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/response/AcceptMeetingInvitationMessage.java b/src/main/java/microsoft/exchange/webservices/data/core/service/response/AcceptMeetingInvitationMessage.java deleted file mode 100644 index bb110e63d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/response/AcceptMeetingInvitationMessage.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.response; - -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.item.MeetingResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Represents a meeting acceptance message. - */ -public final class AcceptMeetingInvitationMessage extends - CalendarResponseMessage { - - /** - * The tentative. - */ - private boolean tentative; - - /** - * Initializes a new instance of the AcceptMeetingInvitationMessage class. - * - * @param referenceItem the reference item - * @param tentative the tentative - * @throws Exception the exception - */ - public AcceptMeetingInvitationMessage(Item referenceItem, boolean tentative) throws Exception { - super(referenceItem); - this.tentative = tentative; - } - - /** - * This methods lets subclasses of ServiceObject override the default - * mechanism by which the XML element name associated with their type is - * retrieved. - * - * @return The XML element name associated with this type. If this method - * returns null or empty, the XML element name associated with this - * type is determined by the EwsObjectDefinition attribute that - * decorates the type, if present. - *

- * Item and folder classes that can be returned by EWS MUST rely on - * the EwsObjectDefinition attribute for XML element name determination. - *

- */ - @Override public String getXmlElementName() { - // getXmlElementOverride is pvt and getXmlElementName returns - // getXmlElementOverride - if (this.tentative) { - return XmlElementNames.TentativelyAcceptItem; - } else { - return XmlElementNames.AcceptItem; - } - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the tentative. - * - * @return Gets a value indicating whether the associated meeting is - * tentatively accepted. - */ - public boolean getTentative() { - return this.tentative; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/response/CalendarResponseMessage.java b/src/main/java/microsoft/exchange/webservices/data/core/service/response/CalendarResponseMessage.java deleted file mode 100644 index 0645b2a0d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/response/CalendarResponseMessage.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.response; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.service.item.EmailMessage; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.schema.CalendarResponseObjectSchema; -import microsoft.exchange.webservices.data.core.service.schema.EmailMessageSchema; -import microsoft.exchange.webservices.data.core.service.schema.ItemSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.property.Sensitivity; -import microsoft.exchange.webservices.data.property.complex.AttachmentCollection; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; -import microsoft.exchange.webservices.data.property.complex.EmailAddressCollection; -import microsoft.exchange.webservices.data.property.complex.InternetMessageHeaderCollection; -import microsoft.exchange.webservices.data.property.complex.MessageBody; - -/** - * Represents the base class for accept, tentatively accept and decline response - * messages. - * - * @param The type of message that is created when this response message is - * saved. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class CalendarResponseMessage - extends CalendarResponseMessageBase { - - /** - * Initializes a new instance of the CalendarResponseMessage class. - * - * @param referenceItem The reference item - * @throws Exception the exception - */ - protected CalendarResponseMessage(Item referenceItem) throws Exception { - super(referenceItem); - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return CalendarResponseObjectSchema.Instance; - } - - /** - * Gets the body of the response. - * - * @return the body - * @throws Exception the exception - */ - public MessageBody getBody() throws Exception { - return (MessageBody) this - .getObjectFromPropertyDefinition(ItemSchema.Body); - } - - /** - * Sets the body. - * - * @param value the new body - * @throws Exception the exception - */ - public void setBody(MessageBody value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition(ItemSchema.Body, - value); - } - - /** - * Gets a list of recipients the response will be sent to. - * - * @return the to recipients - * @throws Exception the exception - */ - public EmailAddressCollection getToRecipients() throws Exception { - return (EmailAddressCollection) this - .getObjectFromPropertyDefinition( - EmailMessageSchema.ToRecipients); - } - - /** - * Gets a list of recipients the response will be sent to as Cc. - * - * @return the cc recipients - * @throws Exception the exception - */ - public EmailAddressCollection getCcRecipients() throws Exception { - return (EmailAddressCollection) this - .getObjectFromPropertyDefinition( - EmailMessageSchema.CcRecipients); - } - - /** - * Gets a list of recipients this response will be sent to as Bcc. - * - * @return the bcc recipients - * @throws Exception the exception - */ - public EmailAddressCollection getBccRecipients() throws Exception { - return (EmailAddressCollection) this - .getObjectFromPropertyDefinition( - EmailMessageSchema.BccRecipients); - } - - /** - * Gets the item class. - * - * @return the item class - * @throws Exception the exception - */ - protected String getItemClass() throws Exception { - return (String) this - .getObjectFromPropertyDefinition(ItemSchema.ItemClass); - } - - /** - * Sets the item class. - * - * @param value the new item class - * @throws Exception the exception - */ - protected void setItemClass(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.ItemClass, value); - } - - /** - * Gets the sensitivity of this response. - * - * @return the sensitivity - * @throws Exception the exception - */ - public Sensitivity getSensitivity() throws Exception { - return (Sensitivity) this - .getObjectFromPropertyDefinition(ItemSchema.Sensitivity); - } - - /** - * Sets the sensitivity. - * - * @param value the new sensitivity - * @throws Exception the exception - */ - public void setSensitivity(Sensitivity value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ItemSchema.Sensitivity, value); - } - - /** - * Gets a list of attachments to this response. - * - * @return the attachments - * @throws Exception the exception - */ - public AttachmentCollection getAttachments() throws Exception { - return (AttachmentCollection) this - .getObjectFromPropertyDefinition(ItemSchema.Attachments); - } - - /** - * Gets the internet message headers. - * - * @return the internet message headers - * @throws Exception the exception - */ - protected InternetMessageHeaderCollection getInternetMessageHeaders() - throws Exception { - return (InternetMessageHeaderCollection) this - .getObjectFromPropertyDefinition( - ItemSchema.InternetMessageHeaders); - } - - /** - * Gets the sender of this response. - * - * @return the sender - * @throws Exception the exception - */ - public EmailAddress getSender() throws Exception { - return (EmailAddress) this - .getObjectFromPropertyDefinition(EmailMessageSchema.Sender); - } - - /** - * Sets the sender. - * - * @param value the new sender - * @throws Exception the exception - */ - public void setSender(EmailAddress value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.Sender, value); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/response/CalendarResponseMessageBase.java b/src/main/java/microsoft/exchange/webservices/data/core/service/response/CalendarResponseMessageBase.java deleted file mode 100644 index 7b33c9639..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/response/CalendarResponseMessageBase.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.response; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.service.item.EmailMessage; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.misc.CalendarActionResults; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -/** - * Represents the base class for all calendar-related response messages. - * - * @param The type of message that is created when this response message is - * saved. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class CalendarResponseMessageBase - extends ResponseObject { - - /** - * Initializes a new instance of the CalendarResponseMessageBase class. - * - * @param referenceItem the reference item - * @throws Exception the exception - */ - CalendarResponseMessageBase(Item referenceItem) throws Exception { - super(referenceItem); - } - - /** - * Saves the response in the specified folder. Calling this method results - * in a call to EWS. - * - * @param destinationFolderId The Id of the folder in which to save the response. - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - - public CalendarActionResults calendarSave(FolderId destinationFolderId) - throws Exception { - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - - return new CalendarActionResults(this.internalCreate( - destinationFolderId, MessageDisposition.SaveOnly)); - } - - /** - * Saves the response in the specified folder. Calling this method results - * in a call to EWS. - * - * @param destinationFolderName The name of the folder in which to save the response. - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - public CalendarActionResults calendarSave( - WellKnownFolderName destinationFolderName) throws Exception { - return new CalendarActionResults(this.internalCreate(new FolderId( - destinationFolderName), MessageDisposition.SaveOnly)); - } - - /** - * Saves the response in the Drafts folder. Calling this method results in a - * call to EWS. - * - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - public CalendarActionResults calendarSave() throws Exception { - return new CalendarActionResults(this.internalCreate(null, - MessageDisposition.SaveOnly)); - } - - /** - * Sends this response without saving a copy. Calling this method results in - * a call to EWS. - * - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - public CalendarActionResults calendarSend() throws Exception { - return new CalendarActionResults(this.internalCreate(null, - MessageDisposition.SendOnly)); - } - - /** - * Sends this response ans saves a copy in the specified folder. Calling - * this method results in a call to EWS. - * - * @param destinationFolderId The Id of the folder in which to save the copy of the message. - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - - public CalendarActionResults calendarSendAndSaveCopy( - FolderId destinationFolderId) throws Exception { - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - return new CalendarActionResults(this.internalCreate( - destinationFolderId, MessageDisposition.SendAndSaveCopy)); - } - - /** - * Sends this response ans saves a copy in the specified folder. Calling - * this method results in a call to EWS. - * - * @param destinationFolderName the destination folder name - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - public CalendarActionResults calendarSendAndSaveCopy( - WellKnownFolderName destinationFolderName) throws Exception { - return new CalendarActionResults(this.internalCreate(new FolderId( - destinationFolderName), MessageDisposition.SendAndSaveCopy)); - } - - /** - * Sends this response ans saves a copy in the specified folder. Calling - * this method results in a call to EWS. - * - * @return A CalendarActionResults object containing the various item that - * were created or modified as a results of this operation. - * @throws Exception the exception - */ - public CalendarActionResults calendarSendAndSaveCopy() throws Exception { - return new CalendarActionResults(this.internalCreate(null, - MessageDisposition.SendAndSaveCopy)); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/response/CancelMeetingMessage.java b/src/main/java/microsoft/exchange/webservices/data/core/service/response/CancelMeetingMessage.java deleted file mode 100644 index 9c66ee19b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/response/CancelMeetingMessage.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.response; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.item.MeetingCancellation; -import microsoft.exchange.webservices.data.core.service.schema.CancelMeetingMessageSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.MessageBody; - -/** - * Represents a meeting cancellation message. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.CancelCalendarItem, returnedByServer = false) -public final class CancelMeetingMessage extends - CalendarResponseMessageBase { - - /** - * Initializes a new instance of the class. - * - * @param referenceItem the reference item - * @throws Exception the exception - */ - public CancelMeetingMessage(Item referenceItem) throws Exception { - super(referenceItem); - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ServiceObjectSchema getSchema() { - return CancelMeetingMessageSchema.Instance; - } - - /** - * Gets the body of the response. - * - * @return the body - * @throws ServiceLocalException the service local exception - */ - public MessageBody getBody() throws ServiceLocalException { - return getPropertyBag().getObjectFromPropertyDefinition( - CancelMeetingMessageSchema.Body); - } - - /** - * Sets the body. - * - * @param value the new body - * @throws Exception the exception - */ - public void setBody(MessageBody value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - CancelMeetingMessageSchema.Body, value); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/response/DeclineMeetingInvitationMessage.java b/src/main/java/microsoft/exchange/webservices/data/core/service/response/DeclineMeetingInvitationMessage.java deleted file mode 100644 index 3d187bbf1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/response/DeclineMeetingInvitationMessage.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.response; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.item.MeetingResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; - -/** - * Represents a meeting declination message. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.DeclineItem, returnedByServer = false) -public final class DeclineMeetingInvitationMessage extends - CalendarResponseMessage { - - /** - * Initializes a new instance of the DeclineMeetingInvitationMessage class. - * - * @param referenceItem the reference item - * @throws Exception the exception - */ - public DeclineMeetingInvitationMessage(Item referenceItem) - throws Exception { - super(referenceItem); - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/response/PostReply.java b/src/main/java/microsoft/exchange/webservices/data/core/service/response/PostReply.java deleted file mode 100644 index 38685e8ef..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/response/PostReply.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.response; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.item.PostItem; -import microsoft.exchange.webservices.data.core.service.schema.EmailMessageSchema; -import microsoft.exchange.webservices.data.core.service.schema.ItemSchema; -import microsoft.exchange.webservices.data.core.service.schema.PostReplySchema; -import microsoft.exchange.webservices.data.core.service.schema.ResponseObjectSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition; -import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.core.exception.misc.InvalidOperationException; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.MessageBody; - -import java.util.List; - -/** - * Represents a reply to a post item. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.PostReplyItem, returnedByServer = false) -public final class PostReply extends ServiceObject { - - /** - * The reference item. - */ - private Item referenceItem; - - /** - * Initializes a new instance of the class. - * - * @param referenceItem the reference item - * @throws Exception the exception - */ - public PostReply(Item referenceItem) throws Exception { - super(referenceItem.getService()); - referenceItem.throwIfThisIsNew(); - - this.referenceItem = referenceItem; - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override - public ServiceObjectSchema getSchema() { - return PostReplySchema.Instance; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Create a PostItem response. - * - * @param parentFolderId the parent folder id - * @param messageDisposition the message disposition - * @return Created PostItem. - * @throws Exception the exception - */ - protected PostItem internalCreate(FolderId parentFolderId, - MessageDisposition messageDisposition) throws Exception { - ((ItemId) this - .getObjectFromPropertyDefinition( - ResponseObjectSchema.ReferenceItemId)) - .assign(this.referenceItem.getId()); - - List items = this.getService().internalCreateResponseObject(this, - parentFolderId, messageDisposition); - - PostItem postItem = EwsUtilities.findFirstItemOfType(PostItem.class, - items); - - // This should never happen. If it does, we have a bug. - EwsUtilities - .ewsAssert(postItem != null, "PostReply.InternalCreate", - "postItem is null. The CreateItem call did" + " not return the expected PostItem."); - - return postItem; - } - - /** - * Loads the specified set of property on the object. - * - * @param propertySet the property set - * @throws InvalidOperationException the invalid operation exception - */ - @Override - protected void internalLoad(PropertySet propertySet) - throws InvalidOperationException { - throw new InvalidOperationException("Loading this type of object is not supported."); - } - - /** - * Deletes the object. - * - * @param deleteMode the delete mode - * @param sendCancellationsMode the send cancellations mode - * @param affectedTaskOccurrences the affected task occurrences - * @throws InvalidOperationException the invalid operation exception - */ - @Override - protected void internalDelete(DeleteMode deleteMode, - SendCancellationsMode sendCancellationsMode, - AffectedTaskOccurrence affectedTaskOccurrences) - throws InvalidOperationException { - throw new InvalidOperationException("Deleting this type of object isn't authorized."); - } - - /** - * Saves the post reply in the same folder as the original post item. - * Calling this method results in a call to EWS. - * - * @return A PostItem representing the posted reply - * @throws Exception the exception - */ - public PostItem save() throws Exception { - return this.internalCreate(null, null); - } - - /** - * Saves the post reply in the same folder as the original post item. - * Calling this method results in a call to EWS. - * - * @param destinationFolderId the destination folder id - * @return A PostItem representing the posted reply - * @throws Exception the exception - */ - public PostItem save(FolderId destinationFolderId) throws Exception { - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - return this.internalCreate(destinationFolderId, null); - } - - /** - * Saves the post reply in a specified folder. Calling this method results - * in a call to EWS. - * - * @param destinationFolderName the destination folder name - * @return A PostItem representing the posted reply. - * @throws Exception the exception - */ - public PostItem save(WellKnownFolderName destinationFolderName) - throws Exception { - return this.internalCreate(new FolderId(destinationFolderName), null); - } - - /** - * Gets the subject of the post reply. - * - * @return the subject - * @throws Exception the exception - */ - public String getSubject() throws Exception { - return (String) this - .getObjectFromPropertyDefinition(EmailMessageSchema.Subject); - } - - /** - * Sets the subject. - * - * @param value the new subject - * @throws Exception the exception - */ - public void setSubject(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.Subject, value); - } - - /** - * Gets the body of the post reply. - * - * @return the body - * @throws Exception the exception - */ - public MessageBody getBody() throws Exception { - return (MessageBody) this - .getObjectFromPropertyDefinition(ItemSchema.Body); - } - - /** - * Sets the body. - * - * @param value the new body - * @throws Exception the exception - */ - public void setBody(MessageBody value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition(ItemSchema.Body, - value); - } - - /** - * Gets the body prefix that should be prepended to the original - * post item's body. - * - * @return the body prefix - * @throws Exception the exception - */ - public MessageBody getBodyPrefix() throws Exception { - return (MessageBody) this - .getObjectFromPropertyDefinition( - ResponseObjectSchema.BodyPrefix); - } - - /** - * Sets the body prefix. - * - * @param value the new body prefix - * @throws Exception the exception - */ - public void setBodyPrefix(MessageBody value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ResponseObjectSchema.BodyPrefix, value); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/response/RemoveFromCalendar.java b/src/main/java/microsoft/exchange/webservices/data/core/service/response/RemoveFromCalendar.java deleted file mode 100644 index a6c2ad011..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/response/RemoveFromCalendar.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.response; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.schema.ResponseObjectSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition; -import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ItemId; - -import java.util.List; - -/** - * Represents a response object created to remove a calendar item from a meeting - * cancellation. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.RemoveItem, returnedByServer = false) public class RemoveFromCalendar extends - ServiceObject { - - /** - * The reference item. - */ - private Item referenceItem; - - /** - * Initializes a new instance of the RemoveFromCalendar class. - * - * @param referenceItem The reference item - * @throws Exception the exception - */ - public RemoveFromCalendar(Item referenceItem) throws Exception { - super(referenceItem.getService()); - - referenceItem.throwIfThisIsNew(); - - this.referenceItem = referenceItem; - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return ResponseObjectSchema.Instance; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Loads the specified set of property on the object. - * - * @param propertySet The property to load. - */ - @Override - protected void internalLoad(PropertySet propertySet) { - throw new UnsupportedOperationException(); - } - - /** - * Deletes the object. - * - * @param deleteMode The deletion mode. - * @param sendCancellationsMode Indicates whether meeting cancellation messages should be - * sent. - * @param affectedTaskOccurrences Indicate which occurrence of a recurring task should be - * deleted. - */ - @Override - protected void internalDelete(DeleteMode deleteMode, - SendCancellationsMode sendCancellationsMode, - AffectedTaskOccurrence affectedTaskOccurrences) { - throw new UnsupportedOperationException(); - } - - /** - * Create response object. - * - * @param parentFolderId The parent folder id. - * @param messageDisposition The message disposition. - * @return A list of item that were created or modified as a results of - * this operation. - * @throws Exception the exception - */ - public List internalCreate(FolderId parentFolderId, MessageDisposition messageDisposition) throws Exception { - ((ItemId) this.getPropertyBag().getObjectFromPropertyDefinition( - ResponseObjectSchema.ReferenceItemId)) - .assign(this.referenceItem.getId()); - - return this.getService().internalCreateResponseObject(this, - parentFolderId, messageDisposition); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/response/ResponseMessage.java b/src/main/java/microsoft/exchange/webservices/data/core/service/response/ResponseMessage.java deleted file mode 100644 index 8245f28c2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/response/ResponseMessage.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.response; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.item.EmailMessage; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.schema.EmailMessageSchema; -import microsoft.exchange.webservices.data.core.service.schema.ItemSchema; -import microsoft.exchange.webservices.data.core.service.schema.ResponseMessageSchema; -import microsoft.exchange.webservices.data.core.service.schema.ResponseObjectSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.ResponseMessageType; -import microsoft.exchange.webservices.data.property.complex.EmailAddressCollection; -import microsoft.exchange.webservices.data.property.complex.MessageBody; - -/** - * The Class ResponseMessage. - */ -public final class ResponseMessage extends ResponseObject { - - /** - * Represents the base class for e-mail related response (Reply, Reply all - * and Forward). - */ - private ResponseMessageType responseType; - - /** - * Initializes a new instance of the class. - * - * @param referenceItem the reference item - * @param responseType the response type - * @throws Exception the exception - */ - public ResponseMessage(Item referenceItem, ResponseMessageType responseType) - throws Exception { - super(referenceItem); - this.responseType = responseType; - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return ResponseMessageSchema.Instance; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * This methods lets subclasses of ServiceObject override the default - * mechanism by which the XML element name associated with their type is - * retrieved. - * - * @return The XML element name associated with this type. If this method - * returns null or empty, the XML element name associated with this - * type is determined by the EwsObjectDefinition attribute that - * decorates the type,if present. - */ - protected String getXmlElementNameOverride() { - - if (this.responseType == ResponseMessageType.Reply) { - return XmlElementNames.ReplyToItem; - } else if (this.responseType == ResponseMessageType.ReplyAll) { - return XmlElementNames.ReplyAllToItem; - } else if (this.responseType == ResponseMessageType.Forward) { - return XmlElementNames.ForwardItem; - } else { - EwsUtilities.ewsAssert(false, "ResponseMessage.GetXmlElementNameOverride", - "An unexpected value for responseType could not be handled."); - return null; // Because the compiler wants it - } - - } - - /** - * Gets a value indicating the type of response this object represents. - * - * @return the response type - */ - public ResponseMessageType getResponseType() { - return this.responseType; - } - - /** - * Gets the body of the response. - * - * @return the body - * @throws Exception the exception - */ - public MessageBody getBody() throws Exception { - return (MessageBody) this - .getObjectFromPropertyDefinition(ItemSchema.Body); - } - - /** - * Sets the body. - * - * @param value the new body - * @throws Exception the exception - */ - public void setBody(MessageBody value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition(ItemSchema.Body, - value); - } - - /** - * Gets a list of recipients the response will be sent to. - * - * @return the to recipients - * @throws Exception the exception - */ - public EmailAddressCollection getToRecipients() throws Exception { - return (EmailAddressCollection) this - .getObjectFromPropertyDefinition( - EmailMessageSchema.ToRecipients); - } - - /** - * Gets a list of recipients the response will be sent to as Cc. - * - * @return the cc recipients - * @throws Exception the exception - */ - public EmailAddressCollection getCcRecipients() throws Exception { - return (EmailAddressCollection) this - .getObjectFromPropertyDefinition( - EmailMessageSchema.CcRecipients); - } - - /** - * Gets a list of recipients the response will be sent to as Cc. - * - * @return the bcc recipients - * @throws Exception the exception - */ - public EmailAddressCollection getBccRecipients() throws Exception { - return (EmailAddressCollection) this - .getObjectFromPropertyDefinition( - EmailMessageSchema.BccRecipients); - } - - /** - * Gets the subject of this response. - * - * @return the subject - * @throws Exception the exception - */ - public String getSubject() throws Exception { - return (String) this - .getObjectFromPropertyDefinition(EmailMessageSchema.Subject); - } - - /** - * Sets the subject. - * - * @param value the new subject - * @throws Exception the exception - */ - public void setSubject(String value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - EmailMessageSchema.Subject, value); - } - - /** - * Gets the body prefix of this response. The body prefix will be - * prepended to the original message's body when the response is created. - * - * @return the body prefix - * @throws Exception the exception - */ - public MessageBody getBodyPrefix() throws Exception { - return (MessageBody) this - .getObjectFromPropertyDefinition( - ResponseObjectSchema.BodyPrefix); - } - - /** - * Sets the body prefix. - * - * @param value the new body prefix - * @throws Exception the exception - */ - public void setBodyPrefix(MessageBody value) throws Exception { - this.getPropertyBag().setObjectFromPropertyDefinition( - ResponseObjectSchema.BodyPrefix, value); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/response/ResponseObject.java b/src/main/java/microsoft/exchange/webservices/data/core/service/response/ResponseObject.java deleted file mode 100644 index 7d6aceffc..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/response/ResponseObject.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.response; - -/** - * Represents the base class for all response that can be sent. - * - */ -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.EmailMessage; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.schema.ResponseObjectSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition; -import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ItemId; - -import java.util.List; - -/** - * The Class ResponseObject. - * - * @param the generic type - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class ResponseObject extends ServiceObject { - - /** - * The reference item. - */ - private Item referenceItem; - - /** - * Initializes a new instance of the class. - * - * @param referenceItem the reference item - * @throws Exception the exception - */ - protected ResponseObject(Item referenceItem) throws Exception { - super(referenceItem.getService()); - referenceItem.throwIfThisIsNew(); - this.referenceItem = referenceItem; - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return ResponseObjectSchema.Instance; - } - - /** - * Loads the specified set of property on the object. - * - * @param propertySet the property set - */ - @Override - protected void internalLoad(PropertySet propertySet) { - throw new UnsupportedOperationException(); - } - - /** - * Deletes the object. - * - * @param deleteMode the delete mode - * @param sendCancellationsMode the send cancellations mode - * @param affectedTaskOccurrences the affected task occurrences - */ - @Override - protected void internalDelete(DeleteMode deleteMode, - SendCancellationsMode sendCancellationsMode, - AffectedTaskOccurrence affectedTaskOccurrences) { - throw new UnsupportedOperationException(); - } - - /** - * Create the response object. - * - * @param destinationFolderId the destination folder id - * @param messageDisposition the message disposition - * @return The list of item returned by EWS. - * @throws Exception the exception - */ - protected List internalCreate(FolderId destinationFolderId, - MessageDisposition messageDisposition) throws Exception { - ((ItemId) this.getPropertyBag().getObjectFromPropertyDefinition( - ResponseObjectSchema.ReferenceItemId)) - .assign(this.referenceItem.getId()); - return this.getService().internalCreateResponseObject(this, - destinationFolderId, messageDisposition); - } - - /** - * Saves the response in the specified folder. Calling this method results - * in a call to EWS. - * - * @param destinationFolderId the destination folder id - * @return A TMessage that represents the response. - * @throws Exception the exception - */ - public TMessage save(FolderId destinationFolderId) throws Exception { - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - return (TMessage) this.internalCreate(destinationFolderId, - MessageDisposition.SaveOnly).get(0); - } - - /** - * Saves the response in the specified folder. Calling this method results - * in a call to EWS. - * - * @param destinationFolderName the destination folder name - * @return A TMessage that represents the response. - * @throws Exception the exception - */ - public TMessage save(WellKnownFolderName destinationFolderName) - throws Exception { - return (TMessage) this.internalCreate( - new FolderId(destinationFolderName), - MessageDisposition.SaveOnly).get(0); - } - - /** - * Saves the response in the Drafts folder. Calling this method results in a - * call to EWS. - * - * @return A TMessage that represents the response. - * @throws Exception the exception - */ - public TMessage save() throws Exception { - return (TMessage) this - .internalCreate(null, MessageDisposition.SaveOnly).get(0); - } - - /** - * Sends this response without saving a copy. Calling this method results in - * a call to EWS. - * - * @throws Exception the exception - */ - public void send() throws Exception { - this.internalCreate(null, MessageDisposition.SendOnly); - } - - /** - * Sends this response and saves a copy in the specified folder. Calling - * this method results in a call to EWS. - * - * @param destinationFolderId the destination folder id - * @throws Exception the exception - */ - public void sendAndSaveCopy(FolderId destinationFolderId) throws Exception { - EwsUtilities.validateParam(destinationFolderId, "destinationFolderId"); - this.internalCreate(destinationFolderId, - MessageDisposition.SendAndSaveCopy); - } - - /** - * Sends this response and saves a copy in the specified folder. Calling - * this method results in a call to EWS. - * - * @param destinationFolderName the destination folder name - * @throws Exception the exception - */ - public void sendAndSaveCopy(WellKnownFolderName destinationFolderName) - throws Exception { - this.internalCreate(new FolderId(destinationFolderName), - MessageDisposition.SendAndSaveCopy); - } - - /** - * Sends this response and saves a copy in the Sent Items folder. Calling - * this method results in a call to EWS. - * - * @throws Exception the exception - */ - public void sendAndSaveCopy() throws Exception { - this.internalCreate(null, MessageDisposition.SendAndSaveCopy); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/response/SuppressReadReceipt.java b/src/main/java/microsoft/exchange/webservices/data/core/service/response/SuppressReadReceipt.java deleted file mode 100644 index 4431cabb3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/response/SuppressReadReceipt.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.response; - -import microsoft.exchange.webservices.data.attribute.ServiceObjectDefinition; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.schema.ResponseObjectSchema; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AffectedTaskOccurrence; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.MessageDisposition; -import microsoft.exchange.webservices.data.core.enumeration.service.SendCancellationsMode; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ItemId; - -/** - * Represents a response object created to supress read receipts for an item. - */ -@ServiceObjectDefinition(xmlElementName = XmlElementNames.SuppressReadReceipt, returnedByServer = false) -public final class SuppressReadReceipt extends ServiceObject { - - /** - * The reference item. - */ - private Item referenceItem; - - /** - * Initializes a new instance of the class. - * - * @param referenceItem the reference item - * @throws Exception the exception - */ - public SuppressReadReceipt(Item referenceItem) throws Exception { - super(referenceItem.getService()); - - referenceItem.throwIfThisIsNew(); - this.referenceItem = referenceItem; - } - - /** - * Internal method to return the schema associated with this type of object. - * - * @return The schema associated with this type of object. - */ - @Override public ServiceObjectSchema getSchema() { - return ResponseObjectSchema.Instance; - } - - /** - * Gets the minimum required server version. - * - * @return Earliest Exchange version in which this service object type is - * supported. - */ - @Override public ExchangeVersion getMinimumRequiredServerVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Loads the specified set of property on the object. - * - * @param propertySet the property set - */ - @Override - protected void internalLoad(PropertySet propertySet) { - throw new UnsupportedOperationException(); - } - - /** - * Deletes the object. - * - * @param deleteMode the delete mode - * @param sendCancellationsMode the send cancellations mode - * @param affectedTaskOccurrences the affected task occurrences - */ - @Override - protected void internalDelete(DeleteMode deleteMode, - SendCancellationsMode sendCancellationsMode, - AffectedTaskOccurrence affectedTaskOccurrences) { - throw new UnsupportedOperationException(); - } - - /** - * Create the response object. - * - * @param parentFolderId the parent folder id - * @param messageDisposition the message disposition - * @throws Exception the exception - */ - public void internalCreate(FolderId parentFolderId, MessageDisposition messageDisposition) throws Exception { - ((ItemId) this.getPropertyBag().getObjectFromPropertyDefinition( - ResponseObjectSchema.ReferenceItemId)) - .assign(this.referenceItem.getId()); - this.getService().internalCreateResponseObject(this, parentFolderId, - messageDisposition); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/AppointmentSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/AppointmentSchema.java deleted file mode 100644 index 36514a67c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/AppointmentSchema.java +++ /dev/null @@ -1,895 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.Schema; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.item.Appointment; -import microsoft.exchange.webservices.data.core.enumeration.service.calendar.AppointmentType; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.LegacyFreeBusyStatus; -import microsoft.exchange.webservices.data.core.enumeration.property.MeetingResponseType; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.AttendeeCollection; -import microsoft.exchange.webservices.data.property.complex.DeletedOccurrenceInfoCollection; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.complex.ItemCollection; -import microsoft.exchange.webservices.data.property.complex.OccurrenceInfo; -import microsoft.exchange.webservices.data.property.complex.OccurrenceInfoCollection; -import microsoft.exchange.webservices.data.property.definition.BoolPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ContainedPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.DateTimePropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.GenericPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.IntPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.MeetingTimeZonePropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.RecurrencePropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.StartTimeZonePropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.StringPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.TimeSpanPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.TimeZonePropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents the schema for appointment and meeting request. - */ -@Schema -public class AppointmentSchema extends ItemSchema { - - /** - * Field URIs for Appointment. - */ - private static interface FieldUris { - - /** - * The Start. - */ - String Start = "calendar:Start"; - - /** - * The End. - */ - String End = "calendar:End"; - - /** - * The Original start. - */ - String OriginalStart = "calendar:OriginalStart"; - - /** - * The Is all day event. - */ - String IsAllDayEvent = "calendar:IsAllDayEvent"; - - /** - * The Legacy free busy status. - */ - String LegacyFreeBusyStatus = "calendar:LegacyFreeBusyStatus"; - - /** - * The Location. - */ - String Location = "calendar:Location"; - - /** - * The When. - */ - String When = "calendar:When"; - - /** - * The Is meeting. - */ - String IsMeeting = "calendar:IsMeeting"; - - /** - * The Is cancelled. - */ - String IsCancelled = "calendar:IsCancelled"; - - /** - * The Is recurring. - */ - String IsRecurring = "calendar:IsRecurring"; - - /** - * The Meeting request was sent. - */ - String MeetingRequestWasSent = "calendar:MeetingRequestWasSent"; - - /** - * The Is response requested. - */ - String IsResponseRequested = "calendar:IsResponseRequested"; - - /** - * The Calendar item type. - */ - String CalendarItemType = "calendar:CalendarItemType"; - - /** - * The My response type. - */ - String MyResponseType = "calendar:MyResponseType"; - - /** - * The Organizer. - */ - String Organizer = "calendar:Organizer"; - - /** - * The Required attendees. - */ - String RequiredAttendees = "calendar:RequiredAttendees"; - - /** - * The Optional attendees. - */ - String OptionalAttendees = "calendar:OptionalAttendees"; - - /** - * The Resources. - */ - String Resources = "calendar:Resources"; - - /** - * The Conflicting meeting count. - */ - String ConflictingMeetingCount = "calendar:ConflictingMeetingCount"; - - /** - * The Adjacent meeting count. - */ - String AdjacentMeetingCount = "calendar:AdjacentMeetingCount"; - - /** - * The Conflicting meetings. - */ - String ConflictingMeetings = "calendar:ConflictingMeetings"; - - /** - * The Adjacent meetings. - */ - String AdjacentMeetings = "calendar:AdjacentMeetings"; - - /** - * The Duration. - */ - String Duration = "calendar:Duration"; - - /** - * The Time zone. - */ - String TimeZone = "calendar:TimeZone"; - - /** - * The Appointment reply time. - */ - String AppointmentReplyTime = "calendar:AppointmentReplyTime"; - - /** - * The Appointment sequence number. - */ - String AppointmentSequenceNumber = "calendar:AppointmentSequenceNumber"; - - /** - * The Appointment state. - */ - String AppointmentState = "calendar:AppointmentState"; - - /** - * The Recurrence. - */ - String Recurrence = "calendar:Recurrence"; - - /** - * The First occurrence. - */ - String FirstOccurrence = "calendar:FirstOccurrence"; - - /** - * The Last occurrence. - */ - String LastOccurrence = "calendar:LastOccurrence"; - - /** - * The Modified occurrences. - */ - String ModifiedOccurrences = "calendar:ModifiedOccurrences"; - - /** - * The Deleted occurrences. - */ - String DeletedOccurrences = "calendar:DeletedOccurrences"; - - /** - * The Meeting time zone. - */ - String MeetingTimeZone = "calendar:MeetingTimeZone"; - - /** - * The Start time zone. - */ - String StartTimeZone = "calendar:StartTimeZone"; - - /** - * The End time zone. - */ - String EndTimeZone = "calendar:EndTimeZone"; - - /** - * The Conference type. - */ - String ConferenceType = "calendar:ConferenceType"; - - /** - * The Allow new time proposal. - */ - String AllowNewTimeProposal = "calendar:AllowNewTimeProposal"; - - /** - * The Is online meeting. - */ - String IsOnlineMeeting = "calendar:IsOnlineMeeting"; - - /** - * The Meeting workspace url. - */ - String MeetingWorkspaceUrl = "calendar:MeetingWorkspaceUrl"; - - /** - * The Net show url. - */ - String NetShowUrl = "calendar:NetShowUrl"; - - /** - * The Uid. - */ - String Uid = "calendar:UID"; - - /** - * The Recurrence id. - */ - String RecurrenceId = "calendar:RecurrenceId"; - - /** - * The Date time stamp. - */ - String DateTimeStamp = "calendar:DateTimeStamp"; - } - - // Defines the StartTimeZone property. - /** - * The Constant StartTimeZone. - */ - public static final PropertyDefinition StartTimeZone = - new StartTimeZonePropertyDefinition( - XmlElementNames.StartTimeZone, FieldUris.StartTimeZone, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the EndTimeZone property. - /** - * The Constant EndTimeZone. - */ - public static final PropertyDefinition EndTimeZone = - new TimeZonePropertyDefinition( - XmlElementNames.EndTimeZone, FieldUris.EndTimeZone, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010); - - // Defines the Start property. - /** - * The Constant Start. - */ - public static final PropertyDefinition Start = - new DateTimePropertyDefinition( - XmlElementNames.Start, FieldUris.Start, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the End property. - /** - * The Constant End. - */ - public static final PropertyDefinition End = new DateTimePropertyDefinition( - XmlElementNames.End, FieldUris.End, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the OriginalStart property. - /** - * The Constant OriginalStart. - */ - public static final PropertyDefinition OriginalStart = - new DateTimePropertyDefinition( - XmlElementNames.OriginalStart, FieldUris.OriginalStart, - ExchangeVersion.Exchange2007_SP1); - - // Defines the IsAllDayEvent property. - /** - * The Constant IsAllDayEvent. - */ - public static final PropertyDefinition IsAllDayEvent = - new BoolPropertyDefinition( - XmlElementNames.IsAllDayEvent, FieldUris.IsAllDayEvent, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the LegacyFreeBusyStatus property. - /** - * The Constant LegacyFreeBusyStatus. - */ - public static final PropertyDefinition LegacyFreeBusyStatus = - new GenericPropertyDefinition( - LegacyFreeBusyStatus.class, - XmlElementNames.LegacyFreeBusyStatus, - FieldUris.LegacyFreeBusyStatus, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the Location property. - /** - * The Constant Location. - */ - public static final PropertyDefinition Location = - new StringPropertyDefinition( - XmlElementNames.Location, FieldUris.Location, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the When property. - /** - * The Constant When. - */ - public static final PropertyDefinition When = new StringPropertyDefinition( - XmlElementNames.When, FieldUris.When, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the IsMeeting property. - /** - * The Constant IsMeeting. - */ - public static final PropertyDefinition IsMeeting = - new BoolPropertyDefinition( - XmlElementNames.IsMeeting, FieldUris.IsMeeting, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the IsCancelled property. - /** - * The Constant IsCancelled. - */ - public static final PropertyDefinition IsCancelled = - new BoolPropertyDefinition( - XmlElementNames.IsCancelled, FieldUris.IsCancelled, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the IsRecurring property. - /** - * The Constant IsRecurring. - */ - public static final PropertyDefinition IsRecurring = - new BoolPropertyDefinition( - XmlElementNames.IsRecurring, FieldUris.IsRecurring, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the MeetingRequestWasSent property. - /** - * The Constant MeetingRequestWasSent. - */ - public static final PropertyDefinition MeetingRequestWasSent = - new BoolPropertyDefinition( - XmlElementNames.MeetingRequestWasSent, - FieldUris.MeetingRequestWasSent, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the IsResponseRequested property. - /** - * The Constant IsResponseRequested. - */ - public static final PropertyDefinition IsResponseRequested = - new BoolPropertyDefinition( - XmlElementNames.IsResponseRequested, FieldUris.IsResponseRequested, - EnumSet.of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the AppointmentType property. - /** - * The Constant AppointmentType. - */ - public static final PropertyDefinition AppointmentType = - new GenericPropertyDefinition( - AppointmentType.class, - XmlElementNames.CalendarItemType, FieldUris.CalendarItemType, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the MyResponseType property. - /** - * The Constant MyResponseType. - */ - public static final PropertyDefinition MyResponseType = - new GenericPropertyDefinition( - MeetingResponseType.class, - XmlElementNames.MyResponseType, FieldUris.MyResponseType, EnumSet - .of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the Organizer property. - /** - * The Constant Organizer. - */ - public static final PropertyDefinition Organizer = - new ContainedPropertyDefinition( - EmailAddress.class, - XmlElementNames.Organizer, FieldUris.Organizer, - XmlElementNames.Mailbox, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public EmailAddress createComplexProperty() { - return new EmailAddress(); - } - }); - - // Defines the RequiredAttendees property. - - /** - * The Constant RequiredAttendees. - */ - public static final PropertyDefinition RequiredAttendees = - new ComplexPropertyDefinition( - AttendeeCollection.class, - XmlElementNames.RequiredAttendees, FieldUris.RequiredAttendees, - EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public AttendeeCollection createComplexProperty() { - return new AttendeeCollection(); - } - }); - - // Defines the OptionalAttendees property. - /** - * The Constant OptionalAttendees. - */ - public static final PropertyDefinition OptionalAttendees = - new ComplexPropertyDefinition( - AttendeeCollection.class, - XmlElementNames.OptionalAttendees, FieldUris.OptionalAttendees, - EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public AttendeeCollection createComplexProperty() { - return new AttendeeCollection(); - } - }); - - // Defines the Resources property. - - /** - * The Constant Resources. - */ - public static final PropertyDefinition Resources = - new ComplexPropertyDefinition( - AttendeeCollection.class, - XmlElementNames.Resources, FieldUris.Resources, EnumSet.of( - PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public AttendeeCollection createComplexProperty() { - return new AttendeeCollection(); - } - }); - - // Defines the ConflictingMeetingCount property. - /** - * The Constant ConflictingMeetingCount. - */ - public static final PropertyDefinition ConflictingMeetingCount = - new IntPropertyDefinition( - XmlElementNames.ConflictingMeetingCount, - FieldUris.ConflictingMeetingCount, - ExchangeVersion.Exchange2007_SP1); - - // Defines the AdjacentMeetingCount property. - /** - * The Constant AdjacentMeetingCount. - */ - public static final PropertyDefinition AdjacentMeetingCount = - new IntPropertyDefinition( - XmlElementNames.AdjacentMeetingCount, - FieldUris.AdjacentMeetingCount, ExchangeVersion.Exchange2007_SP1); - - // Defines the ConflictingMeetings property. - /** - * The Constant ConflictingMeetings. - */ - public static final PropertyDefinition ConflictingMeetings = - new ComplexPropertyDefinition>( - XmlElementNames.ConflictingMeetings, - FieldUris.ConflictingMeetings, - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate - >() { - public ItemCollection createComplexProperty() { - return new ItemCollection(); - } - }); - - // Defines the AdjacentMeetings property. - /** - * The Constant AdjacentMeetings. - */ - public static final PropertyDefinition AdjacentMeetings = - new ComplexPropertyDefinition>( - XmlElementNames.AdjacentMeetings, - FieldUris.AdjacentMeetings, - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate - >() { - public ItemCollection createComplexProperty() { - return new ItemCollection(); - } - }); - - // Defines the Duration property. - /** - * The Constant Duration. - */ - public static final PropertyDefinition Duration = - new TimeSpanPropertyDefinition( - XmlElementNames.Duration, FieldUris.Duration, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the TimeZone property. - /** - * The Constant TimeZone. - */ - public static final PropertyDefinition TimeZone = - new StringPropertyDefinition( - XmlElementNames.TimeZone, FieldUris.TimeZone, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the AppointmentReplyTime property. - /** - * The Constant AppointmentReplyTime. - */ - public static final PropertyDefinition AppointmentReplyTime = - new DateTimePropertyDefinition( - XmlElementNames.AppointmentReplyTime, - FieldUris.AppointmentReplyTime, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the AppointmentSequenceNumber property. - /** - * The Constant AppointmentSequenceNumber. - */ - public static final PropertyDefinition AppointmentSequenceNumber = - new IntPropertyDefinition( - XmlElementNames.AppointmentSequenceNumber, - FieldUris.AppointmentSequenceNumber, - ExchangeVersion.Exchange2007_SP1); - - // Defines the AppointmentState property. - /** - * The Constant AppointmentState. - */ - public static final PropertyDefinition AppointmentState = - new IntPropertyDefinition( - XmlElementNames.AppointmentState, FieldUris.AppointmentState, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the Recurrence property. - /** - * The Constant Recurrence. - */ - public static final PropertyDefinition Recurrence = - new RecurrencePropertyDefinition( - XmlElementNames.Recurrence, FieldUris.Recurrence, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete), - ExchangeVersion.Exchange2007_SP1); - - // Defines the FirstOccurrence property. - /** - * The Constant FirstOccurrence. - */ - public static final PropertyDefinition FirstOccurrence = - new ComplexPropertyDefinition( - OccurrenceInfo.class, - XmlElementNames.FirstOccurrence, FieldUris.FirstOccurrence, - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public OccurrenceInfo createComplexProperty() { - return new OccurrenceInfo(); - } - }); - - // Defines the LastOccurrence property. - /** - * The Constant LastOccurrence. - */ - public static final PropertyDefinition LastOccurrence = - new ComplexPropertyDefinition( - OccurrenceInfo.class, - XmlElementNames.LastOccurrence, FieldUris.LastOccurrence, - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public OccurrenceInfo createComplexProperty() { - return new OccurrenceInfo(); - } - }); - - // Defines the ModifiedOccurrences property. - /** - * The Constant ModifiedOccurrences. - */ - public static final PropertyDefinition ModifiedOccurrences = - new ComplexPropertyDefinition( - OccurrenceInfoCollection.class, - XmlElementNames.ModifiedOccurrences, - FieldUris.ModifiedOccurrences, - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate - () { - public OccurrenceInfoCollection createComplexProperty() { - return new OccurrenceInfoCollection(); - } - }); - - // Defines the DeletedOccurrences property. - /** - * The Constant DeletedOccurrences. - */ - public static final PropertyDefinition DeletedOccurrences = - new ComplexPropertyDefinition( - DeletedOccurrenceInfoCollection.class, - XmlElementNames.DeletedOccurrences, - FieldUris.DeletedOccurrences, - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate - () { - public DeletedOccurrenceInfoCollection createComplexProperty() { - return new DeletedOccurrenceInfoCollection(); - } - }); - - // Defines the MeetingTimeZone property. - /** - * The Constant MeetingTimeZone. - */ - public static final PropertyDefinition MeetingTimeZone = - new MeetingTimeZonePropertyDefinition( - XmlElementNames.MeetingTimeZone, FieldUris.MeetingTimeZone, EnumSet - .of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate), - ExchangeVersion.Exchange2007_SP1); - - // Defines the ConferenceType property. - /** - * The Constant ConferenceType. - */ - public static final PropertyDefinition ConferenceType = - new IntPropertyDefinition( - XmlElementNames.ConferenceType, FieldUris.ConferenceType, EnumSet - .of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the AllowNewTimeProposal property. - /** - * The Constant AllowNewTimeProposal. - */ - public static final PropertyDefinition AllowNewTimeProposal = - new BoolPropertyDefinition( - XmlElementNames.AllowNewTimeProposal, - FieldUris.AllowNewTimeProposal, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the IsOnlineMeeting property. - /** - * The Constant IsOnlineMeeting. - */ - public static final PropertyDefinition IsOnlineMeeting = - new BoolPropertyDefinition( - XmlElementNames.IsOnlineMeeting, FieldUris.IsOnlineMeeting, EnumSet - .of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the MeetingWorkspaceUrl property. - /** - * The Constant MeetingWorkspaceUrl. - */ - public static final PropertyDefinition MeetingWorkspaceUrl = - new StringPropertyDefinition( - XmlElementNames.MeetingWorkspaceUrl, FieldUris.MeetingWorkspaceUrl, - EnumSet.of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the NetShowUrl property. - /** - * The Constant NetShowUrl. - */ - public static final PropertyDefinition NetShowUrl = - new StringPropertyDefinition( - XmlElementNames.NetShowUrl, FieldUris.NetShowUrl, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the iCalendar Uid property. - /** - * The Constant ICalUid. - */ - public static final PropertyDefinition ICalUid = - new StringPropertyDefinition( - XmlElementNames.Uid, FieldUris.Uid, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - // Defines the iCalendar RecurrenceId property. - /** - * The Constant ICalRecurrenceId. - */ - public static final PropertyDefinition ICalRecurrenceId = - new DateTimePropertyDefinition( - XmlElementNames.RecurrenceId, FieldUris.RecurrenceId, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, true); - // Defines the iCalendar DateTimeStamp property. - /** - * The Constant ICalDateTimeStamp. - */ - public static final PropertyDefinition ICalDateTimeStamp = - new DateTimePropertyDefinition( - XmlElementNames.DateTimeStamp, FieldUris.DateTimeStamp, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, true); // isNullable - - // Instance of schema. - // This must be after the declaration of property definitions. - /** - * The Constant Instance. - */ - public static final AppointmentSchema Instance = new AppointmentSchema(); - - /** - * Registers property. - *

- * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the - * same order as they are defined in types.xsd) - *

- */ - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(Start); - this.registerProperty(End); - this.registerProperty(OriginalStart); - this.registerProperty(IsAllDayEvent); - this.registerProperty(LegacyFreeBusyStatus); - this.registerProperty(Location); - this.registerProperty(When); - this.registerProperty(IsMeeting); - this.registerProperty(IsCancelled); - this.registerProperty(IsRecurring); - this.registerProperty(MeetingRequestWasSent); - this.registerProperty(IsResponseRequested); - this.registerProperty(AppointmentType); - this.registerProperty(MyResponseType); - this.registerProperty(Organizer); - this.registerProperty(RequiredAttendees); - this.registerProperty(OptionalAttendees); - this.registerProperty(Resources); - this.registerProperty(ConflictingMeetingCount); - this.registerProperty(AdjacentMeetingCount); - this.registerProperty(ConflictingMeetings); - this.registerProperty(AdjacentMeetings); - this.registerProperty(Duration); - this.registerProperty(TimeZone); - this.registerProperty(AppointmentReplyTime); - this.registerProperty(AppointmentSequenceNumber); - this.registerProperty(AppointmentState); - this.registerProperty(Recurrence); - this.registerProperty(FirstOccurrence); - this.registerProperty(LastOccurrence); - this.registerProperty(ModifiedOccurrences); - this.registerProperty(DeletedOccurrences); - this.registerInternalProperty(MeetingTimeZone); - this.registerProperty(StartTimeZone); - this.registerProperty(EndTimeZone); - this.registerProperty(ConferenceType); - this.registerProperty(AllowNewTimeProposal); - this.registerProperty(IsOnlineMeeting); - this.registerProperty(MeetingWorkspaceUrl); - this.registerProperty(NetShowUrl); - this.registerProperty(ICalUid); - this.registerProperty(ICalRecurrenceId); - this.registerProperty(ICalDateTimeStamp); - } - - /** - * Instantiates a new appointment schema. - */ - AppointmentSchema() { - super(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/CalendarResponseObjectSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/CalendarResponseObjectSchema.java deleted file mode 100644 index cf8951bc6..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/CalendarResponseObjectSchema.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -/** - * Represents the schema for CalendarResponseObject. - */ -public class CalendarResponseObjectSchema extends ServiceObjectSchema { - - // This must be declared after the property definitions - /** - * The Constant Instance. - */ - public static final CalendarResponseObjectSchema Instance = - new CalendarResponseObjectSchema(); - - /** - * Registers property. - */ - // / IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the - // same order as they are defined in types.xsd) - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(ItemSchema.ItemClass); - this.registerProperty(ItemSchema.Sensitivity); - this.registerProperty(ItemSchema.Body); - this.registerProperty(ItemSchema.Attachments); - this.registerProperty(ItemSchema.InternetMessageHeaders); - this.registerProperty(EmailMessageSchema.Sender); - this.registerProperty(EmailMessageSchema.ToRecipients); - this.registerProperty(EmailMessageSchema.CcRecipients); - this.registerProperty(EmailMessageSchema.BccRecipients); - this.registerProperty(EmailMessageSchema.IsReadReceiptRequested); - this.registerProperty(EmailMessageSchema.IsDeliveryReceiptRequested); - this.registerProperty(ResponseObjectSchema.ReferenceItemId); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/CancelMeetingMessageSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/CancelMeetingMessageSchema.java deleted file mode 100644 index 55f2647dc..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/CancelMeetingMessageSchema.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.complex.MessageBody; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents a meeting cancellation message. - */ -public class CancelMeetingMessageSchema extends ServiceObjectSchema { - - /** - * The Constant Body. - */ - public static final PropertyDefinition Body = - new ComplexPropertyDefinition( - MessageBody.class, - XmlElementNames.NewBodyContent, EnumSet - .of(PropertyDefinitionFlags.CanSet), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public MessageBody createComplexProperty() { - return new MessageBody(); - } - }); - - /** - * This must be declared after the property definitions. - */ - public static final CancelMeetingMessageSchema Instance = - new CancelMeetingMessageSchema(); - - /** - * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN - * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd) - */ - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(EmailMessageSchema.IsReadReceiptRequested); - this.registerProperty(EmailMessageSchema.IsDeliveryReceiptRequested); - this.registerProperty(ResponseObjectSchema.ReferenceItemId); - this.registerProperty(CancelMeetingMessageSchema.Body); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ContactGroupSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ContactGroupSchema.java deleted file mode 100644 index 859234436..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ContactGroupSchema.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.Schema; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.GroupMemberCollection; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents the schema for contact groups. - */ -@Schema -public class ContactGroupSchema extends ItemSchema { - - - // Defines the DisplayName property. - /** - * The Constant DisplayName. - */ - public static final PropertyDefinition DisplayName = - ContactSchema.DisplayName; - - - // Defines the FileAs property. - /** - * The Constant FileAs. - */ - public static final PropertyDefinition FileAs = ContactSchema.FileAs; - - - // Defines the Members property. - /** - * The Constant Members. - */ - public static final PropertyDefinition Members = - new ComplexPropertyDefinition( - GroupMemberCollection.class, - XmlElementNames.Members, - FieldUris.Members, - EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate), - ExchangeVersion.Exchange2010, - new ICreateComplexPropertyDelegate() { - @Override - public GroupMemberCollection createComplexProperty() { - return new GroupMemberCollection(); - } - }); - - - //This must be declared after the property definitions. - /** - * The Constant Instance. - */ - public static final ContactGroupSchema Instance = - new ContactGroupSchema(); - - - // Initializes a new instance of the - // class. - - /** - * Instantiates a new contact group schema. - */ - protected ContactGroupSchema() { - super(); - } - - //Registers property. - // IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. - // the same order as they are defined in types.xsd) - - /** - * Registers property. - *

- * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the - * same order as they are defined in types.xsd) - *

- */ - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(DisplayName); - this.registerProperty(FileAs); - this.registerProperty(Members); - } - - - // Field URIs for Members. - - - /** - * The Interface FieldUris. - */ - private static interface FieldUris { - /** - * FieldUri for members. - */ - String Members = "distributionlist:Members"; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ContactSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ContactSchema.java deleted file mode 100644 index da6ba708d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ContactSchema.java +++ /dev/null @@ -1,1296 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.Schema; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.ContactSource; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.FileAsMapping; -import microsoft.exchange.webservices.data.core.enumeration.property.PhysicalAddressIndex; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.ByteArrayArray; -import microsoft.exchange.webservices.data.property.complex.CompleteName; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; -import microsoft.exchange.webservices.data.property.complex.EmailAddressCollection; -import microsoft.exchange.webservices.data.property.complex.EmailAddressDictionary; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.complex.ImAddressDictionary; -import microsoft.exchange.webservices.data.property.complex.PhoneNumberDictionary; -import microsoft.exchange.webservices.data.property.complex.PhysicalAddressDictionary; -import microsoft.exchange.webservices.data.property.complex.StringList; -import microsoft.exchange.webservices.data.property.definition.BoolPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ByteArrayPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ContainedPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.DateTimePropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.GenericPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.IndexedPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.StringPropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents the schema for contacts. - */ -@Schema -public class ContactSchema extends ItemSchema { - - /** - * FieldURIs for contacts. - */ - private interface FieldUris { - - /** - * The File as. - */ - String FileAs = "contacts:FileAs"; - - /** - * The File as mapping. - */ - String FileAsMapping = "contacts:FileAsMapping"; - - /** - * The Display name. - */ - String DisplayName = "contacts:DisplayName"; - - /** - * The Given name. - */ - String GivenName = "contacts:GivenName"; - - /** - * The Initials. - */ - String Initials = "contacts:Initials"; - - /** - * The Middle name. - */ - String MiddleName = "contacts:MiddleName"; - - /** - * The Nick name. - */ - String NickName = "contacts:Nickname"; - - /** - * The Complete name. - */ - String CompleteName = "contacts:CompleteName"; - - /** - * The Company name. - */ - String CompanyName = "contacts:CompanyName"; - - /** - * The Email address. - */ - String EmailAddress = "contacts:EmailAddress"; - - /** - * The Email addresses. - */ - String EmailAddresses = "contacts:EmailAddresses"; - - /** - * The Physical addresses. - */ - String PhysicalAddresses = "contacts:PhysicalAddresses"; - - /** - * The Phone number. - */ - String PhoneNumber = "contacts:PhoneNumber"; - - /** - * The Phone numbers. - */ - String PhoneNumbers = "contacts:PhoneNumbers"; - - /** - * The Assistant name. - */ - String AssistantName = "contacts:AssistantName"; - - /** - * The Birthday. - */ - String Birthday = "contacts:Birthday"; - - /** - * The Business home page. - */ - String BusinessHomePage = "contacts:BusinessHomePage"; - - /** - * The Children. - */ - String Children = "contacts:Children"; - - /** - * The Companies. - */ - String Companies = "contacts:Companies"; - - /** - * The Contact source. - */ - String ContactSource = "contacts:ContactSource"; - - /** - * The Department. - */ - String Department = "contacts:Department"; - - /** - * The Generation. - */ - String Generation = "contacts:Generation"; - - /** - * The Im address. - */ - String ImAddress = "contacts:ImAddress"; - - /** - * The Im addresses. - */ - String ImAddresses = "contacts:ImAddresses"; - - /** - * The Job title. - */ - String JobTitle = "contacts:JobTitle"; - - /** - * The Manager. - */ - String Manager = "contacts:Manager"; - - /** - * The Mileage. - */ - String Mileage = "contacts:Mileage"; - - /** - * The Office location. - */ - String OfficeLocation = "contacts:OfficeLocation"; - - /** - * The Physical address city. - */ - String PhysicalAddressCity = "contacts:PhysicalAddress:City"; - - /** - * The Physical address country or region. - */ - String PhysicalAddressCountryOrRegion = - "contacts:PhysicalAddress:CountryOrRegion"; - - /** - * The Physical address state. - */ - String PhysicalAddressState = "contacts:PhysicalAddress:State"; - - /** - * The Physical address street. - */ - String PhysicalAddressStreet = "contacts:PhysicalAddress:Street"; - - /** - * The Physical address postal code. - */ - String PhysicalAddressPostalCode = - "contacts:PhysicalAddress:PostalCode"; - - /** - * The Postal address index. - */ - String PostalAddressIndex = "contacts:PostalAddressIndex"; - - /** - * The Profession. - */ - String Profession = "contacts:Profession"; - - /** - * The Spouse name. - */ - String SpouseName = "contacts:SpouseName"; - - /** - * The Surname. - */ - String Surname = "contacts:Surname"; - - /** - * The Wedding anniversary. - */ - String WeddingAnniversary = "contacts:WeddingAnniversary"; - - /** - * The Has picture. - */ - String HasPicture = "contacts:HasPicture"; - - /** - * The PhoneticFullName. - */ - - String PhoneticFullName = "contacts:PhoneticFullName"; - - /** - * The PhoneticFirstName. - */ - - String PhoneticFirstName = "contacts:PhonetiFirstName"; - - /** - * The PhoneticFirstName. - */ - - String PhoneticLastName = "contacts:PhonetiLastName"; - - /** - * The Aias. - */ - - String Alias = "contacts:Alias"; - - /** - * The Notes. - */ - - String Notes = "contacts:Notes"; - - /** - * The Photo. - */ - - String Photo = "contacts:Photo"; - - /** - * The UserSMIMECertificate. - */ - - String UserSMIMECertificate = "contacts:UserSMIMECertificate"; - - /** - * The MSExchangeCertificate. - */ - - String MSExchangeCertificate = "contacts:MSExchangeCertificate"; - - /** - * The DirectoryId. - */ - - String DirectoryId = "contacts:DirectoryId"; - - /** - * The ManagerMailbox. - */ - - String ManagerMailbox = "contacts:ManagerMailbox"; - - /** - * The DirectReports. - */ - - String DirectReports = "contacts:DirectReports"; - } - - - /** - * Defines the FileAs property. - */ - public static final PropertyDefinition FileAs = - new StringPropertyDefinition( - XmlElementNames.FileAs, FieldUris.FileAs, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the FileAsMapping property. - */ - public static final PropertyDefinition FileAsMapping = - new GenericPropertyDefinition( - FileAsMapping.class, - XmlElementNames.FileAsMapping, FieldUris.FileAsMapping, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the DisplayName property. - */ - public static final PropertyDefinition DisplayName = - new StringPropertyDefinition( - XmlElementNames.DisplayName, FieldUris.DisplayName, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the GivenName property. - */ - public static final PropertyDefinition GivenName = - new StringPropertyDefinition( - XmlElementNames.GivenName, FieldUris.GivenName, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Initials property. - */ - public static final PropertyDefinition Initials = - new StringPropertyDefinition( - XmlElementNames.Initials, FieldUris.Initials, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the MiddleName property. - */ - public static final PropertyDefinition MiddleName = - new StringPropertyDefinition( - XmlElementNames.MiddleName, FieldUris.MiddleName, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the NickName property. - */ - public static final PropertyDefinition NickName = - new StringPropertyDefinition( - XmlElementNames.NickName, FieldUris.NickName, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the CompleteName property. - */ - public static final PropertyDefinition CompleteName = - new ComplexPropertyDefinition( - CompleteName.class, - XmlElementNames.CompleteName, FieldUris.CompleteName, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public CompleteName createComplexProperty() { - return new CompleteName(); - } - }); - - /** - * Defines the CompanyName property. - */ - public static final PropertyDefinition CompanyName = - new StringPropertyDefinition( - XmlElementNames.CompanyName, FieldUris.CompanyName, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the EmailAddresses property. - */ - public static final PropertyDefinition EmailAddresses = - new ComplexPropertyDefinition( - EmailAddressDictionary.class, - XmlElementNames.EmailAddresses, - FieldUris.EmailAddresses, - EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate - () { - @Override - public EmailAddressDictionary createComplexProperty() { - return new EmailAddressDictionary(); - } - }); - - /** - * Defines the PhysicalAddresses property. - */ - public static final PropertyDefinition PhysicalAddresses = - new ComplexPropertyDefinition( - PhysicalAddressDictionary.class, - XmlElementNames.PhysicalAddresses, - FieldUris.PhysicalAddresses, - EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate - () { - @Override - public PhysicalAddressDictionary createComplexProperty() { - return new PhysicalAddressDictionary(); - } - }); - - /** - * Defines the PhoneNumbers property. - */ - public static final PropertyDefinition PhoneNumbers = - new ComplexPropertyDefinition( - PhoneNumberDictionary.class, - XmlElementNames.PhoneNumbers, - FieldUris.PhoneNumbers, - EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate - () { - @Override - public PhoneNumberDictionary createComplexProperty() { - return new PhoneNumberDictionary(); - } - }); - - /** - * Defines the AssistantName property. - */ - public static final PropertyDefinition AssistantName = - new StringPropertyDefinition( - XmlElementNames.AssistantName, FieldUris.AssistantName, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Birthday property. - */ - public static final PropertyDefinition Birthday = - new DateTimePropertyDefinition( - XmlElementNames.Birthday, FieldUris.Birthday, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the BusinessHomePage property. - *

- * Defined as anyURI in the EWS schema. String is fine here. - */ - public static final PropertyDefinition BusinessHomePage = - new StringPropertyDefinition( - XmlElementNames.BusinessHomePage, FieldUris.BusinessHomePage, - EnumSet.of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Children property. - */ - public static final PropertyDefinition Children = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.Children, FieldUris.Children, EnumSet.of( - PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public StringList createComplexProperty() { - return new StringList(); - } - }); - - /** - * Defines the Companies property. - */ - public static final PropertyDefinition Companies = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.Companies, FieldUris.Companies, EnumSet.of( - PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public StringList createComplexProperty() { - return new StringList(); - } - }); - - /** - * Defines the ContactSource property. - */ - public static final PropertyDefinition ContactSource = - new GenericPropertyDefinition( - ContactSource.class, - XmlElementNames.ContactSource, FieldUris.ContactSource, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Department property. - */ - public static final PropertyDefinition Department = - new StringPropertyDefinition( - XmlElementNames.Department, FieldUris.Department, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Generation property. - */ - public static final PropertyDefinition Generation = - new StringPropertyDefinition( - XmlElementNames.Generation, FieldUris.Generation, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the ImAddresses property. - */ - public static final PropertyDefinition ImAddresses = - new ComplexPropertyDefinition( - ImAddressDictionary.class, - XmlElementNames.ImAddresses, FieldUris.ImAddresses, EnumSet.of( - PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public ImAddressDictionary createComplexProperty() { - return new ImAddressDictionary(); - } - }); - - /** - * Defines the JobTitle property. - */ - public static final PropertyDefinition JobTitle = - new StringPropertyDefinition( - XmlElementNames.JobTitle, FieldUris.JobTitle, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Manager property. - */ - public static final PropertyDefinition Manager = - new StringPropertyDefinition( - XmlElementNames.Manager, FieldUris.Manager, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Mileage property. - */ - public static final PropertyDefinition Mileage = - new StringPropertyDefinition( - XmlElementNames.Mileage, FieldUris.Mileage, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the OfficeLocation property. - */ - public static final PropertyDefinition OfficeLocation = - new StringPropertyDefinition( - XmlElementNames.OfficeLocation, FieldUris.OfficeLocation, EnumSet - .of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the PostalAddressIndex property. - */ - public static final PropertyDefinition PostalAddressIndex = - new GenericPropertyDefinition( - PhysicalAddressIndex.class, - XmlElementNames.PostalAddressIndex, FieldUris.PostalAddressIndex, - EnumSet.of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Profession property. - */ - public static final PropertyDefinition Profession = - new StringPropertyDefinition( - XmlElementNames.Profession, FieldUris.Profession, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the SpouseName property. - */ - public static final PropertyDefinition SpouseName = - new StringPropertyDefinition( - XmlElementNames.SpouseName, FieldUris.SpouseName, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Surname property. - */ - public static final PropertyDefinition Surname = - new StringPropertyDefinition( - XmlElementNames.Surname, FieldUris.Surname, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the WeddingAnniversary property. - */ - public static final PropertyDefinition WeddingAnniversary = - new DateTimePropertyDefinition( - XmlElementNames.WeddingAnniversary, FieldUris.WeddingAnniversary, - EnumSet.of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the HasPicture property. - */ - public static final PropertyDefinition HasPicture = - new BoolPropertyDefinition( - XmlElementNames.HasPicture, FieldUris.HasPicture, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010); - /** - * Defines PhoeniticFullName property ** - */ - - public static final PropertyDefinition PhoneticFullName = - new StringPropertyDefinition( - XmlElementNames.PhoneticFullName, - FieldUris.PhoneticFullName, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines PhoenticFirstName property ** - */ - - public static final PropertyDefinition PhoneticFirstName = - new StringPropertyDefinition( - XmlElementNames.PhoneticFirstName, - FieldUris.PhoneticFirstName, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines PhoneticLastName Property ** - */ - - public static final PropertyDefinition PhoneticLastName = - new StringPropertyDefinition( - XmlElementNames.PhoneticLastName, - FieldUris.PhoneticLastName, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the Alias Property ** - */ - - public static final PropertyDefinition Alias = - new StringPropertyDefinition( - XmlElementNames.Alias, - FieldUris.Alias, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - - /** - * Defines the Notes Property ** - */ - - public static final PropertyDefinition Notes = - new StringPropertyDefinition( - XmlElementNames.Notes, - FieldUris.Notes, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines Photo Property ** - */ - - public static final PropertyDefinition Photo = - new ByteArrayPropertyDefinition( - XmlElementNames.Photo, - FieldUris.Photo, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines UserSMIMECertificate Property ** - */ - - public static final PropertyDefinition UserSMIMECertificate = - new ComplexPropertyDefinition( - ByteArrayArray.class, - XmlElementNames.UserSMIMECertificate, - FieldUris.UserSMIMECertificate, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public ByteArrayArray createComplexProperty() { - return new ByteArrayArray(); - } - }); - - /** - * Defines MSExchangeCertificate Property ** - */ - - public static final PropertyDefinition MSExchangeCertificate = - new ComplexPropertyDefinition( - ByteArrayArray.class, - XmlElementNames.MSExchangeCertificate, - FieldUris.MSExchangeCertificate, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public ByteArrayArray createComplexProperty() { - return new ByteArrayArray(); - } - }); - - - /** - * Defines DirectoryId Property ** - */ - - public static final PropertyDefinition DirectoryId = - new StringPropertyDefinition( - XmlElementNames.DirectoryId, - FieldUris.DirectoryId, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines ManagerMailbox Property ** - */ - - public static final PropertyDefinition ManagerMailbox = - new ContainedPropertyDefinition( - EmailAddress.class, - XmlElementNames.ManagerMailbox, - FieldUris.ManagerMailbox, - XmlElementNames.Mailbox, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public EmailAddress createComplexProperty() { - return new EmailAddress(); - } - }); - - /** - * Defines DirectReports Property ** - */ - - public static final PropertyDefinition DirectReports = - new ComplexPropertyDefinition( - EmailAddressCollection.class, - XmlElementNames.DirectReports, - FieldUris.DirectReports, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public EmailAddressCollection createComplexProperty() - - { - return new EmailAddressCollection(); - } - }); - - - - /** - * Defines the EmailAddress1 property. - */ - public static final IndexedPropertyDefinition EmailAddress1 = - new IndexedPropertyDefinition( - FieldUris.EmailAddress, "EmailAddress1"); - - /** - * Defines the EmailAddress2 property. - */ - public static final IndexedPropertyDefinition EmailAddress2 = - new IndexedPropertyDefinition( - FieldUris.EmailAddress, "EmailAddress2"); - - /** - * Defines the EmailAddress3 property. - */ - public static final IndexedPropertyDefinition EmailAddress3 = - new IndexedPropertyDefinition( - FieldUris.EmailAddress, "EmailAddress3"); - - /** - * Defines the ImAddress1 property. - */ - public static final IndexedPropertyDefinition ImAddress1 = - new IndexedPropertyDefinition( - FieldUris.ImAddress, "ImAddress1"); - - /** - * Defines the ImAddress2 property. - */ - public static final IndexedPropertyDefinition ImAddress2 = - new IndexedPropertyDefinition( - FieldUris.ImAddress, "ImAddress2"); - - /** - * Defines the ImAddress3 property. - */ - public static final IndexedPropertyDefinition ImAddress3 = - new IndexedPropertyDefinition( - FieldUris.ImAddress, "ImAddress3"); - - /** - * Defines the AssistentPhone property. - */ - public static final IndexedPropertyDefinition AssistantPhone = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "AssistantPhone"); - - /** - * Defines the BusinessFax property. - */ - public static final IndexedPropertyDefinition BusinessFax = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "BusinessFax"); - - /** - * Defines the BusinessPhone property. - */ - public static final IndexedPropertyDefinition BusinessPhone = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "BusinessPhone"); - - /** - * Defines the BusinessPhone2 property. - */ - public static final IndexedPropertyDefinition BusinessPhone2 = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "BusinessPhone2"); - - /** - * Defines the Callback property. - */ - public static final IndexedPropertyDefinition Callback = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "Callback"); - - /** - * Defines the CarPhone property. - */ - public static final IndexedPropertyDefinition CarPhone = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "CarPhone"); - - /** - * Defines the CompanyMainPhone property. - */ - public static final IndexedPropertyDefinition CompanyMainPhone = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "CompanyMainPhone"); - - /** - * Defines the HomeFax property. - */ - public static final IndexedPropertyDefinition HomeFax = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "HomeFax"); - - /** - * Defines the HomePhone property. - */ - public static final IndexedPropertyDefinition HomePhone = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "HomePhone"); - - /** - * Defines the HomePhone2 property. - */ - public static final IndexedPropertyDefinition HomePhone2 = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "HomePhone2"); - - /** - * Defines the Isdn property. - */ - public static final IndexedPropertyDefinition Isdn = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "Isdn"); - - /** - * Defines the MobilePhone property. - */ - public static final IndexedPropertyDefinition MobilePhone = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "MobilePhone"); - - /** - * Defines the OtherFax property. - */ - public static final IndexedPropertyDefinition OtherFax = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "OtherFax"); - - /** - * Defines the OtherTelephone property. - */ - public static final IndexedPropertyDefinition OtherTelephone = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "OtherTelephone"); - - /** - * Defines the Pager property. - */ - public static final IndexedPropertyDefinition Pager = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "Pager"); - - /** - * Defines the PrimaryPhone property. - */ - public static final IndexedPropertyDefinition PrimaryPhone = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "PrimaryPhone"); - - /** - * Defines the RadioPhone property. - */ - public static final IndexedPropertyDefinition RadioPhone = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "RadioPhone"); - - /** - * Defines the Telex property. - */ - public static final IndexedPropertyDefinition Telex = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "Telex"); - - /** - * Defines the TtyTddPhone property. - */ - public static final IndexedPropertyDefinition TtyTddPhone = - new IndexedPropertyDefinition( - FieldUris.PhoneNumber, "TtyTddPhone"); - - /** - * Defines the BusinessAddressStreet property. - */ - public static final IndexedPropertyDefinition BusinessAddressStreet = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressStreet, "Business"); - - /** - * Defines the BusinessAddressCity property. - */ - public static final IndexedPropertyDefinition BusinessAddressCity = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressCity, "Business"); - - /** - * Defines the BusinessAddressState property. - */ - public static final IndexedPropertyDefinition BusinessAddressState = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressState, "Business"); - - /** - * Defines the BusinessAddressCountryOrRegion property. - */ - public static final IndexedPropertyDefinition - BusinessAddressCountryOrRegion = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressCountryOrRegion, "Business"); - - /** - * Defines the BusinessAddressPostalCode property. - */ - public static final IndexedPropertyDefinition BusinessAddressPostalCode = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressPostalCode, "Business"); - - /** - * Defines the HomeAddressStreet property. - */ - public static final IndexedPropertyDefinition HomeAddressStreet = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressStreet, "Home"); - - /** - * Defines the HomeAddressCity property. - */ - public static final IndexedPropertyDefinition HomeAddressCity = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressCity, "Home"); - - /** - * Defines the HomeAddressState property. - */ - public static final IndexedPropertyDefinition HomeAddressState = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressState, "Home"); - - /** - * Defines the HomeAddressCountryOrRegion property. - */ - public static final IndexedPropertyDefinition HomeAddressCountryOrRegion = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressCountryOrRegion, "Home"); - - /** - * Defines the HomeAddressPostalCode property. - */ - public static final IndexedPropertyDefinition HomeAddressPostalCode = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressPostalCode, "Home"); - - /** - * Defines the OtherAddressStreet property. - */ - public static final IndexedPropertyDefinition OtherAddressStreet = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressStreet, "Other"); - - /** - * Defines the OtherAddressCity property. - */ - public static final IndexedPropertyDefinition OtherAddressCity = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressCity, "Other"); - - /** - * Defines the OtherAddressState property. - */ - public static final IndexedPropertyDefinition OtherAddressState = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressState, "Other"); - - /** - * Defines the OtherAddressCountryOrRegion property. - */ - public static final IndexedPropertyDefinition OtherAddressCountryOrRegion = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressCountryOrRegion, "Other"); - - /** - * Defines the OtherAddressPostalCode property. - */ - public static final IndexedPropertyDefinition OtherAddressPostalCode = - new IndexedPropertyDefinition( - FieldUris.PhysicalAddressPostalCode, "Other"); - - // This must be declared after the property definitions - /** - * The Constant Instance. - */ - public static final ContactSchema Instance = new ContactSchema(); - - /** - * Registers property. - *

- * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the - * same order as they are defined in types.xsd) - */ - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(FileAs); - this.registerProperty(FileAsMapping); - this.registerProperty(DisplayName); - this.registerProperty(GivenName); - this.registerProperty(Initials); - this.registerProperty(MiddleName); - this.registerProperty(NickName); - this.registerProperty(CompleteName); - this.registerProperty(CompanyName); - this.registerProperty(EmailAddresses); - this.registerProperty(PhysicalAddresses); - this.registerProperty(PhoneNumbers); - this.registerProperty(AssistantName); - this.registerProperty(Birthday); - this.registerProperty(BusinessHomePage); - this.registerProperty(Children); - this.registerProperty(Companies); - this.registerProperty(ContactSource); - this.registerProperty(Department); - this.registerProperty(Generation); - this.registerProperty(ImAddresses); - this.registerProperty(JobTitle); - this.registerProperty(Manager); - this.registerProperty(Mileage); - this.registerProperty(OfficeLocation); - this.registerProperty(PostalAddressIndex); - this.registerProperty(Profession); - this.registerProperty(SpouseName); - this.registerProperty(Surname); - this.registerProperty(WeddingAnniversary); - this.registerProperty(HasPicture); - this.registerProperty(PhoneticFullName); - this.registerProperty(PhoneticFirstName); - this.registerProperty(PhoneticLastName); - this.registerProperty(Alias); - this.registerProperty(Notes); - this.registerProperty(Photo); - this.registerProperty(UserSMIMECertificate); - this.registerProperty(MSExchangeCertificate); - this.registerProperty(DirectoryId); - this.registerProperty(ManagerMailbox); - this.registerProperty(DirectReports); - - this.registerIndexedProperty(EmailAddress1); - this.registerIndexedProperty(EmailAddress2); - this.registerIndexedProperty(EmailAddress3); - this.registerIndexedProperty(ImAddress1); - this.registerIndexedProperty(ImAddress2); - this.registerIndexedProperty(ImAddress3); - this.registerIndexedProperty(AssistantPhone); - this.registerIndexedProperty(BusinessFax); - this.registerIndexedProperty(BusinessPhone); - this.registerIndexedProperty(BusinessPhone2); - this.registerIndexedProperty(Callback); - this.registerIndexedProperty(CarPhone); - this.registerIndexedProperty(CompanyMainPhone); - this.registerIndexedProperty(HomeFax); - this.registerIndexedProperty(HomePhone); - this.registerIndexedProperty(HomePhone2); - this.registerIndexedProperty(Isdn); - this.registerIndexedProperty(MobilePhone); - this.registerIndexedProperty(OtherFax); - this.registerIndexedProperty(OtherTelephone); - this.registerIndexedProperty(Pager); - this.registerIndexedProperty(PrimaryPhone); - this.registerIndexedProperty(RadioPhone); - this.registerIndexedProperty(Telex); - this.registerIndexedProperty(TtyTddPhone); - this.registerIndexedProperty(BusinessAddressStreet); - this.registerIndexedProperty(BusinessAddressCity); - this.registerIndexedProperty(BusinessAddressState); - this.registerIndexedProperty(BusinessAddressCountryOrRegion); - this.registerIndexedProperty(BusinessAddressPostalCode); - this.registerIndexedProperty(HomeAddressStreet); - this.registerIndexedProperty(HomeAddressCity); - this.registerIndexedProperty(HomeAddressState); - this.registerIndexedProperty(HomeAddressCountryOrRegion); - this.registerIndexedProperty(HomeAddressPostalCode); - this.registerIndexedProperty(OtherAddressStreet); - this.registerIndexedProperty(OtherAddressCity); - this.registerIndexedProperty(OtherAddressState); - this.registerIndexedProperty(OtherAddressCountryOrRegion); - this.registerIndexedProperty(OtherAddressPostalCode); - - } - - /** - * Instantiates a new contact schema. - */ - ContactSchema() { - super(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ConversationSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ConversationSchema.java deleted file mode 100644 index a10767132..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ConversationSchema.java +++ /dev/null @@ -1,658 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.Schema; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.ConversationFlagStatus; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.Importance; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.ConversationId; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.complex.ItemIdCollection; -import microsoft.exchange.webservices.data.property.complex.StringList; -import microsoft.exchange.webservices.data.property.definition.BoolPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.DateTimePropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.GenericPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.IntPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.StringPropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents the schema for Conversation. - */ -@Schema -public class ConversationSchema extends ServiceObjectSchema { - - /** - * Field URIs for Item. - */ - private static class FieldUris { - /** - * The Constant ConversationId. - */ - public static final String ConversationId = - "conversation:ConversationId"; - - /** - * The Constant ConversationTopic. - */ - public static final String ConversationTopic = - "conversation:ConversationTopic"; - - /** - * The Constant UniqueRecipients. - */ - public static final String UniqueRecipients = - "conversation:UniqueRecipients"; - - /** - * The Constant GlobalUniqueRecipients. - */ - public static final String GlobalUniqueRecipients = - "conversation:GlobalUniqueRecipients"; - - /** - * The Constant UniqueUnreadSenders. - */ - public static final String UniqueUnreadSenders = - "conversation:UniqueUnreadSenders"; - - /** - * The Constant GlobalUniqueUnreadSenders. - */ - public static final String GlobalUniqueUnreadSenders = - "conversation:GlobalUniqueUnreadSenders"; - - /** - * The Constant UniqueSenders. - */ - public static final String UniqueSenders = "conversation:UniqueSenders"; - - /** - * The Constant GlobalUniqueSenders. - */ - public static final String GlobalUniqueSenders = - "conversation:GlobalUniqueSenders"; - - /** - * The Constant LastDeliveryTime. - */ - public static final String LastDeliveryTime = - "conversation:LastDeliveryTime"; - - /** - * The Constant GlobalLastDeliveryTime. - */ - public static final String GlobalLastDeliveryTime = - "conversation:GlobalLastDeliveryTime"; - - /** - * The Constant Categories. - */ - public static final String Categories = "conversation:Categories"; - - /** - * The Constant GlobalCategories. - */ - public static final String GlobalCategories = - "conversation:GlobalCategories"; - - /** - * The Constant FlagStatus. - */ - public static final String FlagStatus = "conversation:FlagStatus"; - - /** - * The Constant GlobalFlagStatus. - */ - public static final String GlobalFlagStatus = - "conversation:GlobalFlagStatus"; - - /** - * The Constant HasAttachments. - */ - public static final String HasAttachments = - "conversation:HasAttachments"; - - /** - * The Constant GlobalHasAttachments. - */ - public static final String GlobalHasAttachments = - "conversation:GlobalHasAttachments"; - - /** - * The Constant MessageCount. - */ - public static final String MessageCount = "conversation:MessageCount"; - - /** - * The Constant GlobalMessageCount. - */ - public static final String GlobalMessageCount = - "conversation:GlobalMessageCount"; - - /** - * The Constant UnreadCount. - */ - public static final String UnreadCount = "conversation:UnreadCount"; - - /** - * The Constant GlobalUnreadCount. - */ - public static final String GlobalUnreadCount = - "conversation:GlobalUnreadCount"; - - /** - * The Constant Size. - */ - public static final String Size = "conversation:Size"; - - /** - * The Constant GlobalSize. - */ - public static final String GlobalSize = "conversation:GlobalSize"; - - /** - * The Constant ItemClasses. - */ - public static final String ItemClasses = "conversation:ItemClasses"; - - /** - * The Constant GlobalItemClasses. - */ - public static final String GlobalItemClasses = - "conversation:GlobalItemClasses"; - - /** - * The Constant Importance. - */ - public static final String Importance = "conversation:Importance"; - - /** - * The Constant GlobalImportance. - */ - public static final String GlobalImportance = - "conversation:GlobalImportance"; - - /** - * The Constant ItemIds. - */ - public static final String ItemIds = "conversation:ItemIds"; - - /** - * The Constant GlobalItemIds. - */ - public static final String GlobalItemIds = "conversation:GlobalItemIds"; - - } - - - /** - * Defines the Id property. - */ - public static final PropertyDefinition Id = new ComplexPropertyDefinition( - ConversationId.class, - XmlElementNames.ConversationId, FieldUris.ConversationId, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public ConversationId createComplexProperty() { - return new ConversationId(); - } - }); - - /** - * Defines the Topic property. - */ - public static final PropertyDefinition Topic = - new StringPropertyDefinition( - XmlElementNames.ConversationTopic, - FieldUris.ConversationTopic, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the UniqueRecipients property. - */ - public static final PropertyDefinition UniqueRecipients = new - ComplexPropertyDefinition( - StringList.class, - XmlElementNames.UniqueRecipients, - FieldUris.UniqueRecipients, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(); - } - }); - - - /** - * Defines the GlobalUniqueRecipients property. - */ - public static final PropertyDefinition GlobalUniqueRecipients = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.GlobalUniqueRecipients, - FieldUris.GlobalUniqueRecipients, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(); - } - }); - - /** - * Defines the UniqueUnreadSenders property. - */ - public static final PropertyDefinition UniqueUnreadSenders = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.UniqueUnreadSenders, - FieldUris.UniqueUnreadSenders, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(); - } - }); - - /** - * Defines the GlobalUniqueUnreadSenders property. - */ - public static final PropertyDefinition GlobalUniqueUnreadSenders = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.GlobalUniqueUnreadSenders, - FieldUris.GlobalUniqueUnreadSenders, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(); - } - }); - - /** - * Defines the UniqueSenders property. - */ - public static final PropertyDefinition UniqueSenders = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.UniqueSenders, - FieldUris.UniqueSenders, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(); - } - }); - - /** - * Defines the GlobalUniqueSenders property. - */ - public static final PropertyDefinition GlobalUniqueSenders = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.GlobalUniqueSenders, - FieldUris.GlobalUniqueSenders, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(); - } - }); - - /** - * Defines the LastDeliveryTime property. - */ - public static final PropertyDefinition LastDeliveryTime = - new DateTimePropertyDefinition( - XmlElementNames.LastDeliveryTime, - FieldUris.LastDeliveryTime, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the GlobalLastDeliveryTime property. - */ - public static final PropertyDefinition GlobalLastDeliveryTime = - new DateTimePropertyDefinition( - XmlElementNames.GlobalLastDeliveryTime, - FieldUris.GlobalLastDeliveryTime, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the Categories property. - */ - public static final PropertyDefinition Categories = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.Categories, - FieldUris.Categories, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(); - } - }); - - /** - * Defines the GlobalCategories property. - */ - public static final PropertyDefinition GlobalCategories = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.GlobalCategories, - FieldUris.GlobalCategories, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(); - } - }); - - /** - * Defines the FlagStatus property. - */ - public static final PropertyDefinition FlagStatus = - new GenericPropertyDefinition( - ConversationFlagStatus.class, - XmlElementNames.FlagStatus, - FieldUris.FlagStatus, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the GlobalFlagStatus property. - */ - public static final PropertyDefinition GlobalFlagStatus = - new GenericPropertyDefinition( - ConversationFlagStatus.class, - XmlElementNames.GlobalFlagStatus, - FieldUris.GlobalFlagStatus, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the HasAttachments property. - */ - public static final PropertyDefinition HasAttachments = - new BoolPropertyDefinition( - XmlElementNames.HasAttachments, - FieldUris.HasAttachments, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the GlobalHasAttachments property. - */ - public static final PropertyDefinition GlobalHasAttachments = - new BoolPropertyDefinition( - XmlElementNames.GlobalHasAttachments, - FieldUris.GlobalHasAttachments, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the MessageCount property. - */ - public static final PropertyDefinition MessageCount = - new IntPropertyDefinition( - XmlElementNames.MessageCount, - FieldUris.MessageCount, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the GlobalMessageCount property. - */ - public static final PropertyDefinition GlobalMessageCount = - new IntPropertyDefinition( - XmlElementNames.GlobalMessageCount, - FieldUris.GlobalMessageCount, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the UnreadCount property. - */ - public static final PropertyDefinition UnreadCount = - new IntPropertyDefinition( - XmlElementNames.UnreadCount, - FieldUris.UnreadCount, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the GlobalUnreadCount property. - */ - public static final PropertyDefinition GlobalUnreadCount = - new IntPropertyDefinition( - XmlElementNames.GlobalUnreadCount, - FieldUris.GlobalUnreadCount, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the Size property. - */ - public static final PropertyDefinition Size = - new IntPropertyDefinition( - XmlElementNames.Size, - FieldUris.Size, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the GlobalSize property. - */ - public static final PropertyDefinition GlobalSize = - new IntPropertyDefinition( - XmlElementNames.GlobalSize, - FieldUris.GlobalSize, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the ItemClasses property. - */ - public static final PropertyDefinition ItemClasses = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.ItemClasses, - FieldUris.ItemClasses, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(XmlElementNames. - ItemClass); - } - }); - - /** - * Defines the GlobalItemClasses property. - */ - public static final PropertyDefinition GlobalItemClasses = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.GlobalItemClasses, - FieldUris.GlobalItemClasses, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(XmlElementNames. - ItemClass); - } - }); - - /** - * Defines the Importance property. - */ - public static final PropertyDefinition Importance = - new GenericPropertyDefinition( - Importance.class, - XmlElementNames.Importance, - FieldUris.Importance, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the GlobalImportance property. - */ - public static final PropertyDefinition GlobalImportance = - new GenericPropertyDefinition( - Importance.class, - XmlElementNames.GlobalImportance, - FieldUris.GlobalImportance, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1); - - /** - * Defines the ItemIds property. - */ - public static final PropertyDefinition ItemIds = - new ComplexPropertyDefinition( - ItemIdCollection.class, - XmlElementNames.ItemIds, - FieldUris.ItemIds, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public ItemIdCollection createComplexProperty() { - return new ItemIdCollection(); - } - }); - - /** - * Defines the GlobalItemIds property. - */ - public static final PropertyDefinition GlobalItemIds = - new ComplexPropertyDefinition( - ItemIdCollection.class, - XmlElementNames.GlobalItemIds, - FieldUris.GlobalItemIds, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP1, - new ICreateComplexPropertyDelegate() { - public ItemIdCollection createComplexProperty() { - return new ItemIdCollection(); - } - }); - - /** - * This must be declared after the property definitions - */ - public static final ConversationSchema Instance = - new ConversationSchema(); - - /** - * Registers property. - */ - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(Id); - this.registerProperty(Topic); - this.registerProperty(UniqueRecipients); - this.registerProperty(GlobalUniqueRecipients); - this.registerProperty(UniqueUnreadSenders); - this.registerProperty(GlobalUniqueUnreadSenders); - this.registerProperty(UniqueSenders); - this.registerProperty(GlobalUniqueSenders); - this.registerProperty(LastDeliveryTime); - this.registerProperty(GlobalLastDeliveryTime); - this.registerProperty(Categories); - this.registerProperty(GlobalCategories); - this.registerProperty(FlagStatus); - this.registerProperty(GlobalFlagStatus); - this.registerProperty(HasAttachments); - this.registerProperty(GlobalHasAttachments); - this.registerProperty(MessageCount); - this.registerProperty(GlobalMessageCount); - this.registerProperty(UnreadCount); - this.registerProperty(GlobalUnreadCount); - this.registerProperty(Size); - this.registerProperty(GlobalSize); - this.registerProperty(ItemClasses); - this.registerProperty(GlobalItemClasses); - this.registerProperty(Importance); - this.registerProperty(GlobalImportance); - this.registerProperty(ItemIds); - this.registerProperty(GlobalItemIds); - } - - /** - * Initializes a new instance of - * the ConversationSchema class. - */ - protected ConversationSchema() { - super(); - } - - - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/EmailMessageSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/EmailMessageSchema.java deleted file mode 100644 index 6de408b4e..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/EmailMessageSchema.java +++ /dev/null @@ -1,422 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.Schema; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; -import microsoft.exchange.webservices.data.property.complex.EmailAddressCollection; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.definition.BoolPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ByteArrayPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ContainedPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.StringPropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents the schema for e-mail messages. - */ -@Schema -public class EmailMessageSchema extends ItemSchema { - - /** - * The Interface FieldUris. - */ - private static interface FieldUris { - - /** - * The Conversation index. - */ - String ConversationIndex = "message:ConversationIndex"; - - /** - * The Conversation topic. - */ - String ConversationTopic = "message:ConversationTopic"; - - /** - * The Internet message id. - */ - String InternetMessageId = "message:InternetMessageId"; - - /** - * The Is read. - */ - String IsRead = "message:IsRead"; - - /** - * The Is response requested. - */ - String IsResponseRequested = "message:IsResponseRequested"; - - /** - * The Is read receipt requested. - */ - String IsReadReceiptRequested = "message:IsReadReceiptRequested"; - - /** - * The Is delivery receipt requested. - */ - String IsDeliveryReceiptRequested = - "message:IsDeliveryReceiptRequested"; - - /** - * The References. - */ - String References = "message:References"; - - /** - * The Reply to. - */ - String ReplyTo = "message:ReplyTo"; - - /** - * The From. - */ - String From = "message:From"; - - /** - * The Sender. - */ - String Sender = "message:Sender"; - - /** - * The To recipients. - */ - String ToRecipients = "message:ToRecipients"; - - /** - * The Cc recipients. - */ - String CcRecipients = "message:CcRecipients"; - - /** - * The Bcc recipients. - */ - String BccRecipients = "message:BccRecipients"; - - /** - * The Received by. - */ - String ReceivedBy = "message:ReceivedBy"; - - /** - * The Received representing. - */ - String ReceivedRepresenting = "message:ReceivedRepresenting"; - } - - - /** - * Defines the ToRecipients property. - */ - public static final PropertyDefinition ToRecipients = - new ComplexPropertyDefinition( - EmailAddressCollection.class, - XmlElementNames.ToRecipients, - FieldUris.ToRecipients, - EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public EmailAddressCollection createComplexProperty() { - return new EmailAddressCollection(); - } - }); - - /** - * Defines the BccRecipients property. - */ - public static final PropertyDefinition BccRecipients = - new ComplexPropertyDefinition( - EmailAddressCollection.class, - XmlElementNames.BccRecipients, - FieldUris.BccRecipients, - EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate - () { - @Override - public EmailAddressCollection createComplexProperty() { - return new EmailAddressCollection(); - } - }); - - /** - * Defines the CcRecipients property. - */ - public static final PropertyDefinition CcRecipients = - new ComplexPropertyDefinition( - EmailAddressCollection.class, - XmlElementNames.CcRecipients, - FieldUris.CcRecipients, - EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate - () { - @Override - public EmailAddressCollection createComplexProperty() { - return new EmailAddressCollection(); - } - }); - - /** - * Defines the ConversationIndex property. - */ - public static final PropertyDefinition ConversationIndex = - new ByteArrayPropertyDefinition( - XmlElementNames.ConversationIndex, FieldUris.ConversationIndex, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the ConversationTopic property. - */ - public static final PropertyDefinition ConversationTopic = - new StringPropertyDefinition( - XmlElementNames.ConversationTopic, FieldUris.ConversationTopic, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the From property. - */ - public static final PropertyDefinition From = - new ContainedPropertyDefinition( - EmailAddress.class, - XmlElementNames.From, FieldUris.From, XmlElementNames.Mailbox, - EnumSet.of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public EmailAddress createComplexProperty() { - return new EmailAddress(); - } - }); - - /** - * Defines the IsDeliveryReceiptRequested property. - */ - public static final PropertyDefinition IsDeliveryReceiptRequested = - new BoolPropertyDefinition( - XmlElementNames.IsDeliveryReceiptRequested, - FieldUris.IsDeliveryReceiptRequested, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsRead property. - */ - public static final PropertyDefinition IsRead = new BoolPropertyDefinition( - XmlElementNames.IsRead, FieldUris.IsRead, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsReadReceiptRequested property. - */ - public static final PropertyDefinition IsReadReceiptRequested = - new BoolPropertyDefinition( - XmlElementNames.IsReadReceiptRequested, - FieldUris.IsReadReceiptRequested, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsResponseRequested property. - */ - public static final PropertyDefinition IsResponseRequested = - new BoolPropertyDefinition( - XmlElementNames.IsResponseRequested, FieldUris.IsResponseRequested, - EnumSet.of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, true); // isNullable - - /** - * Defines the InternetMessageId property. - */ - public static final PropertyDefinition InternetMessageId = - new StringPropertyDefinition( - XmlElementNames.InternetMessageId, FieldUris.InternetMessageId, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the References property. - */ - public static final PropertyDefinition References = - new StringPropertyDefinition( - XmlElementNames.References, FieldUris.References, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the ReplyTo property. - */ - public static final PropertyDefinition ReplyTo = - new ComplexPropertyDefinition( - EmailAddressCollection.class, - XmlElementNames.ReplyTo, - FieldUris.ReplyTo, - EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate - () { - @Override - public EmailAddressCollection createComplexProperty() { - return new EmailAddressCollection(); - } - }); - - /** - * Defines the Sender property. - */ - public static final PropertyDefinition Sender = - new ContainedPropertyDefinition( - EmailAddress.class, - XmlElementNames.Sender, FieldUris.Sender, XmlElementNames.Mailbox, - EnumSet.of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public EmailAddress createComplexProperty() { - return new EmailAddress(); - } - }); - - /** - * Defines the ReceivedBy property. - */ - public static final PropertyDefinition ReceivedBy = - new ContainedPropertyDefinition( - EmailAddress.class, - XmlElementNames.ReceivedBy, FieldUris.ReceivedBy, - XmlElementNames.Mailbox, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public EmailAddress createComplexProperty() { - return new EmailAddress(); - } - }); - - /** - * Defines the ReceivedRepresenting property. - */ - public static final PropertyDefinition ReceivedRepresenting = - new ContainedPropertyDefinition( - EmailAddress.class, - XmlElementNames.ReceivedRepresenting, - FieldUris.ReceivedRepresenting, XmlElementNames.Mailbox, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public EmailAddress createComplexProperty() { - return new EmailAddress(); - } - }); - - /** - * The Constant Instance. - */ - public static final EmailMessageSchema Instance = - new EmailMessageSchema(); - - /** - * Gets the single instance of EmailMessageSchema. - * - * @return single instance of EmailMessageSchema - */ - public static EmailMessageSchema getInstance() { - return Instance; - } - - /** - * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN - * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd) - */ - @Override - protected void registerProperties() { - super.registerProperties(); - this.registerProperty(Sender); - this.registerProperty(ToRecipients); - this.registerProperty(CcRecipients); - this.registerProperty(BccRecipients); - this.registerProperty(IsReadReceiptRequested); - this.registerProperty(IsDeliveryReceiptRequested); - this.registerProperty(ConversationIndex); - this.registerProperty(ConversationTopic); - this.registerProperty(From); - this.registerProperty(InternetMessageId); - this.registerProperty(IsRead); - this.registerProperty(IsResponseRequested); - this.registerProperty(References); - this.registerProperty(ReplyTo); - this.registerProperty(ReceivedBy); - this.registerProperty(ReceivedRepresenting); - } - - /** - * Initializes a new instance. - */ - protected EmailMessageSchema() { - super(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/FolderSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/FolderSchema.java deleted file mode 100644 index 0388baad6..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/FolderSchema.java +++ /dev/null @@ -1,251 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.Schema; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.complex.ManagedFolderInformation; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.EffectiveRightsPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.IntPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PermissionSetPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.StringPropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents the schema for folder. - */ -@Schema -public class FolderSchema extends ServiceObjectSchema { - - /** - * Field URIs for folder. - */ - private static class FieldUris { - - /** - * The Constant FolderId. - */ - public final static String FolderId = "folder:FolderId"; - - /** - * The Constant ParentFolderId. - */ - public final static String ParentFolderId = "folder:ParentFolderId"; - - /** - * The Constant DisplayName. - */ - public final static String DisplayName = "folder:DisplayName"; - - /** - * The Constant UnreadCount. - */ - public final static String UnreadCount = "folder:UnreadCount"; - - /** - * The Constant TotalCount. - */ - public final static String TotalCount = "folder:TotalCount"; - - /** - * The Constant ChildFolderCount. - */ - public final static String ChildFolderCount = "folder:ChildFolderCount"; - - /** - * The Constant FolderClass. - */ - public final static String FolderClass = "folder:FolderClass"; - - /** - * The Constant ManagedFolderInformation. - */ - public final static String ManagedFolderInformation = - "folder:ManagedFolderInformation"; - - /** - * The Constant EffectiveRights. - */ - public final static String EffectiveRights = "folder:EffectiveRights"; - - /** - * The Constant PermissionSet. - */ - public final static String PermissionSet = "folder:PermissionSet"; - } - - - /** - * Defines the Id property. - */ - public static final PropertyDefinition Id = - new ComplexPropertyDefinition( - FolderId.class, - XmlElementNames.FolderId, FieldUris.FolderId, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public FolderId createComplexProperty() { - return new FolderId(); - } - } - - ); - - /** - * Defines the FolderClass property. - */ - public static final PropertyDefinition FolderClass = - new StringPropertyDefinition( - XmlElementNames.FolderClass, FieldUris.FolderClass, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the ParentFolderId property. - */ - public static final PropertyDefinition ParentFolderId = - new ComplexPropertyDefinition( - FolderId.class, - XmlElementNames.ParentFolderId, FieldUris.ParentFolderId, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public FolderId createComplexProperty() { - return new FolderId(); - } - }); - - /** - * Defines the ChildFolderCount property. - */ - public static final PropertyDefinition ChildFolderCount = - new IntPropertyDefinition( - XmlElementNames.ChildFolderCount, FieldUris.ChildFolderCount, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the DisplayName property. - */ - public static final PropertyDefinition DisplayName = - new StringPropertyDefinition( - XmlElementNames.DisplayName, FieldUris.DisplayName, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the UnreadCount property. - */ - public static final PropertyDefinition UnreadCount = - new IntPropertyDefinition( - XmlElementNames.UnreadCount, FieldUris.UnreadCount, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the TotalCount property. - */ - public static final PropertyDefinition TotalCount = - new IntPropertyDefinition( - XmlElementNames.TotalCount, FieldUris.TotalCount, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the ManagedFolderInformation property. - */ - public static final PropertyDefinition ManagedFolderInformation = - new ComplexPropertyDefinition( - ManagedFolderInformation.class, - XmlElementNames.ManagedFolderInformation, - FieldUris.ManagedFolderInformation, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate - () { - public ManagedFolderInformation createComplexProperty() { - return new ManagedFolderInformation(); - } - }); - - /** - * Defines the EffectiveRights property. - */ - public static final PropertyDefinition EffectiveRights = - new EffectiveRightsPropertyDefinition( - XmlElementNames.EffectiveRights, FieldUris.EffectiveRights, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Permissions property. - */ - public static final PropertyDefinition Permissions = - new PermissionSetPropertyDefinition( - XmlElementNames.PermissionSet, FieldUris.PermissionSet, EnumSet.of( - PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete), - ExchangeVersion.Exchange2007_SP1); - - /** - * This must be declared after the property definitions. - */ - public static final FolderSchema Instance = new FolderSchema(); - - /** - * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN - * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd) - */ - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(Id); - this.registerProperty(ParentFolderId); - this.registerProperty(FolderClass); - this.registerProperty(DisplayName); - this.registerProperty(TotalCount); - this.registerProperty(ChildFolderCount); - this.registerProperty(ServiceObjectSchema.extendedProperties); - this.registerProperty(ManagedFolderInformation); - this.registerProperty(EffectiveRights); - this.registerProperty(Permissions); - this.registerProperty(UnreadCount); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ItemSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ItemSchema.java deleted file mode 100644 index 1cde6fad2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ItemSchema.java +++ /dev/null @@ -1,753 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.Schema; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.Importance; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.core.enumeration.property.Sensitivity; -import microsoft.exchange.webservices.data.property.complex.ConversationId; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.complex.InternetMessageHeaderCollection; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.MessageBody; -import microsoft.exchange.webservices.data.property.complex.MimeContent; -import microsoft.exchange.webservices.data.property.complex.StringList; -import microsoft.exchange.webservices.data.property.complex.UniqueBody; -import microsoft.exchange.webservices.data.property.definition.AttachmentsPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.BoolPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ByteArrayPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.DateTimePropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.EffectiveRightsPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.GenericPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.IntPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ResponseObjectsPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.StringPropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents the schema for generic item. - */ -@Schema -public class ItemSchema extends ServiceObjectSchema { - - /** - * The Interface FieldUris. - */ - private static interface FieldUris { - - /** - * The Item id. - */ - String ItemId = "item:ItemId"; - - /** - * The Parent folder id. - */ - String ParentFolderId = "item:ParentFolderId"; - - /** - * The Item class. - */ - String ItemClass = "item:ItemClass"; - - /** - * The Mime content. - */ - String MimeContent = "item:MimeContent"; - - /** - * The Attachments. - */ - String Attachments = "item:Attachments"; - - /** - * The Subject. - */ - String Subject = "item:Subject"; - - /** - * The Date time received. - */ - String DateTimeReceived = "item:DateTimeReceived"; - - /** - * The Size. - */ - String Size = "item:Size"; - - /** - * The Categories. - */ - String Categories = "item:Categories"; - - /** - * The Has attachments. - */ - String HasAttachments = "item:HasAttachments"; - - /** - * The Importance. - */ - String Importance = "item:Importance"; - - /** - * The In reply to. - */ - String InReplyTo = "item:InReplyTo"; - - /** - * The Internet message headers. - */ - String InternetMessageHeaders = "item:InternetMessageHeaders"; - - /** - * The Is associated. - */ - String IsAssociated = "item:IsAssociated"; - - /** - * The Is draft. - */ - String IsDraft = "item:IsDraft"; - - /** - * The Is from me. - */ - String IsFromMe = "item:IsFromMe"; - - /** - * The Is resend. - */ - String IsResend = "item:IsResend"; - - /** - * The Is submitted. - */ - String IsSubmitted = "item:IsSubmitted"; - - /** - * The Is unmodified. - */ - String IsUnmodified = "item:IsUnmodified"; - - /** - * The Date time sent. - */ - String DateTimeSent = "item:DateTimeSent"; - - /** - * The Date time created. - */ - String DateTimeCreated = "item:DateTimeCreated"; - - /** - * The Body. - */ - String Body = "item:Body"; - - /** - * The Response objects. - */ - String ResponseObjects = "item:ResponseObjects"; - - /** - * The Sensitivity. - */ - String Sensitivity = "item:Sensitivity"; - - /** - * The Reminder due by. - */ - String ReminderDueBy = "item:ReminderDueBy"; - - /** - * The Reminder is set. - */ - String ReminderIsSet = "item:ReminderIsSet"; - - /** - * The Reminder minutes before start. - */ - String ReminderMinutesBeforeStart = "item:ReminderMinutesBeforeStart"; - - /** - * The Display to. - */ - String DisplayTo = "item:DisplayTo"; - - /** - * The Display cc. - */ - String DisplayCc = "item:DisplayCc"; - - /** - * The Culture. - */ - String Culture = "item:Culture"; - - /** - * The Effective rights. - */ - String EffectiveRights = "item:EffectiveRights"; - - /** - * The Last modified name. - */ - String LastModifiedName = "item:LastModifiedName"; - - /** - * The Last modified time. - */ - String LastModifiedTime = "item:LastModifiedTime"; - - /** - * The Web client read form query string. - */ - String WebClientReadFormQueryString = - "item:WebClientReadFormQueryString"; - - /** - * The Web client edit form query string. - */ - String WebClientEditFormQueryString = - "item:WebClientEditFormQueryString"; - - /** - * The Conversation id. - */ - String ConversationId = "item:ConversationId"; - - /** - * The Unique body. - */ - String UniqueBody = "item:UniqueBody"; - - String StoreEntryId = "item:StoreEntryId"; - } - - - /** - * Defines the Id property. - */ - public static final PropertyDefinition Id = new ComplexPropertyDefinition( - ItemId.class, - XmlElementNames.ItemId, FieldUris.ItemId, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public ItemId createComplexProperty() { - return new ItemId(); - } - }); - - /** - * Defines the Body property. - */ - public static final PropertyDefinition Body = new - ComplexPropertyDefinition( - MessageBody.class, - XmlElementNames.Body, FieldUris.Body, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public MessageBody createComplexProperty() { - return new MessageBody(); - } - }); - - /** - * Defines the ItemClass property. - */ - public static final PropertyDefinition ItemClass = new StringPropertyDefinition( - XmlElementNames.ItemClass, FieldUris.ItemClass, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Subject property. - */ - public static final PropertyDefinition Subject = new - StringPropertyDefinition( - XmlElementNames.Subject, FieldUris.Subject, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the MimeContent property. - */ - public static final PropertyDefinition MimeContent = - new ComplexPropertyDefinition( - MimeContent.class, - XmlElementNames.MimeContent, FieldUris.MimeContent, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.MustBeExplicitlyLoaded), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public MimeContent createComplexProperty() { - return new MimeContent(); - } - }); - - /** - * Defines the ParentFolderId property. - */ - public static final PropertyDefinition ParentFolderId = - new ComplexPropertyDefinition( - FolderId.class, - XmlElementNames.ParentFolderId, FieldUris.ParentFolderId, - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public FolderId createComplexProperty() { - return new FolderId(); - } - }); - - /** - * Defines the Sensitivity property. - */ - public static final PropertyDefinition Sensitivity = - new GenericPropertyDefinition( - Sensitivity.class, - XmlElementNames.Sensitivity, FieldUris.Sensitivity, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Attachments property. - */ - public static final PropertyDefinition Attachments = new AttachmentsPropertyDefinition(); - - /** - * Defines the DateTimeReceived property. - */ - public static final PropertyDefinition DateTimeReceived = - new DateTimePropertyDefinition( - XmlElementNames.DateTimeReceived, FieldUris.DateTimeReceived, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Size property. - */ - public static final PropertyDefinition Size = new IntPropertyDefinition( - XmlElementNames.Size, FieldUris.Size, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Categories property. - */ - public static final PropertyDefinition Categories = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.Categories, FieldUris.Categories, EnumSet.of( - PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(); - } - }); - - /** - * Defines the Importance property. - */ - public static final PropertyDefinition Importance = - new GenericPropertyDefinition( - Importance.class, - XmlElementNames.Importance, FieldUris.Importance, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the InReplyTo property. - */ - public static final PropertyDefinition InReplyTo = - new StringPropertyDefinition( - XmlElementNames.InReplyTo, FieldUris.InReplyTo, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsSubmitted property. - */ - public static final PropertyDefinition IsSubmitted = - new BoolPropertyDefinition( - XmlElementNames.IsSubmitted, FieldUris.IsSubmitted, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsAssociated property. - */ - public static final PropertyDefinition IsAssociated = - new BoolPropertyDefinition( - XmlElementNames.IsAssociated, FieldUris.IsAssociated, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010); - - /** - * Defines the IsDraft property. - */ - public static final PropertyDefinition IsDraft = new BoolPropertyDefinition( - XmlElementNames.IsDraft, FieldUris.IsDraft, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsFromMe property. - */ - public static final PropertyDefinition IsFromMe = - new BoolPropertyDefinition( - XmlElementNames.IsFromMe, FieldUris.IsFromMe, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsResend property. - */ - public static final PropertyDefinition IsResend = - new BoolPropertyDefinition( - XmlElementNames.IsResend, FieldUris.IsResend, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsUnmodified property. - */ - public static final PropertyDefinition IsUnmodified = - new BoolPropertyDefinition( - XmlElementNames.IsUnmodified, FieldUris.IsUnmodified, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the InternetMessageHeaders property. - */ - public static final PropertyDefinition InternetMessageHeaders = - new ComplexPropertyDefinition( - InternetMessageHeaderCollection.class, - XmlElementNames.InternetMessageHeaders, - FieldUris.InternetMessageHeaders, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate - () { - public InternetMessageHeaderCollection createComplexProperty() { - return new InternetMessageHeaderCollection(); - } - }); - - /** - * Defines the DateTimeSent property. - */ - public static final PropertyDefinition DateTimeSent = - new DateTimePropertyDefinition( - XmlElementNames.DateTimeSent, FieldUris.DateTimeSent, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the DateTimeCreated property. - */ - public static final PropertyDefinition DateTimeCreated = - new DateTimePropertyDefinition( - XmlElementNames.DateTimeCreated, FieldUris.DateTimeCreated, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the AllowedResponseActions property. - */ - public static final PropertyDefinition AllowedResponseActions = - new ResponseObjectsPropertyDefinition( - XmlElementNames.ResponseObjects, FieldUris.ResponseObjects, - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the ReminderDueBy property. - */ - - public static final PropertyDefinition ReminderDueBy = - new DateTimePropertyDefinition( - XmlElementNames.ReminderDueBy, FieldUris.ReminderDueBy, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsReminderSet property. - */ - public static final PropertyDefinition IsReminderSet = - new BoolPropertyDefinition( - XmlElementNames.ReminderIsSet, // Note: server-side the name is - // ReminderIsSet - FieldUris.ReminderIsSet, EnumSet.of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the ReminderMinutesBeforeStart property. - */ - public static final PropertyDefinition ReminderMinutesBeforeStart = - new IntPropertyDefinition( - XmlElementNames.ReminderMinutesBeforeStart, - FieldUris.ReminderMinutesBeforeStart, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the DisplayCc property. - */ - public static final PropertyDefinition DisplayCc = - new StringPropertyDefinition( - XmlElementNames.DisplayCc, FieldUris.DisplayCc, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the DisplayTo property. - */ - public static final PropertyDefinition DisplayTo = - new StringPropertyDefinition( - XmlElementNames.DisplayTo, FieldUris.DisplayTo, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the HasAttachments property. - */ - public static final PropertyDefinition HasAttachments = - new BoolPropertyDefinition( - XmlElementNames.HasAttachments, FieldUris.HasAttachments, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Culture property. - */ - public static final PropertyDefinition Culture = - new StringPropertyDefinition( - XmlElementNames.Culture, FieldUris.Culture, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the EffectiveRights property. - */ - public static final PropertyDefinition EffectiveRights = - new EffectiveRightsPropertyDefinition( - XmlElementNames.EffectiveRights, FieldUris.EffectiveRights, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the LastModifiedName property. - */ - public static final PropertyDefinition LastModifiedName = - new StringPropertyDefinition( - XmlElementNames.LastModifiedName, FieldUris.LastModifiedName, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the LastModifiedTime property. - */ - public static final PropertyDefinition LastModifiedTime = - new DateTimePropertyDefinition( - XmlElementNames.LastModifiedTime, FieldUris.LastModifiedTime, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the WebClientReadFormQueryString property. - */ - public static final PropertyDefinition WebClientReadFormQueryString = - new StringPropertyDefinition( - XmlElementNames.WebClientReadFormQueryString, - FieldUris.WebClientReadFormQueryString, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010); - - /** - * Defines the WebClientEditFormQueryString property. - */ - public static final PropertyDefinition WebClientEditFormQueryString = - new StringPropertyDefinition( - XmlElementNames.WebClientEditFormQueryString, - FieldUris.WebClientEditFormQueryString, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010); - - /** - * Defines the ConversationId property. - */ - public static final PropertyDefinition ConversationId = - new ComplexPropertyDefinition( - ConversationId.class, - XmlElementNames.ConversationId, FieldUris.ConversationId, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010, - new ICreateComplexPropertyDelegate() { - public ConversationId createComplexProperty() { - return new ConversationId(); - } - }); - - /** - * Defines the UniqueBody property. - */ - public static final PropertyDefinition UniqueBody = - new ComplexPropertyDefinition( - UniqueBody.class, - XmlElementNames.UniqueBody, FieldUris.UniqueBody, EnumSet - .of(PropertyDefinitionFlags.MustBeExplicitlyLoaded), - ExchangeVersion.Exchange2010, - new ICreateComplexPropertyDelegate() { - public UniqueBody createComplexProperty() { - return new UniqueBody(); - } - }); - - /** - * Defines the StoreEntryId property. - */ - - public static final PropertyDefinition StoreEntryId = - new ByteArrayPropertyDefinition( - XmlElementNames.StoreEntryId, - FieldUris.StoreEntryId, - EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2010_SP2); - - - - /** - * The Constant Instance. - */ - protected static final ItemSchema Instance = new ItemSchema(); - - /** - * Gets the single instance of ItemSchema. - * - * @return single instance of ItemSchema - */ - public static ItemSchema getInstance() { - return Instance; - } - - /** - * Registers property. - *

- * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the - * same order as they are defined in types.xsd) - *

- */ - @Override - protected void registerProperties() { - super.registerProperties(); - this.registerProperty(MimeContent); - this.registerProperty(Id); - this.registerProperty(ParentFolderId); - this.registerProperty(ItemClass); - this.registerProperty(Subject); - this.registerProperty(Sensitivity); - this.registerProperty(Body); - this.registerProperty(Attachments); - this.registerProperty(DateTimeReceived); - this.registerProperty(Size); - this.registerProperty(Categories); - this.registerProperty(Importance); - this.registerProperty(InReplyTo); - this.registerProperty(IsSubmitted); - this.registerProperty(IsDraft); - this.registerProperty(IsFromMe); - this.registerProperty(IsResend); - this.registerProperty(IsUnmodified); - this.registerProperty(InternetMessageHeaders); - this.registerProperty(DateTimeSent); - this.registerProperty(DateTimeCreated); - this.registerProperty(AllowedResponseActions); - this.registerProperty(ReminderDueBy); - this.registerProperty(IsReminderSet); - this.registerProperty(ReminderMinutesBeforeStart); - this.registerProperty(DisplayCc); - this.registerProperty(DisplayTo); - this.registerProperty(HasAttachments); - this.registerProperty(ServiceObjectSchema.extendedProperties); - this.registerProperty(Culture); - this.registerProperty(EffectiveRights); - this.registerProperty(LastModifiedName); - this.registerProperty(LastModifiedTime); - this.registerProperty(IsAssociated); - this.registerProperty(WebClientReadFormQueryString); - this.registerProperty(WebClientEditFormQueryString); - this.registerProperty(ConversationId); - this.registerProperty(UniqueBody); - this.registerProperty(StoreEntryId); - - } - - /** - * Initializes a new instance. - */ - protected ItemSchema() { - super(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/MeetingMessageSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/MeetingMessageSchema.java deleted file mode 100644 index 21b927459..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/MeetingMessageSchema.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.Schema; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.MeetingResponseType; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.definition.BoolPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.GenericPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents the schema for meeting messages. - */ -@Schema -public class MeetingMessageSchema extends EmailMessageSchema { - - /** - * Field URIs for MeetingMessage. - */ - private static interface FieldUris { - - /** - * The Associated calendar item id. - */ - String AssociatedCalendarItemId = "meeting:AssociatedCalendarItemId"; - - /** - * The Is delegated. - */ - String IsDelegated = "meeting:IsDelegated"; - - /** - * The Is out of date. - */ - String IsOutOfDate = "meeting:IsOutOfDate"; - - /** - * The Has been processed. - */ - String HasBeenProcessed = "meeting:HasBeenProcessed"; - - /** - * The Response type. - */ - String ResponseType = "meeting:ResponseType"; - } - - - /** - * Defines the AssociatedAppointmentId property. - */ - public static final PropertyDefinition AssociatedAppointmentId = - new ComplexPropertyDefinition( - // ItemId.class, - XmlElementNames.AssociatedCalendarItemId, - FieldUris.AssociatedCalendarItemId, - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public ItemId createComplexProperty() { - return new ItemId(); - } - }); - - /** - * Defines the IsDelegated property. - */ - public static final PropertyDefinition IsDelegated = - new BoolPropertyDefinition( - XmlElementNames.IsDelegated, FieldUris.IsDelegated, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsOutOfDate property. - */ - public static final PropertyDefinition IsOutOfDate = - new BoolPropertyDefinition( - XmlElementNames.IsOutOfDate, FieldUris.IsOutOfDate, - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the HasBeenProcessed property. - */ - public static final PropertyDefinition HasBeenProcessed = - new BoolPropertyDefinition( - XmlElementNames.HasBeenProcessed, FieldUris.HasBeenProcessed, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the ResponseType property. - */ - public static final PropertyDefinition ResponseType = - new GenericPropertyDefinition( - MeetingResponseType.class, - XmlElementNames.ResponseType, FieldUris.ResponseType, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the ICalendar Uid property. - */ - public static final PropertyDefinition ICalUid = AppointmentSchema.ICalUid; - - /** - * Defines the ICalendar RecurrenceId property. - */ - public static final PropertyDefinition ICalRecurrenceId = - AppointmentSchema.ICalRecurrenceId; - - /** - * Defines the ICalendar DateTimeStamp property. - */ - public static final PropertyDefinition ICalDateTimeStamp = - AppointmentSchema.ICalDateTimeStamp; - - /** - * This must be after the declaration of property definitions. - */ - protected static final MeetingMessageSchema Instance = - new MeetingMessageSchema(); - - /** - * Gets the single instance of MeetingMessageSchema. - * - * @return single instance of MeetingMessageSchema - */ - public static MeetingMessageSchema getInstance() { - return Instance; - } - - /** - * Registers property. - *

- * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the - * same order as they are defined in types.xsd) - */ - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(AssociatedAppointmentId); - this.registerProperty(IsDelegated); - this.registerProperty(IsOutOfDate); - this.registerProperty(HasBeenProcessed); - this.registerProperty(ResponseType); - this.registerProperty(ICalUid); - this.registerProperty(ICalRecurrenceId); - this.registerProperty(ICalDateTimeStamp); - } - - /** - * Initializes a new instance of the class. - */ - protected MeetingMessageSchema() { - super(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/MeetingRequestSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/MeetingRequestSchema.java deleted file mode 100644 index bca9b18b6..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/MeetingRequestSchema.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.Schema; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.LegacyFreeBusyStatus; -import microsoft.exchange.webservices.data.core.enumeration.service.MeetingRequestType; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.definition.GenericPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents the schema for meeting request. - */ -@Schema -public class MeetingRequestSchema extends MeetingMessageSchema { - - /** - * Field URIs for MeetingRequest. - */ - private static interface FieldUris { - - /** - * The Meeting request type. - */ - String MeetingRequestType = "meetingRequest:MeetingRequestType"; - - /** - * The Intended free busy status. - */ - String IntendedFreeBusyStatus = "meetingRequest:IntendedFreeBusyStatus"; - } - - - /** - * Defines the MeetingRequestType property. - */ - public static final PropertyDefinition MeetingRequestType = - new GenericPropertyDefinition( - MeetingRequestType.class, - XmlElementNames.MeetingRequestType, FieldUris.MeetingRequestType, - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IntendedFreeBusyStatus property. - */ - public static final PropertyDefinition IntendedFreeBusyStatus = - new GenericPropertyDefinition( - LegacyFreeBusyStatus.class, - XmlElementNames.IntendedFreeBusyStatus, - FieldUris.IntendedFreeBusyStatus, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Start property. - */ - public static final PropertyDefinition Start = AppointmentSchema.Start; - - /** - * Defines the End property. - */ - public static final PropertyDefinition End = AppointmentSchema.End; - - /** - * Defines the OriginalStart property. - */ - public static final PropertyDefinition OriginalStart = - AppointmentSchema.OriginalStart; - - /** - * Defines the IsAllDayEvent property. - */ - public static final PropertyDefinition IsAllDayEvent = - AppointmentSchema.IsAllDayEvent; - - /** - * Defines the LegacyFreeBusyStatus property. - */ - public static final PropertyDefinition LegacyFreeBusyStatus = - AppointmentSchema.LegacyFreeBusyStatus; - - /** - * Defines the Location property. - */ - public static final PropertyDefinition Location = - AppointmentSchema.Location; - - /** - * Defines the When property. - */ - public static final PropertyDefinition When = AppointmentSchema.When; - - /** - * Defines the IsMeeting property. - */ - public static final PropertyDefinition IsMeeting = - AppointmentSchema.IsMeeting; - - /** - * Defines the IsCancelled property. - */ - public static final PropertyDefinition IsCancelled = - AppointmentSchema.IsCancelled; - - /** - * Defines the IsRecurring property. - */ - public static final PropertyDefinition IsRecurring = - AppointmentSchema.IsRecurring; - - /** - * Defines the MeetingRequestWasSent property. - */ - public static final PropertyDefinition MeetingRequestWasSent = - AppointmentSchema.MeetingRequestWasSent; - - /** - * Defines the AppointmentType property. - */ - public static final PropertyDefinition AppointmentType = - AppointmentSchema.AppointmentType; - - /** - * Defines the MyResponseType property. - */ - public static final PropertyDefinition MyResponseType = - AppointmentSchema.MyResponseType; - - /** - * Defines the Organizer property. - */ - public static final PropertyDefinition Organizer = - AppointmentSchema.Organizer; - - /** - * Defines the RequiredAttendees property. - */ - public static final PropertyDefinition RequiredAttendees = - AppointmentSchema.RequiredAttendees; - - /** - * Defines the OptionalAttendees property. - */ - public static final PropertyDefinition OptionalAttendees = - AppointmentSchema.OptionalAttendees; - - /** - * Defines the Resources property. - */ - public static final PropertyDefinition Resources = - AppointmentSchema.Resources; - - /** - * Defines the ConflictingMeetingCount property. - */ - public static final PropertyDefinition ConflictingMeetingCount = - AppointmentSchema.ConflictingMeetingCount; - - /** - * Defines the AdjacentMeetingCount property. - */ - public static final PropertyDefinition AdjacentMeetingCount = - AppointmentSchema.AdjacentMeetingCount; - - /** - * Defines the ConflictingMeetings property. - */ - public static final PropertyDefinition ConflictingMeetings = - AppointmentSchema.ConflictingMeetings; - - /** - * Defines the AdjacentMeetings property. - */ - public static final PropertyDefinition AdjacentMeetings = - AppointmentSchema.AdjacentMeetings; - - /** - * Defines the Duration property. - */ - public static final PropertyDefinition Duration = - AppointmentSchema.Duration; - - /** - * Defines the TimeZone property. - */ - public static final PropertyDefinition TimeZone = - AppointmentSchema.TimeZone; - - /** - * Defines the AppointmentReplyTime property. - */ - public static final PropertyDefinition AppointmentReplyTime = - AppointmentSchema.AppointmentReplyTime; - - /** - * Defines the AppointmentSequenceNumber property. - */ - public static final PropertyDefinition AppointmentSequenceNumber = - AppointmentSchema.AppointmentSequenceNumber; - - /** - * Defines the AppointmentState property. - */ - public static final PropertyDefinition AppointmentState = - AppointmentSchema.AppointmentState; - - /** - * Defines the Recurrence property. - */ - public static final PropertyDefinition Recurrence = - AppointmentSchema.Recurrence; - - /** - * Defines the FirstOccurrence property. - */ - public static final PropertyDefinition FirstOccurrence = - AppointmentSchema.FirstOccurrence; - /** - * Defines the LastOccurrence property. - */ - public static final PropertyDefinition LastOccurrence = - AppointmentSchema.LastOccurrence; - - /** - * Defines the ModifiedOccurrences property. - */ - public static final PropertyDefinition ModifiedOccurrences = - AppointmentSchema.ModifiedOccurrences; - - /** - * Defines the Duration property. - */ - public static final PropertyDefinition DeletedOccurrences = - AppointmentSchema.DeletedOccurrences; - - /** - * Defines the MeetingTimeZone property. - */ - static final PropertyDefinition MeetingTimeZone = - AppointmentSchema.MeetingTimeZone; - - /** - * Defines the StartTimeZone property. - */ - public static final PropertyDefinition StartTimeZone = - AppointmentSchema.StartTimeZone; - - /** - * Defines the EndTimeZone property. - */ - public static final PropertyDefinition EndTimeZone = - AppointmentSchema.EndTimeZone; - - /** - * Defines the ConferenceType property. - */ - public static final PropertyDefinition ConferenceType = - AppointmentSchema.ConferenceType; - - /** - * Defines the AllowNewTimeProposal property. - */ - public static final PropertyDefinition AllowNewTimeProposal = - AppointmentSchema.AllowNewTimeProposal; - - /** - * Defines the IsOnlineMeeting property. - */ - public static final PropertyDefinition IsOnlineMeeting = - AppointmentSchema.IsOnlineMeeting; - - /** - * Defines the MeetingWorkspaceUrl property. - */ - public static final PropertyDefinition MeetingWorkspaceUrl = - AppointmentSchema.MeetingWorkspaceUrl; - - /** - * Defines the NetShowUrl property. - */ - public static final PropertyDefinition NetShowUrl = - AppointmentSchema.NetShowUrl; - - /** - * This must be after the declaration of property definitions. - */ - public static final MeetingRequestSchema Instance = - new MeetingRequestSchema(); - - /** - * Registers property. - *

- * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the - * same order as they are defined in types.xsd) - */ - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(MeetingRequestType); - this.registerProperty(IntendedFreeBusyStatus); - - this.registerProperty(Start); - this.registerProperty(End); - this.registerProperty(OriginalStart); - this.registerProperty(IsAllDayEvent); - this.registerProperty(LegacyFreeBusyStatus); - this.registerProperty(Location); - this.registerProperty(When); - this.registerProperty(IsMeeting); - this.registerProperty(IsCancelled); - this.registerProperty(IsRecurring); - this.registerProperty(MeetingRequestWasSent); - this.registerProperty(AppointmentType); - this.registerProperty(MyResponseType); - this.registerProperty(Organizer); - this.registerProperty(RequiredAttendees); - this.registerProperty(OptionalAttendees); - this.registerProperty(Resources); - this.registerProperty(ConflictingMeetingCount); - this.registerProperty(AdjacentMeetingCount); - this.registerProperty(ConflictingMeetings); - this.registerProperty(AdjacentMeetings); - this.registerProperty(Duration); - this.registerProperty(TimeZone); - this.registerProperty(AppointmentReplyTime); - this.registerProperty(AppointmentSequenceNumber); - this.registerProperty(AppointmentState); - this.registerProperty(Recurrence); - this.registerProperty(FirstOccurrence); - this.registerProperty(LastOccurrence); - this.registerProperty(ModifiedOccurrences); - this.registerProperty(DeletedOccurrences); - this.registerInternalProperty(MeetingTimeZone); - this.registerProperty(StartTimeZone); - this.registerProperty(EndTimeZone); - this.registerProperty(ConferenceType); - this.registerProperty(AllowNewTimeProposal); - this.registerProperty(IsOnlineMeeting); - this.registerProperty(MeetingWorkspaceUrl); - this.registerProperty(NetShowUrl); - } - - /** - * Initializes a new instance of the class. - */ - protected MeetingRequestSchema() { - super(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/PostItemSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/PostItemSchema.java deleted file mode 100644 index 4a31ac7e4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/PostItemSchema.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.Schema; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.definition.DateTimePropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents the schema for post item. - */ -@Schema -public final class PostItemSchema extends ItemSchema { - - /** - * Field URIs for PostItem. - */ - private static interface FieldUris { - - /** - * The Posted time. - */ - String PostedTime = "postitem:PostedTime"; - } - - - /** - * Defines the ConversationIndex property. - */ - public static final PropertyDefinition ConversationIndex = - EmailMessageSchema.ConversationIndex; - - /** - * Defines the ConversationTopic property. - */ - public static final PropertyDefinition ConversationTopic = - EmailMessageSchema.ConversationTopic; - - /** - * Defines the From property. - */ - public static final PropertyDefinition From = EmailMessageSchema.From; - - /** - * Defines the InternetMessageId property. - */ - public static final PropertyDefinition InternetMessageId = - EmailMessageSchema.InternetMessageId; - - /** - * Defines the IsRead property. - */ - public static final PropertyDefinition IsRead = EmailMessageSchema.IsRead; - - /** - * Defines the PostedTime property. - */ - public static final PropertyDefinition PostedTime = - new DateTimePropertyDefinition( - XmlElementNames.PostedTime, FieldUris.PostedTime, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the References property. - */ - public static final PropertyDefinition References = - EmailMessageSchema.References; - - /** - * Defines the Sender property. - */ - public static final PropertyDefinition Sender = EmailMessageSchema.Sender; - - // This must be after the declaration of property definitions - /** - * The Constant Instance. - */ - public static final PostItemSchema Instance = new PostItemSchema(); - - /** - * Registers property. - *

- * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the - * same order as they are defined in types.xsd) - */ - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(ConversationIndex); - this.registerProperty(ConversationTopic); - this.registerProperty(From); - this.registerProperty(InternetMessageId); - this.registerProperty(IsRead); - this.registerProperty(PostedTime); - this.registerProperty(References); - this.registerProperty(Sender); - } - - /** - * Initializes a new instance of the PostItemSchema class. - */ - protected PostItemSchema() { - super(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/PostReplySchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/PostReplySchema.java deleted file mode 100644 index 97c82498e..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/PostReplySchema.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -/** - * Represents PostReply schema definition. - */ -public final class PostReplySchema extends ServiceObjectSchema { - - // This must be declared after the property definitions - /** - * The Constant Instance. - */ - public static final PostReplySchema Instance = new PostReplySchema(); - - /** - * Registers property. - *

- * IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the - * same order as they are defined in types.xsd) - */ - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(ItemSchema.Subject); - this.registerProperty(ItemSchema.Body); - this.registerProperty(ResponseObjectSchema.ReferenceItemId); - this.registerProperty(ResponseObjectSchema.BodyPrefix); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ResponseMessageSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ResponseMessageSchema.java deleted file mode 100644 index 967a4028e..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ResponseMessageSchema.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -/** - * Represents ResponseMessage schema definition. - */ -public class ResponseMessageSchema extends ServiceObjectSchema { - - /** - * This must be declared after the property definitions. - */ - public static final ResponseMessageSchema Instance = new ResponseMessageSchema(); - - /** - * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN - * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd) - */ - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(ItemSchema.Subject); - this.registerProperty(ItemSchema.Body); - this.registerProperty(EmailMessageSchema.ToRecipients); - this.registerProperty(EmailMessageSchema.CcRecipients); - this.registerProperty(EmailMessageSchema.BccRecipients); - this.registerProperty(EmailMessageSchema.IsReadReceiptRequested); - this.registerProperty(EmailMessageSchema.IsDeliveryReceiptRequested); - this.registerProperty(ResponseObjectSchema.ReferenceItemId); - this.registerProperty(ResponseObjectSchema.BodyPrefix); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ResponseObjectSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ResponseObjectSchema.java deleted file mode 100644 index b995bf19f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ResponseObjectSchema.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.MessageBody; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents ResponseObject schema definition. - */ -public class ResponseObjectSchema extends ServiceObjectSchema { - - /** - * The Reference item id. - */ - public static final PropertyDefinition ReferenceItemId = - new ComplexPropertyDefinition( - ItemId.class, - XmlElementNames.ReferenceItemId, EnumSet.of( - PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public ItemId createComplexProperty() { - return new ItemId(); - } - }); - - /** - * The Body prefix. - */ - public static final PropertyDefinition BodyPrefix = - new ComplexPropertyDefinition( - MessageBody.class, - XmlElementNames.NewBodyContent, EnumSet - .of(PropertyDefinitionFlags.CanSet), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public MessageBody createComplexProperty() { - return new MessageBody(); - } - }); - - /** - * This must be declared after the property definitions. - */ - public static final ResponseObjectSchema Instance = - new ResponseObjectSchema(); - - /** - * Registers property. IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN - * SCHEMA ORDER (i.e. the same order as they are defined in types.xsd) - */ - @Override - protected void registerProperties() { - super.registerProperties(); - this.registerProperty(ResponseObjectSchema.ReferenceItemId); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/SearchFolderSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/SearchFolderSchema.java deleted file mode 100644 index 5a38e08d5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/SearchFolderSchema.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.Schema; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.complex.SearchFolderParameters; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import java.util.EnumSet; - -/** - * The Class SearchFolderSchema. - */ -@Schema -public class SearchFolderSchema extends FolderSchema { - - /** - * Field URIs for search folder. - */ - private static interface FieldUris { - - /** - * The Search parameters. - */ - String SearchParameters = "folder:SearchParameters"; - } - - - /** - * Defines the SearchParameters property. - */ - public static final PropertyDefinition SearchParameters = - new ComplexPropertyDefinition( - SearchFolderParameters.class, - XmlElementNames.SearchParameters, - FieldUris.SearchParameters, - EnumSet.of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.AutoInstantiateOnRead), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - @Override - public SearchFolderParameters createComplexProperty() { - return new SearchFolderParameters(); - } - }); - - // This must be declared after the property definitions - /** - * The Constant Instance. - */ - public static final SearchFolderSchema Instance = new SearchFolderSchema(); - - /** - * Registers property. - */ - // IMPORTANT NOTE: PROPERTIES MUST BE REGISTERED IN SCHEMA ORDER (i.e. the - // same order as they are defined in types.xsd) - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(SearchParameters); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ServiceObjectSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ServiceObjectSchema.java deleted file mode 100644 index 6e99c140e..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/ServiceObjectSchema.java +++ /dev/null @@ -1,441 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ILazyMember; -import microsoft.exchange.webservices.data.core.LazyMember; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.complex.ExtendedPropertyCollection; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.IndexedPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinitionBase; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * Represents the base class for all item and folder schema. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class ServiceObjectSchema implements - Iterable { - - private static final Log LOG = LogFactory.getLog(ServiceObjectSchema.class); - - /** - * The lock object. - */ - private static final Object lockObject = new Object(); - - /** - * List of all schema types. If you add a new ServiceObject subclass that - * has an associated schema, add the schema type to the list below. - */ - private static LazyMember>> allSchemaTypes = new - LazyMember>>(new - ILazyMember>>() { - public List> createInstance() { - List> typeList = new ArrayList>(); - // typeList.add() - /* - * typeList.add(AppointmentSchema.class); - * typeList.add(CalendarResponseObjectSchema.class); - * typeList.add(CancelMeetingMessageSchema.class); - * typeList.add(ContactGroupSchema.class); - * typeList.add(ContactSchema.class); - * typeList.add(EmailMessageSchema.class); - * typeList.add(FolderSchema.class); - * typeList.add(ItemSchema.class); - * typeList.add(MeetingMessageSchema.class); - * typeList.add(MeetingRequestSchema.class); - * typeList.add(PostItemSchema.class); - * typeList.add(PostReplySchema.class); - * typeList.add(ResponseMessageSchema.class); - * typeList.add(ResponseObjectSchema.class); - * typeList.add(ServiceObjectSchema.class); - * typeList.add(SearchFolderSchema.class); - * typeList.add(TaskSchema.class); - */ - // Verify that all Schema types in the Managed API assembly - // have been included. - /* - * var missingTypes = from type in - * Assembly.GetExecutingAssembly().GetTypes() where - * type.IsSubclassOf(typeof(ServiceObjectSchema)) && - * !typeList.Contains(type) select type; if - * (missingTypes.Count() > 0) { throw new - * ServiceLocalException - * ("SchemaTypeList does not include all - * defined schema types." - * ); } - */ - return typeList; - } - }); - - /** - * Dictionary of all property definitions. - */ - private static LazyMember> - allSchemaProperties = new - LazyMember>( - new ILazyMember>() { - public Map createInstance() { - Map propDefDictionary = - new HashMap(); - for (Class c : ServiceObjectSchema.allSchemaTypes - .getMember()) { - ServiceObjectSchema.addSchemaPropertiesToDictionary(c, - propDefDictionary); - } - return propDefDictionary; - } - }); - - /** - * Adds schema property to dictionary. - * - * @param type Schema type. - * @param propDefDictionary The property definition dictionary. - */ - protected static void addSchemaPropertiesToDictionary(Class type, - Map propDefDictionary) { - Field[] fields = type.getDeclaredFields(); - for (Field field : fields) { - int modifier = field.getModifiers(); - if (Modifier.isPublic(modifier) && Modifier.isStatic(modifier)) { - Object o; - try { - o = field.get(null); - if (o instanceof PropertyDefinition) { - PropertyDefinition propertyDefinition = - (PropertyDefinition) o; - // Some property definitions descend from - // ServiceObjectPropertyDefinition but don't have - // a Uri, like ExtendedProperties. Ignore them. - if (null != propertyDefinition.getUri() && - !propertyDefinition.getUri().isEmpty()) { - PropertyDefinitionBase existingPropertyDefinition; - if (propDefDictionary - .containsKey(propertyDefinition.getUri())) { - existingPropertyDefinition = propDefDictionary - .get(propertyDefinition.getUri()); - EwsUtilities - .ewsAssert(existingPropertyDefinition == propertyDefinition, - "Schema.allSchemaProperties." + "delegate", - String.format("There are at least " + - "two distinct property " + - "definitions with the" + - " following URI: %s", propertyDefinition.getUri())); - } else { - propDefDictionary.put(propertyDefinition - .getUri(), propertyDefinition); - // The following is a "generic hack" to register - // property that are not public and - // thus not returned by the above GetFields - // call. It is currently solely used to register - // the MeetingTimeZone property. - List associatedInternalProperties = - propertyDefinition.getAssociatedInternalProperties(); - for (PropertyDefinition associatedInternalProperty : associatedInternalProperties) { - propDefDictionary - .put(associatedInternalProperty - .getUri(), - associatedInternalProperty); - } - - } - } - } - } catch (IllegalArgumentException e) { - LOG.error(e); - - // Skip the field - } catch (IllegalAccessException e) { - LOG.error(e); - - // Skip the field - } - - } - } - } - - /** - * Adds the schema property names to dictionary. - * - * @param type The type. - * @param propertyNameDictionary The property name dictionary. - */ - protected static void addSchemaPropertyNamesToDictionary(Class type, - Map propertyNameDictionary) { - - Field[] fields = type.getDeclaredFields(); - for (Field field : fields) { - int modifier = field.getModifiers(); - if (Modifier.isPublic(modifier) && Modifier.isStatic(modifier)) { - Object o; - try { - o = field.get(null); - if (o instanceof PropertyDefinition) { - PropertyDefinition propertyDefinition = - (PropertyDefinition) o; - propertyNameDictionary.put(propertyDefinition, field - .getName()); - } - } catch (IllegalArgumentException e) { - LOG.error(e); - - // Skip the field - } catch (IllegalAccessException e) { - LOG.error(e); - - // Skip the field - } - } - } - } - - /** - * Initializes a new instance. - */ - protected ServiceObjectSchema() { - this.registerProperties(); - } - - /** - * Finds the property definition. - * - * @param uri The URI. - * @return Property definition. - */ - public static PropertyDefinitionBase findPropertyDefinition(String uri) { - return ServiceObjectSchema.allSchemaProperties.getMember().get(uri); - } - - /** - * Initialize schema property names. - */ - public static void initializeSchemaPropertyNames() { - synchronized (lockObject) { - for (Class type : ServiceObjectSchema.allSchemaTypes.getMember()) { - Field[] fields = type.getDeclaredFields(); - for (Field field : fields) { - int modifier = field.getModifiers(); - if (Modifier.isPublic(modifier) && - Modifier.isStatic(modifier)) { - Object o; - try { - o = field.get(null); - if (o instanceof PropertyDefinition) { - PropertyDefinition propertyDefinition = - (PropertyDefinition) o; - propertyDefinition.setName(field.getName()); - } - } catch (IllegalArgumentException e) { - LOG.error(e); - - // Skip the field - } catch (IllegalAccessException e) { - LOG.error(e); - - // Skip the field - } - } - } - } - } - } - - /** - * Defines the ExtendedProperties property. - */ - public static final PropertyDefinition extendedProperties = - new ComplexPropertyDefinition( - ExtendedPropertyCollection.class, - XmlElementNames.ExtendedProperty, - EnumSet.of(PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.ReuseInstance, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public ExtendedPropertyCollection createComplexProperty() { - return new ExtendedPropertyCollection(); - } - }); - - /** - * The property. - */ - private Map properties = - new HashMap(); - - /** - * The visible property. - */ - private List visibleProperties = - new ArrayList(); - - /** - * The first class property. - */ - private List firstClassProperties = - new ArrayList(); - - /** - * The first class summary property. - */ - private List firstClassSummaryProperties = - new ArrayList(); - - private List indexedProperties = - new ArrayList(); - - /** - * Registers a schema property. - * - * @param property The property to register. - * @param isInternal Indicates whether the property is internal or should be - * visible to developers. - */ - private void registerProperty(PropertyDefinition property, - boolean isInternal) { - this.properties.put(property.getXmlElement(), property); - - if (!isInternal) { - this.visibleProperties.add(property); - } - - // If this property does not have to be requested explicitly, add - // it to the list of firstClassProperties. - if (!property.hasFlag(PropertyDefinitionFlags.MustBeExplicitlyLoaded)) { - this.firstClassProperties.add(property); - } - - // If this property can be found, add it to the list of - // firstClassSummaryProperties - if (property.hasFlag(PropertyDefinitionFlags.CanFind)) { - this.firstClassSummaryProperties.add(property); - } - } - - /** - * Registers a schema property that will be visible to developers. - * - * @param property The property to register. - */ - protected void registerProperty(PropertyDefinition property) { - this.registerProperty(property, false); - } - - /** - * Registers an internal schema property. - * - * @param property The property to register. - */ - protected void registerInternalProperty(PropertyDefinition property) { - this.registerProperty(property, true); - } - - /** - * Registers an indexed property. - * - * @param indexedProperty The indexed property to register. - */ - protected void registerIndexedProperty(IndexedPropertyDefinition - indexedProperty) { - this.indexedProperties.add(indexedProperty); - } - - - /** - * Registers property. - */ - protected void registerProperties() { - } - - /** - * Gets the list of first class property for this service object type. - * - * @return the first class property - */ - public List getFirstClassProperties() { - return this.firstClassProperties; - } - - /** - * Gets the list of first class summary property for this service object - * type. - * - * @return the first class summary property - */ - public List getFirstClassSummaryProperties() { - return this.firstClassSummaryProperties; - } - - /** - * Tries to get property definition. - * - * @param xmlElementName Name of the XML element. - * @param propertyDefinitionOutParam The property definition. - * @return True if property definition exists. - */ - public boolean tryGetPropertyDefinition(String xmlElementName, - OutParam propertyDefinitionOutParam) { - if (this.properties.containsKey(xmlElementName)) { - propertyDefinitionOutParam.setParam(this.properties - .get(xmlElementName)); - return true; - } else { - return false; - } - } - - /** - * Returns an iterator over a set of elements of type T. - * - * @return an Iterator. - */ - @Override - public Iterator iterator() { - return this.visibleProperties.iterator(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/TaskSchema.java b/src/main/java/microsoft/exchange/webservices/data/core/service/schema/TaskSchema.java deleted file mode 100644 index 7da388a24..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/core/service/schema/TaskSchema.java +++ /dev/null @@ -1,464 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core.service.schema; - -import microsoft.exchange.webservices.data.attribute.Schema; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.core.enumeration.service.TaskMode; -import microsoft.exchange.webservices.data.core.enumeration.service.TaskStatus; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.complex.StringList; -import microsoft.exchange.webservices.data.property.definition.BoolPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.ComplexPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.DateTimePropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.DoublePropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.GenericPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.IntPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.RecurrencePropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.StringPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.TaskDelegationStatePropertyDefinition; - -import java.util.EnumSet; - -/** - * Represents the schema for task item. - */ -@Schema -public class TaskSchema extends ItemSchema { - - /** - * Field URIs for tasks. - */ - private static class FieldUris { - - /** - * The Constant ActualWork. - */ - public final static String ActualWork = "task:ActualWork"; - - /** - * The Constant AssignedTime. - */ - public final static String AssignedTime = "task:AssignedTime"; - - /** - * The Constant BillingInformation. - */ - public final static String BillingInformation = - "task:BillingInformation"; - - /** - * The Constant ChangeCount. - */ - public final static String ChangeCount = "task:ChangeCount"; - - /** - * The Constant Companies. - */ - public final static String Companies = "task:Companies"; - - /** - * The Constant CompleteDate. - */ - public final static String CompleteDate = "task:CompleteDate"; - - /** - * The Constant Contacts. - */ - public final static String Contacts = "task:Contacts"; - - /** - * The Constant DelegationState. - */ - public final static String DelegationState = "task:DelegationState"; - - /** - * The Constant Delegator. - */ - public final static String Delegator = "task:Delegator"; - - /** - * The Constant DueDate. - */ - public final static String DueDate = "task:DueDate"; - - /** - * The Constant IsAssignmentEditable. - */ - public final static String IsAssignmentEditable = - "task:IsAssignmentEditable"; - - /** - * The Constant IsComplete. - */ - public final static String IsComplete = "task:IsComplete"; - - /** - * The Constant IsRecurring. - */ - public final static String IsRecurring = "task:IsRecurring"; - - /** - * The Constant IsTeamTask. - */ - public final static String IsTeamTask = "task:IsTeamTask"; - - /** - * The Constant Mileage. - */ - public final static String Mileage = "task:Mileage"; - - /** - * The Constant Owner. - */ - public final static String Owner = "task:Owner"; - - /** - * The Constant PercentComplete. - */ - public final static String PercentComplete = "task:PercentComplete"; - - /** - * The Constant Recurrence. - */ - public final static String Recurrence = "task:Recurrence"; - - /** - * The Constant StartDate. - */ - public final static String StartDate = "task:StartDate"; - - /** - * The Constant Status. - */ - public final static String Status = "task:Status"; - - /** - * The Constant StatusDescription. - */ - public final static String StatusDescription = "task:StatusDescription"; - - /** - * The Constant TotalWork. - */ - public final static String TotalWork = "task:TotalWork"; - } - - - /** - * Defines the ActualWork property. - */ - public static final PropertyDefinition ActualWork = - new IntPropertyDefinition( - XmlElementNames.ActualWork, FieldUris.ActualWork, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - - true); // isNullable - - /** - * Defines the AssignedTime property. - */ - public static final PropertyDefinition AssignedTime = - new DateTimePropertyDefinition( - XmlElementNames.AssignedTime, FieldUris.AssignedTime, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, true); - - /** - * Defines the BillingInformation property. - */ - public static final PropertyDefinition BillingInformation = - new StringPropertyDefinition( - XmlElementNames.BillingInformation, FieldUris.BillingInformation, - EnumSet.of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the ChangeCount property. - */ - public static final PropertyDefinition ChangeCount = - new IntPropertyDefinition( - XmlElementNames.ChangeCount, FieldUris.ChangeCount, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Companies property. - */ - public static final PropertyDefinition Companies = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.Companies, FieldUris.Companies, EnumSet.of( - PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(); - } - }); - - /** - * Defines the CompleteDate property. - */ - public static final PropertyDefinition CompleteDate = - new DateTimePropertyDefinition( - XmlElementNames.CompleteDate, FieldUris.CompleteDate, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, true); // isNullable - - /** - * Defines the Contacts property. - */ - public static final PropertyDefinition Contacts = - new ComplexPropertyDefinition( - StringList.class, - XmlElementNames.Contacts, FieldUris.Contacts, EnumSet.of( - PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public StringList createComplexProperty() { - return new StringList(); - } - }); - - /** - * Defines the DelegationState property. - */ - public static final PropertyDefinition DelegationState = - new TaskDelegationStatePropertyDefinition( - XmlElementNames.DelegationState, FieldUris.DelegationState, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Delegator property. - */ - public static final PropertyDefinition Delegator = - new StringPropertyDefinition( - XmlElementNames.Delegator, FieldUris.Delegator, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the DueDate property. - */ - public static final PropertyDefinition DueDate = - new DateTimePropertyDefinition( - XmlElementNames.DueDate, FieldUris.DueDate, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, true); // isNullable - - /** - * Defines the Mode property. - */ - public static final PropertyDefinition Mode = - new GenericPropertyDefinition( - TaskMode.class, - XmlElementNames.IsAssignmentEditable, - FieldUris.IsAssignmentEditable, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsComplete property. - */ - public static final PropertyDefinition IsComplete = - new BoolPropertyDefinition( - XmlElementNames.IsComplete, FieldUris.IsComplete, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsRecurring property. - */ - public static final PropertyDefinition IsRecurring = - new BoolPropertyDefinition( - XmlElementNames.IsRecurring, FieldUris.IsRecurring, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the IsTeamTask property. - */ - public static final PropertyDefinition IsTeamTask = - new BoolPropertyDefinition( - XmlElementNames.IsTeamTask, FieldUris.IsTeamTask, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Mileage property. - */ - public static final PropertyDefinition Mileage = - new StringPropertyDefinition( - XmlElementNames.Mileage, FieldUris.Mileage, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Owner property. - */ - public static final PropertyDefinition Owner = new StringPropertyDefinition( - XmlElementNames.Owner, FieldUris.Owner, EnumSet - .of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the PercentComplete property. - */ - public static final PropertyDefinition PercentComplete = - new DoublePropertyDefinition( - XmlElementNames.PercentComplete, FieldUris.PercentComplete, EnumSet - .of(PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the Recurrence property. - */ - public static final PropertyDefinition Recurrence = - new RecurrencePropertyDefinition( - XmlElementNames.Recurrence, FieldUris.Recurrence, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the StartDate property. - */ - public static final PropertyDefinition StartDate = - new DateTimePropertyDefinition( - XmlElementNames.StartDate, FieldUris.StartDate, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, true); // isNullable - - /** - * Defines the Status property. - */ - public static final PropertyDefinition Status = - new GenericPropertyDefinition( - TaskStatus.class, - XmlElementNames.Status, FieldUris.Status, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the StatusDescription property. - */ - public static final PropertyDefinition StatusDescription = - new StringPropertyDefinition( - XmlElementNames.StatusDescription, FieldUris.StatusDescription, - EnumSet.of(PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1); - - /** - * Defines the TotalWork property. - */ - public static final PropertyDefinition TotalWork = - new IntPropertyDefinition( - XmlElementNames.TotalWork, FieldUris.TotalWork, EnumSet.of( - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.CanUpdate, - PropertyDefinitionFlags.CanDelete, - PropertyDefinitionFlags.CanFind), - ExchangeVersion.Exchange2007_SP1, true); // isNullable - - /** - * This must be declared after the property definitions. - */ - public static final TaskSchema Instance = new TaskSchema(); - - /** - * This must be declared after the property definitions. - */ - @Override - protected void registerProperties() { - super.registerProperties(); - - this.registerProperty(ActualWork); - this.registerProperty(AssignedTime); - this.registerProperty(BillingInformation); - this.registerProperty(ChangeCount); - this.registerProperty(Companies); - this.registerProperty(CompleteDate); - this.registerProperty(Contacts); - this.registerProperty(DelegationState); - this.registerProperty(Delegator); - this.registerProperty(DueDate); - this.registerProperty(Mode); - this.registerProperty(IsComplete); - this.registerProperty(IsRecurring); - this.registerProperty(IsTeamTask); - this.registerProperty(Mileage); - this.registerProperty(Owner); - this.registerProperty(PercentComplete); - this.registerProperty(Recurrence); - this.registerProperty(StartDate); - this.registerProperty(Status); - this.registerProperty(StatusDescription); - this.registerProperty(TotalWork); - } - - /** - * Initializes a new instance of the class. - */ - TaskSchema() { - super(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/credential/CredentialConstants.java b/src/main/java/microsoft/exchange/webservices/data/credential/CredentialConstants.java deleted file mode 100644 index 9b6172e9b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/credential/CredentialConstants.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.credential; - -//These constants needs to be defined as per user configurations. -public interface CredentialConstants { - String URL = ""; - String USERNAME = ""; - String DOMAIN = ""; - String EMAIL_ID = ""; - String PASSWORD = ""; - String ATTENDEE_EMAIL_ID = ""; - String ATTENDEE_USERNAME = ""; - String ATTENDEE_PASSWORD = ""; - String PROXY_CRED_USERNAME = ""; - String PROXY_CRED_PASSWORD = ""; - String PROXY_CRED_DOMAIN = ""; - String PROXY_HOST = ""; - int PROXY_PORT = 80; - String PATH = ""; - String COPYTOFILEPATH = ""; - String SMTPADDRESS_DISTRIBUTION_GROUP = ""; - String SMTPADDRESS_ROOM = ""; - int THREAD_SLEEP_MILLSEC = 5000; - -} - - - diff --git a/src/main/java/microsoft/exchange/webservices/data/credential/ExchangeCredentials.java b/src/main/java/microsoft/exchange/webservices/data/credential/ExchangeCredentials.java deleted file mode 100644 index 8c052645c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/credential/ExchangeCredentials.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.credential; - -import microsoft.exchange.webservices.data.core.request.HttpWebRequest; -import microsoft.exchange.webservices.data.core.exception.misc.InvalidOperationException; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import java.io.ByteArrayOutputStream; -import java.net.URI; -import java.net.URISyntaxException; - -/** - * Base class of Exchange credential types. - */ -public abstract class ExchangeCredentials { - - /** - * Performs an implicit conversion from to . This - * allows a NetworkCredential object to be implictly converted to an - * ExchangeCredential which is useful when setting credential on an - * ExchangeService. - * - * @param userName Account user name. - * @param password Account password. - * @param domain Account domain. - * @return The result of the conversion. - */ - public static ExchangeCredentials - getExchangeCredentialsFromNetworkCredential( - String userName, String password, String domain) { - return new WebCredentials(userName, password, domain); - } - - - /** - * Return the url without ws-security address. - * - * @param url The url - * @return The absolute uri base. - */ - protected static String getUriWithoutWSSecurity(URI url) { - String absoluteUri = url.toString(); - int index = absoluteUri.indexOf("/wssecurity"); - - if (index == -1) { - return absoluteUri; - } else { - return absoluteUri.substring(0, index); - } - } - - /** - * This method is called to pre-authenticate credential before a service - * request is made. - */ - public void preAuthenticate() { - // do nothing by default. - } - - /** - * This method is called to apply credential to a service request before - * the request is made. - * - * @param client The request. - * @throws java.net.URISyntaxException the uRI syntax exception - */ - public void prepareWebRequest(HttpWebRequest client) - throws URISyntaxException { - // do nothing by default. - } - - /** - * Emit any extra necessary namespace aliases for the SOAP:header block. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - */ - public void emitExtraSoapHeaderNamespaceAliases(XMLStreamWriter writer) - throws XMLStreamException { - // do nothing by default. - } - - /** - * Serialize any extra necessary SOAP headers. This is used for - * authentication schemes that rely on WS-Security, or for endpoints - * requiring WS-Addressing. - * - * @param writer the writer - * @param webMethodName the Web method being called - * @throws XMLStreamException the XML stream exception - */ - public void serializeExtraSoapHeaders(XMLStreamWriter writer, String webMethodName) throws XMLStreamException { - // do nothing by default. - } - - /** - * Adjusts the URL endpoint based on the credential. - * - * @param url The URL. - * @return Adjust URL. - */ - public URI adjustUrl(URI url) throws URISyntaxException { - return new URI(getUriWithoutWSSecurity(url)); - } - - /** - * Gets the flag indicating whether any sign action need taken. - */ - public boolean isNeedSignature() { - return false; - } - - /** - * Add the signature element to the memory stream. - * - * @param memoryStream The memory stream. - */ - public void sign(ByteArrayOutputStream memoryStream) throws Exception { - throw new InvalidOperationException(); - } - - - - /** - * Serialize SOAP headers used for authentication schemes that rely on WS-Security. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - */ - public void serializeWSSecurityHeaders(XMLStreamWriter writer) - throws XMLStreamException { - // do nothing by default. - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/credential/TokenCredentials.java b/src/main/java/microsoft/exchange/webservices/data/credential/TokenCredentials.java deleted file mode 100644 index 7678aa5f9..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/credential/TokenCredentials.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.credential; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentNullException; -import microsoft.exchange.webservices.data.core.request.HttpWebRequest; - -import java.net.URISyntaxException; - -/** - * TokenCredentials provides credential if you already have a token. - */ -public final class TokenCredentials extends WSSecurityBasedCredentials { - - /** - * Initializes a new instance of the TokenCredentials class. - * - * @param securityToken The token. - * @throws ArgumentNullException the argument null exception - */ - public TokenCredentials(String securityToken) throws Exception { - super(securityToken); - EwsUtilities.validateParam(securityToken, "securityToken"); - - } - - /** - * This method is called to apply credential to a service request before - * the request is made. - * - * @param request The request. - * @throws java.net.URISyntaxException the uRI syntax exception - */ - @Override public void prepareWebRequest(HttpWebRequest request) - throws URISyntaxException { - this.setEwsUrl(request.getUrl().toURI()); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/credential/WSSecurityBasedCredentials.java b/src/main/java/microsoft/exchange/webservices/data/credential/WSSecurityBasedCredentials.java deleted file mode 100644 index c0b92e78e..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/credential/WSSecurityBasedCredentials.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.credential; - -import microsoft.exchange.webservices.data.core.EwsUtilities; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Calendar; - -/** - * WSSecurityBasedCredentials is the base class for all credential classes using - * WS-Security. - */ -public abstract class WSSecurityBasedCredentials extends ExchangeCredentials { - - /** - * The security token. - */ - private String securityToken; - - /** - * The ews url. - */ - private URI ewsUrl; - - protected static final String wsuTimeStampFormat = - "" + - "{0:yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'}" + - "{1:yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'}" + - ""; - //kavi-start - // WS-Security SecExt 1.0 Namespace (and the namespace prefix we will use - // for it). - /** The Constant WSSecuritySecExt10NamespacePrefix. */ - //protected static final String WSSecuritySecExt10NamespacePrefix = "wsse"; - - /** The Constant WSSecuritySecExt10Namespace. */ - //protected static final String WSSecuritySecExt10Namespace = - // "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; - - // WS-Addressing 1.0 Namespace (and the namespace prefix we will use for - // it). - - - /** The Constant WSAddressing10NamespacePrefix. */ - //protected static final String WSAddressing10NamespacePrefix = "wsa"; - - /** The Constant WSAddressing10Namespace. */ - //protected static final String WSAddressing10Namespace = - // "http://www.w3.org/2005/08/addressing"; - - //kavi end - - // The WS-Addressing headers format string to use for adding the - // WS-Addressing headers. - // Fill-Ins: %s = Web method name; %s = EWS URL - /** - * The Constant WsAddressingHeadersFormat. - */ - protected static final String wsAddressingHeadersFormat = - "http://schemas.microsoft.com/exchange/services/2006/messages/%s" - + - "http://www.w3.org/2005/08/addressing/anonymous" + - "" + - "%s"; - - // The WS-Security header format string to use for adding the WS-Security - // header. - // Fill-Ins: - // %s = EncryptedData block (the token) - /** - * The Constant WsSecurityHeaderFormat. - */ - protected static final String wsSecurityHeaderFormat = - "" + - " %s" + // EncryptedData (token) - ""; - - private boolean addTimestamp; - - // / Path suffix for WS-Security endpoint. - /** - * The Constant WsSecurityPathSuffix. - */ - protected static final String wsSecurityPathSuffix = "/wssecurity"; - - /** - * Initializes a new instance of the WSSecurityBasedCredentials class. - */ - protected WSSecurityBasedCredentials() { - } - - /** - * Initializes a new instance of the WSSecurityBasedCredentials class. - * - * @param securityToken The security token. - */ - protected WSSecurityBasedCredentials(String securityToken) { - this.securityToken = securityToken; - } - - /** - * Initializes a new instance of the WSSecurityBasedCredentials class. - * - * @param securityToken The security token. - * @param addTimestamp Timestamp should be added. - */ - protected WSSecurityBasedCredentials(String securityToken, boolean addTimestamp) { - this.securityToken = securityToken; - this.addTimestamp = addTimestamp; - } - - /** - * This method is called to pre-authenticate credential before a service - * request is made. - */ - @Override public void preAuthenticate() { - // Nothing special to do here. - } - - /** - * Emit the extra namespace aliases used for WS-Security and WS-Addressing. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - */ - @Override public void emitExtraSoapHeaderNamespaceAliases(XMLStreamWriter writer) - throws XMLStreamException { - writer.writeAttribute( - "xmlns", - "", - EwsUtilities.WSSecuritySecExtNamespacePrefix, - EwsUtilities.WSSecuritySecExtNamespace); - writer.writeAttribute( - "xmlns", - "", - EwsUtilities.WSAddressingNamespacePrefix, - EwsUtilities.WSAddressingNamespace); - } - - /** - * Serialize the WS-Security and WS-Addressing SOAP headers. - * - * @param writer the writer - * @param webMethodName the Web method being called - * @throws XMLStreamException the XML stream exception - */ - @Override public void serializeExtraSoapHeaders(XMLStreamWriter writer, String webMethodName) throws XMLStreamException { - this.serializeWSAddressingHeaders(writer, webMethodName); - this.serializeWSSecurityHeaders(writer); - } - - /** - * Creates the WS-Addressing headers necessary to send with an outgoing request. - * - * @param xmlWriter the XML writer to serialize the headers to - * @param webMethodName the Web method being called - * @throws XMLStreamException the XML stream exception - */ - private void serializeWSAddressingHeaders(XMLStreamWriter xmlWriter, - String webMethodName) throws XMLStreamException { - EwsUtilities.ewsAssert(webMethodName != null, - "WSSecurityBasedCredentials.SerializeWSAddressingHeaders", - "Web method name cannot be null!"); - - EwsUtilities.ewsAssert(this.ewsUrl != null, - "WSSecurityBasedCredentials.SerializeWSAddressingHeaders", - "EWS Url cannot be null!"); - - // Format the WS-Addressing headers. - String wsAddressingHeaders = String.format( - WSSecurityBasedCredentials.wsAddressingHeadersFormat, - webMethodName, this.ewsUrl); - - // And write them out... - xmlWriter.writeCharacters(wsAddressingHeaders); - } - - /** - * Creates the WS-Security header necessary to send with an outgoing request. - * - * @param xmlWriter The XML writer to serialize the headers to - * @throws XMLStreamException the XML stream exception - */ - @Override public void serializeWSSecurityHeaders(XMLStreamWriter xmlWriter) - throws XMLStreamException { - EwsUtilities.ewsAssert(this.securityToken != null, - "WSSecurityBasedCredentials.SerializeWSSecurityHeaders", - "Security token cannot be null!"); - - // - // 2007-09-20T01:13:10.468Z - // 2007-09-20T01:18:10.468Z - // - // - String timestamp = null; - if (this.addTimestamp) { - Calendar utcNow = Calendar.getInstance(); - utcNow.add(Calendar.MINUTE, 5); - timestamp = String.format(WSSecurityBasedCredentials.wsuTimeStampFormat, utcNow, utcNow); - - } - - // Format the WS-Security header based on all the information we have. - String wsSecurityHeader = String.format( - WSSecurityBasedCredentials.wsSecurityHeaderFormat, - timestamp + this.securityToken); - - // And write the header out... - xmlWriter.writeCharacters(wsSecurityHeader); - } - - /** - * Adjusts the URL based on the credential. - * - * @param url The URL. - * @return Adjust URL. - * @throws java.net.URISyntaxException the uRI syntax exception - */ - @Override public URI adjustUrl(URI url) throws URISyntaxException { - return new URI(getUriWithoutWSSecurity(url) + WSSecurityBasedCredentials.wsSecurityPathSuffix); - } - - /** - * Gets the security token. - */ - protected String getSecurityToken() { - return this.securityToken; - } - - /** - * Sets the security token. - */ - protected void setSecurityToken(String value) { - securityToken = value; - } - - /** - * Gets the EWS URL. - */ - protected URI getEwsUrl() { - return this.ewsUrl; - } - - /** - * Sets the EWS URL. - */ - protected void setEwsUrl(URI value) { - ewsUrl = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/credential/WebCredentials.java b/src/main/java/microsoft/exchange/webservices/data/credential/WebCredentials.java deleted file mode 100644 index 2669c38bf..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/credential/WebCredentials.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.credential; - -import microsoft.exchange.webservices.data.core.request.HttpWebRequest; - -/** - * WebCredentials is used for password-based authentication schemes such as - * basic, digest, NTLM, and Kerberos authentication. - */ -public final class WebCredentials extends ExchangeCredentials { - - /** - * The domain. - */ - private String domain; - - /** - * The user. - */ - private String user; - - /** - * The pwd. - */ - private String pwd; - - /** - * The use default credential. - */ - private boolean useDefaultCredentials = true; - - /** - * Gets the domain. - * - * @return the domain - */ - public String getDomain() { - return domain; - } - - /** - * Gets the user. - * - * @return the user - */ - public String getUser() { - return user; - } - - /** - * Gets the pwd. - * - * @return the pwd - */ - public String getPwd() { - return pwd; - } - - /** - * Checks if is use default credential. - * - * @return true, if is use default credential - */ - public boolean isUseDefaultCredentials() { - return useDefaultCredentials; - } - - /** - * Initializes a new instance to use default network credential. - */ - public WebCredentials() { - useDefaultCredentials = true; - this.user = null; - this.pwd = null; - this.domain = null; - } - - /** - * Initializes a new instance to use specified credential. - * - * @param userName Account user name. - * @param password Account password. - * @param domain Account domain. - */ - public WebCredentials(String userName, String password, String domain) { - if (userName == null || password == null) { - throw new IllegalArgumentException( - "User name or password can not be null"); - } - - this.domain = domain; - this.user = userName; - this.pwd = password; - useDefaultCredentials = false; - } - - /** - * Initializes a new instance to use specified credential. - * - * @param username The user name. - * @param password The password. - */ - public WebCredentials(String username, String password) { - this(username, password, ""); - } - - /** - * This method is called to apply credential to a service request before - * the request is made. - * - * @param request The request. - */ - @Override public void prepareWebRequest(HttpWebRequest request) { - if (useDefaultCredentials) { - request.setUseDefaultCredentials(true); - } else { - request.setCredentials(domain, user, pwd); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/credential/WebProxyCredentials.java b/src/main/java/microsoft/exchange/webservices/data/credential/WebProxyCredentials.java deleted file mode 100644 index 64fd45082..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/credential/WebProxyCredentials.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.credential; - -public class WebProxyCredentials { - - private String username; - - private String password; - - private String domain; - - public WebProxyCredentials(String username, String password, String domain) { - this.username = username; - this.password = password; - this.domain = domain; - } - - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - - public String getDomain() { - return domain; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/dns/DnsClient.java b/src/main/java/microsoft/exchange/webservices/data/dns/DnsClient.java deleted file mode 100644 index 311b6996f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/dns/DnsClient.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.dns; - -import microsoft.exchange.webservices.data.EWSConstants; -import microsoft.exchange.webservices.data.core.exception.dns.DnsException; - -import javax.naming.NamingEnumeration; -import javax.naming.NamingException; -import javax.naming.directory.Attribute; -import javax.naming.directory.Attributes; -import javax.naming.directory.DirContext; -import javax.naming.directory.InitialDirContext; - -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.List; - -/** - * Class that represents DNS Query client. - */ -public class DnsClient { - - /** - * Set up the environment used to construct the DirContext. - * - * @param dnsServerAddress - * @return - */ - static Hashtable getEnv(String dnsServerAddress) { - // Set up environment for creating initial context - Hashtable env = new Hashtable(); - env.put("java.naming.factory.initial", - "com.sun.jndi.dns.DnsContextFactory"); - if(dnsServerAddress != null && !dnsServerAddress.isEmpty()) { - env.put("java.naming.provider.url", "dns://" + dnsServerAddress); - } - return env; - } - - /** - * Performs Dns query. - * - * @param the generic type - * @param cls DnsRecord Type - * @param domain the domain - * @param dnsServerAddress IPAddress of DNS server to use (may be null) - * @return DnsRecord The DNS record list (never null but may be empty) - * @throws DnsException the dns exception - */ - - public static List dnsQuery(Class cls, String domain, String dnsServerAddress) throws - DnsException { - - List dnsRecordList = new ArrayList(); - try { - // Create initial context - DirContext ictx = new InitialDirContext(getEnv(dnsServerAddress)); - - // Retrieve SRV record context attribute for the specified domain - Attributes contextAttributes = ictx.getAttributes(domain, - new String[] {EWSConstants.SRVRECORD}); - if (contextAttributes != null) { - NamingEnumeration attributes = contextAttributes.getAll(); - if (attributes != null) { - while (attributes.hasMore()) { - Attribute attr = (Attribute) attributes.next(); - NamingEnumeration srvValues = attr.getAll(); - if (srvValues != null) { - while (srvValues.hasMore()) { - T dnsRecord = cls.newInstance(); - - // Loads the DNS SRV record - dnsRecord.load((String) srvValues.next()); - dnsRecordList.add(dnsRecord); - } - } - } - } - } - } catch (NamingException ne) { - throw new DnsException(ne.getMessage()); - } catch (Exception e) { - throw new DnsException(e.getMessage()); - } - return dnsRecordList; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/dns/DnsRecord.java b/src/main/java/microsoft/exchange/webservices/data/dns/DnsRecord.java deleted file mode 100644 index 4ef1db1e4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/dns/DnsRecord.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.dns; - -import microsoft.exchange.webservices.data.core.exception.dns.DnsException; - -/** - * Represents a DnsRecord. - */ -abstract class DnsRecord { - /* - * Name field of this DNS Record - */ - /** - * The name. - */ - private String name; - /* - * The suggested time for this dnsRecord to be valid - */ - /** - * The time to live. - */ - private int timeToLive; - - /** - * Retrieves the value of the name property. - * - * @return name - */ - public String getName() { - return name; - } - - /** - * Retrieves the value of the timeToLive property. - * - * @return timeToLive - */ - public int getTimeToLive() { - return timeToLive; - } - - /** - * loads the DNS Record. - * - * @param value the value - * @throws DnsException the dns exception - */ - protected void load(String value) throws DnsException { - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/dns/DnsSrvRecord.java b/src/main/java/microsoft/exchange/webservices/data/dns/DnsSrvRecord.java deleted file mode 100644 index 2784e5cf3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/dns/DnsSrvRecord.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.dns; - -import microsoft.exchange.webservices.data.core.exception.dns.DnsException; - -import java.util.NoSuchElementException; -import java.util.StringTokenizer; - -/** - * Represents a DNS SRV Record. - */ -public class DnsSrvRecord extends DnsRecord { - /* - * The string representing the target host - */ - /** - * The target. - */ - private String target; - - /* - * priority of the target host specified in the owner name. - */ - /** - * The priority. - */ - private int priority; - /* - * weight of the target host - */ - /** - * The weight. - */ - private int weight; - /* - * port used on the target for the service - */ - /** - * The port. - */ - private int port; - - /** - * Retrieves the value of the target property. - * - * @return target - */ - public String getNameTarget() { - return this.target; - } - - /** - * Retrieves the value of the priority property. - * - * @return priority - */ - public int getPriority() { - return priority; - } - - /** - * Retrieves the value of the weight property. - * - * @return weight - */ - public int getWeight() { - return weight; - } - - /** - * Retrieves the value of the port property. - * - * @return port - */ - public int getPort() { - return port; - } - - /** - * Initializes a new instance of the DnsSrvRecord class. - * - * @param srvRecord srvRecord that is fetched from JNDI - * @throws DnsException the dns exception - */ - protected void load(String srvRecord) throws DnsException { - super.load(null); - StringTokenizer strTokens = new StringTokenizer(srvRecord); - try { - while (strTokens.hasMoreTokens()) { - String priority = strTokens.nextToken(); - this.priority = Integer.parseInt(priority); - - String weight = strTokens.nextToken(); - this.weight = Integer.parseInt(weight); - - String port = strTokens.nextToken(); - this.port = Integer.parseInt(port); - - String target = strTokens.nextToken(); - this.target = target; - } - } catch (NumberFormatException ne) { - throw new DnsException("NumberFormatException " + ne.getMessage()); - } catch (NoSuchElementException ne) { - throw new DnsException("NoSuchElementException " + ne.getMessage()); - } - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/messaging/PhoneCall.java b/src/main/java/microsoft/exchange/webservices/data/messaging/PhoneCall.java deleted file mode 100644 index 549a313fa..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/messaging/PhoneCall.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.messaging; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.error.ConnectionFailureCause; -import microsoft.exchange.webservices.data.core.enumeration.service.PhoneCallState; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -/** - * Represents a phone call. - */ -public final class PhoneCall extends ComplexProperty { - - /** - * The Constant successfullResponseText. - */ - private final static String SuccessfullResponseText = "OK"; - - /** - * The Constant successfullResponseCode. - */ - private final static int SuccessfullResponseCode = 200; - - /** - * The service. - */ - private ExchangeService service; - - /** - * The state. - */ - private PhoneCallState state; - - /** - * The connection failure cause. - */ - private ConnectionFailureCause connectionFailureCause; - - /** - * The sip response text. - */ - private String sipResponseText; - - /** - * The sip response code. - */ - private int sipResponseCode; - - /** - * The id. - */ - private PhoneCallId id; - - /** - * PhoneCall Constructor. - * - * @param service the service - */ - public PhoneCall(ExchangeService service) { - EwsUtilities.ewsAssert(service != null, "PhoneCall.ctor", "service is null"); - - this.service = service; - this.state = PhoneCallState.Connecting; - this.connectionFailureCause = ConnectionFailureCause.None; - this.sipResponseText = PhoneCall.SuccessfullResponseText; - this.sipResponseCode = PhoneCall.SuccessfullResponseCode; - } - - /** - * PhoneCall Constructor. - * - * @param service the service - * @param id the id - */ - protected PhoneCall(ExchangeService service, PhoneCallId id) { - this(service); - this.id = id; - } - - /** - * Refreshes the state of this phone call. - * - * @throws Exception the exception - */ - public void refresh() throws Exception { - PhoneCall phoneCall = service.getUnifiedMessaging() - .getPhoneCallInformation(this.id); - this.state = phoneCall.getState(); - this.connectionFailureCause = phoneCall.getConnectionFailureCause(); - this.sipResponseText = phoneCall.getSipResponseText(); - this.sipResponseCode = phoneCall.getSipResponseCode(); - } - - /** - * Disconnects this phone call. - * - * @throws Exception the exception - */ - public void disconnect() throws Exception { - // If call is already disconnected, throw exception - // - if (this.state == PhoneCallState.Disconnected) { - throw new ServiceLocalException("The phone call has already been disconnected."); - } - - this.service.getUnifiedMessaging().disconnectPhoneCall(this.id); - this.state = PhoneCallState.Disconnected; - } - - /** - * Tries to read an element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.PhoneCallState)) { - this.state = reader.readElementValue(PhoneCallState.class); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.ConnectionFailureCause)) { - this.connectionFailureCause = reader - .readElementValue(ConnectionFailureCause.class); - return true; - } else if (reader.getLocalName() - .equals(XmlElementNames.SIPResponseText)) { - this.sipResponseText = reader.readElementValue(); - return true; - } else if (reader.getLocalName() - .equals(XmlElementNames.SIPResponseCode)) { - this.sipResponseCode = reader.readElementValue(Integer.class); - return true; - } else { - return false; - } - - } - - /** - * Gets a value indicating the last known state of this phone call. - * - * @return the state - */ - public PhoneCallState getState() { - return state; - } - - /** - * Gets the SIP response text of this phone call. - * - * @return the sip response text - */ - public String getSipResponseText() { - return sipResponseText; - } - - /** - * Gets the SIP response code of this phone call. - * - * @return the sip response code - */ - public int getSipResponseCode() { - return sipResponseCode; - } - - /** - * Gets a value indicating the reason why this phone call failed to connect. - * - * @return the connection failure cause - */ - public ConnectionFailureCause getConnectionFailureCause() { - return connectionFailureCause; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/messaging/PhoneCallId.java b/src/main/java/microsoft/exchange/webservices/data/messaging/PhoneCallId.java deleted file mode 100644 index ec6ac3a3f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/messaging/PhoneCallId.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.messaging; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -/** - * Represents the Id of a phone call. - */ -public final class PhoneCallId extends ComplexProperty { - - /** - * The id. - */ - private String id; - - /** - * Initializes a new instance of the PhoneCallId class. - */ - public PhoneCallId() { - } - - /** - * Initializes a new instance of the PhoneCallId class. - * - * @param id the id - */ - protected PhoneCallId(String id) { - this.id = id; - } - - /** - * Reads attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.id = reader.readAttributeValue(XmlAttributeNames.Id); - } - - /** - * Writes attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.Id, this.id); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { - this.writeToXml(writer, XmlElementNames.PhoneCallId); - } - - /** - * Gets the Id of the phone call. - * - * @return the id - */ - protected String getId() { - return id; - } - - /** - * Sets the id. - * - * @param id the new id - */ - protected void setId(String id) { - this.id = id; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/messaging/UnifiedMessaging.java b/src/main/java/microsoft/exchange/webservices/data/messaging/UnifiedMessaging.java deleted file mode 100644 index 8ef7f559d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/messaging/UnifiedMessaging.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.messaging; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.request.DisconnectPhoneCallRequest; -import microsoft.exchange.webservices.data.core.request.GetPhoneCallRequest; -import microsoft.exchange.webservices.data.core.request.PlayOnPhoneRequest; -import microsoft.exchange.webservices.data.core.response.GetPhoneCallResponse; -import microsoft.exchange.webservices.data.core.response.PlayOnPhoneResponse; -import microsoft.exchange.webservices.data.property.complex.ItemId; - -/** - * Represents the Unified Messaging functionalities. - */ -public final class UnifiedMessaging { - - /** - * The service. - */ - private ExchangeService service; - - /** - * Constructor. - * - * @param service the service - */ - public UnifiedMessaging(ExchangeService service) { - this.service = service; - } - - /** - * Calls a phone and reads a message to the person who picks up. - * - * @param itemId the item id - * @param dialString the dial string - * @return An object providing status for the phone call. - * @throws Exception the exception - */ - public PhoneCall playOnPhone(ItemId itemId, String dialString) - throws Exception { - EwsUtilities.validateParam(itemId, "itemId"); - EwsUtilities.validateParam(dialString, "dialString"); - - PlayOnPhoneRequest request = new PlayOnPhoneRequest(service); - request.setDialString(dialString); - request.setItemId(itemId); - PlayOnPhoneResponse serviceResponse = request.execute(); - - PhoneCall callInformation = new PhoneCall(service, serviceResponse - .getPhoneCallId()); - - return callInformation; - } - - /** - * Retrieves information about a current phone call. - * - * @param id the id - * @return An object providing status for the phone call. - * @throws Exception the exception - */ - protected PhoneCall getPhoneCallInformation(PhoneCallId id) - throws Exception { - GetPhoneCallRequest request = new GetPhoneCallRequest(service); - request.setId(id); - GetPhoneCallResponse response = request.execute(); - - return response.getPhoneCall(); - } - - /** - * Disconnects a phone call. - * - * @param id the id - * @throws Exception the exception - */ - protected void disconnectPhoneCall(PhoneCallId id) throws Exception { - DisconnectPhoneCallRequest request = new DisconnectPhoneCallRequest( - service); - request.setId(id); - request.execute(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/AbstractAsyncCallback.java b/src/main/java/microsoft/exchange/webservices/data/misc/AbstractAsyncCallback.java deleted file mode 100644 index eaa694b71..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/AbstractAsyncCallback.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.concurrent.Future; - -public abstract class AbstractAsyncCallback implements Runnable, Callback { - - private static final Log LOG = LogFactory.getLog(AbstractAsyncCallback.class); - - Future task; - static boolean callbackProcessed = false; - - AbstractAsyncCallback() { - } - - AbstractAsyncCallback(Future t) { - this.task = t; - } - - public void run() { - while (!callbackProcessed) { - - if (task.isDone()) { - processMe(task); - callbackProcessed = true; - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - LOG.error(e); - } - break; - } - - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/AbstractFolderIdWrapper.java b/src/main/java/microsoft/exchange/webservices/data/misc/AbstractFolderIdWrapper.java deleted file mode 100644 index 5e9e72dab..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/AbstractFolderIdWrapper.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; - -/** - * Represents the abstraction of a folder Id. - */ -public abstract class AbstractFolderIdWrapper { - - /** - * Obtains the Folder object associated with the wrapper. - * - * @return The Folder object associated with the wrapper. - */ - public Folder getFolder() { - return null; - } - - /** - * Initializes a new instance of AbstractFolderIdWrapper. - */ - protected AbstractFolderIdWrapper() { - } - - /** - * Writes the Id encapsulated in the wrapper to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - protected abstract void writeToXml(EwsServiceXmlWriter writer) - throws Exception; - - /** - * Validates folderId against specified version. - * - * @param version the version - * @throws ServiceVersionException the service version exception - */ - protected void validate(ExchangeVersion version) - throws ServiceVersionException { - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/AbstractItemIdWrapper.java b/src/main/java/microsoft/exchange/webservices/data/misc/AbstractItemIdWrapper.java deleted file mode 100644 index 2acd24a41..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/AbstractItemIdWrapper.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.service.item.Item; - -/** - * Represents the abstraction of an item Id. - */ -abstract class AbstractItemIdWrapper { - - /** - * Initializes a new instance of the class. - */ - protected AbstractItemIdWrapper() { - } - - /** - * Obtains the ItemBase object associated with the wrapper. - * - * @return The ItemBase object associated with the wrapper - */ - public Item getItem() { - return null; - } - - /** - * Writes the Id encapsulated in the wrapper to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - protected abstract void writeToXml(EwsServiceXmlWriter writer) - throws Exception; -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/AsyncExecutor.java b/src/main/java/microsoft/exchange/webservices/data/misc/AsyncExecutor.java deleted file mode 100644 index 15589b88a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/AsyncExecutor.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; -import java.util.concurrent.RunnableFuture; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -public class AsyncExecutor extends ThreadPoolExecutor implements ExecutorService { - final static ArrayBlockingQueue queue = new ArrayBlockingQueue(1); - - public AsyncExecutor() { - super(1, 5, 10, TimeUnit.SECONDS, queue); - } - - public Future submit(Callable task, AsyncCallback callback) { - if (task == null) { - throw new NullPointerException(); - } - RunnableFuture ftask = newTaskFor(task); - execute(ftask); - if (callback != null) { - callback.setTask(ftask); - } - new Thread(callback).start(); - return ftask; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/AsyncRequestResult.java b/src/main/java/microsoft/exchange/webservices/data/misc/AsyncRequestResult.java deleted file mode 100644 index feb339ddc..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/AsyncRequestResult.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.request.HttpWebRequest; -import microsoft.exchange.webservices.data.core.request.ServiceRequestBase; -import microsoft.exchange.webservices.data.core.request.SimpleServiceRequestBase; -import microsoft.exchange.webservices.data.core.request.WaitHandle; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.FutureTask; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -public class AsyncRequestResult implements IAsyncResult { - - ServiceRequestBase serviceRequest; - HttpWebRequest webRequest; - AsyncCallback wasasyncCallback; - IAsyncResult webAsyncResult; - Object asyncState; - Future task; - - AsyncRequestResult(Future task) { - this.task = task; - } - - - public AsyncRequestResult(ServiceRequestBase serviceRequest, - HttpWebRequest webRequest, Future task, - Object asyncState) throws Exception { - EwsUtilities.validateParam(serviceRequest, "serviceRequest"); - EwsUtilities.validateParam(webRequest, "webRequest"); - EwsUtilities.validateParam(task, "task"); - this.serviceRequest = serviceRequest; - this.webRequest = webRequest; - this.asyncState = asyncState; - this.task = task; - - } - - public void setServiceRequestBase(ServiceRequestBase serviceRequest) { - this.serviceRequest = serviceRequest; - } - - private ServiceRequestBase getServiceRequest() { - return this.serviceRequest; - } - - public void setHttpWebRequest(HttpWebRequest webRequest) { - this.webRequest = webRequest; - } - - public HttpWebRequest getHttpWebRequest() { - return this.webRequest; - } - - public FutureTask getTask() { - return (FutureTask) this.task; - } - - public static T extractServiceRequest( - ExchangeService exchangeService, Future asyncResult) throws Exception { - EwsUtilities.validateParam(asyncResult, "asyncResult"); - AsyncRequestResult asyncRequestResult = (AsyncRequestResult) asyncResult; - if (asyncRequestResult == null) { - /** - * String.InvalidAsyncResult is copied from the error message - * HttpWebRequest.EndGetResponse() Just use this simple string for - * all kinds of invalid IAsyncResult parameters. - */ - throw new ArgumentException("Invalid AsyncResult.", - "asyncResult"); - } - // Validate the serivce request. - if (asyncRequestResult.serviceRequest == null) { - throw new ArgumentException("Invalid AsyncResult.", - "asyncResult"); - } - // Validate the service object - if (!asyncRequestResult.serviceRequest.getService().equals( - exchangeService)) { - throw new ArgumentException("Invalid AsyncResult.", - "asyncResult"); - } - T serviceRequest = (T) asyncRequestResult.getServiceRequest(); - // Validate the request type - if (serviceRequest == null) { - throw new ArgumentException("Invalid AsyncResult.", - "asyncResult"); - } - return serviceRequest; - - } - - - @Override - public boolean cancel(boolean arg0) { - // TODO Auto-generated method stub - return false; - } - - - - @Override - public Object get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, - TimeoutException { - // TODO Auto-generated method stub - return null; - } - - - @Override - public boolean isCancelled() { - // TODO Auto-generated method stub - return false; - } - - - @Override - public boolean isDone() { - // TODO Auto-generated method stub - return false; - } - - - @Override - public Object getAsyncState() { - // TODO Auto-generated method stub - return null; - } - - - @Override - public WaitHandle getAsyncWaitHanle() { - // TODO Auto-generated method stub - return null; - } - - - @Override - public boolean getCompleteSynchronously() { - // TODO Auto-generated method stub - return false; - } - - - @Override - public boolean getIsCompleted() { - // TODO Auto-generated method stub - return false; - } - - - @Override - public Object get() throws InterruptedException, ExecutionException { - // TODO Auto-generated method stub - return this.task.get(); - } - - - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/CalendarActionResults.java b/src/main/java/microsoft/exchange/webservices/data/misc/CalendarActionResults.java deleted file mode 100644 index c1afe48a0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/CalendarActionResults.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.service.item.Appointment; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.service.item.MeetingCancellation; -import microsoft.exchange.webservices.data.core.service.item.MeetingRequest; -import microsoft.exchange.webservices.data.core.service.item.MeetingResponse; - -/** - * Represents the results of an action performed on a calendar item or meeting - * message, such as accepting, tentatively accepting or declining a meeting - * request. - */ -public final class CalendarActionResults { - - /** - * The appointment. - */ - private Appointment appointment; - - /** - * The meeting request. - */ - private MeetingRequest meetingRequest; - - /** - * The meeting response. - */ - private MeetingResponse meetingResponse; - - /** - * The meeting cancellation. - */ - private MeetingCancellation meetingCancellation; - - /** - * Initializes a new instance of the class. - * - * @param items the item - */ - public CalendarActionResults(Iterable items) { - this.appointment = EwsUtilities.findFirstItemOfType(Appointment.class, items); - this.meetingRequest = EwsUtilities.findFirstItemOfType( - MeetingRequest.class, items); - this.meetingResponse = EwsUtilities.findFirstItemOfType( - MeetingResponse.class, items); - this.meetingCancellation = EwsUtilities.findFirstItemOfType( - MeetingCancellation.class, items); - } - - /** - * Gets the meeting that was accepted, tentatively accepted or declined. - *

- * When a meeting is accepted or tentatively accepted via an Appointment - * object, EWS recreates the meeting, and Appointment represents that new - * version. When a meeting is accepted or tentatively accepted via a - * MeetingRequest object, EWS creates an associated meeting in the - * attendee's calendar and Appointment represents that meeting. When - * declining a meeting via an Appointment object, EWS moves the appointment - * to the attendee's Deleted Items folder and Appointment represents that - * moved copy. When declining a meeting via a MeetingRequest object, EWS - * creates an associated meeting in the attendee's Deleted Items folder, and - * Appointment represents that meeting. When a meeting is declined via - * either an Appointment or a MeetingRequest object from the Deleted Items - * folder, Appointment is null. - * - * @return appointment - */ - public Appointment getAppointment() { - return this.appointment; - } - - /** - * Gets the meeting request that was moved to the Deleted Items folder as a - * result of an attendee accepting, tentatively accepting or declining a - * meeting request. If the meeting request is accepted, tentatively accepted - * or declined from the Deleted Items folder, it is permanently deleted and - * MeetingRequest is null. - * - * @return meetingRequest - */ - public MeetingRequest getMeetingRequest() { - return this.meetingRequest; - } - - /** - * Gets the copy of the response that is sent to the organizer of a meeting - * when the meeting is accepted, tentatively accepted or declined by an - * attendee. MeetingResponse is null if the attendee chose not to send a - * response. - * - * @return meetingResponse - */ - public MeetingResponse getMeetingResponse() { - return this.meetingResponse; - } - - /** - * Gets the copy of the meeting cancellation message sent by the organizer - * to the attendees of a meeting when the meeting is cancelled. - * - * @return meetingCancellation - */ - public MeetingCancellation getMeetingCancellation() { - return this.meetingCancellation; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/CallableMethod.java b/src/main/java/microsoft/exchange/webservices/data/misc/CallableMethod.java deleted file mode 100644 index e8d3d33c5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/CallableMethod.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.request.HttpClientWebRequest; -import microsoft.exchange.webservices.data.core.request.HttpWebRequest; -import microsoft.exchange.webservices.data.core.exception.http.EWSHttpException; -import microsoft.exchange.webservices.data.core.exception.http.HttpErrorException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.IOException; -import java.util.concurrent.Callable; - -public class CallableMethod implements Callable { - - private static final Log LOG = LogFactory.getLog(CallableMethod.class); - - HttpWebRequest request; - - public CallableMethod(HttpWebRequest request) { - this.request = request; - } - - protected HttpClientWebRequest executeMethod() throws EWSHttpException, HttpErrorException, IOException { - - request.executeRequest(); - return (HttpClientWebRequest) request; - } - - public HttpWebRequest call() { - - try { - return executeMethod(); - } catch (EWSHttpException e) { - // TODO Auto-generated catch block - LOG.error(e); - } catch (HttpErrorException e) { - // TODO Auto-generated catch block - LOG.error(e); - } catch (IOException e) { - // TODO Auto-generated catch block - LOG.error(e); - } - return request; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/ConversationAction.java b/src/main/java/microsoft/exchange/webservices/data/misc/ConversationAction.java deleted file mode 100644 index a86c7db8d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/ConversationAction.java +++ /dev/null @@ -1,387 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ConversationActionType; -import microsoft.exchange.webservices.data.core.enumeration.service.DeleteMode; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.property.complex.ConversationId; -import microsoft.exchange.webservices.data.property.complex.StringList; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.Date; - -/** - * ConversationAction class that represents - * ConversationActionType in the request XML. - * This class really is meant for representing - * single ConversationAction that needs to - * be taken on a conversation. - */ -public class ConversationAction { - - private static final Log LOG = LogFactory.getLog(ConversationAction.class); - - private ConversationActionType action; - private ConversationId conversationId; - private boolean processRightAway; - - private boolean enableAlwaysDelete; - private StringList categories; - private FolderIdWrapper moveFolderId; - private FolderIdWrapper contextFolderId; - private DeleteMode deleteType; - private Boolean isRead; - private Date conversationLastSyncTime; - - /** - * Gets conversation action - * - * @return action - */ - protected ConversationActionType getAction() { - return this.action; - } - - /** - * Sets conversation action - */ - public void setAction(ConversationActionType value) { - this.action = value; - } - - /** - * Gets conversation id - * - * @return conversationId - */ - protected ConversationId getConversationId() { - return this.conversationId; - } - - /** - * Sets conversation id - */ - public void setConversationId(ConversationId value) { - this.conversationId = value; - } - - /** - * Gets ProcessRightAway - * - * @return processRightAway - */ - protected boolean getProcessRightAway() { - return this.processRightAway; - } - - /** - * Sets ProcessRightAway - */ - public void setProcessRightAway(boolean value) { - this.processRightAway = value; - } - - - /** - * Gets conversation categories for Always Categorize action - * - * @return categories - */ - protected StringList getCategories() { - return this.categories; - } - - /** - * Sets conversation categories for Always Categorize actions - */ - public void setCategories(StringList value) { - this.categories = value; - } - - /** - * Gets Enable Always Delete value for Always Delete action - * - * @return enableAlwaysDelete - */ - protected boolean getEnableAlwaysDelete() { - return this.enableAlwaysDelete; - } - - /** - * Sets Enable Always Delete value for Always Delete action - */ - public void setEnableAlwaysDelete(boolean value) { - this.enableAlwaysDelete = value; - } - - /** - * IsRead - * - * @return isRead - */ - protected Boolean getIsRead() { - return this.isRead; - } - - /** - * IsRead - */ - public void setIsRead(Boolean value) { - this.isRead = value; - } - - /** - * DeleteType - * - * @return deleteType - */ - protected DeleteMode getDeleteType() { - return this.deleteType; - } - - /** - * DeleteType - */ - public void setDeleteType(DeleteMode value) { - this.deleteType = value; - } - - /** - * ConversationLastSyncTime is used in one - * time action to determine the item - * on which to take the action. - * - * @return conversationLastSyncTime - */ - protected Date getConversationLastSyncTime() { - return this.conversationLastSyncTime; - } - - /** - * ConversationLastSyncTime is used in - * one time action to determine the item - * on which to take the action. - */ - public void setConversationLastSyncTime(Date value) { - this.conversationLastSyncTime = value; - } - - /** - * Gets folder id ContextFolder - * - * @return contextFolderId - */ - protected FolderIdWrapper getContextFolderId() { - return this.contextFolderId; - } - - /** - * Sets folder id ContextFolder - */ - public void setContextFolderId(FolderIdWrapper value) { - this.contextFolderId = value; - } - - /** - * Gets folder id for Move action - * - * @return moveFolderId - */ - protected FolderIdWrapper getDestinationFolderId() { - return this.moveFolderId; - } - - /** - * Sets folder id for Move action - */ - public void setDestinationFolderId(FolderIdWrapper value) { - this.moveFolderId = value; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - protected String getXmlElementName() { - return XmlElementNames.ApplyConversationAction; - } - - /** - * Validate request. - * - * @throws Exception - */ - public void validate() throws Exception { - EwsUtilities.validateParam(this.conversationId, "conversationId"); - } - - /** - * Writes XML elements. - * - * @param writer The writer. - * @throws Exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeStartElement( - XmlNamespace.Types, - XmlElementNames.ConversationAction); - try { - String actionValue = null; - if (this.getAction() == ConversationActionType.AlwaysCategorize) { - actionValue = XmlElementNames.AlwaysCategorize; - } else if (this.getAction() == ConversationActionType.AlwaysDelete) { - actionValue = XmlElementNames.AlwaysDelete; - } else if (this.getAction() == ConversationActionType.AlwaysMove) { - actionValue = XmlElementNames.AlwaysMove; - } else if (this.getAction() == ConversationActionType.Delete) { - actionValue = XmlElementNames.Delete; - } else if (this.getAction() == ConversationActionType.Copy) { - actionValue = XmlElementNames.Copy; - } else if (this.getAction() == ConversationActionType.Move) { - actionValue = XmlElementNames.Move; - } else if (this.getAction() == ConversationActionType.SetReadState) { - actionValue = XmlElementNames.SetReadState; - } else { - throw new ArgumentException("ConversationAction"); - } - - // Emit the action element - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.Action, - actionValue); - - // Emit the conversation id element - this.getConversationId().writeToXml( - writer, - XmlNamespace.Types, - XmlElementNames.ConversationId); - - if (this.getAction() == ConversationActionType.AlwaysCategorize || - this.getAction() == ConversationActionType.AlwaysDelete || - this.getAction() == ConversationActionType.AlwaysMove) { - // Emit the ProcessRightAway element - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.ProcessRightAway, - EwsUtilities.boolToXSBool(this.getProcessRightAway())); - } - - if (this.getAction() == ConversationActionType.AlwaysCategorize) { - // Emit the categories element - if (this.getCategories() != null && this.getCategories().getSize() > 0) { - this.getCategories().writeToXml( - writer, - XmlNamespace.Types, - XmlElementNames.Categories); - } - } else if (this.getAction() == ConversationActionType.AlwaysDelete) { - // Emit the EnableAlwaysDelete element - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.EnableAlwaysDelete, - EwsUtilities.boolToXSBool(this. - getEnableAlwaysDelete())); - } else if (this.getAction() == ConversationActionType.AlwaysMove) { - // Emit the Move Folder Id - if (this.getDestinationFolderId() != null) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.DestinationFolderId); - this.getDestinationFolderId().writeToXml(writer); - writer.writeEndElement(); - } - } else { - if (this.getContextFolderId() != null) { - writer.writeStartElement( - XmlNamespace.Types, - XmlElementNames.ContextFolderId); - - this.getContextFolderId().writeToXml(writer); - - writer.writeEndElement(); - } - - if (this.getConversationLastSyncTime() != null) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.ConversationLastSyncTime, - this.getConversationLastSyncTime()); - } - - if (this.getAction() == ConversationActionType.Copy) { - EwsUtilities.ewsAssert(this.getDestinationFolderId() != null, - "ApplyconversationActionRequest", - "DestinationFolderId should be set when performing copy action"); - - writer.writeStartElement( - XmlNamespace.Types, - XmlElementNames.DestinationFolderId); - this.getDestinationFolderId().writeToXml(writer); - writer.writeEndElement(); - } else if (this.getAction() == ConversationActionType.Move) { - EwsUtilities.ewsAssert(this.getDestinationFolderId() != null, - "ApplyconversationActionRequest", - "DestinationFolderId should be set when performing move action"); - - writer.writeStartElement( - XmlNamespace.Types, - XmlElementNames.DestinationFolderId); - this.getDestinationFolderId().writeToXml(writer); - writer.writeEndElement(); - } else if (this.getAction() == ConversationActionType.Delete) { - EwsUtilities.ewsAssert(this.getDeleteType() != null, - "ApplyconversationActionRequest", - "DeleteType should be specified when deleting a conversation."); - - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.DeleteType, - this.getDeleteType()); - } else if (this.getAction() == ConversationActionType.SetReadState) { - EwsUtilities.ewsAssert(this.getIsRead() != null, - "ApplyconversationActionRequest", - "IsRead should be specified when marking/unmarking a conversation as read."); - - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsRead, - this.getIsRead()); - } - } - } catch (Exception e) { - LOG.error(e); - } finally { - writer.writeEndElement(); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/DelegateInformation.java b/src/main/java/microsoft/exchange/webservices/data/misc/DelegateInformation.java deleted file mode 100644 index dbe4f85a2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/DelegateInformation.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.response.DelegateUserResponse; -import microsoft.exchange.webservices.data.core.enumeration.service.MeetingRequestsDeliveryScope; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * Represents the results of a GetDelegates operation. - */ -public final class DelegateInformation { - - /** - * The delegate user response. - */ - private Collection delegateUserResponses; - - /** - * The meeting reqests delivery scope. - */ - private MeetingRequestsDeliveryScope meetingReqestsDeliveryScope; - - /** - * Initializes a DelegateInformation object. - * - * @param delegateUserResponses the delegate user response - * @param meetingReqestsDeliveryScope the meeting reqests delivery scope - */ - public DelegateInformation(List delegateUserResponses, - MeetingRequestsDeliveryScope meetingReqestsDeliveryScope) { - this.delegateUserResponses = new ArrayList( - delegateUserResponses); - this.meetingReqestsDeliveryScope = meetingReqestsDeliveryScope; - } - - /** - * Gets a list of response for each of the delegate users concerned by the - * operation. - * - * @return the delegate user response - */ - public Collection getDelegateUserResponses() { - return delegateUserResponses; - } - - /** - * Gets a value indicating if and how meeting request are delivered to - * delegates. - * - * @return the meeting reqests delivery scope - */ - public MeetingRequestsDeliveryScope getMeetingReqestsDeliveryScope() { - return meetingReqestsDeliveryScope; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/EwsTraceListener.java b/src/main/java/microsoft/exchange/webservices/data/misc/EwsTraceListener.java deleted file mode 100644 index ae1c5d165..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/EwsTraceListener.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * EwsTraceListener logs request/response. - */ -public class EwsTraceListener implements ITraceListener { - - private final Log log = LogFactory.getLog(EwsTraceListener.class); - - - public EwsTraceListener() { - } - - /** - * Handles a trace message. - * - * @param traceType The trace type - * @param traceMessage The trace message - */ - @Override - public void trace(String traceType, String traceMessage) { - if(log.isTraceEnabled()) { - log.trace(traceType + " - " + traceMessage); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/ExpandGroupResults.java b/src/main/java/microsoft/exchange/webservices/data/misc/ExpandGroupResults.java deleted file mode 100644 index e916becb1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/ExpandGroupResults.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; - -/** - * Represents the results of an ExpandGroup operation. - */ -public final class ExpandGroupResults implements Iterable { - - /** - * True, if all members are returned. EWS always returns true on ExpandDL, - * i.e. all members are returned. - */ - private boolean includesAllMembers; - - /** - * DL members. - */ - private Collection members = new ArrayList(); - - /** - * Initializes a new instance of the class. - */ - public ExpandGroupResults() { - } - - /** - * Gets the number of members that were returned by the ExpandGroup - * operation. Count might be less than the total number of members in the - * group, in which case the value of the IncludesAllMembers is false. - * - * @return the count - */ - public int getCount() { - return this.getMembers().size(); - } - - /** - * Gets a value indicating whether all the members of the group have been - * returned by ExpandGroup. - * - * @return the includes all members - */ - public boolean getIncludesAllMembers() { - return this.includesAllMembers; - } - - /** - * Gets the members of the expanded group. - * - * @return the members - */ - public Collection getMembers() { - return this.members; - } - - /** - * Gets the members of the expanded group. - * - * @param reader the reader - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader) throws Exception { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.DLExpansion); - if (!reader.isEmptyElement()) { - int totalItemsInView = reader.readAttributeValue(Integer.class, - XmlAttributeNames.TotalItemsInView); - this.includesAllMembers = reader.readAttributeValue(Boolean.class, - XmlAttributeNames.IncludesLastItemInRange); - - for (int i = 0; i < totalItemsInView; i++) { - EmailAddress emailAddress = new EmailAddress(); - - reader.readStartElement(XmlNamespace.Types, - XmlElementNames.Mailbox); - emailAddress.loadFromXml(reader, XmlElementNames.Mailbox); - - this.getMembers().add(emailAddress); - } - - reader.readEndElement(XmlNamespace.Messages, - XmlElementNames.DLExpansion); - } else { - reader.read(); - } - } - - /** - * Returns an iterator over a set of elements of type T. - * - * @return an Iterator. - */ - @Override - public Iterator iterator() { - - return members.iterator(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/FolderIdWrapper.java b/src/main/java/microsoft/exchange/webservices/data/misc/FolderIdWrapper.java deleted file mode 100644 index 03e71f3c7..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/FolderIdWrapper.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -/** - * Represents a folder Id provided by a FolderId object. - */ -public class FolderIdWrapper extends AbstractFolderIdWrapper { - - /** - * The FolderId object providing the Id. - */ - private FolderId folderId; - - /** - * Initializes a new instance of FolderIdWrapper. - * - * @param folderId the folder id - */ - public FolderIdWrapper(FolderId folderId) { - EwsUtilities.ewsAssert(folderId != null, "FolderIdWrapper.ctor", "folderId is null"); - this.folderId = folderId; - } - - /** - * Writes the Id encapsulated in the wrapper to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer) - throws Exception { - this.folderId.writeToXml(writer); - } - - /** - * Validates folderId against specified version. - * - * @param version the version - * @throws ServiceVersionException the service version exception - */ - protected void validate(ExchangeVersion version) - throws ServiceVersionException { - this.folderId.validate(version); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/FolderIdWrapperList.java b/src/main/java/microsoft/exchange/webservices/data/misc/FolderIdWrapperList.java deleted file mode 100644 index 5496fa522..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/FolderIdWrapperList.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Represents a list a abstracted folder Ids. - */ -public class FolderIdWrapperList implements Iterable { - - /** - * The ids. - */ - private List ids = new - ArrayList(); - - /** - * Adds the specified folder. - * - * @param folder the folder - * @throws ServiceLocalException the service local exception - */ - public void add(Folder folder) throws ServiceLocalException { - this.ids.add(new FolderWrapper(folder)); - } - - /** - * Adds the range. - * - * @param folders the folder - * @throws ServiceLocalException the service local exception - */ - protected void addRangeFolder(Iterable folders) - throws ServiceLocalException { - if (folders != null) { - for (Folder folder : folders) { - this.add(folder); - } - } - } - - /** - * Adds the specified folder id. - * - * @param folderId the folder id - */ - public void add(FolderId folderId) { - this.ids.add(new FolderIdWrapper(folderId)); - } - - /** - * Adds the range of folder ids. - * - * @param folderIds the folder ids - */ - public void addRangeFolderId(Iterable folderIds) { - if (folderIds != null) { - for (FolderId folderId : folderIds) { - this.add(folderId); - } - } - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param ewsNamesapce the ews namesapce - * @param xmlElementName the xml element name - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer, XmlNamespace ewsNamesapce, String xmlElementName) throws Exception { - if (this.getCount() > 0) { - writer.writeStartElement(ewsNamesapce, xmlElementName); - - for (AbstractFolderIdWrapper folderIdWrapper : this.ids) { - folderIdWrapper.writeToXml(writer); - } - - writer.writeEndElement(); - } - } - - /** - * Gets the id count. - * - * @return the count - */ - public int getCount() { - return this.ids.size(); - } - - /** - * Gets the at - * the specified index. - * - * @param i the i - * @return the index - */ - public AbstractFolderIdWrapper getFolderIdWrapperList(int i) { - return this.ids.get(i); - } - - /** - * Validates list of folderIds against a specified request version. - * - * @param version the version - * @throws ServiceVersionException the service version exception - */ - public void validate(ExchangeVersion version) - throws ServiceVersionException { - for (AbstractFolderIdWrapper folderIdWrapper : this.ids) { - folderIdWrapper.validate(version); - } - } - - /* - * (non-Javadoc) - * - * @see java.lang.Iterable#iterator() - */ - @Override - public Iterator iterator() { - return ids.iterator(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/FolderWrapper.java b/src/main/java/microsoft/exchange/webservices/data/misc/FolderWrapper.java deleted file mode 100644 index d9c8ff4c3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/FolderWrapper.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -/** - * Represents a folder Id provided by a Folder object. - */ -class FolderWrapper extends AbstractFolderIdWrapper { - - /** - * The Folder object providing the Id. - */ - private Folder folder; - - /** - * Initializes a new instance of FolderWrapper. - * - * @param folder the folder - * @throws ServiceLocalException the service local exception - */ - protected FolderWrapper(Folder folder) throws ServiceLocalException { - EwsUtilities.ewsAssert(folder != null, "FolderWrapper.ctor", "folder is null"); - EwsUtilities.ewsAssert(!folder.isNew(), "FolderWrapper.ctor", "folder does not have an Id"); - this.folder = folder; - } - - /** - * Obtains the Folder object associated with the wrapper. - * - * @return The Folder object associated with the wrapper - */ - public Folder getFolder() { - return this.folder; - } - - /** - * Writes the Id encapsulated in the wrapper to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { - this.folder.getId().writeToXml(writer); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/HangingTraceStream.java b/src/main/java/microsoft/exchange/webservices/data/misc/HangingTraceStream.java deleted file mode 100644 index d4c3bcec8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/HangingTraceStream.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.request.HangingServiceRequestBase; -import microsoft.exchange.webservices.data.core.enumeration.misc.TraceFlags; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.xml.stream.XMLStreamException; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * A stream that traces everything it returns from its Read() call. - * That trace may be retrieved at the end of the stream. - */ -public class HangingTraceStream extends InputStream { - - private static final Log LOG = LogFactory.getLog(HangingTraceStream.class); - - private final InputStream underlyingStream; - private final ExchangeService service; - private ByteArrayOutputStream responseCopy; - - /** - * Initializes a new instance of the HangingTraceStream class. - * - * @param stream The stream. - * @param service the service. - */ - public HangingTraceStream(final InputStream stream, final ExchangeService service) { - this.underlyingStream = stream; - this.service = service; - } - - /** - * Gets a value indicating whether the current stream supports reading. - * - * @return true - */ - public boolean getCanRead() { - return true; - } - - /** - * Gets a value indicating whether the current stream supports seeking. - * - * @return false - */ - public boolean getCanSeek() { - return false; - } - - /** - * Gets a value indicating whether the current stream supports writing. - * - * @return false - */ - public boolean getCanWrite() { - return false; - } - - /** - * When overridden in a derived class, clears all buffers - * for this stream and causes any buffered data to be - * written to the underlying device. - *@exception An I/O error occurs. - */ - /* - * @Override public void close() { // no-op } - */ - - /** - * When overridden in a derived class, reads a sequence of - * bytes from the current stream and advances the - * position within the stream by the number of bytes read. - * - * @param buffer An array of bytes. When this method returns, the buffer - * contains the specified byte array with the values between - * @param offset The zero-based byte offset in at which to - * begin storing the data read from the current stream. - * @param count The maximum number of bytes to be read from the current stream. - * @return The total number of bytes read into the buffer. - * This can be less than the number of bytes requested if that - * many bytes are not currently available, or zero (0) - * if the end of the stream has been reached. - * @throws IOException The sum of offset and count is larger than the buffer length. - */ - @Override - public int read(byte[] buffer, int offset, int count) throws IOException { - count = HangingServiceRequestBase.BUFFER_SIZE; - final int retVal = underlyingStream.read(buffer, offset, count); - - if (HangingServiceRequestBase.isLogAllWireBytes()) { - final String readString = new String(buffer, offset, count, "UTF-8"); - final String logMessage = String.format( - "HangingTraceStream ID [%d] returned %d bytes. Bytes returned: [%s]", - hashCode(), retVal, readString); - - try { - service.traceMessage(TraceFlags.DebugMessage, logMessage); - } catch (final XMLStreamException e) { - LOG.error(e); - } - } - - if (responseCopy != null) { - responseCopy.write(buffer, offset, retVal); - } - - return retVal; - } - - /** - * Sets the response copy. - * - * @param responseCopy a copy of response - */ - public void setResponseCopy(final ByteArrayOutputStream responseCopy) { - this.responseCopy = responseCopy; - } - - @Override - public int read() throws IOException { - return 0; - } - -} - diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/IFunctions.java b/src/main/java/microsoft/exchange/webservices/data/misc/IFunctions.java deleted file mode 100644 index 99c07e0e5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/IFunctions.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import org.apache.commons.codec.binary.Base64; - -import java.util.Date; -import java.util.UUID; - -/** - * Class with re-usable function implementations. - */ - -public final class IFunctions { - - private IFunctions() { - throw new UnsupportedOperationException(); - } - - public static class ToString implements IFunction { - public static final ToString INSTANCE = new ToString(); - - public String func(final Object o) { - return String.valueOf(o); - } - } - - public static class ToBoolean implements IFunction { - public static final ToBoolean INSTANCE = new ToBoolean(); - - public Boolean func(final String s) { - return Boolean.parseBoolean(s); - } - } - - public static class StringToObject implements IFunction { - public static final StringToObject INSTANCE = new StringToObject(); - - public Object func(final String o) { - return o; - } - } - - public static class ToUUID implements IFunction { - public static final ToUUID INSTANCE = new ToUUID(); - - public Object func(final String s) { - return UUID.fromString(s); - } - } - - public static class Base64Decoder implements IFunction { - public static final Base64Decoder INSTANCE = new Base64Decoder(); - - public Object func(final String s) { - return Base64.decodeBase64(s); - } - } - - public static class Base64Encoder implements IFunction { - public static final Base64Encoder INSTANCE = new Base64Encoder(); - - public String func(final Object o) { - return Base64.encodeBase64String((byte[]) o); - } - } - - public static class ToLowerCase implements IFunction { - public static final ToLowerCase INSTANCE = new ToLowerCase(); - - public String func(final Object o) { - return o == null ? null : o.toString().toLowerCase(); - } - } - - public static class DateTimeToXSDateTime implements IFunction { - public static final DateTimeToXSDateTime INSTANCE = new DateTimeToXSDateTime(); - - public String func(final Object o) { - return EwsUtilities.dateTimeToXSDateTime((Date) o); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/ImpersonatedUserId.java b/src/main/java/microsoft/exchange/webservices/data/misc/ImpersonatedUserId.java deleted file mode 100644 index f4164f5d0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/ImpersonatedUserId.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ConnectingIdType; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -/** - * Represents an impersonated user Id. - */ -public final class ImpersonatedUserId { - - /** - * The id type. - */ - private ConnectingIdType idType; - - /** - * The id. - */ - private String id; - - /** - * Instantiates a new impersonated user id. - */ - public ImpersonatedUserId() { - } - - /** - * Initializes a new instance of ConnectingId. - * - * @param idType The type of this Id. - * @param id The user Id. - */ - public ImpersonatedUserId(ConnectingIdType idType, String id) { - this(); - this.idType = idType; - this.id = id; - } - - /** - * Writes to XML. - * - * @param writer The writer - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer) throws Exception { - if (this.id == null || this.id.isEmpty()) { - throw new Exception("The Id property must be set."); - } - - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.ExchangeImpersonation); - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.ConnectingSID); - - // For 2007 SP1, use PrimarySmtpAddress for type SmtpAddress - String connectingIdTypeLocalName = (this.idType == - ConnectingIdType.SmtpAddress) && - (writer.getService().getRequestedServerVersion() == - ExchangeVersion.Exchange2007_SP1) ? - XmlElementNames.PrimarySmtpAddress : - this.getIdType().toString(); - - writer.writeElementValue(XmlNamespace.Types, connectingIdTypeLocalName, - this.id); - - writer.writeEndElement(); // ConnectingSID - writer.writeEndElement(); // ExchangeImpersonation - } - - /** - * Gets the type of the Id. - * - * @return the id type - */ - public ConnectingIdType getIdType() { - return idType; - } - - /** - * Sets the id type. - * - * @param idType the new id type - */ - public void setIdType(ConnectingIdType idType) { - this.idType = idType; - } - - /** - * Gets the user Id. - * - * @return the id - */ - public String getId() { - return id; - } - - /** - * Sets the id. - * - * @param id the new id - */ - public void setId(String id) { - this.id = id; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/ItemIdWrapper.java b/src/main/java/microsoft/exchange/webservices/data/misc/ItemIdWrapper.java deleted file mode 100644 index 1d704202d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/ItemIdWrapper.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.property.complex.ItemId; - -/** - * Represents an item Id provided by a ItemId object. - */ -class ItemIdWrapper extends AbstractItemIdWrapper { - - /** - * The ItemId object providing the Id. - */ - private ItemId itemId; - - /** - * Initializes a new instance of ItemIdWrapper. - * - * @param itemId the item id - */ - protected ItemIdWrapper(ItemId itemId) { - EwsUtilities.ewsAssert(itemId != null, "ItemIdWrapper.ctor", "itemId is null"); - this.itemId = itemId; - } - - /** - * Writes the Id encapsulated in the wrapper to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { - this.itemId.writeToXml(writer); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/ItemIdWrapperList.java b/src/main/java/microsoft/exchange/webservices/data/misc/ItemIdWrapperList.java deleted file mode 100644 index 7a5f9ef02..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/ItemIdWrapperList.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.ItemId; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Represents a list a abstracted item Ids. - */ -public class ItemIdWrapperList implements Iterable { - - /** - * The item ids. - */ - private List itemIds = - new ArrayList(); - - /** - * Initializes a new instance of the class. - */ - public ItemIdWrapperList() { - } - - /** - * Adds the specified item. - * - * @param item the item - * @throws ServiceLocalException the service local exception - */ - protected void add(Item item) throws ServiceLocalException { - this.itemIds.add(new ItemWrapper(item)); - - } - - /** - * Adds the specified item. - * - * @param items the item - * @throws ServiceLocalException the service local exception - */ - public void addRangeItem(Iterable items) - throws ServiceLocalException { - for (Item item : items) { - this.add(item); - } - } - - /** - * Adds the range. - * - * @param itemIds the item ids - */ - public void addRange(Iterable itemIds) { - for (ItemId itemId : itemIds) { - this.add(itemId); - } - } - - /** - * Adds the specified item id. - * - * @param itemId the item id - */ - protected void add(ItemId itemId) { - this.itemIds.add(new ItemIdWrapper(itemId)); - - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param ewsNamesapce the ews namesapce - * @param xmlElementName the xml element name - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer, XmlNamespace ewsNamesapce, String xmlElementName) throws Exception { - if (this.getCount() > 0) { - writer.writeStartElement(ewsNamesapce, xmlElementName); - - for (AbstractItemIdWrapper itemIdWrapper : this.itemIds) { - itemIdWrapper.writeToXml(writer); - } - - writer.writeEndElement(); - } - } - - /** - * Gets the count. - * - * @return the count - */ - public int getCount() { - return this.itemIds.size(); - } - - /** - * Gets the item at the specified index. - * - * @param i the i - * @return the item id wrapper list - */ - public Item getItemIdWrapperList(int i) { - return this.itemIds.get(i).getItem(); - } - - /** - * Gets an Iterator that iterates through the elements of the collection. - * - * @return An IEnumerator for the collection - */ - @Override - public Iterator iterator() { - - return itemIds.iterator(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/ItemWrapper.java b/src/main/java/microsoft/exchange/webservices/data/misc/ItemWrapper.java deleted file mode 100644 index 5b13cbe3a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/ItemWrapper.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -/** - * Represents an item Id provided by a ItemBase object. - */ -class ItemWrapper extends AbstractItemIdWrapper { - - /** - * The ItemBase object providing the Id. - */ - private Item item; - - /** - * Initializes a new instance of ItemWrapper. - * - * @param item the item - * @throws ServiceLocalException the service local exception - */ - protected ItemWrapper(final Item item) throws ServiceLocalException { - EwsUtilities.ewsAssert(item != null, "ItemWrapper.ctor", "item is null"); - EwsUtilities.ewsAssert(!item.isNew(), "ItemWrapper.ctor", "item does not have an Id"); - this.item = item; - } - - /** - * Obtains the ItemBase object associated with the wrapper. - * - * @return The ItemBase object associated with the wrapper - */ - public Item getItem() { - return this.item; - } - - /** - * Writes the Id encapsulated in the wrapper to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { - this.item.getId().writeToXml(writer); - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/MapiTypeConverter.java b/src/main/java/microsoft/exchange/webservices/data/misc/MapiTypeConverter.java deleted file mode 100644 index 4ad9dbf68..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/MapiTypeConverter.java +++ /dev/null @@ -1,326 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ILazyMember; -import microsoft.exchange.webservices.data.core.LazyMember; -import microsoft.exchange.webservices.data.core.enumeration.property.MapiPropertyType; -import microsoft.exchange.webservices.data.core.exception.misc.FormatException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -/** - * Utility class to convert between MAPI Property type values and strings. - */ -public class MapiTypeConverter { - - private static final Log LOG = LogFactory.getLog(MapiTypeConverter.class); - - private static final IFunction DATE_TIME_PARSER = new IFunction() { - public Object func(final String s) { - return parseDateTime(s); - } - }; - - private static final IFunction MAPI_VALUE_PARSER = new IFunction() { - public Object func(final String s) { - return MapiTypeConverter.parseMapiIntegerValue(s); - } - }; - - /** - * The mapi type converter map. - */ - private static final LazyMember MAPI_TYPE_CONVERTER_MAP = - new LazyMember(new ILazyMember() { - @Override - public MapiTypeConverterMap createInstance() { - MapiTypeConverterMap map = new MapiTypeConverterMap(); - - map.put(MapiPropertyType.ApplicationTime, new MapiTypeConverterMapEntry(Double.class)); - - MapiTypeConverterMapEntry mapitype = new MapiTypeConverterMapEntry(Double.class); - mapitype.setIsArray(true); - map.put(MapiPropertyType.ApplicationTimeArray, mapitype); - - mapitype = new MapiTypeConverterMapEntry(Byte[].class); - mapitype.setParse(IFunctions.Base64Decoder.INSTANCE); - mapitype.setConvertToString(IFunctions.Base64Encoder.INSTANCE); - map.put(MapiPropertyType.Binary, mapitype); - - mapitype = new MapiTypeConverterMapEntry(Byte[].class); - mapitype.setParse(IFunctions.Base64Decoder.INSTANCE); - mapitype.setConvertToString(IFunctions.Base64Encoder.INSTANCE); - mapitype.setIsArray(true); - map.put(MapiPropertyType.BinaryArray, mapitype); - - mapitype = new MapiTypeConverterMapEntry(Boolean.class); - mapitype.setParse(IFunctions.ToBoolean.INSTANCE); - mapitype.setConvertToString(IFunctions.ToLowerCase.INSTANCE); - map.put(MapiPropertyType.Boolean, mapitype); - - mapitype = new MapiTypeConverterMapEntry(UUID.class); - mapitype.setParse(IFunctions.ToUUID.INSTANCE); - mapitype.setConvertToString(IFunctions.ToString.INSTANCE); - map.put(MapiPropertyType.CLSID, mapitype); - - mapitype = new MapiTypeConverterMapEntry(UUID.class); - mapitype.setParse(IFunctions.ToUUID.INSTANCE); - mapitype.setConvertToString(IFunctions.ToString.INSTANCE); - mapitype.setIsArray(true); - map.put(MapiPropertyType.CLSIDArray, mapitype); - - map.put(MapiPropertyType.Currency, new MapiTypeConverterMapEntry(Long.class)); - - mapitype = new MapiTypeConverterMapEntry(Long.class); - mapitype.setIsArray(true); - map.put(MapiPropertyType.CurrencyArray, mapitype); - - map.put(MapiPropertyType.Double, new MapiTypeConverterMapEntry(Double.class)); - - mapitype = new MapiTypeConverterMapEntry(Double.class); - mapitype.setIsArray(true); - map.put(MapiPropertyType.DoubleArray, mapitype); - - map.put(MapiPropertyType.Error, new MapiTypeConverterMapEntry(Integer.class)); - map.put(MapiPropertyType.Float, new MapiTypeConverterMapEntry(Float.class)); - - mapitype = new MapiTypeConverterMapEntry(Float.class); - mapitype.setIsArray(true); - map.put(MapiPropertyType.FloatArray, mapitype); - - mapitype = new MapiTypeConverterMapEntry(Integer.class); - mapitype.setParse(MAPI_VALUE_PARSER); - map.put(MapiPropertyType.Integer, mapitype); - - mapitype = new MapiTypeConverterMapEntry(Integer.class); - mapitype.setIsArray(true); - map.put(MapiPropertyType.IntegerArray, mapitype); - - map.put(MapiPropertyType.Long, new MapiTypeConverterMapEntry(Long.class)); - - mapitype = new MapiTypeConverterMapEntry(Long.class); - mapitype.setIsArray(true); - map.put(MapiPropertyType.LongArray, mapitype); - - mapitype = new MapiTypeConverterMapEntry(String.class); - mapitype.setParse(IFunctions.StringToObject.INSTANCE); - map.put(MapiPropertyType.Object, mapitype); - - mapitype = new MapiTypeConverterMapEntry(String.class); - mapitype.setParse(IFunctions.StringToObject.INSTANCE); - mapitype.setIsArray(true); - map.put(MapiPropertyType.ObjectArray, mapitype); - - map.put(MapiPropertyType.Short, new MapiTypeConverterMapEntry(Short.class)); - - mapitype = new MapiTypeConverterMapEntry(Short.class); - mapitype.setIsArray(true); - map.put(MapiPropertyType.ShortArray, mapitype); - - mapitype = new MapiTypeConverterMapEntry(String.class); - mapitype.setParse(IFunctions.StringToObject.INSTANCE); - map.put(MapiPropertyType.String, mapitype); - - mapitype = new MapiTypeConverterMapEntry(String.class); - mapitype.setParse(IFunctions.StringToObject.INSTANCE); - mapitype.setIsArray(true); - map.put(MapiPropertyType.StringArray, mapitype); - - mapitype = new MapiTypeConverterMapEntry(Date.class); - mapitype.setParse(DATE_TIME_PARSER); - mapitype.setConvertToString(IFunctions.DateTimeToXSDateTime.INSTANCE); - map.put(MapiPropertyType.SystemTime, mapitype); - - mapitype = new MapiTypeConverterMapEntry(Date.class); - mapitype.setParse(DATE_TIME_PARSER); - mapitype.setConvertToString(IFunctions.DateTimeToXSDateTime.INSTANCE); - mapitype.setIsArray(true); - map.put(MapiPropertyType.SystemTimeArray, mapitype); - - return map; - } - }); - - - /** - * Converts the string list to array. - * - * @param mapiPropType Type of the MAPI property. - * @param strings the strings - * @return Array of objects. - * @throws Exception the exception - */ - public static List convertToValue(MapiPropertyType mapiPropType, Iterator strings) throws Exception { - EwsUtilities.validateParam(strings, "strings"); - - MapiTypeConverterMapEntry typeConverter = getMapiTypeConverterMap() - .get(mapiPropType); - List array = new ArrayList(); - - int index = 0; - - while (strings.hasNext()) { - Object value = typeConverter.convertToValueOrDefault(strings.next()); - array.add(index, value); - } - return array; - } - - /** - * Converts a string to value consistent with MAPI type. - * - * @param mapiPropType the mapi prop type - * @param stringValue the string value - * @return the object - * @throws ServiceXmlDeserializationException the service xml deserialization exception - * @throws FormatException the format exception - */ - public static Object convertToValue(MapiPropertyType mapiPropType, String stringValue) throws ServiceXmlDeserializationException, FormatException { - return getMapiTypeConverterMap().get(mapiPropType).convertToValue( - stringValue); - - } - - /** - * Converts a value to a string. - * - * @param mapiPropType the mapi prop type - * @param value the value - * @return String value. - */ - public static String convertToString(MapiPropertyType mapiPropType, Object value) { - /* - * if(! (value instanceof FuncInterface)){ return null; } - */ - return (value == null) ? "" : getMapiTypeConverterMap().get( - mapiPropType).getConvertToString().func(value); - } - - /** - * Change value to a value of compatible type. - * - * @param mapiType the mapi type - * @param value the value - * @return the object - * @throws Exception the exception - */ - public static Object changeType(MapiPropertyType mapiType, Object value) - throws Exception { - EwsUtilities.validateParam(value, "value"); - - return getMapiTypeConverterMap().get(mapiType).changeType(value); - } - - /** - * Converts a MAPI Integer value. - * Usually the value is an integer but there are cases where the value has been "schematized" to an - * Enumeration value (e.g. NoData) which we have no choice but to fallback and represent as a string. - * - * @param s The string value. - * @return Integer value or the original string if the value could not be parsed as such. - */ - protected static Object parseMapiIntegerValue(String s) { - int intValue; - try { - intValue = Integer.parseInt(s.trim()); - return Integer.valueOf(intValue); - } catch (NumberFormatException e) { - return s; - } - } - - /** - * Determines whether MapiPropertyType is an array type. - * - * @param mapiType the mapi type - * @return true, if is array type - */ - public static boolean isArrayType(MapiPropertyType mapiType) { - return getMapiTypeConverterMap().get(mapiType).getIsArray(); - } - - /** - * Gets the MAPI type converter map. - * - * @return the mapi type converter map - */ - public static Map - getMapiTypeConverterMap() { - - return MAPI_TYPE_CONVERTER_MAP.getMember(); - } - - - private static Object parseDateTime(String s) { - String utcPattern = "yyyy-MM-dd'T'HH:mm:ss'Z'"; - String errMsg = String.format("Date String %s not in " + "valid UTC/local format", s); - DateFormat utcFormatter = new SimpleDateFormat(utcPattern); - Date dt; - - if (s.endsWith("Z")) { - try { - dt = utcFormatter.parse(s); - } catch (ParseException e) { - s = s.substring(0, 10) + "T12:00:00Z"; - try { - dt = utcFormatter.parse(s); - } catch (ParseException e1) { - LOG.error(e); - throw new IllegalArgumentException( - errMsg, e); - } - } - } else if (s.endsWith("z")) { - // String in UTC format yyyy-MM-ddTHH:mm:ssZ - utcFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'z'"); - try { - dt = utcFormatter.parse(s); - } catch (ParseException e) { - throw new IllegalArgumentException(e); - } - } else { - utcFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); - try { - dt = utcFormatter.parse(s); - } catch (ParseException e) { - throw new IllegalArgumentException(e); - } - } - return dt; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/MapiTypeConverterMapEntry.java b/src/main/java/microsoft/exchange/webservices/data/misc/MapiTypeConverterMapEntry.java deleted file mode 100644 index 6ca1f0228..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/MapiTypeConverterMapEntry.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ILazyMember; -import microsoft.exchange.webservices.data.core.LazyMember; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentNullException; -import microsoft.exchange.webservices.data.core.exception.misc.FormatException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -/** - * Represents an entry in the MapiTypeConverter map. - */ -public class MapiTypeConverterMapEntry { - - private static final Log LOG = LogFactory.getLog(MapiTypeConverterMapEntry.class); - - /** - * Map CLR types used for MAPI property to matching default values. - */ - private static LazyMember, Object>> defaultValueMap = new LazyMember, Object>>( - new ILazyMember, Object>>() { - public Map, Object> createInstance() { - - Map, Object> map = new HashMap, Object>(); - - map.put(Boolean.class, false); - map.put(Byte[].class, null); - map.put(Short.class, new Short((short) 0)); - map.put(Integer.class, 0); - map.put(Long.class, new Long(0L)); - map.put(Float.class, new Float(0.0)); - map.put(Double.class, new Double(0.0D)); - SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - try { - map.put(Date.class, formatter.parse("0001-01-01 12:00:00")); - } catch (ParseException e) { - LOG.error(e); - } - map.put(UUID.class, UUID.fromString("00000000-0000-0000-0000-000000000000")); - map.put(String.class, null); - - return map; - - } - }); - /** - * The is array. - */ - boolean isArray; - - /** - * The type. - */ - Class type; - - /** - * The convert to string. - */ - IFunction convertToString; - - /** - * The parse. - */ - IFunction parse; - - /** - * Initializes a new instance of the MapiTypeConverterMapEntry class. - * - * @param type The type. y default, converting a type to string is done by - * calling value.ToString. Instances can override this behavior. - *

- * By default, converting a string to the appropriate value type - * is done by calling Convert.ChangeType Instances may override - * this behavior. - */ - public MapiTypeConverterMapEntry(Class type) { - EwsUtilities.ewsAssert(defaultValueMap.getMember().containsKey(type), "MapiTypeConverterMapEntry ctor", - "No default value entry for type " + type.getName()); - - this.type = type; - this.convertToString = IFunctions.ToString.INSTANCE; - this.parse = IFunctions.StringToObject.INSTANCE; - } - - /** - * Change value to a value of compatible type. - *

- * The type of a simple value should match exactly or be convertible to the - * appropriate type. An array value has to be a single dimension (rank), - * contain at least one value and contain elements that exactly match the - * expected type. (We could relax this last requirement so that, for - * example, you could pass an array of Int32 that could be converted to an - * array of Double but that seems like overkill). - * - * @param value The value. - * @return New value. - * @throws Exception the exception - */ - public Object changeType(Object value) throws Exception { - if (this.getIsArray()) { - this.validateValueAsArray(value); - return value; - } else if (value.getClass() == this.getType()) { - return value; - } else { - try { - if (this.getType().isInstance(Integer.valueOf(0))) { - Object o = null; - o = Integer.parseInt(value + ""); - return o; - } else if (this.getType().isInstance(new Date())) { - DateFormat df = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss'Z'"); - return df.parse(value + ""); - } else if (this.getType().isInstance(Boolean.valueOf(false))) { - Object o = null; - o = Boolean.parseBoolean(value + ""); - return o; - } else if (this.getType().isInstance(String.class)) { - return value; - } - return null; - } catch (ClassCastException ex) { - throw new ArgumentException(String.format( - "The value '%s' of type %s can't be converted to a value of type %s.", "%s", "%s" - , this.getType()), ex); - } - } - } - - /** - * Converts a string to value consistent with type. - *

- * For array types, this method is called for each array element. - * - * @param stringValue String to convert to a value. - * @return value - * @throws ServiceXmlDeserializationException the service xml deserialization exception - * @throws FormatException the format exception - */ - public Object convertToValue(String stringValue) - throws ServiceXmlDeserializationException, FormatException { - try { - return this.getParse().func(stringValue); - } catch (ClassCastException ex) { - throw new ServiceXmlDeserializationException(String - .format("The value '%s' couldn't be converted to type %s.", stringValue, this - .getType()), ex); - } catch (NumberFormatException ex) { - throw new ServiceXmlDeserializationException(String - .format("The value '%s' couldn't be converted to type %s.", stringValue, this.getType()), ex); - } - - } - - /** - * Converts a string to value consistent with type (or uses the default value if the string is null or empty). - * - * @param stringValue to convert to a value. - * @return Value. - * @throws FormatException - * @throws ServiceXmlDeserializationException - */ - public Object convertToValueOrDefault(final String stringValue) - throws ServiceXmlDeserializationException, FormatException { - return (StringUtils.isEmpty(stringValue)) - ? getDefaultValue() : convertToValue(stringValue); - } - - /** - * Validates array value. - * - * @param value the value - * @throws ArgumentException the argument exception - * @throws ArgumentNullException the argument exception - */ - private void validateValueAsArray(Object value) throws ArgumentException, ArgumentNullException { - if (value == null) { - throw new ArgumentNullException("value"); - } - - if (value instanceof ArrayList) { - ArrayList arrayList = (ArrayList) value; - if (arrayList.isEmpty()) { - throw new ArgumentException("The Array value must have at least one element."); - } - - if (arrayList.get(0).getClass() != this.getType()) { - throw new ArgumentException(String.format("Type %s can't be used as an array of type %s.", value.getClass(), - this.getType())); - } - } - } - - /** - * Gets the dim. If `array' is an array object returns its dimensions; - * otherwise returns 0 - * - * @param array the array - * @return the dim - */ - public static int getDim(Object array) { - int dim = 0; - Class cls = array.getClass(); - while (cls.isArray()) { - dim++; - cls = cls.getComponentType(); - } - return dim; - } - - /** - * Gets the type. - * - * @return the type - */ - - public Class getType() { - return this.type; - } - - /** - * Sets the type. - * - * @param cls the new type - */ - public void setType(Class cls) { - type = cls; - } - - /** - * Gets a value indicating whether this instance is array. - * - * @return the checks if is array - */ - public boolean getIsArray() { - return isArray; - - } - - /** - * Sets the checks if is array. - * - * @param value the new checks if is array - */ - protected void setIsArray(boolean value) { - isArray = value; - } - - /** - * Gets the string to object converter. For array types, this method is - * called for each array element. - * - * @return the convert to string - */ - protected IFunction getConvertToString() { - return convertToString; - } - - /** - * Sets the string to object converter. - * - * @param value the value - */ - protected void setConvertToString(IFunction value) { - convertToString = value; - } - - /** - * Gets the string parser. For array types, this method is called for each - * array element. - * - * @return the parses the - */ - protected IFunction getParse() { - return parse; - } - - /** - * Sets the string parser. - * - * @param value the value - */ - protected void setParse(IFunction value) { - parse = value; - } - - /** - * Gets the default value for the type. - * - * @return Type - */ - protected Object getDefaultValue() { - return defaultValueMap.getMember().get(this.type); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/MobilePhone.java b/src/main/java/microsoft/exchange/webservices/data/misc/MobilePhone.java deleted file mode 100644 index 6ec0b2d6d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/MobilePhone.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.ISelfValidate; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; - -/** - * Represents a mobile phone. - */ -public final class MobilePhone implements ISelfValidate { - - /** - * Name of the mobile phone. - */ - private String name; - - /** - * Phone number of the mobile phone. - */ - private String phoneNumber; - - /** - * Initializes a new instance of the class. - */ - public MobilePhone() { - } - - /** - * Initializes a new instance of the MobilePhone class. - * - * @param name The name associated with the mobile phone. - * @param phoneNumber The mobile phone number. - */ - public MobilePhone(String name, String phoneNumber) { - this.name = name; - this.phoneNumber = phoneNumber; - } - - /** - * Gets or sets the name associated with this mobile phone. - */ - public String getName() { - return this.name; - } - - public void setName(String value) { - this.name = value; - } - - - /** - * Gets or sets the number of this mobile phone. - */ - public String getPhoneNumber() { - return this.phoneNumber; - } - - public void setPhoneNumber(String value) { - this.phoneNumber = value; - } - - - /** - * Validates this instance. - * - * @throws ServiceValidationException on validation error - */ - public void validate() throws ServiceValidationException { - if (this.getPhoneNumber() == null || this.getPhoneNumber().isEmpty()) { - throw new ServiceValidationException( - "PhoneNumber cannot be empty."); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/NameResolution.java b/src/main/java/microsoft/exchange/webservices/data/misc/NameResolution.java deleted file mode 100644 index ecd3b50c6..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/NameResolution.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.item.Contact; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.EmailAddress; - -/** - * Represents a suggested name resolution. - */ -public final class NameResolution { - - /** - * The owner. - */ - private NameResolutionCollection owner; - - /** - * The mailbox. - */ - private EmailAddress mailbox = new EmailAddress(); - - /** - * The contact. - */ - private Contact contact; - - /** - * Initializes a new instance of the class. - * - * @param owner the owner - */ - protected NameResolution(NameResolutionCollection owner) { - EwsUtilities.ewsAssert(owner != null, "NameResolution.ctor", "owner is null."); - - this.owner = owner; - } - - /** - * Loads from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - protected void loadFromXml(EwsServiceXmlReader reader) throws Exception { - reader.readStartElement(XmlNamespace.Types, XmlElementNames.Resolution); - reader.readStartElement(XmlNamespace.Types, XmlElementNames.Mailbox); - this.mailbox.loadFromXml(reader, XmlElementNames.Mailbox); - - reader.read(); - if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.Contact)) { - this.contact = new Contact(this.owner.getSession()); - this.contact.loadFromXml(reader, true /* clearPropertyBag */, - PropertySet.FirstClassProperties, - false /* summaryPropertiesOnly */); - - reader.readEndElement(XmlNamespace.Types, - XmlElementNames.Resolution); - } else { - reader.ensureCurrentNodeIsEndElement(XmlNamespace.Types, - XmlElementNames.Resolution); - } - } - - /** - * Gets the mailbox of the suggested resolved name. - * - * @return the mailbox - */ - public EmailAddress getMailbox() { - return this.mailbox; - } - - /** - * Gets the contact information of the suggested resolved name. This - * property is only available when ResolveName is called with - * returnContactDetails = true. - * - * @return the contact - */ - public Contact getContact() { - return this.contact; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/NameResolutionCollection.java b/src/main/java/microsoft/exchange/webservices/data/misc/NameResolutionCollection.java deleted file mode 100644 index bc62daf3d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/NameResolutionCollection.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentOutOfRangeException; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Represents a list of suggested name resolutions. - */ -public final class NameResolutionCollection implements - Iterable { - - /** - * The service. - */ - private ExchangeService service; - - /** - * The includes all resolutions. - */ - private boolean includesAllResolutions; - - /** - * The item. - */ - private List items = new ArrayList(); - - /** - * Represents a list of suggested name resolutions. - * - * @param service the service - */ - public NameResolutionCollection(ExchangeService service) { - EwsUtilities.ewsAssert(service != null, "NameResolutionSet.ctor", "service is null."); - this.service = service; - } - - /** - * Loads from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader) throws Exception { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.ResolutionSet); - int totalItemsInView = reader.readAttributeValue(Integer.class, - XmlAttributeNames.TotalItemsInView); - this.includesAllResolutions = reader.readAttributeValue(Boolean.class, - XmlAttributeNames.IncludesLastItemInRange); - - for (int i = 0; i < totalItemsInView; i++) { - NameResolution nameResolution = new NameResolution(this); - nameResolution.loadFromXml(reader); - this.items.add(nameResolution); - } - - reader.readEndElement(XmlNamespace.Messages, - XmlElementNames.ResolutionSet); - } - - /** - * Gets the session. The session. - * - * @return the session - */ - protected ExchangeService getSession() { - return this.service; - } - - /** - * Gets the total number of elements in the list. - * - * @return the count - */ - public int getCount() { - return this.items.size(); - } - - /** - * Gets a value indicating whether more suggested resolutions are available. - * ResolveName only returns a maximum of 100 name resolutions. When - * IncludesAllResolutions is false, there were more than 100 matching names - * on the server. To narrow the search, provide a more precise name to - * ResolveName. - * - * @return the includes all resolutions - */ - public boolean getIncludesAllResolutions() { - return this.includesAllResolutions; - } - - /** - * Gets the name resolution at the specified index. - * - * @param index the index - * @return The name resolution at the speicfied index. - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public NameResolution nameResolutionCollection(int index) - throws ArgumentOutOfRangeException { - if (index < 0 || index >= this.getCount()) { - throw new ArgumentOutOfRangeException("index", "index is out of range."); - } - - return this.items.get(index); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Iterable#iterator() - */ - @Override - public Iterator iterator() { - - return items.iterator(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/SoapFaultDetails.java b/src/main/java/microsoft/exchange/webservices/data/misc/SoapFaultDetails.java deleted file mode 100644 index 07ce9de59..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/SoapFaultDetails.java +++ /dev/null @@ -1,415 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.EwsXmlReader; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.error.ServiceError; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.security.XmlNodeType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.HashMap; -import java.util.Map; - -/** - * Represents SoapFault details. - */ -public class SoapFaultDetails { - - private static final Log LOG = LogFactory.getLog(SoapFaultDetails.class); - - /** - * The fault code. - */ - private String faultCode; - - /** - * The fault string. - */ - private String faultString; - - /** - * The fault actor. - */ - private String faultActor; - - /** - * The response code. - */ - private ServiceError responseCode = ServiceError.ErrorInternalServerError; - - /** - * The message. - */ - private String message; - - /** - * The error code. - */ - private ServiceError errorCode = ServiceError.NoError; - - /** - * The exception type. - */ - private String exceptionType; - - /** - * The line number. - */ - private int lineNumber; - - /** - * The position within line. - */ - private int positionWithinLine; - - /** - * Dictionary of key/value pairs from the MessageXml node in the fault. - * Usually empty but there are a few cases where SOAP faults may include - * MessageXml details (e.g. CASOverBudgetException includes BackoffTime - * value). - */ - private Map errorDetails = new HashMap(); - - /** - * Parses the. - * - * @param reader the reader - * @param soapNamespace the soap namespace - * @return the soap fault details - * @throws Exception the exception - */ - public static SoapFaultDetails parse(EwsXmlReader reader, XmlNamespace soapNamespace) throws Exception { - SoapFaultDetails soapFaultDetails = new SoapFaultDetails(); - - do { - reader.read(); - if (reader.getNodeType().equals( - new XmlNodeType(XmlNodeType.START_ELEMENT))) { - String localName = reader.getLocalName(); - if (localName.equals(XmlElementNames.SOAPFaultCodeElementName)) { - soapFaultDetails.setFaultCode(reader.readElementValue()); - } else if (localName - .equals(XmlElementNames.SOAPFaultStringElementName)) { - soapFaultDetails.setFaultString(reader.readElementValue()); - } else if (localName - .equals(XmlElementNames.SOAPFaultActorElementName)) { - soapFaultDetails.setFaultActor(reader.readElementValue()); - } else if (localName - .equals(XmlElementNames.SOAPDetailElementName)) { - soapFaultDetails.parseDetailNode(reader); - } - } - } while (!reader.isEndElement(soapNamespace, - XmlElementNames.SOAPFaultElementName)); - - return soapFaultDetails; - } - - /** - * Parses the detail node. - * - * @param reader the reader - * @throws Exception the exception - */ - private void parseDetailNode(EwsXmlReader reader) throws Exception { - do { - reader.read(); - if (reader.getNodeType().equals( - new XmlNodeType(XmlNodeType.START_ELEMENT))) { - String localName = reader.getLocalName(); - if (localName - .equals(XmlElementNames.EwsResponseCodeElementName)) { - try { - this.setResponseCode(reader - .readElementValue(ServiceError.class)); - } catch (Exception e) { - LOG.error(e); - - // ServiceError couldn't be mapped to enum value, treat - // as an ISE - this - .setResponseCode(ServiceError. - ErrorInternalServerError); - } - - } else if (localName - .equals(XmlElementNames.EwsMessageElementName)) { - this.setMessage(reader.readElementValue()); - } else if (localName.equals(XmlElementNames.EwsLineElementName)) { - this.setLineNumber(reader.readElementValue(Integer.class)); - } else if (localName - .equals(XmlElementNames.EwsPositionElementName)) { - this.setPositionWithinLine(reader - .readElementValue(Integer.class)); - } else if (localName - .equals(XmlElementNames.EwsErrorCodeElementName)) { - try { - this.setErrorCode(reader - .readElementValue(ServiceError.class)); - } catch (Exception e) { - LOG.error(e); - - // ServiceError couldn't be mapped to enum value, treat - // as an ISE - this - .setErrorCode(ServiceError. - ErrorInternalServerError); - } - - } else if (localName - .equals(XmlElementNames.EwsExceptionTypeElementName)) { - try { - this.setExceptionType(reader.readElementValue()); - } catch (Exception e) { - LOG.error(e); - this.setExceptionType(null); - } - } else if (localName.equals(XmlElementNames.MessageXml)) { - this.parseMessageXml(reader); - } - } - } while (!reader.isEndElement(XmlNamespace.NotSpecified, - XmlElementNames.SOAPDetailElementName)); - } - - /** - * Parses the message xml. - * - * @param reader the reader - * @throws Exception the exception - * @throws ServiceXmlDeserializationException the service xml deserialization exception - */ - private void parseMessageXml(EwsXmlReader reader) throws Exception, ServiceXmlDeserializationException, Exception { - // E14:172881: E12 and E14 return the MessageXml element in different - // namespaces (types namespace for E12, errors namespace in E14). To - // avoid this problem, the parser will match the namespace from the - // start and end elements. - XmlNamespace elementNS = EwsUtilities.getNamespaceFromUri(reader.getNamespaceUri()); - - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.isStartElement() && !reader.isEmptyElement()) { - String localName = reader.getLocalName(); - if (localName.equals(XmlElementNames.Value)) { - this.errorDetails.put(reader - .readAttributeValue(XmlAttributeNames.Name), - reader.readElementValue()); - } - } - } while (!reader - .isEndElement(elementNS, XmlElementNames.MessageXml)); - } else { - reader.read(); - } - - } - - /** - * Gets the fault code. - * - * @return the fault code - */ - protected String getFaultCode() { - return faultCode; - } - - /** - * Sets the fault code. - * - * @param faultCode the new fault code - */ - protected void setFaultCode(String faultCode) { - this.faultCode = faultCode; - } - - /** - * Gets the fault string. - * - * @return the fault string - */ - public String getFaultString() { - return faultString; - } - - /** - * Sets the fault string. - * - * @param faultString the new fault string - */ - protected void setFaultString(String faultString) { - this.faultString = faultString; - } - - /** - * Gets the fault actor. - * - * @return the fault actor - */ - protected String getFaultActor() { - return faultActor; - } - - /** - * Sets the fault actor. - * - * @param faultActor the new fault actor - */ - protected void setFaultActor(String faultActor) { - this.faultActor = faultActor; - } - - /** - * Gets the response code. - * - * @return the response code - */ - public ServiceError getResponseCode() { - return responseCode; - } - - /** - * Sets the response code. - * - * @param responseCode the new response code - */ - protected void setResponseCode(ServiceError responseCode) { - this.responseCode = responseCode; - } - - /** - * Gets the message. - * - * @return the message - */ - protected String getMessage() { - return message; - } - - /** - * Sets the message. - * - * @param message the new message - */ - protected void setMessage(String message) { - this.message = message; - } - - /** - * Gets the error code. - * - * @return the error code - */ - protected ServiceError getErrorCode() { - return errorCode; - } - - /** - * Sets the error code. - * - * @param errorCode the new error code - */ - protected void setErrorCode(ServiceError errorCode) { - this.errorCode = errorCode; - } - - /** - * Gets the exception type. - * - * @return the exception type - */ - protected String getExceptionType() { - return exceptionType; - } - - /** - * Sets the exception type. - * - * @param exceptionType the new exception type - */ - protected void setExceptionType(String exceptionType) { - this.exceptionType = exceptionType; - } - - /** - * Gets the line number. - * - * @return the line number - */ - protected int getLineNumber() { - return lineNumber; - } - - /** - * Sets the line number. - * - * @param lineNumber the new line number - */ - protected void setLineNumber(int lineNumber) { - this.lineNumber = lineNumber; - } - - /** - * Gets the position within line. - * - * @return the position within line - */ - protected int getPositionWithinLine() { - return positionWithinLine; - } - - /** - * Sets the position within line. - * - * @param positionWithinLine the new position within line - */ - protected void setPositionWithinLine(int positionWithinLine) { - this.positionWithinLine = positionWithinLine; - } - - /** - * Gets the error details. - * - * @return the error details - */ - public Map getErrorDetails() { - return errorDetails; - } - - /** - * Sets the error details. - * - * @param errorDetails the error details - */ - protected void setErrorDetails(Map errorDetails) { - this.errorDetails = errorDetails; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/Time.java b/src/main/java/microsoft/exchange/webservices/data/misc/Time.java deleted file mode 100644 index 8419c2d46..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/Time.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; - -import java.util.Calendar; -import java.util.Date; - -/** - * Represents time. - */ -public final class Time { - - /** - * The hours. - */ - private int hours; - - /** - * The minutes. - */ - private int minutes; - - /** - * The seconds. - */ - private int seconds; - - /** - * Initializes a new instance of Time. - */ - protected Time() { - } - - /** - * Initializes a new instance of Time. - * - * @param minutes The number of minutes since 12:00AM. - * @throws ArgumentException the argument exception - */ - - protected Time(int minutes) throws ArgumentException { - this(); - if (minutes < 0 || minutes >= 1440) { - throw new ArgumentException(String.format("%s,%s", "minutes must be between 0 and 1439, inclusive.", "minutes")); - } - - this.hours = minutes / 60; - this.minutes = minutes % 60; - this.seconds = 0; - } - - /** - * Initializes a new instance of Time. - * - * @param dateTime the date time - * @throws ArgumentException the argument exception - */ - public Time(Date dateTime) throws ArgumentException { - if (dateTime != null) { - Calendar cal = Calendar.getInstance(); - cal.setTime(dateTime); - this.setHours(cal.get(Calendar.HOUR)); - this.setMinutes(cal.get(Calendar.MINUTE)); - this.setSeconds(cal.get(Calendar.SECOND)); - } - } - - /** - * Initializes a new instance of Time. - * - * @param hours the hours - * @param minutes the minutes - * @param seconds the seconds - */ - protected Time(int hours, int minutes, int seconds) { - this(); - this.hours = hours; - this.minutes = minutes; - this.seconds = seconds; - } - - /** - * Convert Time to XML Schema time. - * - * @return String in XML Schema time format - */ - - public String toXSTime() { - return String.format("%s,%s,%s,%s", "{0:00}:{1:00}:{2:00}", - this.getHours(), this - .getMinutes(), this.getSeconds()); - } - - /** - * Converts the time into a number of minutes since 12:00AM. - * - * @return The number of minutes since 12:00AM the time represents. - */ - - protected int convertToMinutes() { - return this.getMinutes() + (this.getHours() * 60); - } - - /** - * Gets the hours. - * - * @return the hours - */ - protected int getHours() { - return this.hours; - } - - /** - * sets the hours. - * - * @param value the new hours - * @throws ArgumentException the argument exception - */ - - protected void setHours(int value) throws ArgumentException { - if (value >= 0 && value < 24) { - this.hours = value; - } else { - throw new ArgumentException("Hour must be between 0 and 23."); - } - } - - /** - * Gets the minutes. - * - * @return the minutes - */ - protected int getMinutes() { - return this.minutes; - } - - /** - * Sets the minutes. - * - * @param value the new minutes - * @throws ArgumentException the argument exception - */ - protected void setMinutes(int value) throws ArgumentException { - if (value >= 0 && value < 60) { - this.minutes = value; - } else { - throw new ArgumentException("Minute must be between 0 and 59."); - } - } - - /** - * Gets the seconds. - * - * @return the seconds - */ - protected int getSeconds() { - return this.seconds; - } - - /** - * Sets the seconds. - * - * @param value the new seconds - * @throws ArgumentException the argument exception - */ - protected void setSeconds(int value) throws ArgumentException { - if (value >= 0 && value < 60) { - this.seconds = value; - } else { - throw new ArgumentException("Second must be between 0 and 59."); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/TimeSpan.java b/src/main/java/microsoft/exchange/webservices/data/misc/TimeSpan.java deleted file mode 100644 index c4b1866c7..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/TimeSpan.java +++ /dev/null @@ -1,503 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.exception.misc.FormatException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * The Class TimeSpan. - */ -public class TimeSpan implements Comparable, java.io.Serializable, Cloneable { - - private static final Log LOG = LogFactory.getLog(TimeSpan.class); - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - /** - * The time. - */ - private long time = 0; - - /** - * Constant for milliseconds unit and conversion. - */ - public static final int MILLISECONDS = 1; - - /** - * Constant for seconds unit and conversion. - */ - public static final int SECONDS = MILLISECONDS * 1000; - - /** - * Constant for minutes unit and conversion. - */ - public static final int MINUTES = SECONDS * 60; - - /** - * Constant for hours unit and conversion. - */ - public static final int HOURS = MINUTES * 60; - - /** - * Constant for days unit and conversion. - */ - public static final int DAYS = HOURS * 24; - - /** - * Represents the Maximum TimeSpan value. - */ - public static final TimeSpan MAX_VALUE = new TimeSpan(Long.MAX_VALUE); - - /** - * Represents the Minimum TimeSpan value. - */ - public static final TimeSpan MIN_VALUE = new TimeSpan(Long.MIN_VALUE); - - /** - * Represents the TimeSpan with a value of zero. - */ - public static final TimeSpan ZERO = new TimeSpan(0L); - - /** - * Creates a new instance of TimeSpan based on the number of milliseconds - * entered. - * - * @param time the number of milliseconds for this TimeSpan. - */ - public TimeSpan(long time) { - this.time = time; - } - - /** - * Creates a new TimeSpan object based on the unit and value entered. - * - * @param units the type of unit to use to create a TimeSpan instance. - * @param value the number of units to use to create a TimeSpan instance. - */ - public TimeSpan(int units, long value) { - this.time = TimeSpan.toMilliseconds(units, value); - } - - /* - * public static TimeSpan fromMinutes(int value) { int l = value*60*100; - * return l; } - */ - - /** - * Subtracts two Date objects creating a new TimeSpan object. - * - * @param date1 Date to use as the base value. - * @param date2 Date to subtract from the base value. - * @return a TimeSpan object representing the difference bewteen the two - * Date objects. - */ - public static TimeSpan subtract(java.util.Date date1, - java.util.Date date2) { - return new TimeSpan(date1.getTime() - date2.getTime()); - } - - /** - * Compares this object with the specified object for order. Returns a - * negative integer, zero, or a positive integer as this object is less - * than, equal to, or greater than the specified object. Comparison is based - * on the number of milliseconds in this TimeSpan. - * - * @param o the Object to be compared. - * @return a negative integer, zero, or a positive integer as this object is - * less than, equal to, or greater than the specified object. - */ - public int compareTo(TimeSpan o) { - TimeSpan compare = (TimeSpan) o; - if (this.time == compare.time) { - return 0; - } - if (this.time > compare.time) { - return +1; - } - return -1; - } - - /** - * Indicates whether some other object is "equal to" this one. Comparison is - * based on the number of milliseconds in this TimeSpan. - * - * @param obj the reference object with which to compare. - * @return if the obj argument is a TimeSpan object with the exact same - * number of milliseconds. otherwise. - */ - public boolean equals(Object obj) { - if (obj instanceof TimeSpan) { - TimeSpan compare = (TimeSpan) obj; - if (this.time == compare.time) { - return true; - } - } - return false; - } - - /** - * Returns a hash code value for the object. This method is supported for - * the benefit of hashtables such as those provided by - * java.util.Hashtable. The method uses the same algorithm as - * found in the Long class. - * - * @return a hash code value for this object. - * @see Object#equals(Object) - * @see java.util.Hashtable - */ - public int hashCode() { - return Long.valueOf(this.time).hashCode(); - } - - /** - * Returns a string representation of the object in the format. - * "[-]d.hh:mm:ss.ff" where "-" is an optional sign for negative TimeSpan - * values, the "d" component is days, "hh" is hours, "mm" is minutes, "ss" - * is seconds, and "ff" is milliseconds - * - * @return a string containing the number of milliseconds. - */ - public String toString() { - StringBuffer sb = new StringBuffer(); - long millis = this.time; - if (millis < 0) { - sb.append("-"); - millis = -millis; - } - - long day = millis / TimeSpan.DAYS; - - if (day != 0) { - sb.append(day); - sb.append("d."); - millis = millis % TimeSpan.DAYS; - } - - sb.append(millis / TimeSpan.HOURS); - millis = millis % TimeSpan.HOURS; - sb.append("h:"); - sb.append(millis / TimeSpan.MINUTES); - millis = millis % TimeSpan.MINUTES; - sb.append("m:"); - sb.append(millis / TimeSpan.SECONDS); - sb.append("s"); - millis = millis % TimeSpan.SECONDS; - if (millis != 0) { - sb.append("."); - sb.append(millis); - sb.append("ms"); - } - return sb.toString(); - } - - /** - * Returns a clone of this TimeSpan. - * - * @return a clone of this TimeSpan. - */ - public Object clone() { - try { - return super.clone(); - } catch (CloneNotSupportedException e) { - LOG.error(e); - throw new InternalError(); - } - } - - /** - * Indicates whether the value of the TimeSpan is positive. - * - * @return if the value of the TimeSpan is greater than - * zero. otherwise. - */ - public boolean isPositive() { - return this.compareTo(TimeSpan.ZERO) > 0 ? true : false; - } - - /** - * Indicates whether the value of the TimeSpan is negative. - * - * @return if the value of the TimeSpan is less than zero. - * otherwise. - */ - public boolean isNegative() { - return this.compareTo(TimeSpan.ZERO) < 0 ? true : false; - } - - /** - * Indicates whether the value of the TimeSpan is zero. - * - * @return if the value of the TimeSpan is equal to zero. - * otherwise. - */ - public boolean isZero() { - return this.equals(TimeSpan.ZERO); - } - - /** - * Gets the number of milliseconds. - * - * @return the number of milliseconds. - */ - public long getMilliseconds() { - return (((this.time % TimeSpan.HOURS) % TimeSpan.MINUTES) % TimeSpan.MILLISECONDS) - / TimeSpan.MILLISECONDS; - } - - /** - * Gets the number of milliseconds. - * - * @return the number of milliseconds. - */ - public long getTotalMilliseconds() { - return this.time; - } - - /** - * Gets the number of seconds (truncated). - * - * @return the number of seconds. - */ - public long getSeconds() { - return ((this.time % TimeSpan.HOURS) % TimeSpan.MINUTES) / TimeSpan.SECONDS; - } - - /** - * Gets the number of seconds including fractional seconds. - * - * @return the number of seconds. - */ - public double getTotalSeconds() { - return this.time / 1000.0d; - } - - /** - * Gets the number of minutes (truncated). - * - * @return the number of minutes. - */ - public long getMinutes() { - return (this.time % TimeSpan.HOURS) / TimeSpan.MINUTES;// (this.time/1000)/60; - } - - /** - * Gets the number of minutes including fractional minutes. - * - * @return the number of minutes. - */ - public double getTotalMinutes() { - return (this.time / 1000.0d) / 60.0d; - } - - /** - * Gets the number of hours (truncated). - * - * @return the number of hours. - */ - public long getHours() { - return ((this.time / 1000) / 60) / 60; - } - - /** - * Gets the number of hours including fractional hours. - * - * @return the number of hours. - */ - public double getTotalHours() { - return ((this.time / 1000.0d) / 60.0d) / 60.0d; - } - - /** - * Gets the number of days (truncated). - * - * @return the number of days. - */ - public long getDays() { - return (((this.time / 1000) / 60) / 60) / 24; - } - - /** - * Gets the number of days including fractional days. - * - * @return the number of days. - */ - public double getTotalDays() { - return (((this.time / 1000.0d) / 60.0d) / 60.0d) / 24.0d; - } - - /** - * Adds a TimeSpan to this TimeSpan. - * - * @param timespan the TimeSpan to add to this TimeSpan. - */ - public void add(TimeSpan timespan) { - add(TimeSpan.MILLISECONDS, timespan.time); - } - - /** - * Adds a number of units to this TimeSpan. - * - * @param units the type of unit to add to this TimeSpan. - * @param value the number of units to add to this TimeSpan. - */ - public void add(int units, long value) { - this.time += TimeSpan.toMilliseconds(units, value); - } - - /** - * Compares two TimeSpan objects. - * - * @param first first TimeSpan to use in the compare. - * @param second second TimeSpan to use in the compare. - * @return a negative integer, zero, or a positive integer as the first - * TimeSpan is less than, equal to, or greater than the second - * TimeSpan. - */ - public static int compare(TimeSpan first, TimeSpan second) { - if (first.time == second.time) { - return 0; - } - if (first.time > second.time) { - return +1; - } - return -1; - } - - /** - * Returns a TimeSpan whose value is the absolute value of this TimeSpan. - * - * @return a TimeSpan whose value is the absolute value of this TimeSpan. - */ - public TimeSpan duration() { - return new TimeSpan(Math.abs(this.time)); - } - - /** - * Returns a TimeSpan whose value is the negated value of this TimeSpan. - * - * @return a TimeSpan whose value is the negated value of this TimeSpan. - */ - public TimeSpan negate() { - return new TimeSpan(-this.time); - } - - /** - * Subtracts a TimeSpan from this TimeSpan. - * - * @param timespan the TimeSpan to subtract from this TimeSpan. - */ - public void subtract(TimeSpan timespan) { - subtract(TimeSpan.MILLISECONDS, timespan.time); - } - - /** - * Subtracts a number of units from this TimeSpan. - * - * @param units the type of unit to subtract from this TimeSpan. - * @param value the number of units to subtract from this TimeSpan. - */ - public void subtract(int units, long value) { - add(units, -value); - } - - /** - * To milliseconds. - * - * @param units the units - * @param value the value - * @return the long - */ - private static long toMilliseconds(int units, long value) { - long millis; - switch (units) { - case TimeSpan.MILLISECONDS: - case TimeSpan.SECONDS: - case TimeSpan.MINUTES: - case TimeSpan.HOURS: - case TimeSpan.DAYS: - millis = value * units; - break; - default: - throw new IllegalArgumentException("Unrecognized units: " + units); - } - return millis; - } - - public static TimeSpan parse(String s) throws Exception { - String str = s.trim(); - String[] st1 = str.split("\\."); - int days = 0, millsec = 0, totMillSec = 0; - String data = str; - switch (st1.length) { - case 1: - data = str; - break; - case 2: - if (st1[0].split(":").length > 1) { - millsec = Integer.parseInt(st1[1]); - data = st1[0]; - } else { - days = Integer.parseInt(st1[0]); - data = st1[1]; - } - break; - case 3: - days = Integer.parseInt(st1[0]); - data = st1[1]; - millsec = Integer.parseInt(st1[2]); - break; - default: - throw new FormatException("Bad Format"); - - } - String[] st = data.split(":"); - switch (st.length) { - case 1: - totMillSec = Integer.parseInt(str) * 24 * 60 * 60 * 1000; - break; - case 2: - totMillSec = (Integer.parseInt(st[0]) * 60 * 60 * 1000) + (Integer.parseInt(st[1]) * 60 * 1000); - break; - case 3: - totMillSec = (Integer.parseInt(st[0]) * 60 * 60 * 1000) + (Integer.parseInt(st[1]) * 60 * 1000) + ( - Integer.parseInt(st[2]) * 1000); - break; - case 4: - totMillSec = - (Integer.parseInt(st[0]) * 24 * 60 * 60 * 1000) + (Integer.parseInt(st[1]) * 60 * 60 * 1000) + ( - Integer.parseInt(st[2]) * 60 * 1000) + (Integer.parseInt(st[3]) * 1000); - break; - default: - throw new FormatException("Bad Format/Overflow"); - } - totMillSec += (days * 24 * 60 * 60 * 1000) + millsec; - return new TimeSpan(totMillSec); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/UserConfiguration.java b/src/main/java/microsoft/exchange/webservices/data/misc/UserConfiguration.java deleted file mode 100644 index 24cc11512..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/UserConfiguration.java +++ /dev/null @@ -1,683 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.UserConfigurationProperties; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.InvalidOperationException; -import microsoft.exchange.webservices.data.core.exception.service.local.PropertyException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.UserConfigurationDictionary; -import microsoft.exchange.webservices.data.security.XmlNodeType; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.xml.stream.XMLStreamException; - -import java.util.EnumSet; - -/** - * Represents an object that can be used to store user-defined configuration - * settings. - */ -public class UserConfiguration { - - private static final Log LOG = LogFactory.getLog(UserConfiguration.class); - - /** - * The object version. - */ - private static ExchangeVersion ObjectVersion = ExchangeVersion.Exchange2010; - - /** - * For consistency with ServiceObject behavior, access to ItemId is - * permitted for a new object. - */ - /** - * The Constant PropertiesAvailableForNewObject. - */ - private final static EnumSet - PropertiesAvailableForNewObject = - EnumSet.of(UserConfigurationProperties.BinaryData, - UserConfigurationProperties.Dictionary, - UserConfigurationProperties.XmlData); - - /** - * The No property. - */ - private final UserConfigurationProperties NoProperties = - UserConfigurationProperties.values()[0]; - - /** - * The service. - */ - private ExchangeService service; - - /** - * The name. - */ - private String name; - - /** - * The parent folder id. - */ - private FolderId parentFolderId = null; - - /** - * The item id. - */ - private ItemId itemId = null; - - /** - * The dictionary. - */ - private UserConfigurationDictionary dictionary = null; - - /** - * The xml data. - */ - private byte[] xmlData = null; - - /** - * The binary data. - */ - private byte[] binaryData = null; - - /** - * The property available for access. - */ - private EnumSet propertiesAvailableForAccess; - - /** - * The updated property. - */ - private EnumSet updatedProperties; - - /** - * Indicates whether changes trigger an update or create operation. - */ - private boolean isNew = false; - - /** - * Initializes a new instance of class. - * - * @param service The service to which the user configuration is bound. - * @throws Exception the exception - */ - public UserConfiguration(ExchangeService service) throws Exception { - this(service, PropertiesAvailableForNewObject); - } - - /** - * Writes a byte array to Xml. - * - * @param writer the writer - * @param byteArray byte array to write - * @param xmlElementName name of the Xml element - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - private static void writeByteArrayToXml(EwsServiceXmlWriter writer, - byte[] byteArray, String xmlElementName) throws XMLStreamException, ServiceXmlSerializationException { - EwsUtilities.ewsAssert(writer != null, "UserConfiguration.WriteByteArrayToXml", "writer is null"); - EwsUtilities.ewsAssert(xmlElementName != null, "UserConfiguration.WriteByteArrayToXml", - "xmlElementName is null"); - - writer.writeStartElement(XmlNamespace.Types, xmlElementName); - - if (byteArray != null && byteArray.length > 0) { - writer.writeValue(Base64.encodeBase64String(byteArray), xmlElementName); - } - - writer.writeEndElement(); - } - - - /** - * Writes to Xml. - * - * @param writer The writer. - * @param xmlNamespace The XML namespace. - * @param name The user configuration name. - * @param parentFolderId The Id of the folder containing the user configuration. - * @throws Exception the exception - */ - public static void writeUserConfigurationNameToXml(EwsServiceXmlWriter writer, XmlNamespace xmlNamespace, - String name, FolderId parentFolderId) throws Exception { - EwsUtilities.ewsAssert(writer != null, "UserConfiguration.WriteUserConfigurationNameToXml", - "writer is null"); - EwsUtilities.ewsAssert(name != null, "UserConfiguration.WriteUserConfigurationNameToXml", "name is null"); - EwsUtilities.ewsAssert(parentFolderId != null, "UserConfiguration.WriteUserConfigurationNameToXml", - "parentFolderId is null"); - - writer.writeStartElement(xmlNamespace, - XmlElementNames.UserConfigurationName); - - writer.writeAttributeValue(XmlAttributeNames.Name, name); - - parentFolderId.writeToXml(writer); - - writer.writeEndElement(); - } - - /** - * Initializes a new instance of class. - * - * @param service The service to which the user configuration is bound. - * @param requestedProperties The property requested for this user configuration. - * @throws Exception the exception - */ - public UserConfiguration(ExchangeService service, EnumSet requestedProperties) - throws Exception { - EwsUtilities.validateParam(service, "service"); - - if (service.getRequestedServerVersion().ordinal() < UserConfiguration.ObjectVersion.ordinal()) { - throw new ServiceVersionException(String.format( - "The object type %s is only valid for Exchange Server version %s or later versions.", this - .getClass().getName(), UserConfiguration.ObjectVersion)); - } - - this.service = service; - this.isNew = true; - - this.initializeProperties(requestedProperties); - } - - /** - * Gets the name of the user configuration. - * - * @return the name - */ - public String getName() { - return this.name; - } - - /** - * Sets the name. - * - * @param value the new name - */ - public void setName(String value) { - this.name = value; - } - - /** - * Gets the Id of the folder containing the user configuration. - * - * @return the parent folder id - */ - public FolderId getParentFolderId() { - return this.parentFolderId; - } - - /** - * Sets the parent folder id. - * - * @param value the new parent folder id - */ - public void setParentFolderId(FolderId value) { - this.parentFolderId = value; - } - - /** - * Gets the Id of the user configuration. - * - * @return the item id - */ - public ItemId getItemId() { - return this.itemId; - } - - /** - * Gets the dictionary of the user configuration. - * - * @return the dictionary - */ - public UserConfigurationDictionary getDictionary() { - return this.dictionary; - } - - /** - * Gets the xml data of the user configuration. - * - * @return the xml data - * @throws PropertyException the property exception - */ - public byte[] getXmlData() throws PropertyException { - - this.validatePropertyAccess(UserConfigurationProperties.XmlData); - - return this.xmlData; - } - - /** - * Sets the xml data. - * - * @param value the new xml data - */ - public void setXmlData(byte[] value) { - this.xmlData = value; - - this.markPropertyForUpdate(UserConfigurationProperties.XmlData); - } - - /** - * Gets the binary data of the user configuration. - * - * @return the binary data - * @throws PropertyException the property exception - */ - public byte[] getBinaryData() throws PropertyException { - this.validatePropertyAccess(UserConfigurationProperties.BinaryData); - - return this.binaryData; - - } - - /** - * Sets the binary data. - * - * @param value the new binary data - */ - public void setBinaryData(byte[] value) { - this.binaryData = value; - this.markPropertyForUpdate(UserConfigurationProperties.BinaryData); - } - - /** - * Gets a value indicating whether this user configuration has been - * modified. - * - * @return the checks if is dirty - */ - public boolean getIsDirty() { - return (!this.updatedProperties.contains(NoProperties)) - || this.dictionary.getIsDirty(); - } - - /** - * Binds to an existing user configuration and loads the specified - * property. Calling this method results in a call to EWS. - * - * @param service The service to which the user configuration is bound. - * @param name The name of the user configuration. - * @param parentFolderId The Id of the folder containing the user configuration. - * @param properties The property to load. - * @return A user configuration instance. - * @throws IndexOutOfBoundsException the index out of bounds exception - * @throws Exception the exception - */ - public static UserConfiguration bind(ExchangeService service, String name, - FolderId parentFolderId, UserConfigurationProperties properties) - throws IndexOutOfBoundsException, Exception { - - UserConfiguration result = service.getUserConfiguration(name, - parentFolderId, properties); - result.isNew = false; - return result; - } - - /** - * Binds to an existing user configuration and loads the specified - * property. - * - * @param service The service to which the user configuration is bound. - * @param name The name of the user configuration. - * @param parentFolderName The name of the folder containing the user configuration. - * @param properties The property to load. - * @return A user configuration instance. - * @throws IndexOutOfBoundsException the index out of bounds exception - * @throws Exception the exception - */ - public static UserConfiguration bind(ExchangeService service, String name, - WellKnownFolderName parentFolderName, - UserConfigurationProperties properties) - throws IndexOutOfBoundsException, Exception { - return UserConfiguration.bind(service, name, new FolderId( - parentFolderName), properties); - } - - /** - * Saves the user configuration. Calling this method results in a call to - * EWS. - * - * @param name The name of the user configuration. - * @param parentFolderId The Id of the folder in which to save the user configuration. - * @throws Exception the exception - */ - public void save(String name, FolderId parentFolderId) throws Exception { - EwsUtilities.validateParam(name, "name"); - EwsUtilities.validateParam(parentFolderId, "parentFolderId"); - - parentFolderId.validate(this.service.getRequestedServerVersion()); - - if (!this.isNew) { - throw new InvalidOperationException( - "Calling Save isn't allowed because this user configuration isn't new. To apply local changes to this user configuration, call Update instead."); - } - - this.parentFolderId = parentFolderId; - this.name = name; - - this.service.createUserConfiguration(this); - - this.isNew = false; - - this.resetIsDirty(); - } - - /** - * Saves the user configuration. Calling this method results in a call to - * EWS. - * - * @param name The name of the user configuration. - * @param parentFolderName The name of the folder in which to save the user - * configuration. - * @throws Exception the exception - */ - public void save(String name, WellKnownFolderName parentFolderName) - throws Exception { - this.save(name, new FolderId(parentFolderName)); - } - - /** - * Updates the user configuration by applying local changes to the Exchange - * server. Calling this method results in a call to EWS - * - * @throws Exception the exception - */ - - public void update() throws Exception { - if (this.isNew) { - throw new InvalidOperationException( - "This user configuration can't be updated because it's never been saved."); - } - - if (this.isPropertyUpdated(UserConfigurationProperties.BinaryData) - || this - .isPropertyUpdated(UserConfigurationProperties. - Dictionary) - || this.isPropertyUpdated(UserConfigurationProperties. - XmlData)) { - - this.service.updateUserConfiguration(this); - } - - this.resetIsDirty(); - } - - /** - * Deletes the user configuration. Calling this method results in a call to - * EWS. - * - * @throws Exception the exception - */ - public void delete() throws Exception { - if (this.isNew) { - throw new InvalidOperationException( - "This user configuration object can't be deleted because it's never been saved."); - } else { - this.service - .deleteUserConfiguration(this.name, this.parentFolderId); - } - } - - /** - * Loads the specified property on the user configuration. Calling this - * method results in a call to EWS. - * - * @param properties The property to load. - * @throws Exception the exception - */ - public void load(UserConfigurationProperties properties) throws Exception { - this.initializeProperties(EnumSet.of(properties)); - this.service.loadPropertiesForUserConfiguration(this, properties); - } - - /** - * Writes to XML. - * - * @param writer The writer. - * @param xmlNamespace The XML namespace. - * @param xmlElementName Name of the XML element. - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer, XmlNamespace xmlNamespace, String xmlElementName) throws Exception { - EwsUtilities.ewsAssert(writer != null, "UserConfiguration.WriteToXml", "writer is null"); - EwsUtilities.ewsAssert(xmlElementName != null, "UserConfiguration.WriteToXml", "xmlElementName is null"); - - writer.writeStartElement(xmlNamespace, xmlElementName); - - // Write the UserConfigurationName element - writeUserConfigurationNameToXml(writer, XmlNamespace.Types, this.name, - this.parentFolderId); - - // Write the Dictionary element - if (this.isPropertyUpdated(UserConfigurationProperties.Dictionary)) { - this.dictionary.writeToXml(writer, XmlElementNames.Dictionary); - } - - // Write the XmlData element - if (this.isPropertyUpdated(UserConfigurationProperties.XmlData)) { - this.writeXmlDataToXml(writer); - } - - // Write the BinaryData element - if (this.isPropertyUpdated(UserConfigurationProperties.BinaryData)) { - this.writeBinaryDataToXml(writer); - } - - writer.writeEndElement(); - } - - /** - * Determines whether the specified property was updated. - * - * @param property property to evaluate. - * @return Boolean indicating whether to send the property Xml. - */ - private boolean isPropertyUpdated(UserConfigurationProperties property) { - boolean isPropertyDirty = false; - boolean isPropertyEmpty = false; - - switch (property) { - case Dictionary: - isPropertyDirty = this.getDictionary().getIsDirty(); - isPropertyEmpty = this.getDictionary().getCount() == 0; - break; - case XmlData: - isPropertyDirty = this.updatedProperties.contains(property); - isPropertyEmpty = (this.xmlData == null) || - (this.xmlData.length == 0); - break; - case BinaryData: - isPropertyDirty = this.updatedProperties.contains(property); - isPropertyEmpty = (this.binaryData == null) || - (this.binaryData.length == 0); - break; - default: - EwsUtilities.ewsAssert(false, "UserConfiguration.IsPropertyUpdated", - "property not supported: " + property.toString()); - break; - } - - // Consider the property updated, if it's been modified, and either - // . there's a value or - // . there's no value but the operation is update. - return isPropertyDirty && ((!isPropertyEmpty) || (!this.isNew)); - } - - /** - * Writes the XmlData property to Xml. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - private void writeXmlDataToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - EwsUtilities.ewsAssert(writer != null, "UserConfiguration.WriteXmlDataToXml", "writer is null"); - - writeByteArrayToXml(writer, this.xmlData, XmlElementNames.XmlData); - } - - /** - * Writes the BinaryData property to Xml. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - private void writeBinaryDataToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - EwsUtilities.ewsAssert(writer != null, "UserConfiguration.WriteBinaryDataToXml", "writer is null"); - - writeByteArrayToXml(writer, this.binaryData, - XmlElementNames.BinaryData); - } - - - - /** - * Loads from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader) throws Exception { - EwsUtilities.ewsAssert(reader != null, "UserConfiguration.loadFromXml", "reader is null"); - - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.UserConfiguration); - reader.read(); // Position at first property element - - do { - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - if (reader.getLocalName().equals( - XmlElementNames.UserConfigurationName)) { - String responseName = reader - .readAttributeValue(XmlAttributeNames.Name); - - EwsUtilities.ewsAssert(this.name.equals(responseName), "UserConfiguration.loadFromXml", - "UserConfigurationName does not match: Expected: " + this.name - + " Name in response: " + responseName); - - reader.skipCurrentElement(); - } else if (reader.getLocalName().equals(XmlElementNames.ItemId)) { - this.itemId = new ItemId(); - this.itemId.loadFromXml(reader, XmlElementNames.ItemId); - } else if (reader.getLocalName().equals( - XmlElementNames.Dictionary)) { - this.dictionary.loadFromXml(reader, - XmlElementNames.Dictionary); - } else if (reader.getLocalName() - .equals(XmlElementNames.XmlData)) { - this.xmlData = Base64.decodeBase64(reader.readElementValue()); - } else if (reader.getLocalName().equals( - XmlElementNames.BinaryData)) { - this.binaryData = Base64.decodeBase64(reader.readElementValue()); - } else { - EwsUtilities.ewsAssert(false, "UserConfiguration.loadFromXml", - "Xml element not supported: " + reader.getLocalName()); - } - } - - // If XmlData was loaded, read is skipped because GetXmlData - // positions the reader at the next property. - reader.read(); - } while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.UserConfiguration)); - } - - /** - * Initializes property. - * - * @param requestedProperties The property requested for this UserConfiguration. - */ - // / InitializeProperties is called in 3 cases: - // / . Create new object: From the UserConfiguration constructor. - // / . Bind to existing object: Again from the constructor. The constructor - // is called eventually by the GetUserConfiguration request. - // / . Refresh property: From the Load method. - private void initializeProperties( - EnumSet requestedProperties) { - this.itemId = null; - this.dictionary = new UserConfigurationDictionary(); - this.xmlData = null; - this.binaryData = null; - this.propertiesAvailableForAccess = requestedProperties; - - this.resetIsDirty(); - } - - /** - * Resets flags to indicate that property haven't been modified. - */ - private void resetIsDirty() { - try { - this.updatedProperties = EnumSet.of(NoProperties); - } catch (Exception e) { - LOG.error(e); - } - this.dictionary.setIsDirty(false); - } - - /** - * Determines whether the specified property may be accessed. - * - * @param property Property to access. - * @throws PropertyException the property exception - */ - private void validatePropertyAccess(UserConfigurationProperties property) - throws PropertyException { - if (!this.propertiesAvailableForAccess.contains(property)) { - throw new PropertyException("You must load or assign this property before you can read its value.", property - .toString()); - } - } - - /** - * Adds the passed property to updatedProperties. - * - * @param property Property to update. - */ - private void markPropertyForUpdate(UserConfigurationProperties property) { - this.updatedProperties.add(property); - this.propertiesAvailableForAccess.add(property); - - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/availability/AttendeeInfo.java b/src/main/java/microsoft/exchange/webservices/data/misc/availability/AttendeeInfo.java deleted file mode 100644 index 52fd2a5aa..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/availability/AttendeeInfo.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc.availability; - -import microsoft.exchange.webservices.data.ISelfValidate; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.availability.MeetingAttendeeType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -/** - * Represents information about an attendee for which to request availability - * information. - */ -public final class AttendeeInfo implements ISelfValidate { - - /** - * The smtp address. - */ - private String smtpAddress; - - /** - * The attendee type. - */ - private MeetingAttendeeType attendeeType = MeetingAttendeeType.Required; - - /** - * The exclude conflicts. - */ - private boolean excludeConflicts; - - /** - * Initializes a new instance of the AttendeeInfo class. - */ - public AttendeeInfo() { - } - - /** - * Initializes a new instance of the AttendeeInfo class. - * - * @param smtpAddress the smtp address - * @param attendeeType the attendee type - * @param excludeConflicts the exclude conflicts - */ - public AttendeeInfo(String smtpAddress, MeetingAttendeeType attendeeType, - boolean excludeConflicts) { - this(); - this.smtpAddress = smtpAddress; - this.attendeeType = attendeeType; - this.excludeConflicts = excludeConflicts; - } - - /** - * Initializes a new instance of the AttendeeInfo class. - * - * @param smtpAddress the smtp address - */ - public AttendeeInfo(String smtpAddress) { - this(smtpAddress, MeetingAttendeeType.Required, false); - this.smtpAddress = smtpAddress; - } - - /** - * Defines an implicit conversion between a string representing an SMTP - * address and AttendeeInfo. - * - * @param smtpAddress the smtp address - * @return An AttendeeInfo initialized with the specified SMTP address. - */ - public static AttendeeInfo getAttendeeInfoFromString(String smtpAddress) { - return new AttendeeInfo(smtpAddress); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer) throws Exception { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.MailboxData); - - writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Email); - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Address, - this.smtpAddress); - writer.writeEndElement(); // Email - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.AttendeeType, this.attendeeType); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.ExcludeConflicts, this.excludeConflicts); - - writer.writeEndElement(); // MailboxData - } - - /** - * Gets the SMTP address of this attendee. - * - * @return the smtp address - */ - public String getSmtpAddress() { - return smtpAddress; - } - - /** - * Sets the smtp address. - * - * @param smtpAddress the new smtp address - */ - public void setSmtpAddress(String smtpAddress) { - this.smtpAddress = smtpAddress; - } - - /** - * Gets the type of this attendee. - * - * @return the attendee type - */ - public MeetingAttendeeType getAttendeeType() { - return attendeeType; - } - - /** - * Sets the attendee type. - * - * @param attendeeType the new attendee type - */ - public void setAttendeeType(MeetingAttendeeType attendeeType) { - this.attendeeType = attendeeType; - } - - /** - * Gets a value indicating whether times when this attendee is not - * available should be returned. - * - * @return true, if is exclude conflicts - */ - public boolean isExcludeConflicts() { - return excludeConflicts; - } - - /** - * Sets the exclude conflicts. - * - * @param excludeConflicts the new exclude conflicts - */ - public void setExcludeConflicts(boolean excludeConflicts) { - this.excludeConflicts = excludeConflicts; - } - - /** - * Validates this instance. - * - * @throws Exception the exception - */ - public void validate() throws Exception { - EwsUtilities.validateParam(this.smtpAddress, "SmtpAddress"); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/availability/AvailabilityOptions.java b/src/main/java/microsoft/exchange/webservices/data/misc/availability/AvailabilityOptions.java deleted file mode 100644 index 3888ceb32..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/availability/AvailabilityOptions.java +++ /dev/null @@ -1,403 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc.availability; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.request.GetUserAvailabilityRequest; -import microsoft.exchange.webservices.data.core.enumeration.availability.FreeBusyViewType; -import microsoft.exchange.webservices.data.core.enumeration.availability.SuggestionQuality; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -import java.util.Date; - -/** - * Represents the options of a GetAvailability request. - */ -public final class AvailabilityOptions { - - /** - * The merged free busy interval. - */ - private int mergedFreeBusyInterval = 30; - - /** - * The requested free busy view. - */ - private FreeBusyViewType requestedFreeBusyView = FreeBusyViewType.Detailed; - - /** - * The good suggestion threshold. - */ - private int goodSuggestionThreshold = 25; - - /** - * The maximum suggestions per day. - */ - private int maximumSuggestionsPerDay = 10; - - /** - * The maximum non work hours suggestions per day. - */ - private int maximumNonWorkHoursSuggestionsPerDay = 0; - - /** - * The meeting duration. - */ - private int meetingDuration = 60; - - /** - * The minimum suggestion quality. - */ - private SuggestionQuality minimumSuggestionQuality = SuggestionQuality.Fair; - - /** - * The detailed suggestions window. - */ - private TimeWindow detailedSuggestionsWindow; - - /** - * The current meeting time. - */ - private Date currentMeetingTime; - - /** - * The global object id. - */ - private String globalObjectId; - - /** - * Validates this instance against the specified time window. - * - * @param timeWindow the time window - * @throws Exception the exception - */ - public void validate(long timeWindow) throws Exception { - if (this.mergedFreeBusyInterval > timeWindow) { - throw new IllegalArgumentException( - "MergedFreeBusyInterval must be smaller than the specified time window."); - } - - EwsUtilities.validateParamAllowNull(this.detailedSuggestionsWindow, "DetailedSuggestionsWindow"); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param request the request - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer, GetUserAvailabilityRequest request) throws Exception { - if (request.isFreeBusyViewRequested()) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.FreeBusyViewOptions); - - request.getTimeWindow().writeToXmlUnscopedDatesOnly(writer, - XmlElementNames.TimeWindow); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.MergedFreeBusyIntervalInMinutes, - this.mergedFreeBusyInterval); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.RequestedView, this.requestedFreeBusyView); - - writer.writeEndElement(); // FreeBusyViewOptions - } - - if (request.isSuggestionsViewRequested()) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.SuggestionsViewOptions); - - writer - .writeElementValue(XmlNamespace.Types, - XmlElementNames.GoodThreshold, - this.goodSuggestionThreshold); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.MaximumResultsByDay, - this.maximumSuggestionsPerDay); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.MaximumNonWorkHourResultsByDay, - this.maximumNonWorkHoursSuggestionsPerDay); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.MeetingDurationInMinutes, - this.meetingDuration); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.MinimumSuggestionQuality, - this.minimumSuggestionQuality); - - TimeWindow timeWindowToSerialize = - this.detailedSuggestionsWindow == null ? request - .getTimeWindow() : - this.detailedSuggestionsWindow; - - timeWindowToSerialize.writeToXmlUnscopedDatesOnly(writer, - XmlElementNames.DetailedSuggestionsWindow); - - if (this.currentMeetingTime != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.CurrentMeetingTime, - this.currentMeetingTime); - } - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.GlobalObjectId, this.globalObjectId); - - writer.writeEndElement(); // SuggestionsViewOptions - } - } - - /** - * Initializes a new instance of the AvailabilityOptions class. - */ - public AvailabilityOptions() { - } - - /** - * Gets the time difference between two successive slots in a - * FreeBusyMerged view. MergedFreeBusyInterval must be between 5 and 1440. - * The default value is 30. - * - * @return the merged free busy interval - */ - public int getMergedFreeBusyInterval() { - return this.mergedFreeBusyInterval; - } - - /** - * Sets the merged free busy interval. - * - * @param value the new merged free busy interval - */ - public void setMergedFreeBusyInterval(int value) { - if (value < 5 || value > 1440) { - throw new IllegalArgumentException(String.format("%s,%s,%s,%s", "%s must be between %d and %d.", - "MergedFreeBusyInterval", 5, 1440)); - } - - this.mergedFreeBusyInterval = value; - } - - /** - * Gets the requested type of free/busy view. The default value is - * FreeBusyViewType.Detailed. - * - * @return the requested free busy view - */ - public FreeBusyViewType getRequestedFreeBusyView() { - return this.requestedFreeBusyView; - } - - /** - * Sets the requested free busy view. - * - * @param value the new requested free busy view - */ - public void setRequestedFreeBusyView(FreeBusyViewType value) { - this.requestedFreeBusyView = value; - } - - /** - * Gets the percentage of attendees that must have the time period - * open for the time period to qualify as a good suggested meeting time. - * GoodSuggestionThreshold must be between 1 and 49. The default value is - * 25. - * - * @return the good suggestion threshold - */ - public int getGoodSuggestionThreshold() { - return this.goodSuggestionThreshold; - } - - /** - * Sets the good suggestion threshold. - * - * @param value the new good suggestion threshold - */ - public void setGoodSuggestionThreshold(int value) { - if (value < 1 || value > 49) { - throw new IllegalArgumentException(String.format("%s must be between %d and %d.", - "GoodSuggestionThreshold", 1, 49)); - } - - this.goodSuggestionThreshold = value; - } - - /** - * Gets the number of suggested meeting times that should be - * returned per day. MaximumSuggestionsPerDay must be between 0 and 48. The - * default value is 10. - * - * @return the maximum suggestions per day - */ - public int getMaximumSuggestionsPerDay() { - return this.maximumSuggestionsPerDay; - } - - /** - * Sets the maximum suggestions per day. - * - * @param value the new maximum suggestions per day - */ - public void setMaximumSuggestionsPerDay(int value) { - if (value < 0 || value > 48) { - throw new IllegalArgumentException(String.format("%s,%s,%s,%s", "%s must be between %d and %d.", - "MaximumSuggestionsPerDay", 0, 48)); - } - - this.maximumSuggestionsPerDay = value; - } - - /** - * Gets the number of suggested meeting times outside regular - * working hours per day. MaximumNonWorkHoursSuggestionsPerDay must be - * between 0 and 48. The default value is 0. - * - * @return the maximum non work hours suggestions per day - */ - public int getMaximumNonWorkHoursSuggestionsPerDay() { - return this.maximumNonWorkHoursSuggestionsPerDay; - } - - /** - * Sets the maximum non work hours suggestions per day. - * - * @param value the new maximum non work hours suggestions per day - */ - public void setMaximumNonWorkHoursSuggestionsPerDay(int value) { - if (value < 0 || value > 48) { - throw new IllegalArgumentException(String.format("%s must be between %d and %d.", - "MaximumNonWorkHoursSuggestionsPerDay", 0, 48)); - } - - this.maximumNonWorkHoursSuggestionsPerDay = value; - } - - /** - * Gets the duration, in minutes, of the meeting for which to obtain - * suggestions. MeetingDuration must be between 30 and 1440. The default - * value is 60. - * - * @return the meeting duration - */ - public int getMeetingDuration() { - return this.meetingDuration; - } - - /** - * Sets the meeting duration. - * - * @param value the new meeting duration - */ - public void setMeetingDuration(int value) { - if (value < 30 || value > 1440) { - throw new IllegalArgumentException(String.format("%s,%s,%s,%s", "%s must be between %d and %d.", "MeetingDuration", - 30, 1440)); - } - - this.meetingDuration = value; - } - - /** - * Gets the minimum quality of suggestions that should be returned. - * The default is SuggestionQuality.Fair. - * - * @return the minimum suggestion quality - */ - public SuggestionQuality getMinimumSuggestionQuality() { - return this.minimumSuggestionQuality; - } - - /** - * Sets the minimum suggestion quality. - * - * @param value the new minimum suggestion quality - */ - public void setMinimumSuggestionQuality(SuggestionQuality value) { - this.minimumSuggestionQuality = value; - } - - /** - * Gets the time window for which detailed information about - * suggested meeting times should be returned. - * - * @return the detailed suggestions window - */ - public TimeWindow getDetailedSuggestionsWindow() { - return this.detailedSuggestionsWindow; - } - - /** - * Sets the detailed suggestions window. - * - * @param value the new detailed suggestions window - */ - public void setDetailedSuggestionsWindow(TimeWindow value) { - this.detailedSuggestionsWindow = value; - } - - /** - * Gets the start time of a meeting that you want to update with the - * suggested meeting times. - * - * @return the current meeting time - */ - public Date getCurrentMeetingTime() { - return this.currentMeetingTime; - } - - /** - * Sets the current meeting time. - * - * @param value the new current meeting time - */ - public void setCurrentMeetingTime(Date value) { - this.currentMeetingTime = value; - } - - /** - * Gets the global object Id of a meeting that will be modified - * based on the data returned by GetUserAvailability. - * - * @return the global object id - */ - public String getGlobalObjectId() { - return this.globalObjectId; - } - - /** - * Sets the global object id. - * - * @param value the new global object id - */ - public void setGlobalObjectId(String value) { - this.globalObjectId = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/availability/GetUserAvailabilityResults.java b/src/main/java/microsoft/exchange/webservices/data/misc/availability/GetUserAvailabilityResults.java deleted file mode 100644 index fdc196238..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/availability/GetUserAvailabilityResults.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc.availability; - -import microsoft.exchange.webservices.data.core.response.AttendeeAvailability; -import microsoft.exchange.webservices.data.core.response.ServiceResponseCollection; -import microsoft.exchange.webservices.data.core.response.SuggestionsResponse; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException; -import microsoft.exchange.webservices.data.property.complex.availability.Suggestion; - -import java.util.Collection; - -/** - * Represents the results of a GetUserAvailability operation. - */ -public final class GetUserAvailabilityResults { - - /** - * The attendees availability. - */ - private ServiceResponseCollection - attendeesAvailability; - - /** - * The suggestions response. - */ - private SuggestionsResponse suggestionsResponse; - - /** - * Initializes a new instance of the GetUserAvailabilityResults class. - */ - public GetUserAvailabilityResults() { - } - - /** - * Gets the suggestions response for the requested meeting time. - * - * @return the suggestions response - */ - public SuggestionsResponse getSuggestionsResponse() { - return this.suggestionsResponse; - } - - /** - * Sets the suggestions response. - * - * @param value the new suggestions response - */ - public void setSuggestionsResponse(SuggestionsResponse value) { - this.suggestionsResponse = value; - } - - /** - * Gets a collection of AttendeeAvailability objects representing - * availability information for each of the specified attendees. - * - * @return the attendees availability - */ - public ServiceResponseCollection - getAttendeesAvailability() { - return this.attendeesAvailability; - } - - /** - * Sets the attendees availability. - * - * @param value the new attendees availability - */ - public void setAttendeesAvailability(ServiceResponseCollection value) { - this.attendeesAvailability = value; - } - - /** - * Gets a collection of suggested meeting times for the specified time - * period. - * - * @return the suggestions - * @throws ServiceResponseException the service response exception - */ - public Collection getSuggestions() - throws ServiceResponseException { - if (this.suggestionsResponse == null) { - return null; - } else { - this.suggestionsResponse.throwIfNecessary(); - - return this.suggestionsResponse.getSuggestions(); - } - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/availability/LegacyAvailabilityTimeZone.java b/src/main/java/microsoft/exchange/webservices/data/misc/availability/LegacyAvailabilityTimeZone.java deleted file mode 100644 index 7590eb80b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/availability/LegacyAvailabilityTimeZone.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc.availability; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.time.DayOfTheWeek; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.TimeSpan; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; -import microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition; - -import java.util.UUID; - -/** - * Represents a time zone as used by GetUserAvailabilityRequest. - */ -public final class LegacyAvailabilityTimeZone extends ComplexProperty { - - /** - * The bias. - */ - private TimeSpan bias; - - /** - * The standard time. - */ - private LegacyAvailabilityTimeZoneTime standardTime; - - /** - * The daylight time. - */ - private LegacyAvailabilityTimeZoneTime daylightTime; - - /** - * Initializes a new instance of the LegacyAvailabilityTimeZone class. - */ - public LegacyAvailabilityTimeZone() { - super(); - this.bias = new TimeSpan(0); - // If there are no adjustment rules (which is the - //case for UTC), we have to come up with two - // dummy time changes which both have a delta of - //zero and happen at two hard coded dates. This - // simulates a time zone in which there are no time changes. - this.daylightTime = new LegacyAvailabilityTimeZoneTime(); - this.daylightTime.setDelta(new TimeSpan(0)); - this.daylightTime.setDayOrder(1); - this.daylightTime.setDayOfTheWeek(DayOfTheWeek.Sunday); - this.daylightTime.setMonth(10); - this.daylightTime.setTimeOfDay(new TimeSpan(2 * 60 * 60 * 1000)); - this.daylightTime.setYear(0); - - this.standardTime = new LegacyAvailabilityTimeZoneTime(); - this.standardTime.setDelta(new TimeSpan(0)); - this.standardTime.setDayOrder(1); - this.standardTime.setDayOfTheWeek(DayOfTheWeek.Sunday); - this.standardTime.setMonth(3); - this.standardTime.setTimeOfDay(new TimeSpan(2 * 60 * 60 * 1000)); - this.daylightTime.setYear(0); - } - - /** - * To time zone info. - * - * @return the time zone - */ - public TimeZoneDefinition toTimeZoneInfo() { - - /*NumberFormat formatter = new DecimalFormat("00"); - String timeZoneId = this.bias.isNegative() ? "GMT+"+formatter. - format(this.bias.getHours())+":"+ - formatter.format(this.bias.getMinutes()) : - "GMT-"+formatter.format(this.bias.getHours())+":"+ - formatter.format(this.bias.getMinutes()); -*/ - TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(); - timeZoneDefinition.id = UUID.randomUUID().toString(); - timeZoneDefinition.name = "Custom time zone"; - return timeZoneDefinition; - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.Bias)) { - this.bias = new TimeSpan((long) - reader.readElementValue(Integer.class) * 60 * 1000); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.StandardTime)) { - this.standardTime = new LegacyAvailabilityTimeZoneTime(); - this.standardTime.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.DaylightTime)) { - this.daylightTime = new LegacyAvailabilityTimeZoneTime(); - this.daylightTime.loadFromXml(reader, reader.getLocalName()); - return true; - } else { - - return false; - } - - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.Bias, - (int) this.bias.getTotalMinutes()); - - this.standardTime.writeToXml(writer, XmlElementNames.StandardTime); - this.daylightTime.writeToXml(writer, XmlElementNames.DaylightTime); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/availability/LegacyAvailabilityTimeZoneTime.java b/src/main/java/microsoft/exchange/webservices/data/misc/availability/LegacyAvailabilityTimeZoneTime.java deleted file mode 100644 index 4df4a9b88..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/availability/LegacyAvailabilityTimeZoneTime.java +++ /dev/null @@ -1,312 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc.availability; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.time.DayOfTheWeek; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.TimeSpan; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents a custom time zone time change. - */ -final class LegacyAvailabilityTimeZoneTime extends ComplexProperty { - - /** - * The delta. - */ - private TimeSpan delta; - - /** - * The year. - */ - private int year; - - /** - * The month. - */ - private int month; - - /** - * The day order. - */ - private int dayOrder; - - /** - * The day of the week. - */ - private DayOfTheWeek dayOfTheWeek; - - /** - * The time of day. - */ - private TimeSpan timeOfDay; - - /** - * Initializes a new instance of the LegacyAvailabilityTimeZoneTime class. - */ - protected LegacyAvailabilityTimeZoneTime() { - super(); - } - - /** - * initializes a new instance of the LegacyAvailabilityTimeZoneTime class. - * - * @param reader - * the reader - * @return true, if successful - * @throws Exception - * the exception - */ - /* - * protected LegacyAvailabilityTimeZoneTime(TimeZone.TransitionTime - * transitionTime, TimeSpan delta) { this(); this.delta = delta; - * - * if (transitionTime.IsFixedDateRule) { // TimeZoneInfo doesn't support an - * actual year. Fixed date transitions occur at the same // date every year - * the adjustment rule the transition belongs to applies. The best thing // - * we can do here is use the current year. this.year = Date.Today.Year; - * this.month = transitionTime.Month; this.dayOrder = transitionTime.Day; - * this.timeOfDay = transitionTime.TimeOfDay.TimeOfDay; } else { // For - * floating rules, the mapping is direct. this.year = 0; this.month = - * transitionTime.Month; this.dayOfTheWeek = - * EwsUtilities.SystemToEwsDayOfTheWeek(transitionTime.DayOfWeek); - * this.dayOrder = transitionTime.Week; this.timeOfDay = - * transitionTime.TimeOfDay.TimeOfDay; } } - */ - - /** - * Converts this instance to TimeZoneInfo.TransitionTime. returns - * TimeZoneInfo.TransitionTime - * - */ - /* - * protected TimeZone.TransitionTime toTransitionTime() { if (this.year == - * 0) { return TimeZone.TransitionTime.createFloatingDateRule( new Date( - * Date.MinValue.Year, DateTime.MinValue.Month, DateTime.MinValue.Day, - * this.timeOfDay.Hours, this.timeOfDay.Minutes, this.timeOfDay.Seconds), - * this.month, this.dayOrder, - * EwsUtilities.ewsToSystemDayOfWeek(this.dayOfTheWeek)); } else { return - * TimeZone.TransitionTime.createFixedDateRule( new - * Date(this.timeOfDay.Ticks), this.month, this.dayOrder); } } - */ - - /** - * Tries to read element from XML. - * - * @param reader accepts EwsServiceXmlReader - * @return True if element was read. - * @throws Exception throws Exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.Bias)) { - this.delta = new TimeSpan((long) - reader.readElementValue(Integer.class) * 60 * 1000); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Time)) { - this.timeOfDay = TimeSpan.parse(reader.readElementValue()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.DayOrder)) { - this.dayOrder = reader.readElementValue(Integer.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.DayOfWeek)) { - this.dayOfTheWeek = reader.readElementValue(DayOfTheWeek.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Month)) { - this.month = reader.readElementValue(Integer.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Year)) { - this.year = reader.readElementValue(Integer.class); - return true; - } else { - return false; - } - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws XMLStreamException the XML stream exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Bias, - (int) this.delta.getMinutes()); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Time, - EwsUtilities.timeSpanToXSTime(this.timeOfDay)); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.DayOrder, - this.dayOrder); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Month, this.month); - - // Only write DayOfWeek if this is a recurring time change - if (this.getYear() == 0) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.DayOfWeek, this.dayOfTheWeek); - } - - // Only emit year if it's non zero, otherwise AS returns - // "Request is invalid" - if (this.getYear() != 0) { - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Year, - this.getYear()); - } - } - - /** - * Gets if current time presents DST transition time - * - * @return month - */ - protected boolean getHasTransitionTime() { - return this.month >= 1 && this.month <= 12; - } - - - /** - * Gets the delta. - * - * @return the delta - */ - protected TimeSpan getDelta() { - return this.delta; - } - - /** - * Sets the delta. - * - * @param delta the new delta - */ - protected void setDelta(TimeSpan delta) { - this.delta = delta; - } - - /** - * Gets the time of day. - * - * @return the time of day - */ - protected TimeSpan getTimeOfDay() { - return this.timeOfDay; - } - - /** - * Sets the time of day. - * - * @param timeOfDay the new time of day - */ - protected void setTimeOfDay(TimeSpan timeOfDay) { - this.timeOfDay = timeOfDay; - } - - /** - * Gets a value that represents: - The day of the month when Year is - * non zero, - The index of the week in the month if Year is equal to zero. - * - * @return the day order - */ - protected int getDayOrder() { - return this.dayOrder; - } - - /** - * Sets the day order. - * - * @param dayOrder the new day order - */ - protected void setDayOrder(int dayOrder) { - this.dayOrder = dayOrder; - } - - /** - * Gets the month. - * - * @return the month - */ - protected int getMonth() { - return this.month; - } - - /** - * Sets the month. - * - * @param month the new month - */ - protected void setMonth(int month) { - this.month = month; - } - - /** - * Gets the day of the week. - * - * @return the day of the week - */ - protected DayOfTheWeek getDayOfTheWeek() { - return this.dayOfTheWeek; - } - - /** - * Sets the day of the week. - * - * @param dayOfTheWeek the new day of the week - */ - protected void setDayOfTheWeek(DayOfTheWeek dayOfTheWeek) { - this.dayOfTheWeek = dayOfTheWeek; - } - - /** - * Gets the year. If Year is 0, the time change occurs every year - * according to a recurring pattern; otherwise, the time change occurs at - * the date specified by Day, Month, Year. - * - * @return the year - */ - protected int getYear() { - return this.year; - } - - /** - * Sets the year. - * - * @param year the new year - */ - protected void setYear(int year) { - this.year = year; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/availability/OofReply.java b/src/main/java/microsoft/exchange/webservices/data/misc/availability/OofReply.java deleted file mode 100644 index bd6f1207c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/availability/OofReply.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc.availability; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents an Out of Office response. - */ -public final class OofReply { - - /** - * The culture. - */ - private String culture = "en-US"; - - /** - * The message. - */ - private String message; - - /** - * Writes an empty OofReply to XML. - * - * @param writer the writer - * @param xmlElementName the xml element name - * @throws XMLStreamException the XML stream exception - */ - public static void writeEmptyReplyToXml(EwsServiceXmlWriter writer, String xmlElementName) throws XMLStreamException { - writer.writeStartElement(XmlNamespace.Types, xmlElementName); - writer.writeEndElement(); // xmlElementName - } - - /** - * Initializes a new instance of the class. - */ - public OofReply() { - } - - /** - * Initializes a new instance of the class. - * - * @param message the message - */ - public OofReply(String message) { - this.message = message; - } - - /** - * Initializes a new instance of the class. - * - * @param message the message - * @return the oof reply from string - */ - public static OofReply getOofReplyFromString(String message) { - return new OofReply(message); - } - - /** - * Gets the string from oof reply. - * - * @param oofReply the oof reply - * @return the string from oof reply - * @throws Exception the exception - */ - public static String getStringFromOofReply(OofReply oofReply) - throws Exception { - EwsUtilities.validateParam(oofReply, "oofReply"); - return oofReply.message; - } - - /** - * Loads from XML. - * - * @param reader the reader - * @param xmlElementName the xml element name - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader, String xmlElementName) - throws Exception { - reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, - xmlElementName); - - if (reader.hasAttributes()) { - this.setCulture(reader.readAttributeValue("xml:lang")); - } - - this.message = reader.readElementValue(XmlNamespace.Types, - XmlElementNames.Message); - - reader.readEndElement(XmlNamespace.Types, xmlElementName); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param xmlElementName the xml element name - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeStartElement(XmlNamespace.Types, xmlElementName); - - if (this.culture != null) { - writer.writeAttributeValue("xml", "lang", this.culture); - } - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Message, - this.message); - - writer.writeEndElement(); // xmlElementName - } - - /** - * Obtains a string representation of the reply. - * - * @return A string containing the reply message. - */ - public String toString() { - return this.message; - } - - /** - * Gets the culture of the reply. - * - * @return the culture - */ - public String getCulture() { - return this.culture; - - } - - /** - * Sets the culture. - * - * @param culture the new culture - */ - public void setCulture(String culture) { - this.culture = culture; - } - - /** - * Gets the the reply message. - * - * @return the message - */ - public String getMessage() { - return this.message; - } - - /** - * Sets the message. - * - * @param message the new message - */ - public void setMessage(String message) { - this.message = message; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/availability/TimeWindow.java b/src/main/java/microsoft/exchange/webservices/data/misc/availability/TimeWindow.java deleted file mode 100644 index 3ef6d88d9..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/availability/TimeWindow.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc.availability; - -import microsoft.exchange.webservices.data.ISelfValidate; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.TimeZone; - -/** - * Represents a time period. - */ -public class TimeWindow implements ISelfValidate { - - /** - * The start time. - */ - private Date startTime; - - /** - * The end time. - */ - private Date endTime; - - /** - * Initializes a new instance of the "TimeWindow" class. - */ - public TimeWindow() { - } - - /** - * Initializes a new instance of the "TimeWindow" class. - * - * @param startTime the start time - * @param endTime the end time - */ - public TimeWindow(Date startTime, Date endTime) { - this(); - this.startTime = startTime; - this.endTime = endTime; - } - - /** - * Gets the start time. - * - * @return the start time - */ - public Date getStartTime() { - return startTime; - } - - /** - * Sets the start time. - * - * @param startTime the new start time - */ - public void setStartTime(Date startTime) { - this.startTime = startTime; - } - - /** - * Gets the end time. - * - * @return the end time - */ - public Date getEndTime() { - return endTime; - } - - /** - * Sets the end time. - * - * @param endTime the new end time - */ - public void setEndTime(Date endTime) { - this.endTime = endTime; - } - - /** - * Loads from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader) throws Exception { - reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, - XmlElementNames.Duration); - - this.startTime = reader.readElementValueAsDateTime(XmlNamespace.Types, - XmlElementNames.StartTime); - this.endTime = reader.readElementValueAsDateTime(XmlNamespace.Types, - XmlElementNames.EndTime); - - reader.readEndElement(XmlNamespace.Types, XmlElementNames.Duration); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param xmlElementName the xml element name - * @param startTime the start time - * @param endTime the end time - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - private static void writeToXml(EwsServiceXmlWriter writer, - String xmlElementName, Object startTime, Object endTime) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeStartElement(XmlNamespace.Types, xmlElementName); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.StartTime, - startTime); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.EndTime, - endTime); - - writer.writeEndElement(); // xmlElementName - } - - /** - * Writes to XML without scoping the dates and without emitting times. - * - * @param writer the writer - * @param xmlElementName the xml element name - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected void writeToXmlUnscopedDatesOnly(EwsServiceXmlWriter writer, - String xmlElementName) throws XMLStreamException, ServiceXmlSerializationException { - final String DateOnlyFormat = "yyyy-MM-dd'T'00:00:00"; - - DateFormat formatter = new SimpleDateFormat(DateOnlyFormat); - formatter.setTimeZone(TimeZone.getTimeZone("UTC")); - - String start = formatter.format(this.startTime); - String end = formatter.format(this.endTime); - TimeWindow.writeToXml(writer, xmlElementName, start, end); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param xmlElementName the xml element name - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) - throws XMLStreamException, ServiceXmlSerializationException { - TimeWindow.writeToXml(writer, xmlElementName, startTime, endTime); - } - - /** - * Gets the duration. - * - * @return the duration - */ - public long getDuration() { - return this.endTime.getTime() - this.startTime.getTime(); - } - - /** - * Validates this instance. - */ - public void validate() { - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/id/AlternateId.java b/src/main/java/microsoft/exchange/webservices/data/misc/id/AlternateId.java deleted file mode 100644 index 3a440c27c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/id/AlternateId.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc.id; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.IdFormat; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -/** - * Represents an Id expressed in a specific format. - */ -public class AlternateId extends AlternateIdBase { - - /** - * Name of schema type used for AlternateId. - */ - public final static String SchemaTypeName = "AlternateIdType"; - - /** - * Id. - */ - private String id; - - /** - * SMTP address of the mailbox that the id belongs to. - */ - private String mailbox; - - /** - * Type (primary or archive) mailbox to which the Id belongs - */ - private boolean isArchive; - - /** - * Initializes a new instance of the class. - */ - public AlternateId() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param format the format - * @param id the id - * @param mailbox the mailbox - */ - public AlternateId(IdFormat format, String id, String mailbox) { - super(format); - this.setUniqueId(id); - this.setMailbox(mailbox); - } - - /** - * Initializes a new instance of the AlternateId class. - * - * @param format The format the Id is expressed in. - * @param id The Id. - * @param mailbox The SMTP address of the mailbox that the Id belongs to. - * @param isArchive Primary (false) or archive (true) mailbox. - */ - public AlternateId( - IdFormat format, - String id, - String mailbox, - boolean isArchive) { - super(format); - this.setUniqueId(id); - this.setMailbox(mailbox); - this.setIsArchive(isArchive); - } - - /** - * Gets the Id. - * - * @return the unique id - */ - public String getUniqueId() { - return this.id; - } - - /** - * Sets the unique id. - * - * @param id the new unique id - */ - public void setUniqueId(String id) { - this.id = id; - } - - /** - * Gets the mailbox to which the Id belongs. - * - * @return the mailbox - */ - public String getMailbox() { - return this.mailbox; - } - - /** - * Sets the mailbox. - * - * @param mailbox the new mailbox - */ - public void setMailbox(String mailbox) { - this.mailbox = mailbox; - } - - /** - * Gets the type (primary or archive) mailbox to which the Id belongs. - */ - public boolean getIsArchive() { - return this.isArchive; - } - - /** - * Sets the type (primary or archive) mailbox to which the Id belongs. - * - * @param isArchive the new isArchive - */ - public void setIsArchive(boolean isArchive) { - this.isArchive = isArchive; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.AlternateId; - } - - /** - * Gets the name of the XML element. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - writer.writeAttributeValue(XmlAttributeNames.Id, this.getUniqueId()); - writer.writeAttributeValue(XmlAttributeNames.Mailbox, - this.getMailbox()); - //.getMailbox() == null || this.getMailbox().isEmpty()) ? "" - //: this.getMailbox()); - if (this.getIsArchive()) { - writer.writeAttributeValue(XmlAttributeNames.IsArchive, true); - } - - } - - /** - * Gets the name of the XML element. - * - * @param reader the reader - * @throws Exception// the exception - */ - @Override public void loadAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - super.loadAttributesFromXml(reader); - - this.setUniqueId(reader.readAttributeValue(XmlAttributeNames.Id)); - this.setMailbox(reader.readAttributeValue(XmlAttributeNames.Mailbox)); - String isArchive = reader.readAttributeValue( - XmlAttributeNames.IsArchive); - - if (!(isArchive == null || isArchive.isEmpty())) { - this.isArchive = reader.readAttributeValue(Boolean.class, - XmlAttributeNames.IsArchive); - } else { - this.isArchive = false; - } - } - - /** - * Validate this instance. - */ - @Override - protected void internalValidate() throws Exception { - EwsUtilities.validateParam(this.getMailbox(), "mailbox"); - } -} - - diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/id/AlternateIdBase.java b/src/main/java/microsoft/exchange/webservices/data/misc/id/AlternateIdBase.java deleted file mode 100644 index 5fb2eccd0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/id/AlternateIdBase.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc.id; - -import microsoft.exchange.webservices.data.ISelfValidate; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.IdFormat; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents the base class for Id expressed in a specific format. - */ -public abstract class AlternateIdBase implements ISelfValidate { - - /** - * Id format. - */ - private IdFormat format; - - /** - * Initializes a new instance of the class. - */ - protected AlternateIdBase() { - } - - /** - * Initializes a new instance of the class. - * - * @param format the format - */ - protected AlternateIdBase(IdFormat format) { - super(); - this.format = format; - } - - /** - * Gets the format in which the Id in expressed. - * - * @return the format - */ - public IdFormat getFormat() { - return this.format; - } - - /** - * Sets the format. - * - * @param format the new format - */ - public void setFormat(IdFormat format) { - this.format = format; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - protected abstract String getXmlElementName(); - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.Format, this.getFormat()); - } - - /** - * Loads the attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void loadAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.setFormat(reader.readAttributeValue(IdFormat.class, - XmlAttributeNames.Format)); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws XMLStreamException the XML stream exception - */ - public void writeToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - writer.writeStartElement(XmlNamespace.Types, this.getXmlElementName()); - this.writeAttributesToXml(writer); - writer.writeEndElement(); // this.GetXmlElementName() - } - - /** - * Validate this instance. - * - * @throws Exception - */ - protected void internalValidate() throws Exception { - // nothing to do. - } - - /** - * Validates this instance. - * - * @throws Exception - */ - public void validate() throws Exception { - this.internalValidate(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/id/AlternatePublicFolderId.java b/src/main/java/microsoft/exchange/webservices/data/misc/id/AlternatePublicFolderId.java deleted file mode 100644 index f824808a1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/id/AlternatePublicFolderId.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc.id; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.IdFormat; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -/** - * Represents the Id of a public folder expressed in a specific format. - */ -public class AlternatePublicFolderId extends AlternateIdBase { - - /** - * Name of schema type used for AlternatePublicFolderId element. - */ - public final static String SchemaTypeName = - "AlternatePublicFolderIdType"; - - private String folderId; - - /** - * Initializes a new instance of AlternatePublicFolderId. - */ - public AlternatePublicFolderId() { - super(); - } - - /** - * Initializes a new instance of AlternatePublicFolderId. - * - * @param format the format - * @param folderId the folder id - */ - public AlternatePublicFolderId(IdFormat format, String folderId) { - super(format); - this.setFolderId(folderId); - } - - /** - * The Id of the public folder. - * - * @return the folder id - */ - public String getFolderId() { - return this.folderId; - - } - - /** - * Sets the folder id. - * - * @param folderId the new folder id - */ - public void setFolderId(String folderId) { - this.folderId = folderId; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.AlternatePublicFolderId; - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - writer.writeAttributeValue(XmlAttributeNames.FolderId, this - .getFolderId()); - } - - /** - * Loads the attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override public void loadAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - super.loadAttributesFromXml(reader); - this.setFolderId(reader.readAttributeValue(XmlAttributeNames.FolderId)); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/misc/id/AlternatePublicFolderItemId.java b/src/main/java/microsoft/exchange/webservices/data/misc/id/AlternatePublicFolderItemId.java deleted file mode 100644 index a6b3996d3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/misc/id/AlternatePublicFolderItemId.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc.id; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.IdFormat; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -/** - * Represents the Id of a public folder item expressed in a specific format. - */ -public class AlternatePublicFolderItemId extends AlternatePublicFolderId { - - /** - * Schema type associated with AlternatePublicFolderItemId. - */ - public final static String SchemaTypeName = - "AlternatePublicFolderItemIdType"; - - /** - * Item id. - */ - private String itemId; - - /** - * Initializes a new instance of the class. - */ - public AlternatePublicFolderItemId() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param format the format - * @param folderId the folder id - * @param itemId the item id - */ - public AlternatePublicFolderItemId(IdFormat format, String folderId, - String itemId) { - super(format, folderId); - this.itemId = itemId; - } - - /** - * Gets The Id of the public folder item. - * - * @return the item id - */ - public String getItemId() { - return this.itemId; - } - - /** - * Sets the item id. - * - * @param itemId the new item id - */ - public void setItemId(String itemId) { - this.itemId = itemId; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.AlternatePublicFolderItemId; - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - writer.writeAttributeValue(XmlAttributeNames.ItemId, this.getItemId()); - } - - /** - * Loads the attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override public void loadAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - super.loadAttributesFromXml(reader); - this.itemId = reader.readAttributeValue(XmlAttributeNames.ItemId); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/notification/FolderEvent.java b/src/main/java/microsoft/exchange/webservices/data/notification/FolderEvent.java deleted file mode 100644 index 93ff8fe32..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/notification/FolderEvent.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.notification; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.notification.EventType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -import java.util.Date; - -/** - * Represents an event that applies to a folder. - */ -public class FolderEvent extends NotificationEvent { - - /** - * The folder id. - */ - private FolderId folderId; - - /** - * The old folder id. - */ - private FolderId oldFolderId; - - /** - * The new number of unread messages. This is is only meaningful when - * EventType is equal to EventType.Modified. For all other event types, it's - * null. - */ - private int unreadCount; - - /** - * Initializes a new instance. - * - * @param eventType the event type - * @param timestamp the timestamp - */ - protected FolderEvent(EventType eventType, Date timestamp) { - super(eventType, timestamp); - } - - /** - * Load from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - protected void internalLoadFromXml(EwsServiceXmlReader reader) - throws Exception { - super.internalLoadFromXml(reader); - - this.folderId = new FolderId(); - this.folderId.loadFromXml(reader, reader.getLocalName()); - - reader.read(); - - setParentFolderId(new FolderId()); - getParentFolderId().loadFromXml(reader, XmlElementNames.ParentFolderId); - - switch (getEventType()) { - case Moved: - case Copied: - reader.read(); - - this.oldFolderId = new FolderId(); - this.oldFolderId.loadFromXml(reader, reader.getLocalName()); - - reader.read(); - - setParentFolderId(new FolderId()); - getParentFolderId().loadFromXml(reader, reader.getLocalName()); - break; - - case Modified: - reader.read(); - if (reader.isStartElement()) { - reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, - XmlElementNames.UnreadCount); - String str = reader.readValue(); - this.unreadCount = Integer.parseInt(str); - } - break; - - default: - break; - } - } - - /** - * Gets the Id of the folder this event applies to. - * - * @return folderId - */ - public FolderId getFolderId() { - return folderId; - } - - /** - * gets the Id of the folder that was moved or copied. OldFolderId is only - * meaningful when EventType is equal to either EventType.Moved or - * EventType.Copied. For all other event types, OldFolderId is null. - * - * @return oldFolderId - */ - public FolderId getOldFolderId() { - return oldFolderId; - } - - /** - * Gets the new number of unread messages. This is is only meaningful when - * EventType is equal to EventType.Modified. For all other event types, - * UnreadCount is null. - * - * @return unreadCount - */ - public int getUnreadCount() { - return unreadCount; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/notification/GetEventsResults.java b/src/main/java/microsoft/exchange/webservices/data/notification/GetEventsResults.java deleted file mode 100644 index 7a1c8910c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/notification/GetEventsResults.java +++ /dev/null @@ -1,260 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.notification; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.ILazyMember; -import microsoft.exchange.webservices.data.core.LazyMember; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.notification.EventType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * Represents a collection of notification events. - */ -public final class GetEventsResults { - /** - * Watermark in event. - */ - private String newWatermark; - - /** - * Subscription id. - */ - private String subscriptionId; - - /** - * Previous watermark. - */ - private String previousWatermark; - - /** - * True if more events available for this subscription. - */ - private boolean moreEventsAvailable; - - /** - * Collection of notification events. - */ - private Collection events = - new ArrayList(); - - /** - * Map XML element name to notification event type. If you add a new - * notification event type, you'll need to add a new entry to the Map here. - */ - private static LazyMember> - xmlElementNameToEventTypeMap = - new LazyMember>( - new ILazyMember>() { - @Override - public Map createInstance() { - Map result = - new HashMap(); - result.put(XmlElementNames.CopiedEvent, EventType.Copied); - result.put(XmlElementNames.CreatedEvent, EventType.Created); - result.put(XmlElementNames.DeletedEvent, EventType.Deleted); - result.put(XmlElementNames.ModifiedEvent, - EventType.Modified); - result.put(XmlElementNames.MovedEvent, EventType.Moved); - result.put(XmlElementNames.NewMailEvent, EventType.NewMail); - result.put(XmlElementNames.StatusEvent, EventType.Status); - result.put(XmlElementNames.FreeBusyChangedEvent, - EventType.FreeBusyChanged); - return result; - } - }); - - /** - * Gets the XML element name to event type mapping. - * - * @return The XML element name to event type mapping. - */ - protected static Map getXmlElementNameToEventTypeMap() { - return GetEventsResults.xmlElementNameToEventTypeMap.getMember(); - } - - /** - * Initializes a new instance. - */ - public GetEventsResults() { - } - - /** - * Loads from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader) throws Exception { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.Notification); - - this.subscriptionId = reader.readElementValue(XmlNamespace.Types, - XmlElementNames.SubscriptionId); - this.previousWatermark = reader.readElementValue(XmlNamespace.Types, - XmlElementNames.PreviousWatermark); - this.moreEventsAvailable = reader.readElementValue(Boolean.class, - XmlNamespace.Types, XmlElementNames.MoreEvents); - - do { - reader.read(); - - if (reader.isStartElement()) { - String eventElementName = reader.getLocalName(); - EventType eventType; - - if (xmlElementNameToEventTypeMap.getMember().containsKey( - eventElementName)) { - eventType = xmlElementNameToEventTypeMap.getMember().get( - eventElementName); - this.newWatermark = reader.readElementValue( - XmlNamespace.Types, XmlElementNames.Watermark); - if (eventType == EventType.Status) { - // We don't need to return status events - reader.readEndElementIfNecessary(XmlNamespace.Types, - eventElementName); - } else { - this.loadNotificationEventFromXml(reader, - eventElementName, eventType); - } - } else { - reader.skipCurrentElement(); - } - - } - - } while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.Notification)); - } - - /** - * Loads a notification event from XML. - * - * @param reader the reader - * @param eventElementName the event element name - * @param eventType the event type - * @throws Exception the exception - */ - private void loadNotificationEventFromXml(EwsServiceXmlReader reader, - String eventElementName, EventType eventType) throws Exception { - Date date = reader.readElementValue(Date.class, XmlNamespace.Types, - XmlElementNames.TimeStamp); - - NotificationEvent notificationEvent; - - reader.read(); - - if (reader.getLocalName().equals(XmlElementNames.FolderId)) { - notificationEvent = new FolderEvent(eventType, date); - } else { - notificationEvent = new ItemEvent(eventType, date); - } - - notificationEvent.loadFromXml(reader, eventElementName); - this.events.add(notificationEvent); - } - - /** - * Gets the Id of the subscription the collection is associated with. - * - * @return the subscription id - */ - protected String getSubscriptionId() { - return subscriptionId; - } - - /** - * Gets the subscription's previous watermark. - * - * @return the previous watermark - */ - protected String getPreviousWatermark() { - return previousWatermark; - } - - /** - * Gets the subscription's new watermark. - * - * @return the new watermark - */ - protected String getNewWatermark() { - return newWatermark; - } - - /** - * Gets a value indicating whether more events are available on the Exchange - * server. - * - * @return true, if is more events available - */ - protected boolean isMoreEventsAvailable() { - return moreEventsAvailable; - } - - /** - * Gets the collection of folder events. - * - * @return the folder events - */ - public Iterable getFolderEvents() { - Collection folderEvents = new ArrayList(); - for (Object event : this.events) { - if (event instanceof FolderEvent) { - folderEvents.add((FolderEvent) event); - } - } - return folderEvents; - } - - /** - * Gets the collection of item events. - * - * @return the item events - */ - public Iterable getItemEvents() { - Collection itemEvents = new ArrayList(); - for (Object event : this.events) { - if (event instanceof ItemEvent) { - itemEvents.add((ItemEvent) event); - } - } - return itemEvents; - } - - /** - * Gets the collection of all events. - * - * @return the all events - */ - public Collection getAllEvents() { - return this.events; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/notification/GetStreamingEventsResults.java b/src/main/java/microsoft/exchange/webservices/data/notification/GetStreamingEventsResults.java deleted file mode 100644 index 8cf433fb3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/notification/GetStreamingEventsResults.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.notification; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.notification.EventType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; - -/** - * Represents a collection of notification events. - */ -public final class GetStreamingEventsResults { - - /** - * Structure to track a subscription and its associated notification events. - */ - protected static class NotificationGroup { - /** - * Subscription Id - */ - protected String subscriptionId; - - /** - * Events in the response associated with the subscription id. - */ - protected Collection events; - } - - - /** - * Collection of notification events. - */ - private Collection events = - new ArrayList(); - - /** - * Initializes a new instance of the class. - */ - public GetStreamingEventsResults() { - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @throws Exception - */ - public void loadFromXml(EwsServiceXmlReader reader) throws Exception { - reader.readStartElement(XmlNamespace.Messages, - XmlElementNames.Notification); - - do { - NotificationGroup notifications = new NotificationGroup(); - notifications.subscriptionId = reader.readElementValue( - XmlNamespace.Types, - XmlElementNames.SubscriptionId); - notifications.events = new ArrayList(); - - synchronized (this) { - this.events.add(notifications); - } - - do { - reader.read(); - - if (reader.isStartElement()) { - String eventElementName = reader.getLocalName(); - EventType eventType; - if (GetEventsResults.getXmlElementNameToEventTypeMap().containsKey(eventElementName)) { - eventType = GetEventsResults.getXmlElementNameToEventTypeMap(). - get(eventElementName); - if (eventType == EventType.Status) { - // We don't need to return status events - reader.readEndElementIfNecessary(XmlNamespace.Types, - eventElementName); - } else { - this.loadNotificationEventFromXml( - reader, - eventElementName, - eventType, - notifications); - } - } else { - reader.skipCurrentElement(); - } - } - } - while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.Notification)); - - reader.read(); - } - while (!reader.isEndElement(XmlNamespace.Messages, - XmlElementNames.Notifications)); - } - - /** - * Loads a notification event from XML. - * - * @param reader The reader. - * @param eventElementName Name of the event XML element. - * @param eventType Type of the event. - * @param notifications Collection of notification - * @throws Exception - */ - private void loadNotificationEventFromXml( - EwsServiceXmlReader reader, - String eventElementName, - EventType eventType, - NotificationGroup notifications) throws Exception { - Date timestamp = reader.readElementValue(Date.class, XmlNamespace.Types, - XmlElementNames.TimeStamp); - - NotificationEvent notificationEvent; - - reader.read(); - - if (reader.getLocalName().equals(XmlElementNames.FolderId)) { - notificationEvent = new FolderEvent(eventType, timestamp); - } else { - notificationEvent = new ItemEvent(eventType, timestamp); - } - - notificationEvent.loadFromXml(reader, eventElementName); - notifications.events.add(notificationEvent); - } - - /** - * Gets the notification collection. - * - * @value The notification collection. - */ - protected Collection getNotifications() { - return this.events; - } -} - diff --git a/src/main/java/microsoft/exchange/webservices/data/notification/ItemEvent.java b/src/main/java/microsoft/exchange/webservices/data/notification/ItemEvent.java deleted file mode 100644 index 02ff5b122..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/notification/ItemEvent.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.notification; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.notification.EventType; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ItemId; - -import java.util.Date; - -/** - * Represents an event that applies to an item. - */ -public final class ItemEvent extends NotificationEvent { - - /** - * Id of the item this event applies to. - */ - private ItemId itemId; - - /** - * Id of the item that moved or copied. This is only meaningful when - * EventType is equal to either EventType.Moved or EventType.Copied. For all - * other event types, it's null. - */ - private ItemId oldItemId; - - /** - * Initializes a new instance. - * - * @param eventType the event type - * @param timestamp the timestamp - */ - protected ItemEvent(EventType eventType, Date timestamp) { - super(eventType, timestamp); - } - - /** - * Load from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - protected void internalLoadFromXml(EwsServiceXmlReader reader) - throws Exception { - super.internalLoadFromXml(reader); - - this.itemId = new ItemId(); - this.itemId.loadFromXml(reader, reader.getLocalName()); - - reader.read(); - - setParentFolderId(new FolderId()); - - getParentFolderId().loadFromXml(reader, XmlElementNames.ParentFolderId); - - EventType eventType = getEventType(); - switch (eventType) { - case Moved: - case Copied: - reader.read(); - - this.oldItemId = new ItemId(); - this.oldItemId.loadFromXml(reader, reader.getLocalName()); - - reader.read(); - - setOldParentFolderId(new FolderId()); - getOldParentFolderId().loadFromXml(reader, reader.getLocalName()); - break; - - default: - break; - } - } - - /** - * Gets the Id of the item this event applies to. - * - * @return itemId - */ - public ItemId getItemId() { - return itemId; - } - - /** - * Gets the Id of the item that was moved or copied. OldItemId is only - * meaningful when EventType is equal to either EventType.Moved or - * EventType.Copied. For all other event types, OldItemId is null. - * - * @return the old item id - */ - public ItemId getOldItemId() { - return oldItemId; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/notification/NotificationEvent.java b/src/main/java/microsoft/exchange/webservices/data/notification/NotificationEvent.java deleted file mode 100644 index ad81d6509..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/notification/NotificationEvent.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.notification; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.enumeration.notification.EventType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.FolderId; - -import java.util.Date; - -/** - * Represents an event as exposed by push and pull notification. - */ -public abstract class NotificationEvent { - - /** - * Type of this event. - */ - private EventType eventType; - - /** - * Date and time when the event occurred. - */ - private Date timestamp; - - /** - * Id of parent folder of the item or folder this event applies to. - */ - private FolderId parentFolderId; - - /** - * Id of the old parent folder of the item or folder this event applies to. - * This property is only meaningful when EventType is equal to either - * EventType.Moved or EventType.Copied. For all other event types, - * oldParentFolderId will be null - */ - private FolderId oldParentFolderId; - - /** - * Initializes a new instance. - * - * @param eventType the event type - * @param timestamp the timestamp - */ - protected NotificationEvent(EventType eventType, Date timestamp) { - this.eventType = eventType; - this.timestamp = timestamp; - } - - /** - * Load from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - protected void internalLoadFromXml(EwsServiceXmlReader reader) throws Exception { - } - - /** - * Loads this NotificationEvent from XML. - * - * @param reader the reader - * @param xmlElementName the xml element name - * @throws Exception the exception - */ - protected void loadFromXml(EwsServiceXmlReader reader, - String xmlElementName) - throws Exception { - this.internalLoadFromXml(reader); - - reader.readEndElementIfNecessary(XmlNamespace.Types, xmlElementName); - } - - /** - * gets the eventType. - * - * @return the eventType. - */ - public EventType getEventType() { - return eventType; - } - - /** - * gets the timestamp. - * - * @return the timestamp. - */ - public Date getTimestamp() { - return timestamp; - } - - /** - * gets the parentFolderId. - * - * @return the parentFolderId. - */ - public FolderId getParentFolderId() { - return parentFolderId; - } - - /** - * Sets the parentFolderId. - * - * @param parentFolderId the new parent folder id - */ - protected void setParentFolderId(FolderId parentFolderId) { - this.parentFolderId = parentFolderId; - } - - /** - * gets the oldParentFolderId. - * - * @return the oldParentFolderId. - */ - public FolderId getOldParentFolderId() { - return oldParentFolderId; - } - - /** - * Sets the oldParentFolderId. - * - * @param oldParentFolderId the new old parent folder id - */ - protected void setOldParentFolderId(FolderId oldParentFolderId) { - - this.oldParentFolderId = oldParentFolderId; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/notification/NotificationEventArgs.java b/src/main/java/microsoft/exchange/webservices/data/notification/NotificationEventArgs.java deleted file mode 100644 index 000ec3154..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/notification/NotificationEventArgs.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.notification; - -/** - * Provides data to a StreamingSubscriptionConnection's - * OnNotificationEvent event. - */ -public class NotificationEventArgs { - private StreamingSubscription subscription; - private Iterable events; - - /** - * Initializes a new instance of the NotificationEventArgs class. - * - * @param subscription The subscription for which notification have been received. - * @param events The events that were received. - */ - protected NotificationEventArgs( - StreamingSubscription subscription, - Iterable events) { - this.setSubscription(subscription); - this.setEvents(events); - } - - /** - * Gets the subscription for which notification have been received. - */ - public StreamingSubscription getSubscription() { - return this.subscription; - - } - - /** - * Sets the events that were received. - */ - protected void setSubscription(StreamingSubscription value) { - this.subscription = value; - } - - /** - * Gets the events that were received. - */ - public Iterable getEvents() { - return this.events; - - } - - /** - * Sets the events that were received. - */ - protected void setEvents(Iterable value) { - this.events = value; - } - - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/notification/PullSubscription.java b/src/main/java/microsoft/exchange/webservices/data/notification/PullSubscription.java deleted file mode 100644 index 77d9abe79..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/notification/PullSubscription.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.notification; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.misc.AsyncCallback; -import microsoft.exchange.webservices.data.misc.IAsyncResult; - -/** - * Represents a pull subscription. - */ -public final class PullSubscription extends SubscriptionBase { - /** - * The more events available. - */ - private boolean moreEventsAvailable; - - /** - * Initializes a new instance. - * - * @param service the service - * @throws Exception the exception - */ - public PullSubscription(ExchangeService service) throws Exception { - super(service); - } - - /** - * Obtains a collection of events that occurred on the subscribed folder - * since the point in time defined by the Watermark property. When GetEvents - * succeeds, Watermark is updated. - * - * @return Returns a collection of events that occurred since the last - * watermark - * @throws Exception the exception - */ - public GetEventsResults getEvents() throws Exception { - GetEventsResults results = getService().getEvents(this.getId(), - this.getWaterMark()); - this.setWaterMark(results.getNewWatermark()); - this.moreEventsAvailable = results.isMoreEventsAvailable(); - return results; - } - - /** - * Begins an asynchronous request to obtain a collection of events that occurred on the subscribed - * folder since the point in time defined by the Watermark property - * - * @param callback The AsyncCallback delegate - * @param state An object that contains state information for this request - * @return An IAsyncResult that references the asynchronous request - * @throws Exception - */ - public IAsyncResult beginGetEvents(AsyncCallback callback, Object state) throws Exception { - return this.getService().beginGetEvents(callback, state, this.getId(), this.getWaterMark()); - } - - /** - * Ends an asynchronous request to obtain a collection of events that occurred on the subscribed - * folder since the point in time defined by the Watermark property. When EndGetEvents succeeds, - * Watermark is updated. - * - * @param asyncResult An IAsyncResult that references the asynchronous request. - * @return Returns a collection of events that occurred since the last watermark. - * @throws Exception - */ - public GetEventsResults endGetEvents(IAsyncResult asyncResult) throws Exception { - GetEventsResults results = this.getService().endGetEvents(asyncResult); - - this.setWaterMark(results.getNewWatermark()); - this.moreEventsAvailable = results.isMoreEventsAvailable(); - - return results; - } - - /** - * Unsubscribes from the pull subscription. - * - * @throws Exception the exception - */ - public void unsubscribe() throws Exception { - getService().unsubscribe(getId()); - } - - /** - * Begins an asynchronous request to unsubscribe from the pull subscription. - * - * @param callback The AsyncCallback delegate. - * @param state An object that contains state information for this request - * @return An IAsyncResult that references the asynchronous request - * @throws Exception - */ - public IAsyncResult beginUnsubscribe(AsyncCallback callback, Object state) throws Exception { - return this.getService().beginUnsubscribe(callback, state, this.getId()); - } - - /** - * Ends an asynchronous request to unsubscribe from the pull subscription. - * - * @param asyncResult An IAsyncResult that references the asynchronous request. - * @throws Exception - */ - public void endUnsubscribe(IAsyncResult asyncResult) throws Exception { - this.getService().endUnsubscribe(asyncResult); - } - - /** - * Gets a value indicating whether more events are available on the server. - * MoreEventsAvailable is undefined (null) until GetEvents is called. - * - * @return true, if is more events available - */ - public boolean isMoreEventsAvailable() { - return moreEventsAvailable; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/notification/StreamingSubscription.java b/src/main/java/microsoft/exchange/webservices/data/notification/StreamingSubscription.java deleted file mode 100644 index abc99149f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/notification/StreamingSubscription.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.notification; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.misc.AsyncCallback; -import microsoft.exchange.webservices.data.misc.IAsyncResult; - -/** - * Represents a streaming subscription. - */ -public final class StreamingSubscription extends SubscriptionBase { - - public StreamingSubscription(ExchangeService service) throws Exception { - super(service); - } - - /** - * Unsubscribes from the streaming subscription. - */ - public void unsubscribe() throws Exception { - this.getService().unsubscribe(this.getId()); - } - - /** - * Begins an asynchronous request to unsubscribe from the streaming subscription. - * - * @param callback The AsyncCallback delegate. - * @param state An object that contains state information for this request. - * @return An IAsyncResult that references the asynchronous request. - * @throws Exception - */ - public IAsyncResult beginUnsubscribe(AsyncCallback callback, Object state) throws Exception { - return this.getService().beginUnsubscribe(callback, state, this.getId()); - } - - /** - * Ends an asynchronous request to unsubscribe from the streaming subscription. - * - * @param asyncResult An IAsyncResult that references the asynchronous request. - */ - public void endUnsubscribe(IAsyncResult asyncResult) throws Exception { - this.getService().endUnsubscribe(asyncResult); - } - - /** - * Gets the service used to create this subscription. - */ - public ExchangeService getService() { - return super.getService(); - } - - - /** - * Gets a value indicating whether this subscription uses watermarks. - */ - @Override - protected boolean getUsesWatermark() { - return false; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/notification/StreamingSubscriptionConnection.java b/src/main/java/microsoft/exchange/webservices/data/notification/StreamingSubscriptionConnection.java deleted file mode 100644 index dae04a0b1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/notification/StreamingSubscriptionConnection.java +++ /dev/null @@ -1,571 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.notification; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentNullException; -import microsoft.exchange.webservices.data.core.request.GetStreamingEventsRequest; -import microsoft.exchange.webservices.data.core.request.HangingRequestDisconnectEventArgs; -import microsoft.exchange.webservices.data.core.request.HangingServiceRequestBase; -import microsoft.exchange.webservices.data.core.response.GetStreamingEventsResponse; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.error.ServiceError; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceResult; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentOutOfRangeException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.remote.ServiceResponseException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.Closeable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Represents a connection to an ongoing stream of events. - */ -public final class StreamingSubscriptionConnection implements Closeable, - HangingServiceRequestBase.IHandleResponseObject, - HangingServiceRequestBase.IHangingRequestDisconnectHandler { - - private static final Log LOG = LogFactory.getLog(StreamingSubscriptionConnection.class); - - /** - * Mapping of streaming id to subscriptions currently on the connection. - */ - private Map subscriptions; - - /** - * connection lifetime, in minutes - */ - private int connectionTimeout; - - /** - * ExchangeService instance used to make the EWS call. - */ - private ExchangeService session; - - /** - * Value indicating whether the class is disposed. - */ - private boolean isDisposed; - - /** - * Currently used instance of a GetStreamingEventsRequest connected to EWS. - */ - private GetStreamingEventsRequest currentHangingRequest; - - - public interface INotificationEventDelegate { - /** - * Represents a delegate that is invoked when notification are received - * from the server - * - * @param sender The StreamingSubscriptionConnection instance that received - * the events. - * @param args The event data. - */ - void notificationEventDelegate(Object sender, NotificationEventArgs args); - } - - - /** - * Notification events Occurs when notification are received from the - * server. - */ - private List onNotificationEvent = new ArrayList(); - - /** - * Set event to happen when property Notify. - * - * @param notificationEvent notification event - */ - public void addOnNotificationEvent( - INotificationEventDelegate notificationEvent) { - onNotificationEvent.add(notificationEvent); - } - - /** - * Remove the event from happening when property Notify. - * - * @param notificationEvent notification event - */ - public void removeNotificationEvent( - INotificationEventDelegate notificationEvent) { - onNotificationEvent.remove(notificationEvent); - } - - /** - * Clears notification events list. - */ - public void clearNotificationEvent() { - onNotificationEvent.clear(); - } - - public interface ISubscriptionErrorDelegate { - - /** - * Represents a delegate that is invoked when an error occurs within a - * streaming subscription connection. - * - * @param sender The StreamingSubscriptionConnection instance within which - * the error occurred. - * @param args The event data. - */ - void subscriptionErrorDelegate(Object sender, - SubscriptionErrorEventArgs args); - } - - - /** - * Subscription events Occur when a subscription encounters an error. - */ - private List onSubscriptionError = new ArrayList(); - - /** - * Set event to happen when property subscriptionError. - * - * @param subscriptionError subscription event - */ - public void addOnSubscriptionError( - ISubscriptionErrorDelegate subscriptionError) { - onSubscriptionError.add(subscriptionError); - } - - /** - * Remove the event from happening when property subscription. - * - * @param subscriptionError subscription event - */ - public void removeSubscriptionError( - ISubscriptionErrorDelegate subscriptionError) { - onSubscriptionError.remove(subscriptionError); - } - - /** - * Clears subscription events list. - */ - public void clearSubscriptionError() { - onSubscriptionError.clear(); - } - - /** - * Disconnect events Occurs when a streaming subscription connection is - * disconnected from the server. - */ - private List onDisconnect = new ArrayList(); - - /** - * Set event to happen when property disconnect. - * - * @param disconnect disconnect event - */ - public void addOnDisconnect(ISubscriptionErrorDelegate disconnect) { - onDisconnect.add(disconnect); - } - - /** - * Remove the event from happening when property disconnect. - * - * @param disconnect disconnect event - */ - public void removeDisconnect(ISubscriptionErrorDelegate disconnect) { - onDisconnect.remove(disconnect); - } - - /** - * Clears disconnect events list. - */ - public void clearDisconnect() { - onDisconnect.clear(); - } - - /** - * Initializes a new instance of the StreamingSubscriptionConnection class. - * - * @param service The ExchangeService instance this connection uses to connect - * to the server. - * @param lifetime The maximum time, in minutes, the connection will remain open. - * Lifetime must be between 1 and 30. - * @throws Exception - */ - public StreamingSubscriptionConnection(ExchangeService service, int lifetime) - throws Exception { - EwsUtilities.validateParam(service, "service"); - - EwsUtilities.validateClassVersion(service, - ExchangeVersion.Exchange2010_SP1, this.getClass().getName()); - - if (lifetime < 1 || lifetime > 30) { - throw new ArgumentOutOfRangeException("lifetime"); - } - - this.session = service; - this.subscriptions = new HashMap(); - this.connectionTimeout = lifetime; - } - - /** - * Initializes a new instance of the StreamingSubscriptionConnection class. - * - * @param service The ExchangeService instance this connection uses to connect - * to the server. - * @param subscriptions Iterable subcriptions - * @param lifetime The maximum time, in minutes, the connection will remain open. - * Lifetime must be between 1 and 30. - * @throws Exception - */ - public StreamingSubscriptionConnection(ExchangeService service, - Iterable subscriptions, int lifetime) - throws Exception { - this(service, lifetime); - EwsUtilities.validateParamCollection(subscriptions.iterator(), "subscriptions"); - for (StreamingSubscription subscription : subscriptions) { - this.subscriptions.put(subscription.getId(), subscription); - } - } - - /** - * Adds a subscription to this connection. - * - * @param subscription The subscription to add. - * @throws Exception Thrown when AddSubscription is called while connected. - */ - public void addSubscription(StreamingSubscription subscription) - throws Exception { - this.throwIfDisposed(); - EwsUtilities.validateParam(subscription, "subscription"); - this.validateConnectionState(false, "Subscriptions can't be added to an open connection."); - - synchronized (this) { - if (this.subscriptions.containsKey(subscription.getId())) { - return; - } - this.subscriptions.put(subscription.getId(), subscription); - } - } - - /** - * Removes the specified streaming subscription from the connection. - * - * @param subscription The subscription to remove. - * @throws Exception Thrown when RemoveSubscription is called while connected. - */ - public void removeSubscription(StreamingSubscription subscription) - throws Exception { - this.throwIfDisposed(); - - EwsUtilities.validateParam(subscription, "subscription"); - - this.validateConnectionState(false, "Subscriptions can't be removed from an open connection."); - - synchronized (this) { - this.subscriptions.remove(subscription.getId()); - } - } - - /** - * Opens this connection so it starts receiving events from the server.This - * results in a long-standing call to EWS. - * - * @throws Exception - * @throws ServiceLocalException Thrown when Open is called while connected. - */ - public void open() throws ServiceLocalException, Exception { - synchronized (this) { - this.throwIfDisposed(); - - this.validateConnectionState(false, "The connection has already opened."); - - if (this.subscriptions.size() == 0) { - throw new ServiceLocalException( - "You must add at least one subscription to this connection before it can be opened."); - } - - this.currentHangingRequest = new GetStreamingEventsRequest( - this.session, this, this.subscriptions.keySet(), - this.connectionTimeout); - - this.currentHangingRequest.addOnDisconnectEvent(this); - - this.currentHangingRequest.internalExecute(); - } - } - - /** - * Called when the request is disconnected. - * - * @param sender The sender. - * @param args The Microsoft.Exchange.WebServices.Data. - * HangingRequestDisconnectEventArgs instance containing the - * event data. - */ - private void onRequestDisconnect(Object sender, - HangingRequestDisconnectEventArgs args) { - this.internalOnDisconnect(args.getException()); - } - - /** - * Closes this connection so it stops receiving events from the server.This - * terminates a long-standing call to EWS. - */ - public void close() { - synchronized (this) { - try { - this.throwIfDisposed(); - - this.validateConnectionState(true, "The connection is already closed."); - - // Further down in the stack, this will result in a - // call to our OnRequestDisconnect event handler, - // doing the necessary cleanup. - this.currentHangingRequest.disconnect(); - } catch (Exception e) { - LOG.error(e); - } - } - } - - /** - * Internal helper method called when the request disconnects. - * - * @param ex The exception that caused the disconnection. May be null. - */ - private void internalOnDisconnect(Exception ex) { - if (!onDisconnect.isEmpty()) { - for (ISubscriptionErrorDelegate disconnect : onDisconnect) { - disconnect.subscriptionErrorDelegate(this, - new SubscriptionErrorEventArgs(null, ex)); - } - } - this.currentHangingRequest = null; - } - - /** - * Gets a value indicating whether this connection is opened - * - * @throws Exception - */ - public boolean getIsOpen() throws Exception { - - this.throwIfDisposed(); - if (this.currentHangingRequest == null) { - return false; - } else { - return this.currentHangingRequest.isConnected(); - } - - } - - /** - * Validates the state of the connection. - * - * @param isConnectedExpected Value indicating whether we expect to be currently connected. - * @param errorMessage The error message. - * @throws Exception - */ - private void validateConnectionState(boolean isConnectedExpected, - String errorMessage) throws Exception { - if ((isConnectedExpected && !this.getIsOpen()) - || (!isConnectedExpected && this.getIsOpen())) { - throw new ServiceLocalException(errorMessage); - } - } - - /** - * Handles the service response object. - * - * @param response The response. - * @throws ArgumentException - */ - private void handleServiceResponseObject(Object response) - throws ArgumentException { - GetStreamingEventsResponse gseResponse = (GetStreamingEventsResponse) response; - - if (gseResponse == null) { - throw new ArgumentNullException("GetStreamingEventsResponse must not be null", - "GetStreamingEventsResponse"); - } else { - if (gseResponse.getResult() == ServiceResult.Success - || gseResponse.getResult() == ServiceResult.Warning) { - if (gseResponse.getResults().getNotifications().size() > 0) { - // We got notification; dole them out. - this.issueNotificationEvents(gseResponse); - } else { - // // This was just a heartbeat, nothing to do here. - } - } else if (gseResponse.getResult() == ServiceResult.Error) { - if (gseResponse.getErrorSubscriptionIds() == null - || gseResponse.getErrorSubscriptionIds().size() == 0) { - // General error - this.issueGeneralFailure(gseResponse); - } else { - // subscription-specific errors - this.issueSubscriptionFailures(gseResponse); - } - } - } - } - - /** - * Issues the subscription failures. - * - * @param gseResponse The GetStreamingEvents response. - */ - private void issueSubscriptionFailures( - GetStreamingEventsResponse gseResponse) { - ServiceResponseException exception = new ServiceResponseException( - gseResponse); - - for (String id : gseResponse.getErrorSubscriptionIds()) { - StreamingSubscription subscription = null; - - synchronized (this) { - // Client can do any good or bad things in the below event - // handler - if (this.subscriptions != null - && this.subscriptions.containsKey(id)) { - subscription = this.subscriptions.get(id); - } - - } - if (subscription != null) { - SubscriptionErrorEventArgs eventArgs = new SubscriptionErrorEventArgs( - subscription, exception); - - if (!onSubscriptionError.isEmpty()) { - for (ISubscriptionErrorDelegate subError : onSubscriptionError) { - subError.subscriptionErrorDelegate(this, eventArgs); - } - } - } - if (gseResponse.getErrorCode() != ServiceError.ErrorMissedNotificationEvents) { - // Client can do any good or bad things in the above event - // handler - synchronized (this) { - if (this.subscriptions != null - && this.subscriptions.containsKey(id)) { - // We are no longer servicing the subscription. - this.subscriptions.remove(id); - } - } - } - } - } - - /** - * Issues the general failure. - * - * @param gseResponse The GetStreamingEvents response. - */ - private void issueGeneralFailure(GetStreamingEventsResponse gseResponse) { - SubscriptionErrorEventArgs eventArgs = new SubscriptionErrorEventArgs( - null, new ServiceResponseException(gseResponse)); - - if (!onSubscriptionError.isEmpty()) { - for (ISubscriptionErrorDelegate subError : onSubscriptionError) { - subError.subscriptionErrorDelegate(this, eventArgs); - } - } - } - - /** - * Issues the notification events. - * - * @param gseResponse The GetStreamingEvents response. - */ - private void issueNotificationEvents(GetStreamingEventsResponse gseResponse) { - - for (GetStreamingEventsResults.NotificationGroup events : gseResponse - .getResults().getNotifications()) { - StreamingSubscription subscription = null; - - synchronized (this) { - // Client can do any good or bad things in the below event - // handler - if (this.subscriptions != null - && this.subscriptions - .containsKey(events.subscriptionId)) { - subscription = this.subscriptions - .get(events.subscriptionId); - } - } - if (subscription != null) { - NotificationEventArgs eventArgs = new NotificationEventArgs( - subscription, events.events); - - if (!onNotificationEvent.isEmpty()) { - for (INotificationEventDelegate notifyEvent : onNotificationEvent) { - notifyEvent.notificationEventDelegate(this, eventArgs); - } - } - } - } - } - - /** - * Frees resources associated with this StreamingSubscriptionConnection. - */ - public void dispose() { - synchronized (this) { - if (!this.isDisposed) { - if (this.currentHangingRequest != null) { - this.currentHangingRequest = null; - } - - this.subscriptions = null; - this.session = null; - - this.isDisposed = true; - } - } - } - - /** - * Throws if disposed. - * - * @throws Exception - */ - private void throwIfDisposed() throws Exception { - if (this.isDisposed) { - throw new Exception(this.getClass().getName()); - } - } - - @Override - public void handleResponseObject(Object response) throws ArgumentException { - this.handleServiceResponseObject(response); - } - - @Override - public void hangingRequestDisconnectHandler(Object sender, - HangingRequestDisconnectEventArgs args) { - this.onRequestDisconnect(sender, args); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/notification/SubscriptionBase.java b/src/main/java/microsoft/exchange/webservices/data/notification/SubscriptionBase.java deleted file mode 100644 index 2f9a41381..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/notification/SubscriptionBase.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.notification; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -/** - * Represents the base class for event subscriptions. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class SubscriptionBase { - - /** - * The service. - */ - private ExchangeService service; - - /** - * The id. - */ - private String id; - - /** - * The watermark. - */ - private String watermark; - - /** - * Instantiates a new subscription base. - * - * @param service the service - * @throws Exception the exception - */ - protected SubscriptionBase(ExchangeService service) throws Exception { - EwsUtilities.validateParam(service, "service"); - // EwsUtilities.validateParam(service, "service"); - - this.service = service; - } - - /** - * Instantiates a new subscription base. - * - * @param service the service - * @param id the id - * @throws Exception the exception - */ - protected SubscriptionBase(ExchangeService service, String id) - throws Exception { - this(service); - EwsUtilities.validateParam(id, "id"); - - this.id = id; - } - - /** - * Instantiates a new subscription base. - * - * @param service the service - * @param id the id - * @param watermark the watermark - * @throws Exception the exception - */ - protected SubscriptionBase(ExchangeService service, String id, - String watermark) throws Exception { - this(service, id); - this.watermark = watermark; - } - - /** - * Load from xml. - * - * @param reader the reader - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader) throws Exception { - this.id = reader.readElementValue(XmlNamespace.Messages, - XmlElementNames.SubscriptionId); - if (this.getUsesWatermark()) { - this.watermark = reader.readElementValue(XmlNamespace.Messages, - XmlElementNames.Watermark); - } - - } - - /** - * Gets the session. - * - * @return the session - */ - protected ExchangeService getService() { - return this.service; - } - - /** - * Gets the id. - * - * @return the id - */ - public String getId() { - return id; - } - - /** - * Sets the id. - * - * @param id the new id - */ - protected void setId(String id) { - this.id = id; - } - - /** - * Sets the water mark. - * - * @param watermark the new water mark - */ - protected void setWaterMark(String watermark) { - this.watermark = watermark; - } - - /** - * Gets the water mark. - * - * @return the water mark - */ - public String getWaterMark() { - return this.watermark; - } - - /** - * Gets whether or not this subscription uses watermarks. - */ - protected boolean getUsesWatermark() { - return true; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/notification/SubscriptionErrorEventArgs.java b/src/main/java/microsoft/exchange/webservices/data/notification/SubscriptionErrorEventArgs.java deleted file mode 100644 index 190cb864c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/notification/SubscriptionErrorEventArgs.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.notification; - -/** - * Provides data to a StreamingSubscriptionConnection's - * OnSubscriptionError and OnDisconnect events. - */ -public class SubscriptionErrorEventArgs { //TODO extends EventObject { - - private StreamingSubscription subscription; - private Exception exception; - - /** - * Initializes a new instance of the SubscriptionErrorEventArgs class. - * - * @param subscription The subscription for which an error occurred. - * If subscription is null, the error applies to the entire connection. - * @param exception The exception representing the error. - * If exception is null, the connection - * was cleanly closed by the server. - */ - protected SubscriptionErrorEventArgs( - StreamingSubscription subscription, - Exception exception) { - // super(subscription); //TODO need to check for EventObject - this.setSubscription(subscription); - this.setException(exception); - } - - /** - * Gets the subscription for which an error occurred. - * If Subscription is null, the error applies to the entire connection. - */ - public StreamingSubscription getSubscription() { - return this.subscription; - - } - - /** - * Sets the subscription for which an error occurred. - * If Subscription is null, the error applies to the entire connection. - */ - protected void setSubscription(StreamingSubscription value) { - this.subscription = value; - - } - - /** - * Gets the exception representing the error. If Exception is null, - * the connection was cleanly closed by the server. - */ - public Exception getException() { - return this.exception; - - } - - /** - * Sets the exception representing the error. If Exception is null, - * the connection was cleanly closed by the server. - */ - protected void setException(Exception value) { - this.exception = value; - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/AppointmentOccurrenceId.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/AppointmentOccurrenceId.java deleted file mode 100644 index b9e2370a2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/AppointmentOccurrenceId.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -/** - * Represents the Id of an occurrence of a recurring appointment. - */ -public final class AppointmentOccurrenceId extends ItemId { - - /** - * Index of the occurrence. - */ - private int occurrenceIndex; - - /** - * Initializes a new instance. - * - * @param recurringMasterUniqueId the recurring master unique id - * @param occurrenceIndex the occurrence index - * @throws Exception the exception - */ - public AppointmentOccurrenceId(String recurringMasterUniqueId, - int occurrenceIndex) throws Exception { - super(recurringMasterUniqueId); - this.occurrenceIndex = occurrenceIndex; - } - - /** - * Gets the index of the occurrence. Note that the occurrence index - * starts at one not zero. - * - * @return the occurrence index - */ - public int getOccurrenceIndex() { - return occurrenceIndex; - } - - /** - * Sets the occurrence index. - * - * @param occurrenceIndex the new occurrence index - */ - public void setOccurrenceIndex(int occurrenceIndex) { - if (occurrenceIndex < 1) { - throw new IllegalArgumentException("OccurrenceIndex must be greater than 0."); - } - this.occurrenceIndex = occurrenceIndex; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override - public String getXmlElementName() { - return XmlElementNames.OccurrenceItemId; - } - - /** - * Gets the name of the XML element. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.RecurringMasterId, this - .getUniqueId()); - writer.writeAttributeValue(XmlAttributeNames.InstanceIndex, this - .getOccurrenceIndex()); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/Attachment.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/Attachment.java deleted file mode 100644 index 493b60b2b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/Attachment.java +++ /dev/null @@ -1,433 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.property.BodyType; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinitionBase; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.Date; - -/** - * Represents an attachment to an item. - */ -public abstract class Attachment extends ComplexProperty { - - private static final Log LOG = LogFactory.getLog(Attachment.class); - - /** - * The owner. - */ - private Item owner; - - /** - * The id. - */ - private String id; - - /** - * The name. - */ - private String name; - - /** - * The content type. - */ - private String contentType; - - /** - * The content id. - */ - private String contentId; - - /** - * The content location. - */ - private String contentLocation; - - /** - * The size. - */ - private int size; - - /** - * The last modified time. - */ - private Date lastModifiedTime; - - /** - * The is inline. - */ - private boolean isInline; - - /** - * Initializes a new instance. - * - * @param owner The owner. - */ - protected Attachment(Item owner) { - this.owner = owner; - } - - /** - * Throws exception if this is not a new service object. - */ - protected void throwIfThisIsNotNew() { - if (!this.isNew()) { - throw new UnsupportedOperationException("Attachments can't be updated."); - } - } - - /** - * Sets value of field. - *

- * We override the base implementation. Attachments cannot be modified so - * any attempts the change a property on an existing attachment is an error. - * - * @param the generic type - * @param field The field - * @param value The value. - * @return true, if successful - */ - public boolean canSetFieldValue(T field, T value) { - this.throwIfThisIsNotNew(); - return super.canSetFieldValue(field, value); - } - - /** - * Gets the Id of the attachment. - * - * @return the id - */ - public String getId() { - return this.id; - } - - /** - * Gets the name of the attachment. - * - * @return the name - */ - public String getName() { - return this.name; - } - - /** - * Sets the name. - * - * @param value the new name - */ - public void setName(String value) { - if (this.canSetFieldValue(this.name, value)) { - this.name = value; - this.changed(); - } - } - - /** - * Gets the content type of the attachment. - * - * @return the content type - */ - public String getContentType() { - return this.contentType; - } - - /** - * Sets the content type. - * - * @param value the new content type - */ - public void setContentType(String value) { - if (this.canSetFieldValue(this.contentType, value)) { - this.contentType = value; - this.changed(); - } - } - - /** - * Gets the content Id of the attachment. ContentId can be used as a - * custom way to identify an attachment in order to reference it from within - * the body of the item the attachment belongs to. - * - * @return the content id - */ - public String getContentId() { - return this.contentId; - } - - /** - * Sets the content id. - * - * @param value the new content id - */ - public void setContentId(String value) { - if (this.canSetFieldValue(this.contentId, value)) { - this.contentId = value; - this.changed(); - } - } - - /** - * Gets the content location of the attachment. ContentLocation can - * be used to associate an attachment with a Url defining its location on - * the Web. - * - * @return the content location - */ - public String getContentLocation() { - return this.contentLocation; - } - - /** - * Sets the content location. - * - * @param value the new content location - */ - public void setContentLocation(String value) { - if (this.canSetFieldValue(this.contentLocation, value)) { - this.contentLocation = value; - this.changed(); - } - } - - /** - * Gets the size of the attachment. - * - * @return the size - * @throws ServiceVersionException throws ServiceVersionException - */ - public int getSize() throws ServiceVersionException { - EwsUtilities.validatePropertyVersion(this.getOwner().getService(), ExchangeVersion.Exchange2010, "Size"); - return this.size; - } - - /** - * Gets the date and time when this attachment was last modified. - * - * @return the last modified time - * @throws ServiceVersionException the service version exception - */ - public Date getLastModifiedTime() throws ServiceVersionException { - - EwsUtilities.validatePropertyVersion(this.getOwner().getService(), - ExchangeVersion.Exchange2010, "LastModifiedTime"); - - return this.lastModifiedTime; - - } - - /** - * Gets a value indicating whether this is an inline attachment. - * Inline attachments are not visible to end users. - * - * @return the checks if is inline - * @throws ServiceVersionException the service version exception - */ - public boolean getIsInline() throws ServiceVersionException { - EwsUtilities.validatePropertyVersion(this.getOwner().getService(), - ExchangeVersion.Exchange2010, "IsInline"); - return this.isInline; - - } - - /** - * Sets the checks if is inline. - * - * @param value the new checks if is inline - * @throws ServiceVersionException the service version exception - */ - public void setIsInline(boolean value) throws ServiceVersionException { - EwsUtilities.validatePropertyVersion(this.getOwner().getService(), - ExchangeVersion.Exchange2010, "IsInline"); - if (this.canSetFieldValue(this.isInline, value)) { - this.isInline = value; - this.changed(); - } - } - - /** - * True if the attachment has not yet been saved, false otherwise. - * - * @return true, if is new - */ - public boolean isNew() { - return (this.getId() == null || this.getId().isEmpty()); - } - - /** - * Gets the owner of the attachment. - * - * @return the owner - */ - public Item getOwner() { - return this.owner; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - public abstract String getXmlElementName(); - - /** - * Tries to read element from XML. - * - * @param reader The reader. - * @return True if element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - - try { - if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.AttachmentId)) { - try { - this.id = reader.readAttributeValue(XmlAttributeNames.Id); - } catch (Exception e) { - LOG.error(e); - return false; - } - if (this.getOwner() != null) { - String rootItemChangeKey = reader - .readAttributeValue(XmlAttributeNames. - RootItemChangeKey); - if (null != rootItemChangeKey && - !rootItemChangeKey.isEmpty()) { - this.getOwner().getRootItemId().setChangeKey( - rootItemChangeKey); - } - } - reader.readEndElementIfNecessary(XmlNamespace.Types, - XmlElementNames.AttachmentId); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.Name)) { - this.name = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.ContentType)) { - this.contentType = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.ContentId)) { - this.contentId = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.ContentLocation)) { - this.contentLocation = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.Size)) { - this.size = reader.readElementValue(Integer.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.LastModifiedTime)) { - this.lastModifiedTime = reader.readElementValueAsDateTime(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.IsInline)) { - this.isInline = reader.readElementValue(Boolean.class); - return true; - } else { - return false; - } - } catch (Exception e) { - LOG.error(e); - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Name, this - .getName()); - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.ContentType, this.getContentType()); - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.ContentId, - this.getContentId()); - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.ContentLocation, this.getContentLocation()); - if (writer.getService().getRequestedServerVersion().ordinal() > - ExchangeVersion.Exchange2007_SP1 - .ordinal()) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.IsInline, this.getIsInline()); - } - } - - /** - * Load the attachment. - * - * @param bodyType Type of the body. - * @param additionalProperties The additional property. - * @throws Exception the exception - */ - protected void internalLoad(BodyType bodyType, - Iterable additionalProperties) - throws Exception { - this.getOwner().getService().getAttachment(this, bodyType, - additionalProperties); - } - - /** - * Validates this instance. - * - * @param attachmentIndex Index of this attachment. - * @throws ServiceValidationException the service validation exception - * @throws Exception the exception - */ - abstract void validate(int attachmentIndex) throws Exception; - - /** - * Loads the attachment. Calling this method results in a call to EWS. - * - * @throws Exception the exception - */ - public void load() throws Exception { - this.internalLoad(null, null); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/AttachmentCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/AttachmentCollection.java deleted file mode 100644 index b39477312..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/AttachmentCollection.java +++ /dev/null @@ -1,476 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.response.CreateAttachmentResponse; -import microsoft.exchange.webservices.data.core.response.DeleteAttachmentResponse; -import microsoft.exchange.webservices.data.core.response.ServiceResponseCollection; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceResult; -import microsoft.exchange.webservices.data.core.exception.service.remote.CreateAttachmentException; -import microsoft.exchange.webservices.data.core.exception.service.remote.DeleteAttachmentException; -import microsoft.exchange.webservices.data.core.exception.misc.InvalidOperationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; - -import java.io.File; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Enumeration; - -/** - * Represents an item's attachment collection. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class AttachmentCollection extends ComplexPropertyCollection - implements IOwnedProperty { - - // The item owner that owns this attachment collection - /** - * The owner. - */ - private Item owner; - - /** - * Initializes a new instance of AttachmentCollection. - */ - public AttachmentCollection() { - super(); - } - - /** - * The owner of this attachment collection. - * - * @return the owner - */ - public ServiceObject getOwner() { - return this.owner; - } - - /** - * The owner of this attachment collection. - * - * @param value accepts ServiceObject - */ - public void setOwner(ServiceObject value) { - Item item = (Item) value; - EwsUtilities.ewsAssert(item != null, "AttachmentCollection.IOwnedProperty.set_Owner", - "value is not a descendant of ItemBase"); - - this.owner = item; - } - - /** - * Adds a file attachment to the collection. - * - * @param fileName the file name - * @return A FileAttachment instance. - */ - public FileAttachment addFileAttachment(String fileName) { - return this.addFileAttachment(new File(fileName).getName(), fileName); - } - - /** - * Adds a file attachment to the collection. - * - * @param name accepts String display name of the new attachment. - * @param fileName accepts String name of the file representing the content of - * the attachment. - * @return A FileAttachment instance. - */ - public FileAttachment addFileAttachment(String name, String fileName) { - FileAttachment fileAttachment = new FileAttachment(this.owner); - fileAttachment.setName(name); - fileAttachment.setFileName(fileName); - - this.internalAdd(fileAttachment); - - return fileAttachment; - } - - /** - * Adds a file attachment to the collection. - * - * @param name accepts String display name of the new attachment. - * @param contentStream accepts InputStream stream from which to read the content of - * the attachment. - * @return A FileAttachment instance. - */ - public FileAttachment addFileAttachment(String name, - InputStream contentStream) { - FileAttachment fileAttachment = new FileAttachment(this.owner); - fileAttachment.setName(name); - fileAttachment.setContentStream(contentStream); - - this.internalAdd(fileAttachment); - - return fileAttachment; - } - - /** - * Adds a file attachment to the collection. - * - * @param name the name - * @param content accepts byte byte arrays representing the content of the - * attachment. - * @return FileAttachment - */ - public FileAttachment addFileAttachment(String name, byte[] content) { - FileAttachment fileAttachment = new FileAttachment(this.owner); - fileAttachment.setName(name); - fileAttachment.setContent(content); - - this.internalAdd(fileAttachment); - - return fileAttachment; - } - - /** - * Adds an item attachment to the collection. - * - * @param the generic type - * @param cls the cls - * @return An ItemAttachment instance. - * @throws Exception the exception - */ - public GenericItemAttachment addItemAttachment( - Class cls) throws Exception { - if (cls.getDeclaredFields().length == 0) { - throw new InvalidOperationException(String.format( - "Items of type %s are not supported as attachments.", cls - .getName())); - } - - GenericItemAttachment itemAttachment = - new GenericItemAttachment( - this.owner); - itemAttachment.setTItem((TItem) EwsUtilities.createItemFromItemClass( - itemAttachment, cls, true)); - - this.internalAdd(itemAttachment); - - return itemAttachment; - } - - /** - * Removes all attachments from this collection. - */ - public void clear() { - this.internalClear(); - } - - /** - * Removes the attachment at the specified index. - * - * @param index Index of the attachment to remove. - */ - public void removeAt(int index) { - if (index < 0 || index >= this.getCount()) { - throw new IllegalArgumentException("parameter \'index\' : " + "index is out of range."); - } - - this.internalRemoveAt(index); - } - - /** - * Removes the specified attachment. - * - * @param attachment The attachment to remove. - * @return True if the attachment was successfully removed from the - * collection, false otherwise. - * @throws Exception the exception - */ - public boolean remove(Attachment attachment) throws Exception { - EwsUtilities.validateParam(attachment, "attachment"); - - return this.internalRemove(attachment); - } - - /** - * Instantiate the appropriate attachment type depending on the current XML - * element name. - * - * @param xmlElementName The XML element name from which to determine the type of - * attachment to create. - * @return An Attachment instance. - */ - @Override - protected Attachment createComplexProperty(String xmlElementName) { - if (xmlElementName.equals(XmlElementNames.FileAttachment)) { - return new FileAttachment(this.owner); - } else if (xmlElementName.equals(XmlElementNames.ItemAttachment)) { - return new ItemAttachment(this.owner); - } else { - return null; - } - } - - /** - * Determines the name of the XML element associated with the - * complexProperty parameter. - * - * @param complexProperty The attachment object for which to determine the XML element - * name with. - * @return The XML element name associated with the complexProperty - * parameter. - */ - @Override - protected String getCollectionItemXmlElementName(Attachment - complexProperty) { - if (complexProperty instanceof FileAttachment) { - return XmlElementNames.FileAttachment; - } else { - return XmlElementNames.ItemAttachment; - } - } - - /** - * Saves this collection by creating new attachment and deleting removed - * ones. - * - * @throws Exception the exception - */ - public void save() throws Exception { - ArrayList attachments = - new ArrayList(); - - for (Attachment attachment : this.getRemovedItems()) { - if (!attachment.isNew()) { - attachments.add(attachment); - } - } - - // If any, delete them by calling the DeleteAttachment web method. - if (attachments.size() > 0) { - this.internalDeleteAttachments(attachments); - } - - attachments.clear(); - - // Retrieve a list of attachments that have to be created. - for (Attachment attachment : this) { - if (attachment.isNew()) { - attachments.add(attachment); - } - } - - // If there are any, create them by calling the CreateAttachment web - // method. - if (attachments.size() > 0) { - if (this.owner.isAttachment()) { - this.internalCreateAttachments(this.owner.getParentAttachment() - .getId(), attachments); - } else { - this.internalCreateAttachments( - this.owner.getId().getUniqueId(), attachments); - } - } - - - // Process all of the item attachments in this collection. - for (Attachment attachment : this) { - ItemAttachment itemAttachment = (ItemAttachment) - ((attachment instanceof - ItemAttachment) ? attachment : - null); - if (itemAttachment != null) { - // Bug E14:80864: Make sure item was created/loaded before - // trying to create/delete sub-attachments - if (itemAttachment.getItem() != null) { - // Create/delete any sub-attachments - itemAttachment.getItem().getAttachments().save(); - - // Clear the item's change log - itemAttachment.getItem().clearChangeLog(); - } - } - } - - super.clearChangeLog(); - } - - /** - * Determines whether there are any unsaved attachment collection changes. - * - * @return True if attachment adds or deletes haven't been processed yet. - * @throws ServiceLocalException - */ - public boolean hasUnprocessedChanges() throws ServiceLocalException { - // Any new attachments? - for (Attachment attachment : this) { - if (attachment.isNew()) { - return true; - } - } - - // Any pending deletions? - for (Attachment attachment : this.getRemovedItems()) { - if (!attachment.isNew()) { - return true; - } - } - - - Collection itemAttachments = - new ArrayList(); - for (Object event : this.getItems()) { - if (event instanceof ItemAttachment) { - itemAttachments.add((ItemAttachment) event); - } - } - - // Recurse: process item attachments to check - // for new or deleted sub-attachments. - for (ItemAttachment itemAttachment : itemAttachments) { - if (itemAttachment.getItem() != null) { - if (itemAttachment.getItem().getAttachments().hasUnprocessedChanges()) { - return true; - } - } - } - - return false; - } - - /** - * Disables the change log clearing mechanism. Attachment collections are - * saved separately from the item they belong to. - */ - @Override public void clearChangeLog() { - // Do nothing - } - - /** - * Validates this instance. - * - * @throws Exception the exception - */ - public void validate() throws Exception { - // Validate all added attachments - if (this.owner.isNew() - && this.owner.getService().getRequestedServerVersion() - .ordinal() >= ExchangeVersion.Exchange2010_SP2 - .ordinal()) { - boolean contactPhotoFound = false; - for (int attachmentIndex = 0; attachmentIndex < this.getAddedItems() - .size(); attachmentIndex++) { - final Attachment attachment = this.getAddedItems().get(attachmentIndex); - if (attachment != null) { - if (attachment.isNew() && attachment instanceof FileAttachment) { - // At the server side, only the last attachment with - // IsContactPhoto is kept, all other IsContactPhoto - // attachments are removed. CreateAttachment will generate - // AttachmentId for each of such attachments (although - // only the last one is valid). - // - // With E14 SP2 CreateItemWithAttachment, such request will only - // return 1 AttachmentId; but the client - // expects to see all, so let us prevent such "invalid" request - // in the first place. - // - // The IsNew check is to still let CreateAttachmentRequest allow - // multiple IsContactPhoto attachments. - // - if (((FileAttachment) attachment).isContactPhoto()) { - if (contactPhotoFound) { - throw new ServiceValidationException("Multiple contact photos in attachment."); - } - contactPhotoFound = true; - } - } - attachment.validate(attachmentIndex); - } - } - } - } - - - /** - * Calls the DeleteAttachment web method to delete a list of attachments. - * - * @param attachments the attachments - * @throws Exception the exception - */ - private void internalDeleteAttachments(Iterable attachments) - throws Exception { - ServiceResponseCollection responses = - this.owner - .getService().deleteAttachments(attachments); - Enumeration enumerator = responses - .getEnumerator(); - while (enumerator.hasMoreElements()) { - DeleteAttachmentResponse response = enumerator.nextElement(); - // We remove all attachments that were successfully deleted from the - // change log. We should never - // receive a warning from EWS, so we ignore them. - if (response.getResult() != ServiceResult.Error) { - this.removeFromChangeLog(response.getAttachment()); - } - } - - // TODO : Should we throw for warnings as well? - if (responses.getOverallResult() == ServiceResult.Error) { - throw new DeleteAttachmentException(responses, "At least one attachment couldn't be deleted."); - } - } - - /** - * Calls the CreateAttachment web method to create a list of attachments. - * - * @param parentItemId the parent item id - * @param attachments the attachments - * @throws Exception the exception - */ - private void internalCreateAttachments(String parentItemId, - Iterable attachments) throws Exception { - ServiceResponseCollection responses = - this.owner - .getService().createAttachments(parentItemId, attachments); - - Enumeration enumerator = responses - .getEnumerator(); - while (enumerator.hasMoreElements()) { - CreateAttachmentResponse response = enumerator.nextElement(); - // We remove all attachments that were successfully created from the - // change log. We should never - // receive a warning from EWS, so we ignore them. - if (response.getResult() != ServiceResult.Error) { - this.removeFromChangeLog(response.getAttachment()); - } - } - - // TODO : Should we throw for warnings as well? - if (responses.getOverallResult() == ServiceResult.Error) { - throw new CreateAttachmentException(responses, "At least one attachment couldn't be created."); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/Attendee.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/Attendee.java deleted file mode 100644 index fdd481eb3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/Attendee.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.MeetingResponseType; - -import java.util.Date; - -/** - * Represents an attendee to a meeting. - */ - -public final class Attendee extends EmailAddress { - - /** - * The response type. - */ - private MeetingResponseType responseType; - - /** - * The last response time. - */ - private Date lastResponseTime; - - /** - * Initializes a new instance of the Attendee class. - */ - public Attendee() { - super(); - } - - /** - * Initializes a new instance of the Attendee class. - * - * @param smtpAddress the smtp address - * @throws Exception the exception - */ - public Attendee(String smtpAddress) throws Exception { - super(smtpAddress); - EwsUtilities.validateParam(smtpAddress, "smtpAddress"); - } - - /** - * Initializes a new instance of the Attendee class. - * - * @param name the name - * @param smtpAddress the smtp address - */ - public Attendee(String name, String smtpAddress) { - super(name, smtpAddress); - } - - /** - * Initializes a new instance of the Attendee class. - * - * @param name the name - * @param smtpAddress the smtp address - * @param routingType the routing type - */ - public Attendee(String name, String smtpAddress, String routingType) { - super(name, smtpAddress, routingType); - } - - /** - * Initializes a new instance of the Attendee class. - * - * @param mailbox the mailbox - * @throws Exception the exception - */ - public Attendee(EmailAddress mailbox) throws Exception { - super(mailbox); - } - - /** - * Gets the type of response the attendee gave to the meeting invitation - * it received. - * - * @return the response type - */ - public MeetingResponseType getResponseType() { - return responseType; - } - - /** - * Gets the last response time. - * - * @return the last response time - */ - public Date getLastResponseTime() { - return lastResponseTime; - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Mailbox)) { - this.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.ResponseType)) { - this.responseType = reader - .readElementValue(MeetingResponseType.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.LastResponseTime)) { - this.lastResponseTime = reader.readElementValueAsDateTime(); - return true; - } else { - return super.tryReadElementFromXml(reader); - } - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeStartElement(this.getNamespace(), XmlElementNames.Mailbox); - super.writeElementsToXml(writer); - writer.writeEndElement(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/AttendeeCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/AttendeeCollection.java deleted file mode 100644 index 1c5f5f628..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/AttendeeCollection.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; - -/** - * Represents a collection of attendees. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class AttendeeCollection extends ComplexPropertyCollection { - - /** - * Initializes a new instance of the AttendeeCollection class. - */ - public AttendeeCollection() { - super(); - } - - /** - * Adds an attendee to the collection. - * - * @param attendee the attendee - */ - public void add(Attendee attendee) { - this.internalAdd(attendee); - } - - /** - * Adds an attendee to the collection. - * - * @param smtpAddress the smtp address - * @return An Attendee instance initialized with the provided SMTP address. - * @throws Exception the exception - */ - public Attendee add(String smtpAddress) throws Exception { - Attendee result = new Attendee(smtpAddress); - - this.internalAdd(result); - - return result; - } - - /** - * Adds an attendee to the collection. - * - * @param name the name - * @param smtpAddress the smtp address - * @return An Attendee instance initialized with the provided name and SMTP - * address. - */ - public Attendee add(String name, String smtpAddress) { - Attendee result = new Attendee(name, smtpAddress); - - this.internalAdd(result); - - return result; - } - - /** - * Clears the collection. - */ - public void clear() { - this.internalClear(); - } - - /** - * Removes an attendee from the collection. - * - * @param index the index - */ - public void removeAt(int index) { - if (index < 0 || index >= this.getCount()) { - throw new IllegalArgumentException("parameter \'index\' : " + "index is out of range."); - } - - this.internalRemoveAt(index); - } - - /** - * Removes an attendee from the collection. - * - * @param attendee the attendee - * @return True if the attendee was successfully removed from the - * collection, false otherwise. - * @throws Exception the exception - */ - public boolean remove(Attendee attendee) throws Exception { - EwsUtilities.validateParam(attendee, "attendee"); - - return this.internalRemove(attendee); - } - - /** - * Creates an Attendee object from an XML element name. - * - * @param xmlElementName the xml element name - * @return An Attendee object. - */ - @Override - protected Attendee createComplexProperty(String xmlElementName) { - if (xmlElementName.equalsIgnoreCase(XmlElementNames.Attendee)) { - return new Attendee(); - } else { - return null; - } - } - - /** - * Retrieves the XML element name corresponding to the provided Attendee - * object. - * - * @param attendee the attendee - * @return The XML element name corresponding to the provided Attendee - * object. - */ - @Override - protected String getCollectionItemXmlElementName(Attendee attendee) { - return XmlElementNames.Attendee; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ByteArrayArray.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ByteArrayArray.java deleted file mode 100644 index 592bd45de..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ByteArrayArray.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents an array of byte arrays - */ -public class ByteArrayArray extends ComplexProperty { - final static String ItemXmlElementName = "Base64Binary"; - private List content = new ArrayList(); - - public ByteArrayArray() { - } - - /** - * Gets the content of the array of byte arrays - */ - public byte[][] getContent() { - return (byte[][]) this.content.toArray(); - } - - /** - * Tries to read element from XML. - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - - if (reader.getLocalName().equalsIgnoreCase( - ByteArrayArray.ItemXmlElementName)) { - this.content.add(reader.readBase64ElementValue()); - return true; - } else { - return false; - } - - } - - /** - * The Writer - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - for (byte[] item : this.content) { - writer.writeStartElement(XmlNamespace.Types, - ByteArrayArray.ItemXmlElementName); - writer.writeBase64ElementValue(item); - writer.writeEndElement(); - } - - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/CompleteName.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/CompleteName.java deleted file mode 100644 index 5f5e1b716..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/CompleteName.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -/** - * Represents the complete name of a contact. - */ -public final class CompleteName extends ComplexProperty { - - /** - * The title. - */ - private String title; - - /** - * The given name. - */ - private String givenName; - - /** - * The middle name. - */ - private String middleName; - - /** - * The surname. - */ - private String surname; - - /** - * The suffix. - */ - private String suffix; - - /** - * The initials. - */ - private String initials; - - /** - * The full name. - */ - private String fullName; - - /** - * The nickname. - */ - private String nickname; - - /** - * The yomi given name. - */ - private String yomiGivenName; - - /** - * The yomi surname. - */ - private String yomiSurname; - - /** - * Gets the contact's title. - * - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * Gets the given name (first name) of the contact. - * - * @return the givenName - */ - public String getGivenName() { - return givenName; - } - - /** - * Gets the middle name of the contact. - * - * @return the middleName - */ - public String getMiddleName() { - return middleName; - } - - /** - * Gets the surname (last name) of the contact. - * - * @return the surname - */ - public String getSurname() { - return surname; - } - - /** - * Gets the suffix of the contact. - * - * @return the suffix - */ - public String getSuffix() { - return suffix; - } - - /** - * Gets the initials of the contact. - * - * @return the initials - */ - public String getInitials() { - return initials; - } - - /** - * Gets the full name of the contact. - * - * @return the fullName - */ - public String getFullName() { - return fullName; - } - - /** - * Gets the nickname of the contact. - * - * @return the nickname - */ - public String getNickname() { - return nickname; - } - - /** - * Gets the Yomi given name (first name) of the contact. - * - * @return the yomiGivenName - */ - public String getYomiGivenName() { - return yomiGivenName; - } - - /** - * Gets the Yomi surname (last name) of the contact. - * - * @return the yomiSurname - */ - public String getYomiSurname() { - return yomiSurname; - } - - /** - * Tries to read element from XML. - * - * @param reader The reader. - * @return True if element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Title)) { - this.title = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.FirstName)) { - this.givenName = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.MiddleName)) { - this.middleName = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.LastName)) { - this.surname = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.Suffix)) { - this.suffix = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.Initials)) { - this.initials = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.FullName)) { - this.fullName = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.NickName)) { - this.nickname = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.YomiFirstName)) { - this.yomiGivenName = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.YomiLastName)) { - this.yomiSurname = reader.readElementValue(); - return true; - } else { - return false; - } - } - - /** - * Writes the elements to XML. - * - * @param writer accepts EwsServiceXmlWriter - * @throws Exception throws Exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Title, - this.title); - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.FirstName, - this.givenName); - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.MiddleName, this.middleName); - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.LastName, - this.surname); - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Suffix, - this.suffix); - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Initials, - this.initials); - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.FullName, - this.fullName); - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.NickName, - this.nickname); - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.YomiFirstName, this.yomiGivenName); - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.YomiLastName, this.yomiSurname); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ComplexProperty.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ComplexProperty.java deleted file mode 100644 index 87351cbe0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ComplexProperty.java +++ /dev/null @@ -1,392 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.ISelfValidate; -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a property that can be sent to or retrieved from EWS. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class ComplexProperty implements ISelfValidate, ComplexFunctionDelegate { - - /** - * The xml namespace. - */ - private XmlNamespace xmlNamespace = XmlNamespace.Types; - - /** - * Initializes a new instance. - */ - protected ComplexProperty() { - - } - - /** - * Gets the namespace. - * - * @return the namespace. - */ - public XmlNamespace getNamespace() { - return xmlNamespace; - } - - /** - * Sets the namespace. - * - * @param xmlNamespace the namespace. - */ - public void setNamespace(XmlNamespace xmlNamespace) { - this.xmlNamespace = xmlNamespace; - } - - /** - * Instance was changed. - */ - public void changed() { - if (!onChangeList.isEmpty()) { - for (IComplexPropertyChangedDelegate change : onChangeList) { - change.complexPropertyChanged(this); - } - } - } - - /** - * Sets value of field. - * - * @param Field type. - * @param field The field. - * @param value The value. - * @return true, if successful - */ - public boolean canSetFieldValue(T field, T value) { - boolean applyChange; - if (field == null) { - applyChange = value != null; - } else { - if (field instanceof Comparable) { - Comparable c = (Comparable) field; - applyChange = value != null && c.compareTo(value) != 0; - } else { - applyChange = true; - } - } - return applyChange; - } - - /** - * Clears the change log. - */ - public void clearChangeLog() { - } - - /** - * Reads the attribute from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - } - - /** - * Reads the text value from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - public void readTextValueFromXml(EwsServiceXmlReader reader) - throws Exception { - } - - /** - * Tries to read element from XML. - * - * @param reader The reader. - * @return True if element was read. - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - return false; - } - - /** - * Tries to read element from XML to patch this property. - * - * @param reader The reader. - * True if element was read. - */ - public boolean tryReadElementFromXmlToPatch(EwsServiceXmlReader reader) throws Exception { - return false; - } - - /** - * Writes the attribute to XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - } - - /** - * Writes elements to XML. - * - * @param writer The writer. - * @throws Exception the exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @param xmlNamespace the xml namespace - * @param xmlElementName Name of the XML element. - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName) throws Exception { - - /*reader.ensureCurrentNodeIsStartElement(xmlNamespace, xmlElementName); - this.readAttributesFromXml(reader); - - if (!reader.isEmptyElement()) { - do { - reader.read(); - - switch (reader.getNodeType().nodeType) { - case XmlNodeType.START_ELEMENT: - if (!this.tryReadElementFromXml(reader)) { - reader.skipCurrentElement(); - } - break; - case XmlNodeType.CHARACTERS: - this.readTextValueFromXml(reader); - break; - } - } while (!reader.isEndElement(xmlNamespace, xmlElementName)); - } else { - // Adding this code to skip the END_ELEMENT of an Empty Element. - reader.read(); - reader.isEndElement(xmlNamespace, xmlElementName); - } */ - - this.internalLoadFromXml(reader, xmlNamespace, xmlElementName); - } - - /** - * Loads from XML to update this property. - * - * @param reader The reader. - * @param xmlElementName Name of the XML element. - * @throws Exception - */ - public void updateFromXml(EwsServiceXmlReader reader, String xmlElementName) throws Exception { - this.updateFromXml(reader, this.getNamespace(), xmlElementName); - } - - /** - * Loads from XML to update itself. - * - * @param reader The reader. - * @param xmlNamespace The XML namespace. - * @param xmlElementName Name of the XML element. - */ - public void updateFromXml( - EwsServiceXmlReader reader, - XmlNamespace xmlNamespace, - String xmlElementName) throws Exception { - this.internalupdateLoadFromXml(reader, xmlNamespace, xmlElementName); - } - - /** - * Loads from XML - * - * @param reader The Reader. - * @param xmlNamespace The Xml NameSpace. - * @param xmlElementName The Xml ElementName - */ - private void internalLoadFromXml( - EwsServiceXmlReader reader, - XmlNamespace xmlNamespace, - String xmlElementName) throws Exception { - reader.ensureCurrentNodeIsStartElement(xmlNamespace, xmlElementName); - - this.readAttributesFromXml(reader); - - if (!reader.isEmptyElement()) { - do { - reader.read(); - - switch (reader.getNodeType().nodeType) { - case XmlNodeType.START_ELEMENT: - if (!this.tryReadElementFromXml(reader)) { - reader.skipCurrentElement(); - } - break; - case XmlNodeType.CHARACTERS: - this.readTextValueFromXml(reader); - break; - } - } while (!reader.isEndElement(xmlNamespace, xmlElementName)); - } else { - // Adding this code to skip the END_ELEMENT of an Empty Element. - reader.read(); - reader.isEndElement(xmlNamespace, xmlElementName); - } - } - - private void internalupdateLoadFromXml( - EwsServiceXmlReader reader, - XmlNamespace xmlNamespace, - String xmlElementName) throws Exception { - reader.ensureCurrentNodeIsStartElement(xmlNamespace, xmlElementName); - - this.readAttributesFromXml(reader); - - if (!reader.isEmptyElement()) { - do { - reader.read(); - - switch (reader.getNodeType().nodeType) { - case XmlNodeType.START_ELEMENT: - if (!this.tryReadElementFromXmlToPatch(reader)) { - reader.skipCurrentElement(); - } - break; - case XmlNodeType.CHARACTERS: - this.readTextValueFromXml(reader); - break; - } - } while (!reader.isEndElement(xmlNamespace, xmlElementName)); - } - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @param xmlElementName Name of the XML element. - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader, String xmlElementName) - throws Exception { - this.loadFromXml(reader, this.getNamespace(), xmlElementName); - } - - /** - * Writes to XML. - * - * @param writer The writer. - * @param xmlNamespace The XML namespace. - * @param xmlElementName Name of the XML element. - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer, XmlNamespace xmlNamespace, String xmlElementName) throws Exception { - writer.writeStartElement(xmlNamespace, xmlElementName); - this.writeAttributesToXml(writer); - this.writeElementsToXml(writer); - writer.writeEndElement(); - } - - /** - * Writes to XML. - * - * @param writer The writer. - * @param xmlElementName Name of the XML element. - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) - throws Exception { - this.writeToXml(writer, this.getNamespace(), xmlElementName); - } - - /** - * Change events occur when property changed. - */ - private List onChangeList = - new ArrayList(); - - /** - * Set event to happen when property changed. - * - * @param change change event - */ - public void addOnChangeEvent(IComplexPropertyChangedDelegate change) { - onChangeList.add(change); - } - - /** - * Remove the event from happening when property changed. - * - * @param change change event - */ - public void removeChangeEvent(IComplexPropertyChangedDelegate change) { - onChangeList.remove(change); - } - - /** - * Clears change events list. - */ - protected void clearChangeEvents() { - onChangeList.clear(); - } - - /** - * Implements ISelfValidate.validate. Validates this instance. - * - * @throws Exception the exception - */ - public void validate() throws Exception { - this.internalValidate(); - } - - /** - * Validates this instance. - * - * @throws Exception the exception - */ - protected void internalValidate() throws Exception { - } - - public Boolean func(EwsServiceXmlReader reader) throws Exception { - return !this.tryReadElementFromXml(reader); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ComplexPropertyCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ComplexPropertyCollection.java deleted file mode 100644 index c8cf52c78..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ComplexPropertyCollection.java +++ /dev/null @@ -1,484 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ICustomXmlUpdateSerializer; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Represents a collection of property that can be sent to and retrieved from - * EWS. - * - * @param ComplexProperty type. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class ComplexPropertyCollection - - extends ComplexProperty implements ICustomXmlUpdateSerializer, - Iterable, IComplexPropertyChangedDelegate { - - /** - * The item. - */ - private final List items = new ArrayList(); - - /** - * The added item. - */ - private final List addedItems = - new ArrayList(); - - /** - * The modified item. - */ - private final List modifiedItems = - new ArrayList(); - - /** - * The removed item. - */ - private final List removedItems = - new ArrayList(); - - /** - * Creates the complex property. - * - * @param xmlElementName Name of the XML element. - * @return Complex property instance. - */ - protected abstract TComplexProperty createComplexProperty( - String xmlElementName); - - /** - * Gets the name of the collection item XML element. - * - * @param complexProperty The complex property. - * @return XML element name. - */ - protected abstract String getCollectionItemXmlElementName( - TComplexProperty complexProperty); - - /** - * Initializes a new instance of. ComplexPropertyCollection - */ - protected ComplexPropertyCollection() { - super(); - } - - /** - * Item changed. - * - * @param property The complex property. - */ - protected void itemChanged(final TComplexProperty property) { - EwsUtilities.ewsAssert( - property != null, "ComplexPropertyCollection.ItemChanged", - "The complexProperty argument must be not null" - ); - - if (!this.addedItems.contains(property)) { - if (!this.modifiedItems.contains(property)) { - this.modifiedItems.add(property); - this.changed(); - } - } - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @param localElementName Name of the local element. - */ - @Override public void loadFromXml(EwsServiceXmlReader reader, String localElementName) throws Exception { - this.loadFromXml( - reader, - XmlNamespace.Types, - localElementName); - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @param xmlNamespace The XML namespace. - * @param localElementName Name of the local element. - */ - @Override public void loadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, - String localElementName) throws Exception { - reader.ensureCurrentNodeIsStartElement(xmlNamespace, - localElementName); - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.isStartElement()) { - TComplexProperty complexProperty = this - .createComplexProperty(reader.getLocalName()); - - if (complexProperty != null) { - complexProperty.loadFromXml(reader, reader - .getLocalName()); - this.internalAdd(complexProperty, true); - } else { - reader.skipCurrentElement(); - } - } - } while (!reader.isEndElement(xmlNamespace, localElementName)); - } else { - reader.read(); - } - } - - /** - * Loads from XML to update itself. - * - * @param reader The reader. - * @param xmlNamespace The XML namespace. - * @param xmlElementName Name of the XML element. - */ - public void updateFromXml( - EwsServiceXmlReader reader, - XmlNamespace xmlNamespace, - String xmlElementName) throws Exception { - reader.ensureCurrentNodeIsStartElement(xmlNamespace, xmlElementName); - - if (!reader.isEmptyElement()) { - int index = 0; - do { - reader.read(); - - if (reader.isStartElement()) { - TComplexProperty complexProperty = this.createComplexProperty(reader.getLocalName()); - TComplexProperty actualComplexProperty = this.getPropertyAtIndex(index++); - - if (complexProperty == null || !complexProperty.equals(actualComplexProperty)) { - throw new ServiceLocalException("Property type incompatible when updating collection."); - } - - actualComplexProperty.updateFromXml(reader, xmlNamespace, reader.getLocalName()); - } - } - while (!reader.isEndElement(xmlNamespace, xmlElementName)); - } - } - - /** - * Writes to XML. - * - * @param writer The writer. - * @param xmlNamespace The XML namespace. - * @param xmlElementName Name of the XML element. - */ - @Override public void writeToXml(EwsServiceXmlWriter writer, XmlNamespace xmlNamespace, - String xmlElementName) throws Exception { - if (this.shouldWriteToXml()) { - super.writeToXml( - writer, - xmlNamespace, - xmlElementName); - } - } - - /** - * Determine whether we should write collection to XML or not. - * - * @return True if collection contains at least one element. - */ - public boolean shouldWriteToXml() { - //Only write collection if it has at least one element. - return this.getCount() > 0; - } - - /** - * Writes elements to XML. - * - * @param writer The writer. - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - for (TComplexProperty complexProperty : this) { - complexProperty.writeToXml(writer, this - .getCollectionItemXmlElementName(complexProperty)); - } - } - - /** - * Clears the change log. - */ - @Override public void clearChangeLog() { - this.removedItems.clear(); - this.addedItems.clear(); - this.modifiedItems.clear(); - } - - /** - * Removes from change log. - * - * @param complexProperty The complex property. - */ - protected void removeFromChangeLog(TComplexProperty complexProperty) { - this.removedItems.remove(complexProperty); - this.modifiedItems.remove(complexProperty); - this.addedItems.remove(complexProperty); - } - - /** - * Gets the item. - * - * @return The item. - */ - public List getItems() { - return this.items; - } - - /** - * Gets the added item. - * - * @return The added item. - */ - protected List getAddedItems() { - return this.addedItems; - } - - /** - * Gets the modified item. - * - * @return The modified item. - */ - protected List getModifiedItems() { - return this.modifiedItems; - } - - /** - * Gets the removed item. - * - * @return The removed item. - */ - protected List getRemovedItems() { - return this.removedItems; - } - - /** - * Add complex property. - * - * @param complexProperty The complex property. - */ - protected void internalAdd(TComplexProperty complexProperty) { - this.internalAdd(complexProperty, false); - } - - /** - * Add complex property. - * - * @param complexProperty The complex property. - * @param loading If true, collection is being loaded. - */ - private void internalAdd(TComplexProperty complexProperty, - boolean loading) { - EwsUtilities.ewsAssert(complexProperty != null, "ComplexPropertyCollection.InternalAdd", - "complexProperty is null"); - - if (!this.items.contains(complexProperty)) { - this.items.add(complexProperty); - if (!loading) { - this.removedItems.remove(complexProperty); - this.addedItems.add(complexProperty); - } - complexProperty.addOnChangeEvent(this); - this.changed(); - } - } - - /** - * Complex property changed. - * - * @param complexProperty accepts ComplexProperty - */ - @Override - public void complexPropertyChanged(final TComplexProperty complexProperty) { - this.itemChanged(complexProperty); - } - - /** - * Clear collection. - */ - protected void internalClear() { - while (this.getCount() > 0) { - this.internalRemoveAt(0); - } - } - - /** - * Remote entry at index. - * - * @param index The index. - */ - protected void internalRemoveAt(int index) { - EwsUtilities.ewsAssert(index >= 0 && index < this.getCount(), - "ComplexPropertyCollection.InternalRemoveAt", "index is out of range."); - - this.internalRemove(this.items.get(index)); - } - - /** - * Remove specified complex property. - * - * @param complexProperty The complex property. - * @return True if the complex property was successfully removed from the - * collection, false otherwise. - */ - protected boolean internalRemove(TComplexProperty complexProperty) { - EwsUtilities.ewsAssert(complexProperty != null, "ComplexPropertyCollection.InternalRemove", - "complexProperty is null"); - - if (this.items.remove(complexProperty)) { - complexProperty.removeChangeEvent(this); - if (!this.addedItems.contains(complexProperty)) { - this.removedItems.add(complexProperty); - } else { - this.addedItems.remove(complexProperty); - } - this.modifiedItems.remove(complexProperty); - this.changed(); - return true; - } else { - return false; - } - } - - /** - * Determines whether a specific property is in the collection. - * - * @param complexProperty The property to locate in the collection. - * @return True if the property was found in the collection, false - * otherwise. - */ - public boolean contains(TComplexProperty complexProperty) { - return this.items.contains(complexProperty); - } - - /** - * Searches for a specific property and return its zero-based index within - * the collection. - * - * @param complexProperty The property to locate in the collection. - * @return The zero-based index of the property within the collection. - */ - public int indexOf(TComplexProperty complexProperty) { - return this.items.indexOf(complexProperty); - } - - /** - * Gets the total number of property in the collection. - * - * @return the count - */ - public int getCount() { - return this.items.size(); - } - - /** - * Gets the property at the specified index. - * - * @param index the index - * @return index The property at the specified index. - * @throws IllegalArgumentException thrown if if index is out of range. - */ - public TComplexProperty getPropertyAtIndex(int index) - throws IllegalArgumentException { - if (index < 0 || index >= this.getCount()) { - throw new IllegalArgumentException( - String.format("index %d is out of range [0..%d[.", index, this.getCount()) - ); - } - return this.items.get(index); - } - - /** - * Gets an enumerator that iterates through the elements of the collection. - * - * @return An Iterator for the collection. - */ - @Override - public Iterator iterator() { - return this.items.iterator(); - } - - /** - * Write set update to xml. - * - * @param writer accepts EwsServiceXmlWriter - * @param ewsObject accepts ServiceObject - * @param propertyDefinition accepts PropertyDefinition - * @return true - * @throws Exception the exception - */ - @Override - public boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject, PropertyDefinition propertyDefinition) - throws Exception { - // If the collection is empty, delete the property. - if (this.getCount() == 0) { - writer.writeStartElement(XmlNamespace.Types, ewsObject - .getDeleteFieldXmlElementName()); - propertyDefinition.writeToXml(writer); - writer.writeEndElement(); - return true; - } - // Otherwise, use the default XML serializer. - else { - return false; - } - } - - /** - * Writes the deletion update to XML. - * - * @param writer The writer. - * @param ewsObject The ews object. - * @return True if property generated serialization. - * @throws Exception the exception - */ - @Override - public boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject) throws Exception { - // Use the default XML serializer. - return false; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ConversationId.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ConversationId.java deleted file mode 100644 index 0624aeaf1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ConversationId.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentNullException; - -/** - * Represents the Id of a Conversation. - */ -public class ConversationId extends ServiceId { - - /** - * Initializes a new instance of the ConversationId class. - */ - public ConversationId() { - super(); - } - - /** - * Defines an implicit conversion between string and ConversationId. - * - * @param uniqueId the unique id - * @return A ConversationId initialized with the specified unique Id. - * @throws Exception the exception - */ - public static ConversationId getConversationIdFromUniqueId(String uniqueId) - throws Exception { - return new ConversationId(uniqueId); - } - - /** - * Defines an implicit conversion between ConversationId and String. - * - * @param conversationId the conversation id - * @return A ConversationId initialized with the specified unique Id. - * @throws ArgumentNullException the argument null exception - */ - public static String getStringFromConversationId( - ConversationId conversationId) throws ArgumentNullException { - if (conversationId == null) { - throw new ArgumentNullException("conversationId"); - } - - if (null == conversationId.getUniqueId() - || conversationId.getUniqueId().isEmpty()) { - return ""; - } else { - // Ignoring the change key info - return conversationId.getUniqueId(); - } - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override - public String getXmlElementName() { - return XmlElementNames.ConversationId; - } - - /** - * Initializes a new instance of ConversationId. - * - * @param uniqueId the unique id - * @throws Exception the exception - */ - public ConversationId(String uniqueId) throws Exception { - super(uniqueId); - } - - /** - * Gets a string representation of the Conversation Id. - * - * @return The string representation of the conversation id. - */ - @Override - public String toString() { - // We have ignored the change key portion - return this.getUniqueId(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/CreateRuleOperation.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/CreateRuleOperation.java deleted file mode 100644 index c47c9823a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/CreateRuleOperation.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; - -/** - * Represents an operation to create a new rule. - */ -public final class CreateRuleOperation extends RuleOperation { - - - /** - * Inbox rule to be created. - */ - private Rule rule; - - /** - * Initializes a new instance of the - * class. - */ - public CreateRuleOperation() { - super(); - } - - /** - * Initializes a new instance of the - * class. - * - * @param rule The inbox rule to create. - */ - public CreateRuleOperation(Rule rule) { - super(); - this.rule = rule; - } - - /** - * Gets or sets the rule to be created. - */ - public Rule getRule() { - - return this.rule; - } - - public void setRule(Rule value) { - - if (this.canSetFieldValue(this.rule, value)) { - this.rule = value; - this.changed(); - - } - } - - /** - * Writes elements to XML. - * - * @param writer The writer. - * @throws Exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.getRule().writeToXml(writer, XmlElementNames.Rule); - } - - /** - * Validates this instance. - * - * @throws Exception - */ - @Override - protected void internalValidate() throws Exception { - EwsUtilities.validateParam(this.rule, "Rule"); - } - - /** - * Gets the Xml element name of the CreateRuleOperation object. - */ - @Override public String getXmlElementName() { - - return XmlElementNames.CreateRuleOperation; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/DelegatePermissions.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/DelegatePermissions.java deleted file mode 100644 index f3dcdc669..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/DelegatePermissions.java +++ /dev/null @@ -1,388 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.permission.folder.DelegateFolderPermissionLevel; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -import java.util.HashMap; -import java.util.Map; - -/** - * Represents the permissions of a delegate user. - */ -public final class DelegatePermissions extends ComplexProperty { - - private Map delegateFolderPermissions; - - /** - * Initializes a new instance of the class. - */ - - protected DelegatePermissions() { - super(); - this.delegateFolderPermissions = new HashMap(); - - delegateFolderPermissions.put( - XmlElementNames.CalendarFolderPermissionLevel, - new DelegateFolderPermission()); - delegateFolderPermissions.put( - XmlElementNames.TasksFolderPermissionLevel, - new DelegateFolderPermission()); - delegateFolderPermissions.put( - XmlElementNames.InboxFolderPermissionLevel, - new DelegateFolderPermission()); - delegateFolderPermissions.put( - XmlElementNames.ContactsFolderPermissionLevel, - new DelegateFolderPermission()); - delegateFolderPermissions.put( - XmlElementNames.NotesFolderPermissionLevel, - new DelegateFolderPermission()); - delegateFolderPermissions.put( - XmlElementNames.JournalFolderPermissionLevel, - new DelegateFolderPermission()); - } - - /** - * Gets the delegate user's permission on the principal's calendar. - * - * @return the calendar folder permission level - */ - public DelegateFolderPermissionLevel getCalendarFolderPermissionLevel() { - return this.delegateFolderPermissions.get(XmlElementNames. - CalendarFolderPermissionLevel).getPermissionLevel(); - - } - - /** - * sets the delegate user's permission on the principal's calendar. - * - * @param value the new calendar folder permission level - */ - public void setCalendarFolderPermissionLevel( - DelegateFolderPermissionLevel value) { - this.delegateFolderPermissions.get(XmlElementNames. - CalendarFolderPermissionLevel).setPermissionLevel(value); - } - - /** - * Gets the delegate user's permission on the principal's tasks - * folder. - * - * @return the tasks folder permission level - */ - public DelegateFolderPermissionLevel getTasksFolderPermissionLevel() { - return this.delegateFolderPermissions.get(XmlElementNames. - TasksFolderPermissionLevel).getPermissionLevel(); - - } - - /** - * Sets the tasks folder permission level. - * - * @param value the new tasks folder permission level - */ - public void setTasksFolderPermissionLevel( - DelegateFolderPermissionLevel value) { - - this.delegateFolderPermissions.get(XmlElementNames. - TasksFolderPermissionLevel).setPermissionLevel(value); - } - - /** - * Gets the delegate user's permission on the principal's inbox. - * - * @return the inbox folder permission level - */ - public DelegateFolderPermissionLevel getInboxFolderPermissionLevel() { - return this.delegateFolderPermissions.get(XmlElementNames. - InboxFolderPermissionLevel). - getPermissionLevel(); - } - - /** - * Sets the inbox folder permission level. - * - * @param value the new inbox folder permission level - */ - public void setInboxFolderPermissionLevel( - DelegateFolderPermissionLevel value) { - this.delegateFolderPermissions.get(XmlElementNames. - InboxFolderPermissionLevel). - setPermissionLevel(value); - } - - /** - * Gets the delegate user's permission on the principal's contacts - * folder. - * - * @return the contacts folder permission level - */ - public DelegateFolderPermissionLevel getContactsFolderPermissionLevel() { - return this.delegateFolderPermissions.get( - XmlElementNames.ContactsFolderPermissionLevel). - getPermissionLevel(); - } - - /** - * Sets the contacts folder permission level. - * - * @param value the new contacts folder permission level - */ - public void setContactsFolderPermissionLevel( - DelegateFolderPermissionLevel value) { - this.delegateFolderPermissions.get( - XmlElementNames.ContactsFolderPermissionLevel). - setPermissionLevel(value); - } - - /** - * Gets the delegate user's permission on the principal's notes - * folder. - * - * @return the notes folder permission level - */ - public DelegateFolderPermissionLevel getNotesFolderPermissionLevel() { - return this.delegateFolderPermissions.get(XmlElementNames. - NotesFolderPermissionLevel). - getPermissionLevel(); - } - - /** - * Sets the notes folder permission level. - * - * @param value the new notes folder permission level - */ - public void setNotesFolderPermissionLevel( - DelegateFolderPermissionLevel value) { - this.delegateFolderPermissions.get(XmlElementNames. - NotesFolderPermissionLevel). - setPermissionLevel(value); - } - - /** - * Gets the delegate user's permission on the principal's journal - * folder. - * - * @return the journal folder permission level - */ - public DelegateFolderPermissionLevel getJournalFolderPermissionLevel() { - return this.delegateFolderPermissions.get(XmlElementNames. - JournalFolderPermissionLevel). - getPermissionLevel(); - } - - /** - * Sets the journal folder permission level. - * - * @param value the new journal folder permission level - */ - public void setJournalFolderPermissionLevel( - DelegateFolderPermissionLevel value) { - this.delegateFolderPermissions.get(XmlElementNames. - JournalFolderPermissionLevel). - setPermissionLevel(value); - } - - /** - * Reset. - */ - protected void reset() { - for (DelegateFolderPermission delegateFolderPermission : this.delegateFolderPermissions.values()) { - delegateFolderPermission.reset(); - } - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return Returns true if element was read. - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - DelegateFolderPermission delegateFolderPermission = null; - - if (this.delegateFolderPermissions.containsKey(reader.getLocalName())) { - delegateFolderPermission = this.delegateFolderPermissions. - get(reader.getLocalName()); - delegateFolderPermission.initialize(reader. - readElementValue(DelegateFolderPermissionLevel.class)); - } - - - return delegateFolderPermission != null; - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.writePermissionToXml(writer, - XmlElementNames.CalendarFolderPermissionLevel); - - this.writePermissionToXml(writer, - XmlElementNames.TasksFolderPermissionLevel); - - this.writePermissionToXml(writer, - XmlElementNames.InboxFolderPermissionLevel); - - this.writePermissionToXml(writer, - XmlElementNames.ContactsFolderPermissionLevel); - - this.writePermissionToXml(writer, - XmlElementNames.NotesFolderPermissionLevel); - - this.writePermissionToXml(writer, - XmlElementNames.JournalFolderPermissionLevel); - } - - /** - * Write permission to Xml. - * - * @param writer the writer - * @param xmlElementName the element name - * @throws XMLStreamException the XML stream exception - */ - private void writePermissionToXml( - EwsServiceXmlWriter writer, - String xmlElementName) throws ServiceXmlSerializationException, - XMLStreamException { - DelegateFolderPermissionLevel delegateFolderPermissionLevel = - this.delegateFolderPermissions. - get(xmlElementName).getPermissionLevel(); - // E14 Bug 298307: UpdateDelegate fails if - //Custom permission level is round tripped - // - if (delegateFolderPermissionLevel != DelegateFolderPermissionLevel.Custom) { - writer.writeElementValue( - XmlNamespace.Types, - xmlElementName, - delegateFolderPermissionLevel); - } - } - - /** - * Validates this instance for AddDelegate. - * - * @throws ServiceValidationException - */ - protected void validateAddDelegate() throws ServiceValidationException { - for (DelegateFolderPermission delegateFolderPermission : this.delegateFolderPermissions.values()) { - if (delegateFolderPermission.getPermissionLevel() == DelegateFolderPermissionLevel.Custom) { - throw new ServiceValidationException("This operation can't be performed because one or more folder " - + "permission levels were set to Custom."); - } - } - } - - /** - * Validates this instance for UpdateDelegate. - * - * @throws ServiceValidationException - */ - protected void validateUpdateDelegate() throws ServiceValidationException { - for (DelegateFolderPermission delegateFolderPermission : this.delegateFolderPermissions.values()) { - if (delegateFolderPermission.getPermissionLevel() == DelegateFolderPermissionLevel.Custom && - !delegateFolderPermission.isExistingPermissionLevelCustom) { - throw new ServiceValidationException("This operation can't be performed because one or more folder " - + "permission levels were set to Custom."); - } - } - } - - /** - * Represents a folder's DelegateFolderPermissionLevel - */ - private static class DelegateFolderPermission { - - /** - * Initializes this DelegateFolderPermission. - * - * @param permissionLevel The DelegateFolderPermissionLevel - */ - protected void initialize( - DelegateFolderPermissionLevel permissionLevel) { - this.setPermissionLevel(permissionLevel); - this.setIsExistingPermissionLevelCustom(permissionLevel == - DelegateFolderPermissionLevel.Custom); - } - - /** - * Resets this DelegateFolderPermission. - */ - protected void reset() { - this.initialize(DelegateFolderPermissionLevel.None); - } - - - private DelegateFolderPermissionLevel permissionLevel = DelegateFolderPermissionLevel.None; - - /** - * Gets the delegate user's permission on a principal's folder. - */ - protected DelegateFolderPermissionLevel getPermissionLevel() { - return this.permissionLevel; - } - - /** - * Sets the delegate user's permission on a principal's folder. - */ - protected void setPermissionLevel( - DelegateFolderPermissionLevel value) { - this.permissionLevel = value; - } - - - private boolean isExistingPermissionLevelCustom; - - /** - * Gets IsExistingPermissionLevelCustom. - */ - protected boolean getIsExistingPermissionLevelCustom() { - return this.isExistingPermissionLevelCustom; - } - - /** - * Sets IsExistingPermissionLevelCustom. - */ - private void setIsExistingPermissionLevelCustom(Boolean value) { - this.isExistingPermissionLevelCustom = value; - } - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/DelegateUser.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/DelegateUser.java deleted file mode 100644 index 1f283cde0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/DelegateUser.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.StandardUser; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; - -/** - * Represents a delegate user. - */ -public final class DelegateUser extends ComplexProperty { - - /** - * The user id. - */ - private UserId userId = new UserId(); - - /** - * The permissions. - */ - private DelegatePermissions permissions = new DelegatePermissions(); - - /** - * The receive copies of meeting messages. - */ - private boolean receiveCopiesOfMeetingMessages; - - /** - * The view private item. - */ - private boolean viewPrivateItems; - - /** - * Initializes a new instance of the class. - */ - public DelegateUser() { - super(); - this.receiveCopiesOfMeetingMessages = false; - this.viewPrivateItems = false; - } - - /** - * Initializes a new instance of the class. - * - * @param primarySmtpAddress the primary smtp address - */ - public DelegateUser(String primarySmtpAddress) { - this(); - this.userId.setPrimarySmtpAddress(primarySmtpAddress); - } - - /** - * Initializes a new instance of the class. - * - * @param standardUser the standard user - */ - public DelegateUser(StandardUser standardUser) { - this(); - - this.userId.setStandardUser(standardUser); - } - - /** - * Gets the user Id of the delegate user. - * - * @return the user id - */ - public UserId getUserId() { - return this.userId; - } - - /** - * Gets the list of delegate user's permissions. - * - * @return the permissions - */ - public DelegatePermissions getPermissions() { - return this.permissions; - } - - /** - * Gets a value indicating if the delegate user should receive - * copies of meeting request. - * - * @return the receive copies of meeting messages - */ - public boolean getReceiveCopiesOfMeetingMessages() { - return this.receiveCopiesOfMeetingMessages; - - } - - /** - * Sets the receive copies of meeting messages. - * - * @param value the new receive copies of meeting messages - */ - public void setReceiveCopiesOfMeetingMessages(boolean value) { - this.receiveCopiesOfMeetingMessages = value; - } - - /** - * Gets a value indicating if the delegate user should be - * able to view the principal's private item. - * - * @return the view private item - */ - public boolean getViewPrivateItems() { - return this.viewPrivateItems; - - } - - /** - * Gets a value indicating if the delegate user should be able to - * view the principal's private item. - * - * @param value the new view private item - */ - public void setViewPrivateItems(boolean value) { - - this.viewPrivateItems = value; - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return true, if successful - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.UserId)) { - - this.userId = new UserId(); - this.userId.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.UserId)) { - - this.permissions.reset(); - this.permissions.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.ReceiveCopiesOfMeetingMessages)) { - - this.receiveCopiesOfMeetingMessages = reader - .readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.ViewPrivateItems)) { - - this.viewPrivateItems = reader.readElementValue(Boolean.class); - return true; - } else { - - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.getUserId().writeToXml(writer, XmlElementNames.UserId); - this.getPermissions().writeToXml(writer, - XmlElementNames.DelegatePermissions); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.ReceiveCopiesOfMeetingMessages, - this.receiveCopiesOfMeetingMessages); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.ViewPrivateItems, this.viewPrivateItems); - } - - /** - * Validates this instance. - * - * @throws ServiceValidationException the service validation exception - */ - protected void internalValidate() throws ServiceValidationException { - if (this.getUserId() == null) { - throw new ServiceValidationException("The UserId in the DelegateUser hasn't been specified."); - } else if (!this.getUserId().isValid()) { - throw new ServiceValidationException( - "The UserId in the DelegateUser is invalid. The StandardUser, PrimarySmtpAddress or SID property must be set."); - } - } - - /** - * Validates this instance for AddDelegate. - * - * @throws Exception - * @throws ServiceValidationException - */ - protected void validateAddDelegate() throws ServiceValidationException, - Exception { - { - this.permissions.validateAddDelegate(); - } - } - - /** - * Validates this instance for UpdateDelegate. - */ - public void validateUpdateDelegate() throws Exception { - { - this.permissions.validateUpdateDelegate(); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/DeleteRuleOperation.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/DeleteRuleOperation.java deleted file mode 100644 index 800c1427d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/DeleteRuleOperation.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents an operation to delete an existing rule. - */ -public final class DeleteRuleOperation extends RuleOperation { - /** - * Id of the inbox rule to delete. - */ - private String ruleId; - - /** - * Initializes a new instance of the - * class. - */ - public DeleteRuleOperation() { - super(); - } - - /** - * Initializes a new instance of the - * class. - * - * @param ruleId The Id of the inbox rule to delete. - */ - public DeleteRuleOperation(String ruleId) { - super(); - this.ruleId = ruleId; - } - - /** - * Gets or sets the Id of the rule to delete. - */ - public String getRuleId() { - return this.ruleId; - } - - public void setRuleId(String value) { - if (this.canSetFieldValue(this.ruleId, value)) { - this.ruleId = value; - this.changed(); - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.RuleId, this.getRuleId()); - } - - /** - * Validates this instance. - */ - @Override - protected void internalValidate() throws Exception { - EwsUtilities.validateParam(this.ruleId, "RuleId"); - } - - /** - * Gets the Xml element name of the DeleteRuleOperation object. - */ - @Override public String getXmlElementName() { - return XmlElementNames.DeleteRuleOperation; - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/DeletedOccurrenceInfo.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/DeletedOccurrenceInfo.java deleted file mode 100644 index 5663d8142..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/DeletedOccurrenceInfo.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.xml.stream.XMLStreamException; - -import java.util.Date; - -/** - * Encapsulates information on the deleted occurrence of a recurring - * appointment. - */ -public class DeletedOccurrenceInfo extends ComplexProperty { - - private static final Log LOG = LogFactory.getLog(DeletedOccurrenceInfo.class); - - /** - * The original start date and time of the deleted occurrence. The EWS - * schema contains a Start property for deleted occurrences but it's really - * the original start date and time of the occurrence. - */ - private Date originalStart; - - /** - * Initializes a new instance of the "DeletedOccurrenceInfo" class. - */ - protected DeletedOccurrenceInfo() { - } - - /** - * Tries to read element from XML. - * - * @param reader The reader. - * @return True if element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Start)) { - try { - this.originalStart = reader.readElementValueAsDateTime(); - } catch (ServiceXmlDeserializationException e) { - LOG.error(e); - } catch (XMLStreamException e) { - LOG.error(e); - } - return true; - } else { - return false; - } - } - - /** - * Gets the original start date and time of the deleted occurrence. - * - * @return the original start - */ - public Date getOriginalStart() { - return this.originalStart; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/DeletedOccurrenceInfoCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/DeletedOccurrenceInfoCollection.java deleted file mode 100644 index 76598e5a8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/DeletedOccurrenceInfoCollection.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; - -/** - * Represents a collection of deleted occurrence objects. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class DeletedOccurrenceInfoCollection extends ComplexPropertyCollection { - - /** - * Initializes a new instance of the OccurrenceInfoCollection class. - */ - public DeletedOccurrenceInfoCollection() { - } - - /** - * Creates the complex property. - * - * @param xmlElementName the xml element name - * @return OccurenceInfo instance. - */ - @Override - protected DeletedOccurrenceInfo createComplexProperty( - String xmlElementName) { - if (xmlElementName.equalsIgnoreCase(XmlElementNames.DeletedOccurrence)) { - return new DeletedOccurrenceInfo(); - } else { - return null; - } - } - - /** - * Gets the name of the collection item XML element. - * - * @param complexProperty the complex property - * @return XML element name. - */ - @Override - protected String getCollectionItemXmlElementName( - DeletedOccurrenceInfo complexProperty) { - return XmlElementNames.Occurrence; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/DictionaryEntryProperty.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/DictionaryEntryProperty.java deleted file mode 100644 index 008e5c334..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/DictionaryEntryProperty.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents an entry of a DictionaryProperty object. - *

- * All descendants of DictionaryEntryProperty must implement a parameterless - * constructor. That constructor does not have to be public. That constructor - * does not have to be public. - * - * @param the generic type - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class DictionaryEntryProperty extends ComplexProperty { - - /** - * The key. - */ - private TKey key; - private Class instance; - - /** - * Initializes a new instance of the "DictionaryEntryProperty<TKey>" - * class. - */ - protected DictionaryEntryProperty(Class cls) { - this.instance = cls; - } - - /** - * Initializes a new instance of the "DictionaryEntryProperty<TKey>" - * class. - * - * @param key The key. - */ - protected DictionaryEntryProperty(Class cls, TKey key) { - super(); - this.key = key; - this.instance = cls; - } - - /** - * Gets the key. - * - * @return the key - */ - protected TKey getKey() { - return key; - } - - /** - * Sets the key. - * - * @param value the value to set - */ - protected void setKey(TKey value) { - this.key = value; - } - - /** - * Reads the attribute from XML. - * - * @param reader accepts EwsServiceXmlReader - * @throws Exception throws Exception - */ - @Override - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.key = reader.readAttributeValue(instance, - XmlAttributeNames.Key); - } - - /** - * Writes the attribute to XML. - * - * @param writer accepts EwsServiceXmlWriter - * @throws ServiceXmlSerializationException throws ServiceXmlSerializationException - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.Key, this.getKey()); - } - - /** - * Writes the set update to XML. - * - * @param writer the writer - * @param ewsObject the ews object - * @param ownerDictionaryXmlElementName name of the owner dictionary XML element - * @return true if update XML was written - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject, String ownerDictionaryXmlElementName) - throws XMLStreamException, ServiceXmlSerializationException { - return false; - } - - /** - * Writes the delete update to XML. - * - * @param writer the writer - * @param ewsObject the ews object - * @return true if update XML was written - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject) throws XMLStreamException, ServiceXmlSerializationException { - return false; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/DictionaryProperty.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/DictionaryProperty.java deleted file mode 100644 index 9a2fef0c5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/DictionaryProperty.java +++ /dev/null @@ -1,388 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ICustomXmlUpdateSerializer; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * Represents a generic dictionary that can be sent to or retrieved from EWS. - * TKey The type of key. TEntry The type of entry. - * - * @param the generic type - * @param the generic type - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class DictionaryProperty - > - extends ComplexProperty implements ICustomXmlUpdateSerializer, IComplexPropertyChangedDelegate { - - /** - * The entries. - */ - private Map entries = new HashMap(); - - /** - * The removed entries. - */ - private Map removedEntries = new HashMap(); - - /** - * The added entries. - */ - private List addedEntries = new ArrayList(); - - /** - * The modified entries. - */ - private List modifiedEntries = new ArrayList(); - - /** - * Entry was changed. - * - * @param complexProperty the complex property - */ - private void entryChanged(final TEntry complexProperty) { - TKey key = complexProperty.getKey(); - - if (!this.addedEntries.contains(key) && !this.modifiedEntries.contains(key)) { - this.modifiedEntries.add(key); - this.changed(); - } - } - - /** - * Writes the URI to XML. - * - * @param writer the writer - * @param key the key - * @throws Exception the exception - */ - private void writeUriToXml(EwsServiceXmlWriter writer, TKey key) - throws Exception { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.IndexedFieldURI); - writer.writeAttributeValue(XmlAttributeNames.FieldURI, this - .getFieldURI()); - writer.writeAttributeValue(XmlAttributeNames.FieldIndex, this - .getFieldIndex(key)); - writer.writeEndElement(); - } - - /** - * Gets the index of the field. - * - * @param key the key - * @return Key index. - */ - protected String getFieldIndex(TKey key) { - return key.toString(); - } - - /** - * Gets the field URI. - * - * @return Field URI. - */ - protected String getFieldURI() { - return null; - } - - /** - * Creates the entry. - * - * @param reader the reader - * @return Dictionary entry. - */ - protected TEntry createEntry(EwsServiceXmlReader reader) { - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Entry)) { - return this.createEntryInstance(); - } else { - return null; - } - } - - /** - * Creates instance of dictionary entry. - * - * @return New instance. - */ - protected abstract TEntry createEntryInstance(); - - /** - * Gets the name of the entry XML element. - * - * @param entry the entry - * @return XML element name. - */ - protected String getEntryXmlElementName(TEntry entry) { - return XmlElementNames.Entry; - } - - /** - * Clears the change log. - */ - public void clearChangeLog() { - this.addedEntries.clear(); - this.removedEntries.clear(); - this.modifiedEntries.clear(); - - for (TEntry entry : this.entries.values()) { - entry.clearChangeLog(); - } - } - - /** - * Add entry. - * - * @param entry the entry - */ - protected void internalAdd(TEntry entry) { - entry.addOnChangeEvent(this); - - this.entries.put(entry.getKey(), entry); - this.addedEntries.add(entry.getKey()); - this.removedEntries.remove(entry.getKey()); - - this.changed(); - } - - /** - * Complex property changed. - * - * @param complexProperty accepts ComplexProperty - */ - @Override - public void complexPropertyChanged(final TEntry complexProperty) { - entryChanged(complexProperty); - } - - /** - * Add or replace entry. - * - * @param entry the entry - */ - protected void internalAddOrReplace(TEntry entry) { - TEntry oldEntry; - if (this.entries.containsKey(entry.getKey())) { - oldEntry = this.entries.get(entry.getKey()); - oldEntry.removeChangeEvent(this); - - entry.addOnChangeEvent(this); - - if (!this.addedEntries.contains(entry.getKey())) { - if (!this.modifiedEntries.contains(entry.getKey())) { - this.modifiedEntries.add(entry.getKey()); - } - } - - this.changed(); - } else { - this.internalAdd(entry); - } - } - - /** - * Remove entry based on key. - * - * @param key the key - */ - protected void internalRemove(TKey key) { - TEntry entry; - if (this.entries.containsKey(key)) { - entry = this.entries.get(key); - entry.removeChangeEvent(this); - - this.entries.remove(key); - this.removedEntries.put(key, entry); - - this.changed(); - } - - this.addedEntries.remove(key); - } - - /** - * Loads from XML. - * - * @param reader the reader - * @param localElementName the local element name - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader, String localElementName) throws Exception { - reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, - localElementName); - - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.isStartElement()) { - TEntry entry = this.createEntry(reader); - - if (entry != null) { - entry.loadFromXml(reader, reader.getLocalName()); - this.internalAdd(entry); - } else { - reader.skipCurrentElement(); - } - } - } while (!reader.isEndElement(XmlNamespace.Types, - localElementName)); - } else { - reader.read(); - } - } - - /** - * Writes to XML. - * - * @param writer The writer - * @param xmlNamespace The XML namespace. - * @param xmlElementName Name of the XML element. - * @throws Exception - */ - @Override public void writeToXml(EwsServiceXmlWriter writer, XmlNamespace xmlNamespace, - String xmlElementName) throws Exception { - // Only write collection if it has at least one element. - if (this.entries.size() > 0) { - super.writeToXml( - writer, - xmlNamespace, - xmlElementName); - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - for (Entry keyValuePair : this.entries.entrySet()) { - keyValuePair.getValue().writeToXml(writer, - this.getEntryXmlElementName(keyValuePair.getValue())); - } - } - - /** - * Gets the entries. - * - * @return The entries. - */ - protected Map getEntries() { - return entries; - } - - /** - * Determines whether this instance contains the specified key. - * - * @param key the key - * @return true if this instance contains the specified key; otherwise, - * false. - */ - public boolean contains(TKey key) { - return this.entries.containsKey(key); - } - - /** - * Writes updates to XML. - * - * @param writer the writer - * @param ewsObject the ews object - * @param propertyDefinition the property definition - * @return True if property generated serialization. - * @throws Exception the exception - */ - public boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject, PropertyDefinition propertyDefinition) - throws Exception { - List tempEntries = new ArrayList(); - - for (TKey key : this.addedEntries) { - tempEntries.add(this.entries.get(key)); - } - for (TKey key : this.modifiedEntries) { - tempEntries.add(this.entries.get(key)); - } - for (TEntry entry : tempEntries) { - - if (!entry.writeSetUpdateToXml(writer, ewsObject, - propertyDefinition.getXmlElement())) { - writer.writeStartElement(XmlNamespace.Types, ewsObject - .getSetFieldXmlElementName()); - this.writeUriToXml(writer, entry.getKey()); - - writer.writeStartElement(XmlNamespace.Types, ewsObject - .getXmlElementName()); - //writer.writeStartElement(XmlNamespace.Types, propertyDefinition.getXmlElementName()); - writer.writeStartElement(XmlNamespace.Types, propertyDefinition.getXmlElement()); - entry.writeToXml(writer, this.getEntryXmlElementName(entry)); - writer.writeEndElement(); - writer.writeEndElement(); - - writer.writeEndElement(); - } - } - - for (TEntry entry : this.removedEntries.values()) { - if (!entry.writeDeleteUpdateToXml(writer, ewsObject)) { - writer.writeStartElement(XmlNamespace.Types, ewsObject - .getDeleteFieldXmlElementName()); - this.writeUriToXml(writer, entry.getKey()); - writer.writeEndElement(); - } - } - - return true; - } - - /** - * Writes deletion update to XML. - * - * @param writer the writer - * @param ewsObject the ews object - * @return True if property generated serialization. - */ - public boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject) { - return false; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/EmailAddress.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/EmailAddress.java deleted file mode 100644 index 5c4e3b2be..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/EmailAddress.java +++ /dev/null @@ -1,395 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.MailboxType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Represents an e-mail address. - */ -public class EmailAddress extends ComplexProperty implements ISearchStringProvider { - - private static final Log LOG = LogFactory.getLog(EmailAddress.class); - - // SMTP routing type. - /** - * The Constant SmtpRoutingType. - */ - protected final static String SmtpRoutingType = "SMTP"; - - // / Display name. - /** - * The name. - */ - private String name; - - // / Email address. - /** - * The address. - */ - private String address; - - // / Routing type. - /** - * The routing type. - */ - private String routingType; - - // / Mailbox type. - /** - * The mailbox type. - */ - private MailboxType mailboxType; - - // / ItemId - Contact or PDL. - /** - * The id. - */ - private ItemId id; - - /** - * Initializes a new instance. - */ - public EmailAddress() { - super(); - } - - /** - * Initializes a new instance. - * - * @param smtpAddress The SMTP address used to initialize the EmailAddress. - */ - public EmailAddress(String smtpAddress) { - this(); - this.address = smtpAddress; - } - - /** - * Initializes a new instance. - * - * @param name The name used to initialize the EmailAddress. - * @param smtpAddress The SMTP address used to initialize the EmailAddress. - */ - public EmailAddress(String name, String smtpAddress) { - this(smtpAddress); - this.name = name; - } - - /** - * Initializes a new instance. - * - * @param name The name used to initialize the EmailAddress. - * @param address The address used to initialize the EmailAddress. - * @param routingType The routing type used to initialize the EmailAddress. - */ - public EmailAddress(String name, String address, String routingType) { - this(name, address); - this.routingType = routingType; - } - - /** - * Initializes a new instance. - * - * @param name The name used to initialize the EmailAddress. - * @param address The address used to initialize the EmailAddress. - * @param routingType The routing type used to initialize the EmailAddress. - * @param mailboxType Mailbox type of the participant. - */ - protected EmailAddress(String name, String address, String routingType, - MailboxType mailboxType) { - this(name, address, routingType); - this.mailboxType = mailboxType; - } - - /** - * Initializes a new instance. - * - * @param name The name used to initialize the EmailAddress. - * @param address The address used to initialize the EmailAddress. - * @param routingType The routing type used to initialize the EmailAddress. - * @param mailboxType Mailbox type of the participant. - * @param id ItemId of a Contact or PDL. - */ - protected EmailAddress(String name, String address, String routingType, - MailboxType mailboxType, ItemId id) { - this(name, address, routingType); - this.mailboxType = mailboxType; - this.id = id; - } - - /** - * Initializes a new instance from another EmailAddress instance. - * - * @param mailbox EMailAddress instance to copy. - * @throws Exception the exception - */ - protected EmailAddress(EmailAddress mailbox) throws Exception { - this(); - EwsUtilities.validateParam(mailbox, "mailbox"); - this.name = mailbox.getName(); - this.address = mailbox.getAddress(); - this.routingType = mailbox.getRoutingType(); - this.mailboxType = mailbox.getMailboxType(); - this.setId(mailbox.getId()); - - } - - /** - * Gets the name associated with the e-mail address. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Sets the name associated with the e-mail address. - * - * @param name the new name - */ - public void setName(String name) { - if (this.canSetFieldValue(this.name, name)) { - this.name = name; - this.changed(); - } - } - - /** - * Gets the actual address associated with the e-mail address. - * - * @return address associated with the e-mail address. - */ - public String getAddress() { - return address; - } - - /** - * Sets the actual address associated with the e-mail address. The type of - * the Address property must match the specified routing type. If - * RoutingType is not set, Address is assumed to be an SMTP address. - * - * @param address address associated with the e-mail address. - */ - public void setAddress(String address) { - - if (this.canSetFieldValue(this.address, address)) { - this.address = address; - this.changed(); - } - - } - - /** - * Gets the routing type associated with the e-mail address. - * - * @return the routing type - */ - public String getRoutingType() { - return routingType; - } - - /** - * Sets the routing type associated with the e-mail address. If RoutingType - * is not set, Address is assumed to be an SMTP address. - * - * @param routingType routing type associated with the e-mail address. - */ - public void setRoutingType(String routingType) { - if (this.canSetFieldValue(this.routingType, routingType)) { - this.routingType = routingType; - this.changed(); - } - } - - /** - * Gets the type of the e-mail address. - * - * @return type of the e-mail address. - */ - public MailboxType getMailboxType() { - return mailboxType; - } - - /** - * Sets the type of the e-mail address. - * - * @param mailboxType the new mailbox type - */ - public void setMailboxType(MailboxType mailboxType) { - if (this.canSetFieldValue(this.mailboxType, mailboxType)) { - this.mailboxType = mailboxType; - this.changed(); - } - } - - /** - * Gets the Id of the contact the e-mail address represents. - * - * @return the id - */ - public ItemId getId() { - return id; - } - - /** - * Sets the Id of the contact the e-mail address represents. When Id is - * specified, Address should be set to null. - * - * @param id the new id - */ - public void setId(ItemId id) { - - if (this.canSetFieldValue(this.id, id)) { - this.id = id; - this.changed(); - } - } - - /** - * Defines an implicit conversion between a string representing an SMTP - * address and EmailAddress. - * - * @param smtpAddress The SMTP address to convert to EmailAddress. - * @return An EmailAddress initialized with the specified SMTP address. - */ - public static EmailAddress getEmailAddressFromString(String smtpAddress) { - return new EmailAddress(smtpAddress); - } - - /** - * Try read element from xml. - * - * @param reader accepts EwsServiceXmlReader - * @return true - * @throws Exception throws Exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - try { - if (reader.getLocalName().equals(XmlElementNames.Name)) { - this.name = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.EmailAddress)) { - this.address = reader.readElementValue(); - return true; - } else if (reader.getLocalName() - .equals(XmlElementNames.RoutingType)) { - this.routingType = reader.readElementValue(); - return true; - } else if (reader.getLocalName() - .equals(XmlElementNames.MailboxType)) { - this.mailboxType = reader.readElementValue(MailboxType.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.ItemId)) { - this.id = new ItemId(); - this.id.loadFromXml(reader, reader.getLocalName()); - return true; - } else { - return false; - } - } catch (Exception e) { - LOG.error(e); - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer The writer. - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Name, this - .getName()); - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.EmailAddress, this.getAddress()); - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.RoutingType, this.getRoutingType()); - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.MailboxType, this.getMailboxType()); - - if (this.getId() != null) { - this.getId().writeToXml(writer, XmlElementNames.ItemId); - } - - } - - /** - * Get a string representation for using this instance in a search filter. - * - * @return String representation of instance. - */ - @Override - public String getSearchString() { - return this.getAddress(); - } - - /** - * Returns string that represents the current instance. - * - * @return String representation of instance. - */ - @Override - public String toString() { - String addressPart; - - if (null == this.getAddress() || this.getAddress().isEmpty()) { - return ""; - } - - if (null != this.getRoutingType() && this.getRoutingType().isEmpty()) { - addressPart = this.getRoutingType() + ":" + this.getAddress(); - } else { - addressPart = this.getAddress(); - } - - if (null != this.getName() && !this.getName().isEmpty()) { - return this.getName() + " <" + addressPart + ">"; - } else { - return addressPart; - } - } - - /** - * Gets the routing type. - * - * @return SMTP Routing type - */ - protected String getSmtpRoutingType() { - return SmtpRoutingType; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/EmailAddressCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/EmailAddressCollection.java deleted file mode 100644 index a0c512c38..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/EmailAddressCollection.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; - -import java.util.Iterator; - -/** - * Represents a collection of e-mail addresses. - */ -public final class EmailAddressCollection extends ComplexPropertyCollection { - - //XML element name - private String collectionItemXmlElementName; - - /** - * Initializes a new instance. - */ - public EmailAddressCollection() { - this(XmlElementNames.Mailbox); - } - - /** - * Initializes a new instance of the EmailAddressCollection class. - * - * @param collectionItemXmlElementName Name of the collection item XML element. - */ - protected EmailAddressCollection(String collectionItemXmlElementName) { - super(); - this.collectionItemXmlElementName = collectionItemXmlElementName; - } - - /** - * Adds an e-mail address to the collection. - * - * @param emailAddress The e-mail address to add. - */ - public void add(EmailAddress emailAddress) { - this.internalAdd(emailAddress); - } - - /** - * Adds multiple e-mail addresses to the collection. - * - * @param emailAddresses The e-mail addresses to add. - */ - public void addEmailRange(Iterator emailAddresses) { - if (null != emailAddresses) { - while (emailAddresses.hasNext()) { - this.add(emailAddresses.next()); - } - } - } - - /** - * Adds an e-mail address to the collection. - * - * @param smtpAddress The SMTP address used to initialize the e-mail address. - * @return An EmailAddress object initialized with the provided SMTP - * address. - */ - public EmailAddress add(String smtpAddress) { - EmailAddress emailAddress = new EmailAddress(smtpAddress); - this.add(emailAddress); - return emailAddress; - } - - /** - * Adds multiple e-mail addresses to the collection. - * - * @param smtpAddresses The SMTP addresses used to initialize the e-mail addresses. - */ - public void addSmtpAddressRange(Iterator smtpAddresses) { - if (null != smtpAddresses) { - while (smtpAddresses.hasNext()) { - this.add(smtpAddresses.next()); - } - } - } - - /** - * Adds an e-mail address to the collection. - * - * @param name The name used to initialize the e-mail address. - * @param smtpAddress The SMTP address used to initialize the e-mail address. - * @return An EmailAddress object initialized with the provided SMTP - * address. - */ - public EmailAddress add(String name, String smtpAddress) { - EmailAddress emailAddress = new EmailAddress(name, smtpAddress); - this.add(emailAddress); - return emailAddress; - } - - /** - * Clears the collection. - */ - public void clear() { - this.internalClear(); - } - - /** - * Removes an e-mail address from the collection. - * - * @param index The index of the e-mail address to remove. - */ - public void removeAt(int index) { - if (index < 0 || index >= this.getCount()) { - throw new IllegalArgumentException( - String.format("index %d is out of range [0..%d[.", index, this.getCount()) - ); - } - - this.internalRemoveAt(index); - } - - /** - * Removes an e-mail address from the collection. - * - * @param emailAddress The e-mail address to remove. - * @return True if the email address was successfully removed from the - * collection, false otherwise. - * @throws Exception the exception - */ - public boolean remove(EmailAddress emailAddress) throws Exception { - EwsUtilities.validateParam(emailAddress, "emailAddress"); - return this.internalRemove(emailAddress); - } - - /** - * Creates an EmailAddress object from an XML element name. - * - * @param xmlElementName The XML element name from which to create the e-mail address. - * @return An EmailAddress object. - */ - @Override - protected EmailAddress createComplexProperty(String xmlElementName) { - if (xmlElementName.equals(this.collectionItemXmlElementName)) { - return new EmailAddress(); - } else { - return null; - } - } - - /** - * Retrieves the XML element name corresponding to the provided EmailAddress - * object. - * - * @param complexProperty The EmailAddress object from which to determine the XML - * element name. - * @return The XML element name corresponding to the provided EmailAddress - * object. - */ - @Override - protected String getCollectionItemXmlElementName( - EmailAddress complexProperty) { - return this.collectionItemXmlElementName; - } - - /** - * Determine whether we should write collection to XML or not. - * - * @return Always true, even if the collection is empty. - */ - @Override - public boolean shouldWriteToXml() { - return true; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/EmailAddressDictionary.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/EmailAddressDictionary.java deleted file mode 100644 index 73b0cf679..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/EmailAddressDictionary.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.property.EmailAddressKey; -import microsoft.exchange.webservices.data.misc.OutParam; - -/** - * Represents a dictionary of e-mail addresses. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class EmailAddressDictionary extends DictionaryProperty { - - /** - * Gets the field URI. - * - * @return Field URI. - */ - @Override - protected String getFieldURI() { - return "contacts:EmailAddress"; - } - - /** - * Creates instance of dictionary entry. - * - * @return New instance. - */ - @Override - protected EmailAddressEntry createEntryInstance() { - return new EmailAddressEntry(); - } - - /** - * Gets the e-mail address at the specified key. - * - * @param key the key - * @return The e-mail address at the specified key. - */ - public EmailAddress getEmailAddress(EmailAddressKey key) { - return this.getEntries().get(key).getEmailAddress(); - } - - /** - * Sets the email address. - * - * @param key the key - * @param value the value - */ - public void setEmailAddress(EmailAddressKey key, EmailAddress value) { - if (value == null) { - this.internalRemove(key); - } else { - EmailAddressEntry entry; - - if (this.getEntries().containsKey(key)) { - entry = this.getEntries().get(key); - entry.setEmailAddress(value); - complexPropertyChanged(entry); - this.changed(); - } else { - entry = new EmailAddressEntry(key, value); - this.internalAdd(entry); - } - } - } - - /** - * Tries to get the e-mail address associated with the specified key. - * - * @param key the key - * @param outparam the outparam - * @return true if the Dictionary contains an e-mail address associated with - * the specified key; otherwise, false. - */ - public boolean tryGetValue(EmailAddressKey key, - OutParam outparam) { - EmailAddressEntry entry = null; - - if (this.getEntries().containsKey(key)) { - entry = this.getEntries().get(key); - outparam.setParam(entry.getEmailAddress()); - - return true; - } else { - outparam = null; - return false; - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/EmailAddressEntry.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/EmailAddressEntry.java deleted file mode 100644 index c91b581dd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/EmailAddressEntry.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.property.EmailAddressKey; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.MailboxType; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -/** - * Represents an entry of an EmailAddressDictionary. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class EmailAddressEntry extends DictionaryEntryProperty implements - IComplexPropertyChangedDelegate { - // / The email address. - /** - * The email address. - */ - private EmailAddress emailAddress; - - /** - * Initializes a new instance of the class. - */ - protected EmailAddressEntry() { - super(EmailAddressKey.class); - this.emailAddress = new EmailAddress(); - this.emailAddress.addOnChangeEvent(this); - } - - /** - * Initializes a new instance of the "EmailAddressEntry" class. - * - * @param key The key. - * @param emailAddress The email address. - */ - protected EmailAddressEntry(EmailAddressKey key, - EmailAddress emailAddress) { - super(EmailAddressKey.class, key); - this.emailAddress = emailAddress; - } - - /** - * Reads the attribute from XML. - * - * @param reader accepts EwsServiceXmlReader - * @throws Exception throws Exception - */ - @Override - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - super.readAttributesFromXml(reader); - this.getEmailAddress().setName( - reader.readAttributeValue(XmlAttributeNames.Name)); - this - .getEmailAddress() - .setRoutingType( - reader - .readAttributeValue(XmlAttributeNames. - RoutingType)); - String mailboxTypeString = reader - .readAttributeValue(XmlAttributeNames.MailboxType); - if ((mailboxTypeString != null) && (!mailboxTypeString.isEmpty())) { - this.getEmailAddress().setMailboxType( - EwsUtilities.parse(MailboxType.class, mailboxTypeString)); - } else { - this.getEmailAddress().setMailboxType(null); - } - } - - /** - * Reads the text value from XML. - * - * @param reader accepts EwsServiceXmlReader - * @throws Exception the exception - */ - @Override - public void readTextValueFromXml(EwsServiceXmlReader reader) - throws Exception { - this.getEmailAddress().setAddress(reader.readValue()); - } - - /** - * Writes the attribute to XML. - * - * @param writer accepts EwsServiceXmlWriter - * @throws ServiceXmlSerializationException throws ServiceXmlSerializationException - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - if (writer.getService().getRequestedServerVersion().ordinal() > - ExchangeVersion.Exchange2007_SP1 - .ordinal()) { - writer.writeAttributeValue(XmlAttributeNames.Name, this - .getEmailAddress().getName()); - writer.writeAttributeValue(XmlAttributeNames.RoutingType, this - .getEmailAddress().getRoutingType()); - if (this.getEmailAddress().getMailboxType() != MailboxType.Unknown) { - writer.writeAttributeValue(XmlAttributeNames.MailboxType, this - .getEmailAddress().getMailboxType()); - } - } - } - - /** - * Writes elements to XML. - * - * @param writer accepts EwsServiceXmlWriter - * @throws ServiceXmlSerializationException throws ServiceXmlSerializationException - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeValue(this.getEmailAddress().getAddress(), - XmlElementNames.EmailAddress); - } - - /** - * Gets the e-mail address of the entry. - * - * @return the email address - */ - public EmailAddress getEmailAddress() { - return this.emailAddress; - // set { this.SetFieldValue(ref this.emailAddress, value); - // } - } - - /** - * Sets the e-mail address of the entry. - * - * @param value the new email address - */ - public void setEmailAddress(Object value) { - //this.canSetFieldValue((EmailAddress) this.emailAddress, value); - if (this.canSetFieldValue(this.emailAddress, value)) { - this.emailAddress = (EmailAddress) value; - } - } - - /** - * E-mail address was changed. - * - * @param complexProperty the complex property - */ - private void emailAddressChanged(ComplexProperty complexProperty) { - this.changed(); - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.ComplexPropertyChangedDelegateInterface - * #complexPropertyChanged(microsoft.exchange.webservices.ComplexProperty) - */ - @Override - public void complexPropertyChanged(ComplexProperty complexProperty) { - this.emailAddressChanged(complexProperty); - - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ExtendedProperty.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ExtendedProperty.java deleted file mode 100644 index 14ec132a3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ExtendedProperty.java +++ /dev/null @@ -1,238 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.MapiTypeConverter; -import microsoft.exchange.webservices.data.property.definition.ExtendedPropertyDefinition; -import org.apache.commons.lang3.StringUtils; - -import javax.xml.stream.XMLStreamException; - -import java.util.ArrayList; - -/** - * Represents an extended property. - */ -public final class ExtendedProperty extends ComplexProperty { - - /** - * The property definition. - */ - private ExtendedPropertyDefinition propertyDefinition; - - /** - * The value. - */ - private Object value; - - /** - * Initializes a new instance. - */ - protected ExtendedProperty() { - } - - /** - * Initializes a new instance. - * - * @param propertyDefinition The definition of the extended property. - * @throws Exception the exception - */ - protected ExtendedProperty(ExtendedPropertyDefinition propertyDefinition) - throws Exception { - this(); - EwsUtilities.validateParam(propertyDefinition, "propertyDefinition"); - this.propertyDefinition = propertyDefinition; - } - - /** - * Tries to read element from XML. - * - * @param reader The reader. - * @return true, if successful - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - - if (reader.getLocalName().equals(XmlElementNames.ExtendedFieldURI)) { - this.propertyDefinition = new ExtendedPropertyDefinition(); - this.propertyDefinition.loadFromXml(reader); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Value)) { - EwsUtilities.ewsAssert(this.getPropertyDefinition() != null, "ExtendedProperty.TryReadElementFromXml", - "PropertyDefintion is missing"); - String stringValue = reader.readElementValue(); - this.value = MapiTypeConverter.convertToValue(this.getPropertyDefinition().getMapiType(), stringValue); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Values)) { - EwsUtilities.ewsAssert(this.getPropertyDefinition() != null, "ExtendedProperty.TryReadElementFromXml", - "PropertyDefintion is missing"); - - StringList stringList = new StringList(XmlElementNames.Value); - stringList.loadFromXml(reader, reader.getLocalName()); - this.value = MapiTypeConverter.convertToValue(this - .getPropertyDefinition().getMapiType(), stringList - .iterator()); - return true; - } else { - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws XMLStreamException the XML stream exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - this.getPropertyDefinition().writeToXml(writer); - - if (MapiTypeConverter.isArrayType(this.getPropertyDefinition() - .getMapiType())) { - ArrayList array = (ArrayList) this.getValue(); - writer - .writeStartElement(XmlNamespace.Types, - XmlElementNames.Values); - for (int index = 0; index < array.size(); index++) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.Value, MapiTypeConverter - .convertToString(this.getPropertyDefinition() - .getMapiType(), array.get(index))); - } - writer.writeEndElement(); - } else { - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Value, - MapiTypeConverter.convertToString(this - .getPropertyDefinition().getMapiType(), this - .getValue())); - } - } - - /** - * Gets the definition of the extended property. - * - * @return The definition of the extended property. - */ - public ExtendedPropertyDefinition getPropertyDefinition() { - return this.propertyDefinition; - } - - /** - * Gets the value of the extended property. - * - * @return the value - */ - public Object getValue() { - return this.value; - } - - /** - * Sets the value of the extended property. - * - * @param val value of the extended property - * @throws Exception the exception - */ - public void setValue(Object val) throws Exception { - EwsUtilities.validateParam(val, "value"); - if (this.canSetFieldValue(this.value, MapiTypeConverter.changeType(this - .getPropertyDefinition().getMapiType(), val))) { - this.value = MapiTypeConverter.changeType(this - .getPropertyDefinition().getMapiType(), val); - this.changed(); - } - } - - /** - * Gets the string value. - * - * @return String - */ - private String getStringValue() { - if (MapiTypeConverter.isArrayType(this.getPropertyDefinition() - .getMapiType())) { - ArrayList array = (ArrayList) this.getValue(); - if (array == null) { - return null; - } else { - StringBuilder sb = new StringBuilder(); - sb.append("["); - for (int index = 0; index < array.size(); index++) { - sb.append(MapiTypeConverter.convertToString(this - .getPropertyDefinition().getMapiType(), array - .get(index))); - sb.append(","); - } - sb.append("]"); - - return sb.toString(); - } - } else { - return MapiTypeConverter.convertToString(this - .getPropertyDefinition().getMapiType(), this.getValue()); - } - } - - /** - * Determines whether the specified is equal - * to the current true if the specified is equal to the current - * - * @param obj the obj - * @return boolean - */ - @Override - public boolean equals(final Object obj) { - if (obj instanceof ExtendedProperty) { - final ExtendedProperty other = (ExtendedProperty) obj; - return other.getPropertyDefinition().equals(this.getPropertyDefinition()) - && StringUtils.equals(this.getStringValue(), other.getStringValue()); - } - return false; - } - - /** - * Serves as a hash function for a particular type. - * - * @return int - */ - @Override - public int hashCode() { - String printableName = this.getPropertyDefinition() != null ? this - .getPropertyDefinition().getPrintableName() : ""; - String stringVal = this.getStringValue(); - return (printableName + stringVal).hashCode(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ExtendedPropertyCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ExtendedPropertyCollection.java deleted file mode 100644 index ab636d4f4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ExtendedPropertyCollection.java +++ /dev/null @@ -1,280 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ICustomXmlUpdateSerializer; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.definition.ExtendedPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import javax.xml.stream.XMLStreamException; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a collection of extended property. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class ExtendedPropertyCollection extends ComplexPropertyCollection implements - ICustomXmlUpdateSerializer { - - /** - * Creates the complex property. - * - * @param xmlElementName Name of the XML element. - * @return Complex property instance. - */ - @Override - protected ExtendedProperty createComplexProperty(String xmlElementName) { - // This method is unused in this class, so just return null. - return null; - } - - /** - * Gets the name of the collection item XML element. - * - * @param complexProperty The complex property. - * @return XML element name. - */ - @Override - protected String getCollectionItemXmlElementName( - ExtendedProperty complexProperty) { - // This method is unused in this class, so just return null. - return null; - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @param localElementName Name of the local element. - * @throws Exception the exception - */ - @Override public void loadFromXml(EwsServiceXmlReader reader, String localElementName) throws Exception { - ExtendedProperty extendedProperty = new ExtendedProperty(); - extendedProperty.loadFromXml(reader, reader.getLocalName()); - this.internalAdd(extendedProperty); - } - - /** - * Writes to XML. - * - * @param writer The writer. - * @param xmlElementName Name of the XML element. - * @throws Exception the exception - */ - @Override public void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) - throws Exception { - for (ExtendedProperty extendedProperty : this) { - extendedProperty.writeToXml(writer, - XmlElementNames.ExtendedProperty); - } - } - - /** - * Gets existing or adds new extended property. - * - * @param propertyDefinition The property definition. - * @return ExtendedProperty. - * @throws Exception the exception - */ - private ExtendedProperty getOrAddExtendedProperty( - ExtendedPropertyDefinition propertyDefinition) throws Exception { - ExtendedProperty extendedProperty = null; - OutParam extendedPropertyOut = - new OutParam(); - if (!this.tryGetProperty(propertyDefinition, extendedPropertyOut)) { - extendedProperty = new ExtendedProperty(propertyDefinition); - this.internalAdd(extendedProperty); - } else { - extendedProperty = extendedPropertyOut.getParam(); - } - return extendedProperty; - } - - /** - * Sets an extended property. - * - * @param propertyDefinition The property definition. - * @param value The value. - * @throws Exception the exception - */ - public void setExtendedProperty(ExtendedPropertyDefinition propertyDefinition, Object value) - throws Exception { - ExtendedProperty extendedProperty = this - .getOrAddExtendedProperty(propertyDefinition); - extendedProperty.setValue(value); - } - - /** - * Removes a specific extended property definition from the collection. - * - * @param propertyDefinition The definition of the extended property to remove. - * @return True if the property matching the extended property definition - * was successfully removed from the collection, false otherwise. - * @throws Exception the exception - */ - public boolean removeExtendedProperty(ExtendedPropertyDefinition propertyDefinition) throws Exception { - EwsUtilities.validateParam(propertyDefinition, "propertyDefinition"); - - ExtendedProperty extendedProperty = null; - OutParam extendedPropertyOut = - new OutParam(); - if (this.tryGetProperty(propertyDefinition, extendedPropertyOut)) { - extendedProperty = extendedPropertyOut.getParam(); - return this.internalRemove(extendedProperty); - } else { - return false; - } - } - - /** - * Tries to get property. - * - * @param propertyDefinition The property definition. - * @param extendedPropertyOut The extended property. - * @return True of property exists in collection. - */ - private boolean tryGetProperty( - ExtendedPropertyDefinition propertyDefinition, - OutParam extendedPropertyOut) { - boolean found = false; - extendedPropertyOut.setParam(null); - for (ExtendedProperty prop : this.getItems()) { - if (prop.getPropertyDefinition().equals(propertyDefinition)) { - found = true; - extendedPropertyOut.setParam(prop); - break; - } - } - return found; - } - - /** - * Tries to get property value. - * - * @param propertyDefinition The property definition. - * @param propertyValueOut The property value. - * @return True if property exists in collection. - * @throws ArgumentException - */ - public boolean tryGetValue(Class cls, ExtendedPropertyDefinition propertyDefinition, - OutParam propertyValueOut) throws ArgumentException { - ExtendedProperty extendedProperty = null; - OutParam extendedPropertyOut = - new OutParam(); - if (this.tryGetProperty(propertyDefinition, extendedPropertyOut)) { - extendedProperty = extendedPropertyOut.getParam(); - if (!cls.isAssignableFrom(propertyDefinition.getType())) { - String errorMessage = String.format( - "Property definition type '%s' and type parameter '%s' aren't compatible.", - propertyDefinition.getType().getSimpleName(), - cls.getSimpleName()); - throw new ArgumentException(errorMessage, "propertyDefinition"); - } - propertyValueOut.setParam((T) extendedProperty.getValue()); - return true; - } else { - propertyValueOut.setParam(null); - return false; - } - } - - - /** - * Writes the update to XML. - * - * @param writer The writer. - * @param ewsObject The ews object. - * @param propertyDefinition Property definition. - * @return True if property generated serialization. - * @throws Exception the exception - */ - @Override - public boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject, PropertyDefinition propertyDefinition) - throws Exception { - List propertiesToSet = - new ArrayList(); - - propertiesToSet.addAll(this.getAddedItems()); - propertiesToSet.addAll(this.getModifiedItems()); - - for (ExtendedProperty extendedProperty : propertiesToSet) { - writer.writeStartElement(XmlNamespace.Types, ewsObject - .getSetFieldXmlElementName()); - extendedProperty.getPropertyDefinition().writeToXml(writer); - - writer.writeStartElement(XmlNamespace.Types, ewsObject - .getXmlElementName()); - extendedProperty.writeToXml(writer, - XmlElementNames.ExtendedProperty); - writer.writeEndElement(); - - writer.writeEndElement(); - } - - for (ExtendedProperty extendedProperty : this.getRemovedItems()) { - writer.writeStartElement(XmlNamespace.Types, ewsObject - .getDeleteFieldXmlElementName()); - extendedProperty.getPropertyDefinition().writeToXml(writer); - writer.writeEndElement(); - } - - return true; - } - - /** - * Writes the deletion update to XML. - * - * @param writer the writer - * @param ewsObject the ews object - * @return true if property generated serialization - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject) throws XMLStreamException, ServiceXmlSerializationException { - for (ExtendedProperty extendedProperty : this.getItems()) { - writer.writeStartElement(XmlNamespace.Types, ewsObject - .getDeleteFieldXmlElementName()); - extendedProperty.getPropertyDefinition().writeToXml(writer); - writer.writeEndElement(); - } - - return true; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/FileAttachment.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/FileAttachment.java deleted file mode 100644 index de3567f36..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/FileAttachment.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; - -import org.apache.commons.io.IOUtils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * Represents a file attachment. - */ -public final class FileAttachment extends Attachment { - - /** - * The file name. - */ - private String fileName; - - /** - * The content stream. - */ - private InputStream contentStream; - - /** - * The content. - */ - private byte[] content; - - /** - * The load to stream. - */ - private OutputStream loadToStream; - - /** - * The is contact photo. - */ - private boolean isContactPhoto; - - /** - * Initializes a new instance. - * - * @param owner the owner - */ - protected FileAttachment(Item owner) { - super(owner); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - public String getXmlElementName() { - return XmlElementNames.FileAttachment; - } - - /** - * {@inheritDoc} - */ - @Override - protected void validate(int attachmentIndex) throws ServiceValidationException { - if ((this.fileName == null || this.fileName.isEmpty()) - && this.content == null && this.contentStream == null) { - throw new ServiceValidationException(String.format( - "The content of the file attachment at index %d must be set.", - attachmentIndex)); - } - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - boolean result = super.tryReadElementFromXml(reader); - - if (!result) { - if (reader.getLocalName().equals(XmlElementNames.IsContactPhoto)) { - this.isContactPhoto = reader.readElementValue(Boolean.class); - } else if (reader.getLocalName().equals(XmlElementNames.Content)) { - if (this.loadToStream != null) { - reader.readBase64ElementValue(this.loadToStream); - } else { - // If there's a file attachment content handler, use it. - // Otherwise - // load the content into a byte array. - // TODO: Should we mark the attachment to indicate that - // content is stored elsewhere? - if (reader.getService().getFileAttachmentContentHandler() != null) { - OutputStream outputStream = reader.getService() - .getFileAttachmentContentHandler() - .getOutputStream(getId()); - if (outputStream != null) { - reader.readBase64ElementValue(outputStream); - } else { - this.content = reader.readBase64ElementValue(); - } - } else { - this.content = reader.readBase64ElementValue(); - } - } - - result = true; - } - } - - return result; - } - - - /** - * For FileAttachment, the only thing need to patch is the AttachmentId. - * - * @param reader The reader. - * @return true if element was read - */ - @Override - public boolean tryReadElementFromXmlToPatch(EwsServiceXmlReader reader) throws Exception { - return super.tryReadElementFromXml(reader); - } - - - /** - * Writes elements and content to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - super.writeElementsToXml(writer); - // ExchangeVersion ev=writer.getService().getRequestedServerVersion(); - if (writer.getService().getRequestedServerVersion().ordinal() > - ExchangeVersion.Exchange2007_SP1 - .ordinal()) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.IsContactPhoto, this.isContactPhoto); - } - - writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Content); - - if (!(this.fileName == null || this.fileName.isEmpty())) { - File fileStream = new File(this.fileName); - FileInputStream fis = null; - try { - fis = new FileInputStream(fileStream); - writer.writeBase64ElementValue(fis); - } finally { - if (fis != null) { - fis.close(); - } - } - - } else if (this.contentStream != null) { - writer.writeBase64ElementValue(this.contentStream); - } else if (this.content != null) { - writer.writeBase64ElementValue(this.content); - } else { - EwsUtilities - .ewsAssert(false, "FileAttachment.WriteElementsToXml", "The attachment's content is not set."); - } - - writer.writeEndElement(); - } - - /** - * Loads the content of the file attachment into the specified stream. - * Calling this method results in a call to EWS. - * - * @param stream the stream - * @throws Exception the exception - */ - public void load(OutputStream stream) throws Exception { - this.loadToStream = stream; - - try { - this.load(); - } finally { - this.loadToStream = null; - } - } - - /** - * Loads the content of the file attachment into the specified file. - * Calling this method results in a call to EWS. - * - * @param fileName the file name - * @throws Exception the exception - */ - public void load(String fileName) throws Exception { - File fileStream = new File(fileName); - - try { - this.loadToStream = new FileOutputStream(fileStream); - this.load(); - this.loadToStream.flush(); - } finally { - IOUtils.closeQuietly(this.loadToStream); - this.loadToStream = null; - } - - this.fileName = fileName; - this.content = null; - this.contentStream = null; - } - - /** - * Gets the name of the file the attachment is linked to. - * - * @return the file name - */ - public String getFileName() { - return this.fileName; - } - - /** - * Sets the file name. - * - * @param fileName the new file name - */ - protected void setFileName(String fileName) { - this.throwIfThisIsNotNew(); - - this.fileName = fileName; - this.content = null; - this.contentStream = null; - } - - /** - * Gets the content stream.Gets the name of the file the attachment - * is linked to. - * - * @return The content stream - */ - protected InputStream getContentStream() { - return this.contentStream; - } - - /** - * Sets the content stream. - * - * @param contentStream the new content stream - */ - protected void setContentStream(InputStream contentStream) { - this.throwIfThisIsNotNew(); - - this.contentStream = contentStream; - this.content = null; - this.fileName = null; - } - - /** - * Gets the content of the attachment into memory. Content is set only - * when Load() is called. - * - * @return the content - */ - public byte[] getContent() { - return this.content; - } - - /** - * Sets the content. - * - * @param content the new content - */ - protected void setContent(byte[] content) { - this.throwIfThisIsNotNew(); - - this.content = content; - this.fileName = null; - this.contentStream = null; - } - - /** - * Gets a value indicating whether this attachment is a contact - * photo. - * - * @return true, if is contact photo - * @throws ServiceVersionException the service version exception - */ - public boolean isContactPhoto() throws ServiceVersionException { - EwsUtilities.validatePropertyVersion(this.getOwner().getService(), - ExchangeVersion.Exchange2010, "IsContactPhoto"); - return this.isContactPhoto; - } - - /** - * Sets the checks if is contact photo. - * - * @param isContactPhoto the new checks if is contact photo - * @throws ServiceVersionException the service version exception - */ - public void setIsContactPhoto(boolean isContactPhoto) - throws ServiceVersionException { - EwsUtilities.validatePropertyVersion(this.getOwner().getService(), - ExchangeVersion.Exchange2010, "IsContactPhoto"); - this.throwIfThisIsNotNew(); - this.isContactPhoto = isContactPhoto; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/FolderId.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/FolderId.java deleted file mode 100644 index cb4a6e0db..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/FolderId.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -/** - * Represents the Id of a folder. - */ -public final class FolderId extends ServiceId { - - /** - * The folder name. - */ - private WellKnownFolderName folderName; - - /** - * The mailbox. - */ - private Mailbox mailbox; - - /** - * Initializes a new instance. - */ - public FolderId() { - super(); - } - - /** - * Initializes a new instance.Use this constructor to link this FolderId to - * an existing folder that you have the unique Id of. - * - * @param uniqueId the unique id - * @throws Exception the exception - */ - public FolderId(String uniqueId) throws Exception { - super(uniqueId); - } - - /** - * Initializes a new instance.Use this constructor to link this FolderId to - * a well known folder (e.g. Inbox, Calendar or Contacts) - * - * @param folderName the folder name - */ - public FolderId(WellKnownFolderName folderName) { - super(); - this.folderName = folderName; - } - - /** - * Initializes a new instance.Use this constructor to link this FolderId to - * a well known folder (e.g. Inbox, Calendar or Contacts) in a specific - * mailbox. - * - * @param folderName the folder name - * @param mailbox the mailbox - */ - public FolderId(WellKnownFolderName folderName, Mailbox mailbox) { - this(folderName); - this.mailbox = mailbox; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - public String getXmlElementName() { - if (this.getFolderName() != null) { - return XmlElementNames.DistinguishedFolderId; - } else { - return XmlElementNames.FolderId; - } - } - - /** - * Writes attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - if (this.getFolderName() != null) { - writer.writeAttributeValue(XmlAttributeNames.Id, this - .getFolderName().toString().toLowerCase()); - - if (this.mailbox != null) { - try { - this.mailbox.writeToXml(writer, XmlElementNames.Mailbox); - } catch (Exception e) { - throw new ServiceXmlSerializationException(e.getMessage()); - } - } - } else { - super.writeAttributesToXml(writer); - } - } - - /** - * Validates FolderId against a specified request version. - * - * @param version the version - * @throws ServiceVersionException the service version exception - */ - public void validate(ExchangeVersion version) - throws ServiceVersionException { - // The FolderName property is a WellKnownFolderName, an enumeration - // type. If the property - // is set, make sure that the value is valid for the request version. - if (this.getFolderName() != null) { - EwsUtilities - .validateEnumVersionValue(this.getFolderName(), version); - } - } - - /** - * Gets the name of the folder associated with the folder Id. Name and Id - * are mutually exclusive; if one is set, the other is null. - * - * @return the folder name - */ - public WellKnownFolderName getFolderName() { - return this.folderName; - } - - /** - * Gets the mailbox of the folder. Mailbox is only set when FolderName is - * set. - * - * @return the mailbox - */ - public Mailbox getMailbox() { - return this.mailbox; - } - - /** - * Defines an implicit conversion between string and FolderId. - * - * @param uniqueId the unique id - * @return A FolderId initialized with the specified unique Id - * @throws Exception the exception - */ - public static FolderId getFolderIdFromString(String uniqueId) - throws Exception { - return new FolderId(uniqueId); - } - - /** - * Defines an implicit conversion between WellKnownFolderName and FolderId. - * - * @param folderName the folder name - * @return A FolderId initialized with the specified folder name - */ - public static FolderId getFolderIdFromWellKnownFolderName( - WellKnownFolderName folderName) { - return new FolderId(folderName); - } - - /** - * True if this instance is valid, false otherwise. - * - * @return the checks if is valid - */ - protected boolean getIsValid() { - if (this.folderName != null) { - return (this.mailbox == null) || this.mailbox.isValid(); - } else { - return super.isValid(); - } - } - - /** - * Determines whether the specified is equal to the current. - * - * @param obj the obj - * @return true if the specified is equal to the current - */ - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (obj instanceof FolderId) { - FolderId other = (FolderId) obj; - - if (this.folderName != null) { - if (other.folderName != null - && this.folderName.equals(other.folderName)) { - if (this.mailbox != null) { - return this.mailbox.equals(other.mailbox); - } else if (other.mailbox == null) { - return true; - } - } - } else if (super.equals(other)) { - return true; - } - - return false; - } else { - return false; - } - } - - /** - * Serves as a hash function for a particular type. - * - * @return A hash code for the current - */ - @Override - public int hashCode() { - int hashCode; - - if (this.folderName != null) { - hashCode = this.folderName.hashCode(); - - if ((this.mailbox != null) && this.mailbox.isValid()) { - hashCode = hashCode ^ this.mailbox.hashCode(); - } - } else { - hashCode = super.hashCode(); - } - - return hashCode; - } - - /** - * Returns a String that represents the current Object. - * - * @return the string - */ - public String toString() { - if (this.isValid()) { - if (this.folderName != null) { - if ((this.mailbox != null) && mailbox.isValid()) { - return String.format("%s,(%s)", this.folderName, - this.mailbox.toString()); - } else { - return this.folderName.toString(); - } - } else { - return super.toString(); - } - } else { - return ""; - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/FolderIdCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/FolderIdCollection.java deleted file mode 100644 index f9fc4c0e3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/FolderIdCollection.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.property.WellKnownFolderName; - -/** - * Represents a collection of folder Ids. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class FolderIdCollection extends ComplexPropertyCollection { - - /** - * Initializes a new instance of the class. - */ - protected FolderIdCollection() { - super(); - } - - /** - * Creates the complex property. - * - * @param xmlElementName Name of the XML element. - * @return Complex property instance. - */ - @Override - /** - * Creates the complex property. - * @param xmlElementName Name of the XML element. - * @return FolderId. - */ - protected FolderId createComplexProperty(String xmlElementName) { - return new FolderId(); - } - - /** - * Adds a folder Id to the collection. - * - * @param folderId The folder Id to add. - * @throws Exception the exception - */ - public void add(FolderId folderId) throws Exception { - EwsUtilities.validateParam(folderId, "folderId"); - if (this.contains(folderId)) { - throw new IllegalArgumentException("The ID is already in the list."); - } - this.internalAdd(folderId); - } - - /** - * Gets the name of the collection item XML element. - * - * @param complexProperty accepts FolderId - * @return XML element name. - */ - @Override - protected String getCollectionItemXmlElementName(FolderId complexProperty) { - return complexProperty.getXmlElementName(); - } - - /** - * Adds a well-known folder to the collection. - * - * @param folderName the folder name - * @return A FolderId encapsulating the specified Id. - */ - public FolderId add(WellKnownFolderName folderName) { - FolderId folderId = new FolderId(folderName); - if (this.contains(folderId)) { - throw new IllegalArgumentException("The ID is already in the list."); - } - this.internalAdd(folderId); - return folderId; - } - - /** - * Clears the collection. - */ - public void clear() { - this.internalClear(); - } - - /** - * Removes the folder Id at the specified index. - * - * @param index The zero-based index of the folder Id to remove. - */ - public void removeAt(int index) { - if (index < 0 || index >= this.getCount()) { - throw new IndexOutOfBoundsException("index is out of range."); - } - this.internalRemoveAt(index); - } - - /** - * Removes the specified folder Id from the collection. - * - * @param folderId The folder Id to remove from the collection. - * @return True if the folder id was successfully removed from the - * collection, false otherwise. - * @throws Exception the exception - */ - public boolean remove(FolderId folderId) throws Exception { - EwsUtilities.validateParam(folderId, "folderId"); - return this.internalRemove(folderId); - } - - /** - * Removes the specified well-known folder from the collection. - * - * @param folderName The well-knwon folder to remove from the collection. - * @return True if the well-known folder was successfully removed from the - * collection, false otherwise. - */ - public boolean remove(WellKnownFolderName folderName) { - FolderId folderId = FolderId - .getFolderIdFromWellKnownFolderName(folderName); - return this.internalRemove(folderId); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/FolderPermission.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/FolderPermission.java deleted file mode 100644 index a1ea10cb3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/FolderPermission.java +++ /dev/null @@ -1,886 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ILazyMember; -import microsoft.exchange.webservices.data.core.LazyMember; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.permission.folder.FolderPermissionLevel; -import microsoft.exchange.webservices.data.core.enumeration.permission.folder.FolderPermissionReadAccess; -import microsoft.exchange.webservices.data.core.enumeration.permission.PermissionScope; -import microsoft.exchange.webservices.data.core.enumeration.property.StandardUser; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * Represents a permission on a folder. - */ -public final class FolderPermission extends ComplexProperty implements IComplexPropertyChangedDelegate { - - private static final Log LOG = LogFactory.getLog(FolderPermission.class); - - private static LazyMember> - defaultPermissions = - new LazyMember>( - new ILazyMember>() { - @Override - public Map - createInstance() { - Map result = - new HashMap(); - - /** The default permissions. */ - FolderPermission permission = new FolderPermission(); - permission.canCreateItems = false; - permission.canCreateSubFolders = false; - permission.deleteItems = PermissionScope.None; - permission.editItems = PermissionScope.None; - permission.isFolderContact = false; - permission.isFolderOwner = false; - permission.isFolderVisible = false; - permission.readItems = FolderPermissionReadAccess.None; - - result.put(FolderPermissionLevel.None, permission); - - permission = new FolderPermission(); - permission.canCreateItems = true; - permission.canCreateSubFolders = false; - permission.deleteItems = PermissionScope.None; - permission.editItems = PermissionScope.None; - permission.isFolderContact = false; - permission.isFolderOwner = false; - permission.isFolderVisible = true; - permission.readItems = FolderPermissionReadAccess.None; - - result.put(FolderPermissionLevel.Contributor, permission); - - permission = new FolderPermission(); - permission.canCreateItems = false; - permission.canCreateSubFolders = false; - permission.deleteItems = PermissionScope.None; - permission.editItems = PermissionScope.None; - permission.isFolderContact = false; - permission.isFolderOwner = false; - permission.isFolderVisible = true; - permission.readItems = FolderPermissionReadAccess. - FullDetails; - - result.put(FolderPermissionLevel.Reviewer, permission); - - permission = new FolderPermission(); - permission.canCreateItems = true; - permission.canCreateSubFolders = false; - permission.deleteItems = PermissionScope.Owned; - permission.editItems = PermissionScope.None; - permission.isFolderContact = false; - permission.isFolderOwner = false; - permission.isFolderVisible = true; - permission.readItems = FolderPermissionReadAccess. - FullDetails; - - result.put(FolderPermissionLevel.NoneditingAuthor, - permission); - - permission = new FolderPermission(); - permission.canCreateItems = true; - permission.canCreateSubFolders = false; - permission.deleteItems = PermissionScope.Owned; - permission.editItems = PermissionScope.Owned; - permission.isFolderContact = false; - permission.isFolderOwner = false; - permission.isFolderVisible = true; - permission.readItems = FolderPermissionReadAccess. - FullDetails; - - result.put(FolderPermissionLevel.Author, permission); - - permission = new FolderPermission(); - permission.canCreateItems = true; - permission.canCreateSubFolders = true; - permission.deleteItems = PermissionScope.Owned; - permission.editItems = PermissionScope.Owned; - permission.isFolderContact = false; - permission.isFolderOwner = false; - permission.isFolderVisible = true; - permission.readItems = FolderPermissionReadAccess. - FullDetails; - - result.put(FolderPermissionLevel.PublishingAuthor, - permission); - - permission = new FolderPermission(); - permission.canCreateItems = true; - permission.canCreateSubFolders = false; - permission.deleteItems = PermissionScope.All; - permission.editItems = PermissionScope.All; - permission.isFolderContact = false; - permission.isFolderOwner = false; - permission.isFolderVisible = true; - permission.readItems = FolderPermissionReadAccess. - FullDetails; - - result.put(FolderPermissionLevel.Editor, permission); - - permission = new FolderPermission(); - permission.canCreateItems = true; - permission.canCreateSubFolders = true; - permission.deleteItems = PermissionScope.All; - permission.editItems = PermissionScope.All; - permission.isFolderContact = false; - permission.isFolderOwner = false; - permission.isFolderVisible = true; - permission.readItems = FolderPermissionReadAccess. - FullDetails; - - result.put(FolderPermissionLevel.PublishingEditor, - permission); - - permission = new FolderPermission(); - permission.canCreateItems = true; - permission.canCreateSubFolders = true; - permission.deleteItems = PermissionScope.All; - permission.editItems = PermissionScope.All; - permission.isFolderContact = true; - permission.isFolderOwner = true; - permission.isFolderVisible = true; - permission.readItems = FolderPermissionReadAccess. - FullDetails; - - result.put(FolderPermissionLevel.Owner, permission); - - permission = new FolderPermission(); - permission.canCreateItems = false; - permission.canCreateSubFolders = false; - permission.deleteItems = PermissionScope.None; - permission.editItems = PermissionScope.None; - permission.isFolderContact = false; - permission.isFolderOwner = false; - permission.isFolderVisible = false; - permission.readItems = FolderPermissionReadAccess.TimeOnly; - - result.put(FolderPermissionLevel.FreeBusyTimeOnly, - permission); - - permission = new FolderPermission(); - permission.canCreateItems = false; - permission.canCreateSubFolders = false; - permission.deleteItems = PermissionScope.None; - permission.editItems = PermissionScope.None; - permission.isFolderContact = false; - permission.isFolderOwner = false; - permission.isFolderVisible = false; - permission.readItems = FolderPermissionReadAccess. - TimeAndSubjectAndLocation; - - result - .put(FolderPermissionLevel. - FreeBusyTimeAndSubjectAndLocation, - permission); - return result; - } - }); - //End Region - - /** - * Variants of pre-defined permission levels that Outlook also displays with - * the same levels. - */ - private static LazyMember> levelVariants = - new LazyMember>( - new ILazyMember>() { - @Override - public List createInstance() { - List results = - new ArrayList(); - - FolderPermission permissionNone = FolderPermission. - defaultPermissions - .getMember().get(FolderPermissionLevel.None); - FolderPermission permissionOwner = FolderPermission. - defaultPermissions - .getMember().get(FolderPermissionLevel.Owner); - - // PermissionLevelNoneOption1 - FolderPermission permission; - try { - permission = (FolderPermission) permissionNone.clone(); - permission.isFolderVisible = true; - results.add(permission); - - // PermissionLevelNoneOption2 - permission = (FolderPermission) permissionNone.clone(); - permission.isFolderContact = true; - results.add(permission); - - // PermissionLevelNoneOption3 - permission = (FolderPermission) permissionNone.clone(); - permission.isFolderContact = true; - permission.isFolderVisible = true; - results.add(permission); - - // PermissionLevelOwnerOption1 - permission = (FolderPermission) permissionOwner.clone(); - permission.isFolderContact = false; - results.add(permission); - - } catch (CloneNotSupportedException e) { - LOG.error(e); - } - return results; - } - }); - - /** - * The user id. - */ - private UserId userId; - - /** - * The can create item. - */ - private boolean canCreateItems; - - /** - * The can create sub folder. - */ - private boolean canCreateSubFolders; - - /** - * The is folder owner. - */ - private boolean isFolderOwner; - - /** - * The is folder visible. - */ - private boolean isFolderVisible; - - /** - * The is folder contact. - */ - private boolean isFolderContact; - - /** - * The edit item. - */ - private PermissionScope editItems = PermissionScope.None; - - /** - * The delete item. - */ - private PermissionScope deleteItems = PermissionScope.None; - - /** - * The read item. - */ - private FolderPermissionReadAccess readItems = FolderPermissionReadAccess.None; - - /** - * The permission level. - */ - private FolderPermissionLevel permissionLevel = FolderPermissionLevel.None; - - /** - * Determines whether the specified folder permission is the same as this - * one. The comparison does not take UserId and PermissionLevel into - * consideration. - * - * @param permission the permission - * @return True is the specified folder permission is equal to this one, - * false otherwise. - */ - private boolean isEqualTo(FolderPermission permission) { - - return this.canCreateItems == permission.canCreateItems && - this.canCreateSubFolders == permission.canCreateSubFolders && - this.isFolderContact == permission.isFolderContact && - this.isFolderVisible == permission.isFolderVisible && - this.isFolderOwner == permission.isFolderOwner && - this.editItems == permission.editItems && - this.deleteItems == permission.deleteItems && - this.readItems == permission.readItems; - } - - /** - * Create a copy of this FolderPermission instance. - * - * @return Clone of this instance. - */ - /* - * private FolderPermission Clone() throws CloneNotSupportedException { - * return (FolderPermission)this.clone(); } - */ - - /** - * Determines the permission level of this folder permission based on its - * individual settings, and sets the PermissionLevel property accordingly. - */ - private void AdjustPermissionLevel() { - for (Entry keyValuePair : defaultPermissions - .getMember().entrySet()) { - if (this.isEqualTo(keyValuePair.getValue())) { - this.permissionLevel = keyValuePair.getKey(); - return; - } - } - this.permissionLevel = FolderPermissionLevel.Custom; - } - - /** - * Copies the values of the individual permissions of the specified folder - * permission to this folder permissions. - * - * @param permission the permission - */ - private void AssignIndividualPermissions(FolderPermission permission) { - this.canCreateItems = permission.canCreateItems; - this.canCreateSubFolders = permission.canCreateSubFolders; - this.isFolderContact = permission.isFolderContact; - this.isFolderOwner = permission.isFolderOwner; - this.isFolderVisible = permission.isFolderVisible; - this.editItems = permission.editItems; - this.deleteItems = permission.deleteItems; - this.readItems = permission.readItems; - } - - /** - * Initializes a new instance of the FolderPermission class. - */ - public FolderPermission() { - super(); - this.userId = new UserId(); - } - - /** - * Initializes a new instance of the FolderPermission class. - * - * @param userId the user id - * @param permissionLevel the permission level - * @throws Exception the exception - */ - public FolderPermission(UserId userId, - FolderPermissionLevel permissionLevel) - throws Exception { - EwsUtilities.validateParam(userId, "userId"); - - this.userId = userId; - this.permissionLevel = permissionLevel; - } - - /** - * Initializes a new instance of the FolderPermission class. - * - * @param primarySmtpAddress the primary smtp address - * @param permissionLevel the permission level - */ - public FolderPermission(String primarySmtpAddress, - FolderPermissionLevel permissionLevel) { - this.userId = new UserId(primarySmtpAddress); - this.permissionLevel = permissionLevel; - } - - /** - * Initializes a new instance of the FolderPermission class. - * - * @param standardUser the standard user - * @param permissionLevel the permission level - */ - public FolderPermission(StandardUser standardUser, - FolderPermissionLevel permissionLevel) { - this.userId = new UserId(standardUser); - this.permissionLevel = permissionLevel; - } - - /** - * Validates this instance. - * - * @param isCalendarFolder the is calendar folder - * @param permissionIndex the permission index - * @throws ServiceValidationException the service validation exception - * @throws ServiceLocalException the service local exception - */ - void validate(boolean isCalendarFolder, int permissionIndex) - throws ServiceValidationException, ServiceLocalException { - // Check UserId - if (!this.userId.isValid()) { - throw new ServiceValidationException(String.format( - "The UserId in the folder permission at index %d is invalid. " - + "The StandardUser, PrimarySmtpAddress, or SID property must be set.", permissionIndex)); - } - - // If this permission is to be used for a non-calendar folder make sure - // that read access and permission level aren't set to Calendar-only - // values - if (!isCalendarFolder) { - if ((this.readItems == FolderPermissionReadAccess.TimeAndSubjectAndLocation) - || (this.readItems == FolderPermissionReadAccess. - TimeOnly)) { - throw new ServiceLocalException(String.format( - "Permission read access value %s cannot be used with non-calendar folder.", - this.readItems)); - } - - if ((this.permissionLevel == FolderPermissionLevel.FreeBusyTimeAndSubjectAndLocation) - || (this.permissionLevel == FolderPermissionLevel. - FreeBusyTimeOnly)) { - throw new ServiceLocalException(String.format( - "Permission level value %s cannot be used with non-calendar folder.", - this.permissionLevel)); - } - } - } - - /** - * Gets the Id of the user the permission applies to. - * - * @return the user id - */ - - public UserId getUserId() { - return this.userId; - } - - /** - * Sets the user id. - * - * @param value the new user id - */ - public void setUserId(UserId value) { - if (this.userId != null) { - this.userId.removeChangeEvent(this); - } - - if (this.canSetFieldValue(this.userId, value)) { - userId = value; - this.changed(); - } - if (this.userId != null) { - this.userId.addOnChangeEvent(this); - } - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.ComplexPropertyChangedDelegateInterface - * #complexPropertyChanged(microsoft.exchange.webservices.ComplexProperty) - */ - @Override - public void complexPropertyChanged(ComplexProperty complexProperty) { - this.propertyChanged(complexProperty); - } - - /** - * Property was changed. - * - * @param complexProperty the complex property - */ - private void propertyChanged(ComplexProperty complexProperty) { - this.changed(); - } - - /** - * Gets a value indicating whether the user can create new item. - * - * @return the can create item - */ - public boolean getCanCreateItems() { - return this.canCreateItems; - } - - /** - * Sets the can create item. - * - * @param value the new can create item - */ - public void setCanCreateItems(boolean value) { - if (this.canSetFieldValue(this.canCreateItems, value)) { - this.canCreateItems = value; - this.changed(); - } - this.AdjustPermissionLevel(); - } - - /** - * Gets a value indicating whether the user can create - * sub-folder. - * - * @return the can create sub folder - */ - public boolean getCanCreateSubFolders() { - return this.canCreateSubFolders; - } - - /** - * Sets the can create sub folder. - * - * @param value the new can create sub folder - */ - public void setCanCreateSubFolders(boolean value) { - if (this.canSetFieldValue(this.canCreateSubFolders, value)) { - this.canCreateSubFolders = value; - this.changed(); - } - this.AdjustPermissionLevel(); - } - - /** - * Gets a value indicating whether the user owns the folder. - * - * @return the checks if is folder owner - */ - public boolean getIsFolderOwner() { - return this.isFolderOwner; - } - - /** - * Sets the checks if is folder owner. - * - * @param value the new checks if is folder owner - */ - public void setIsFolderOwner(boolean value) { - if (this.canSetFieldValue(this.isFolderOwner, value)) { - this.isFolderOwner = value; - this.changed(); - } - this.AdjustPermissionLevel(); - } - - /** - * Gets a value indicating whether the folder is visible to the - * user. - * - * @return the checks if is folder visible - */ - public boolean getIsFolderVisible() { - return this.isFolderVisible; - } - - /** - * Sets the checks if is folder visible. - * - * @param value the new checks if is folder visible - */ - public void setIsFolderVisible(boolean value) { - if (this.canSetFieldValue(this.isFolderVisible, value)) { - this.isFolderVisible = value; - this.changed(); - } - this.AdjustPermissionLevel(); - } - - /** - * Gets a value indicating whether the user is a contact for the - * folder. - * - * @return the checks if is folder contact - */ - public boolean getIsFolderContact() { - return this.isFolderContact; - } - - /** - * Sets the checks if is folder contact. - * - * @param value the new checks if is folder contact - */ - public void setIsFolderContact(boolean value) { - if (this.canSetFieldValue(this.isFolderContact, value)) { - this.isFolderContact = value; - this.changed(); - } - this.AdjustPermissionLevel(); - } - - /** - * Gets a value indicating if/how the user can edit existing - * item. - * - * @return the edits the item - */ - public PermissionScope getEditItems() { - return this.editItems; - } - - /** - * Sets the edits the item. - * - * @param value the new edits the item - */ - public void setEditItems(PermissionScope value) { - if (this.canSetFieldValue(this.editItems, value)) { - this.editItems = value; - this.changed(); - } - this.AdjustPermissionLevel(); - } - - /** - * Gets a value indicating if/how the user can delete existing - * item. - * - * @return the delete item - */ - public PermissionScope getDeleteItems() { - return this.deleteItems; - } - - /** - * Sets the delete item. - * - * @param value the new delete item - */ - public void setDeleteItems(PermissionScope value) { - if (this.canSetFieldValue(this.deleteItems, value)) { - this.deleteItems = value; - this.changed(); - } - this.AdjustPermissionLevel(); - } - - /** - * Gets the read item access permission. - * - * @return the read item - */ - public FolderPermissionReadAccess getReadItems() { - return this.readItems; - } - - /** - * Sets the read item. - * - * @param value the new read item - */ - public void setReadItems(FolderPermissionReadAccess value) { - if (this.canSetFieldValue(this.readItems, value)) { - this.readItems = value; - this.changed(); - } - this.AdjustPermissionLevel(); - } - - /** - * Gets the permission level. - * - * @return the permission level - */ - public FolderPermissionLevel getPermissionLevel() { - return this.permissionLevel; - } - - /** - * Sets the permission level. - * - * @param value the new permission level - * @throws ServiceLocalException the service local exception - */ - public void setPermissionLevel(FolderPermissionLevel value) - throws ServiceLocalException { - if (this.permissionLevel != value) { - if (value == FolderPermissionLevel.Custom) { - throw new ServiceLocalException( - "The PermissionLevel property can't be set to FolderPermissionLevel.Custom. " - + "To define a custom permission, set its individual property to the values you want."); - } - - this.AssignIndividualPermissions(defaultPermissions.getMember() - .get(value)); - if (this.canSetFieldValue(this.permissionLevel, value)) { - this.permissionLevel = value; - this.changed(); - } - } - } - - /** - * Gets the permission level that Outlook would display for this folder - * permission. - * - * @return the display permission level - */ - public FolderPermissionLevel getDisplayPermissionLevel() { - // If permission level is set to Custom, see if there's a variant - // that Outlook would map to the same permission level. - if (this.permissionLevel == FolderPermissionLevel.Custom) { - for (FolderPermission variant : FolderPermission.levelVariants - .getMember()) { - if (this.isEqualTo(variant)) { - return variant.getPermissionLevel(); - } - } - } - - return this.permissionLevel; - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.UserId)) { - this.userId = new UserId(); - this.userId.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.CanCreateItems)) { - this.canCreateItems = reader.readValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.CanCreateSubFolders)) { - this.canCreateSubFolders = reader.readValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.IsFolderOwner)) { - this.isFolderOwner = reader.readValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.IsFolderVisible)) { - this.isFolderVisible = reader.readValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.IsFolderContact)) { - this.isFolderContact = reader.readValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.EditItems)) { - this.editItems = reader.readValue(PermissionScope.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.DeleteItems)) { - this.deleteItems = reader.readValue(PermissionScope.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.ReadItems)) { - this.readItems = reader.readValue(FolderPermissionReadAccess.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.PermissionLevel) - || reader.getLocalName().equalsIgnoreCase( - XmlElementNames.CalendarPermissionLevel)) { - this.permissionLevel = reader - .readValue(FolderPermissionLevel.class); - return true; - } else { - return false; - } - } - - /** - * Loads from XML. - * - * @param reader the reader - * @param xmlNamespace the xml namespace - * @param xmlElementName the xml element name - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName) throws Exception { - super.loadFromXml(reader, xmlNamespace, xmlElementName); - - this.AdjustPermissionLevel(); - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @param isCalendarFolder the is calendar folder - * @throws Exception the exception - */ - protected void writeElementsToXml(EwsServiceXmlWriter writer, - boolean isCalendarFolder) throws Exception { - if (this.userId != null) { - this.userId.writeToXml(writer, XmlElementNames.UserId); - } - - if (this.permissionLevel == FolderPermissionLevel.Custom) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.CanCreateItems, this.canCreateItems); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.CanCreateSubFolders, - this.canCreateSubFolders); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.IsFolderOwner, this.isFolderOwner); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.IsFolderVisible, this.isFolderVisible); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.IsFolderContact, this.isFolderContact); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.EditItems, this.editItems); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.DeleteItems, this.deleteItems); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.ReadItems, this.readItems); - } - - writer - .writeElementValue( - XmlNamespace.Types, - isCalendarFolder ? XmlElementNames. - CalendarPermissionLevel - : XmlElementNames.PermissionLevel, - this.permissionLevel); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param xmlElementName the xml element name - * @param isCalendarFolder the is calendar folder - * @throws Exception the exception - */ - protected void writeToXml(EwsServiceXmlWriter writer, - String xmlElementName, boolean isCalendarFolder) throws Exception { - writer.writeStartElement(this.getNamespace(), xmlElementName); - this.writeAttributesToXml(writer); - this.writeElementsToXml(writer, isCalendarFolder); - writer.writeEndElement(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/FolderPermissionCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/FolderPermissionCollection.java deleted file mode 100644 index ed3be4875..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/FolderPermissionCollection.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.folder.CalendarFolder; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; - -/** - * Represents a collection of folder permissions. - */ -public final class FolderPermissionCollection extends ComplexPropertyCollection { - - private static final Log LOG = LogFactory.getLog(FolderPermissionCollection.class); - - /** - * The is calendar folder. - */ - private boolean isCalendarFolder; - - /** - * The unknown entries. - */ - private Collection unknownEntries = new ArrayList(); - - /** - * Initializes a new instance of the FolderPermissionCollection class. - * - * @param owner the owner - */ - public FolderPermissionCollection(Folder owner) { - super(); - this.isCalendarFolder = owner instanceof CalendarFolder; - } - - /** - * Gets the name of the inner collection XML element. - * - * @return the inner collection xml element name - */ - private String getInnerCollectionXmlElementName() { - return this.isCalendarFolder ? XmlElementNames.CalendarPermissions : - XmlElementNames.Permissions; - } - - /** - * Gets the name of the collection item XML element. - * - * @return the collection item xml element name - */ - private String getCollectionItemXmlElementName() { - return this.isCalendarFolder ? XmlElementNames.CalendarPermission : - XmlElementNames.Permission; - } - - /** - * Gets the name of the collection item XML element. - * - * @param complexProperty the complex property - * @return the collection item xml element name - */ - @Override - protected String getCollectionItemXmlElementName( - FolderPermission complexProperty) { - return this.getCollectionItemXmlElementName(); - } - - /** - * Loads from XML. - * - * @param reader the reader - * @param localElementName the local element name - * @throws Exception the exception - */ - @Override public void loadFromXml(EwsServiceXmlReader reader, String localElementName) throws Exception { - reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, - localElementName); - - reader.readStartElement(XmlNamespace.Types, this - .getInnerCollectionXmlElementName()); - super.loadFromXml(reader, this.getInnerCollectionXmlElementName()); - reader.readEndElementIfNecessary(XmlNamespace.Types, this - .getInnerCollectionXmlElementName()); - - reader.read(); - - if (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.UnknownEntries)) { - do { - reader.read(); - - if (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.UnknownEntry)) { - this.unknownEntries.add(reader.readElementValue()); - } - } while (!reader.isEndElement(XmlNamespace.Types, - XmlElementNames.UnknownEntries)); - } - } - - /** - * Validates this instance. - */ - public void validate() { - for (int permissionIndex = 0; permissionIndex < this.getItems().size(); permissionIndex++) { - FolderPermission permission = this.getItems().get(permissionIndex); - try { - permission.validate(this.isCalendarFolder, permissionIndex); - } catch (ServiceValidationException e) { - LOG.error(e); - } catch (ServiceLocalException e) { - LOG.error(e); - } - } - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeStartElement(XmlNamespace.Types, this - .getInnerCollectionXmlElementName()); - for (FolderPermission folderPermission : this) { - folderPermission.writeToXml(writer, this - .getCollectionItemXmlElementName(folderPermission), - this.isCalendarFolder); - } - writer.writeEndElement(); // this.InnerCollectionXmlElementName - } - - /** - * Creates the complex property. - * - * @param xmlElementName the xml element name - * @return FolderPermission instance. - */ - @Override - protected FolderPermission createComplexProperty(String xmlElementName) { - return new FolderPermission(); - } - - /** - * Adds a permission to the collection. - * - * @param permission the permission - */ - public void add(FolderPermission permission) { - this.internalAdd(permission); - } - - /** - * Adds the specified permissions to the collection. - * - * @param permissions the permissions - * @throws Exception the exception - */ - public void addFolderRange(Iterator permissions) - throws Exception { - EwsUtilities.validateParam(permissions, "permissions"); - - if (null != permissions) { - while (permissions.hasNext()) { - this.add(permissions.next()); - } - } - } - - /** - * Clears this collection. - */ - public void clear() { - this.internalClear(); - } - - /** - * Removes a permission from the collection. - * - * @param permission the permission - * @return True if the folder permission was successfully removed from the - * collection, false otherwise. - */ - public boolean remove(FolderPermission permission) { - return this.internalRemove(permission); - } - - /** - * Removes a permission from the collection. - * - * @param index the index - */ - public void removeAt(int index) { - this.internalRemoveAt(index); - } - - /** - * Gets a list of unknown user Ids in the collection. - * - * @return the unknown entries - */ - public Collection getUnknownEntries() { - return this.unknownEntries; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/GenericItemAttachment.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/GenericItemAttachment.java deleted file mode 100644 index 04f491e3a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/GenericItemAttachment.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.service.item.Item; - -/** - * Represents a strongly typed item attachment. - * - * @param Item type. - */ -public final class GenericItemAttachment extends ItemAttachment { - - /** - * Initializes a new instance of the GenericItemAttachment class. - * - * @param owner the owner - */ - protected GenericItemAttachment(Item owner) { - super(owner); - } - - /** - * Gets the item associated with the attachment. - * - * @return the t item - */ - public TItem getTItem() { - return (TItem) super.getItem(); - } - - /** - * Sets the t item. - * - * @param value the new t item - */ - protected void setTItem(TItem value) { - super.setItem(value); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/GroupMember.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/GroupMember.java deleted file mode 100644 index 901bc64d0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/GroupMember.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.RequiredServerVersion; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.item.Contact; -import microsoft.exchange.webservices.data.core.enumeration.property.EmailAddressKey; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.MailboxType; -import microsoft.exchange.webservices.data.core.enumeration.property.MemberStatus; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -/** - * Represents a group member. - */ -@RequiredServerVersion(version = ExchangeVersion.Exchange2010) -public class GroupMember extends ComplexProperty implements IComplexPropertyChangedDelegate { - - // AddressInformation field. - /** - * The address information. - */ - private EmailAddress addressInformation; - - // Status field. - - /** - * The status. - */ - private MemberStatus status; - - // / Member key field. - - /** - * The key. - */ - private String key; - - /** - * Initializes a new instance of the GroupMember class. - */ - - public GroupMember() { - super(); - - // Key is assigned by server - this.key = null; - - // Member status is calculated by server - this.status = MemberStatus.Unrecognized; - } - - /** - * Initializes a new instance of the GroupMember class. - * - * @param smtpAddress The SMTP address of the member - */ - public GroupMember(String smtpAddress) { - this(); - this.setAddressInformation(new EmailAddress(smtpAddress)); - } - - /** - * Initializes a new instance of the GroupMember class. - * - * @param address the address - * @param routingType The routing type of the address. - * @param mailboxType The mailbox type of the member. - * @throws ServiceLocalException the service local exception - */ - public GroupMember(String address, String routingType, - MailboxType mailboxType) throws ServiceLocalException { - this(); - - switch (mailboxType) { - case PublicGroup: - case PublicFolder: - case Mailbox: - case Contact: - case OneOff: - this.setAddressInformation(new EmailAddress(null, address, - routingType, mailboxType)); - break; - - default: - throw new ServiceLocalException("The mailbox type isn't valid."); - } - } - - /** - * Initializes a new instance of the GroupMember class. - * - * @param smtpAddress The SMTP address of the member - * @param mailboxType The mailbox type of the member. - * @throws ServiceLocalException the service local exception - */ - public GroupMember(String smtpAddress, MailboxType mailboxType) - throws ServiceLocalException { - - this(smtpAddress, EmailAddress.SmtpRoutingType, mailboxType); - - } - - /** - * Initializes a new instance of the GroupMember class. - * - * @param name The name of the one-off member. - * @param address the address - * @param routingType The routing type of the address. - */ - public GroupMember(String name, String address, String routingType) { - this(); - - this.setAddressInformation(new EmailAddress(name, address, routingType, - MailboxType.OneOff)); - } - - /** - * Initializes a new instance of the GroupMember class. - * - * @param name The name of the one-off member. - * @param smtpAddress The SMTP address of the member - */ - public GroupMember(String name, String smtpAddress) { - this(name, smtpAddress, EmailAddress.SmtpRoutingType); - - } - - /** - * Initializes a new instance of the GroupMember class. - * - * @param contactGroupId The Id of the contact group to link the member to. - */ - public GroupMember(ItemId contactGroupId) { - this(); - - this.setAddressInformation(new EmailAddress(null, null, null, - MailboxType.ContactGroup, contactGroupId)); - } - - /** - * Initializes a new instance of the GroupMember class. - * - * @param contactId The Id of the contact member - * @param addressToLink The Id of the contact to link the member to. - */ - public GroupMember(ItemId contactId, String addressToLink) { - this(); - - this.setAddressInformation(new EmailAddress(null, addressToLink, null, - MailboxType.Contact, contactId)); - } - - /** - * Initializes a new instance of the GroupMember class. - * - * @param addressInformation The e-mail address of the member. - * @throws Exception the exception - */ - public GroupMember(EmailAddress addressInformation) throws Exception { - this(); - - this.setAddressInformation(new EmailAddress(addressInformation)); - } - - /** - * Initializes a new instance of the GroupMember class. - * - * @param member GroupMember class instance to copy. - * @throws Exception the exception - */ - protected GroupMember(GroupMember member) throws Exception { - this(); - - EwsUtilities.validateParam(member, "member"); - this.setAddressInformation(new EmailAddress(member - .getAddressInformation())); - } - - /** - * Initializes a new instance of the GroupMember class. - * - * @param contact The contact to link to. - * @param emailAddressKey The contact's e-mail address to link to. - * @throws Exception the exception - */ - public GroupMember(Contact contact, EmailAddressKey emailAddressKey) - throws Exception { - this(); - - EwsUtilities.validateParam(contact, "contact"); - EmailAddress emailAddress = contact.getEmailAddresses() - .getEmailAddress(emailAddressKey); - this.setAddressInformation(new EmailAddress(emailAddress)); - this.getAddressInformation().setId(contact.getId()); - } - - /** - * Gets the key of the member. - * - * @return the key - */ - public String getKey() { - - return this.key; - - } - - /** - * Gets the address information of the member. - * - * @return the address information - */ - public EmailAddress getAddressInformation() { - - return this.addressInformation; - } - - /** - * Sets the address information. - * - * @param value the new address information - */ - protected void setAddressInformation(EmailAddress value) { - - if (this.addressInformation != null) { - - this.addressInformation.removeChangeEvent(this); - } - - this.addressInformation = value; - - if (this.addressInformation != null) { - - this.addressInformation.addOnChangeEvent(this); - } - } - - /** - * Gets the status of the member. - * - * @return the status - */ - - public MemberStatus getStatus() { - - return this.status; - - } - - /** - * Reads the member Key attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.key = reader.readAttributeValue(String.class, - XmlAttributeNames.Key); - } - - /** - * Tries to read Status or Mailbox elements from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.Status)) { - - this.status = EwsUtilities.parse(MemberStatus.class, reader - .readElementValue()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Mailbox)) { - - this.setAddressInformation(new EmailAddress()); - this.getAddressInformation().loadFromXml(reader, - reader.getLocalName()); - return true; - } else { - - return false; - } - } - - /** - * Writes the member key attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - // if this.key is null or empty, writer skips the attribute - writer.writeAttributeValue(XmlAttributeNames.Key, this.key); - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - // No need to write member Status back to server - // Write only AddressInformation container element - this.getAddressInformation().writeToXml(writer, XmlNamespace.Types, - XmlElementNames.Mailbox); - } - - /** - * AddressInformation instance is changed. - * - * @param complexProperty Changed property. - */ - private void addressInformationChanged(ComplexProperty complexProperty) { - this.changed(); - } - - /** - * Complex property changed. - * - * @param complexProperty accepts ComplexProperty - */ - @Override - public void complexPropertyChanged(ComplexProperty complexProperty) { - - this.addressInformationChanged(complexProperty); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/GroupMemberCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/GroupMemberCollection.java deleted file mode 100644 index 5dc5a1c68..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/GroupMemberCollection.java +++ /dev/null @@ -1,475 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ICustomXmlUpdateSerializer; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Contact; -import microsoft.exchange.webservices.data.core.service.schema.ContactGroupSchema; -import microsoft.exchange.webservices.data.core.enumeration.property.EmailAddressKey; -import microsoft.exchange.webservices.data.core.enumeration.property.MailboxType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.definition.GroupMemberPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinition; - -import javax.xml.stream.XMLStreamException; - -import java.util.Iterator; -import java.util.List; - -/** - * Represents a collection of members of GroupMember type. - */ -public final class GroupMemberCollection extends ComplexPropertyCollection implements - ICustomXmlUpdateSerializer { - /** - * If the collection is cleared, then store PDL members collection is - * updated with "SetItemField". If the collection is not cleared, then store - * PDL members collection is updated with "AppendToItemField". - */ - private boolean collectionIsCleared = false; - - /** - * Initializes a new instance. - */ - public GroupMemberCollection() { - super(); - } - - /** - * Retrieves the XML element name corresponding to the provided - * GroupMember object. - * - * @param member the member - * @return The XML element name corresponding to the provided GroupMember - * object - */ - @Override - protected String getCollectionItemXmlElementName(GroupMember member) { - return XmlElementNames.Member; - } - - /** - * * Finds the member with the specified key in the collection.Members that - * have not yet been saved do not have a key. - * - * @param key the key - * @return The member with the specified key - * @throws Exception the exception - */ - public GroupMember find(String key) throws Exception { - EwsUtilities.validateParam(key, "key"); - - for (GroupMember item : this.getItems()) { - if (item.getKey().equals(key)) { - return item; - } - } - - return null; - } - - /** - * Clears the collection. - */ - public void clear() { - // mark the whole collection for deletion - this.internalClear(); - this.collectionIsCleared = true; - } - - /** - * Adds a member to the collection. - * - * @param member the member - * @throws Exception the exception - */ - public void add(GroupMember member) throws Exception { - EwsUtilities.validateParam(member, "member"); - EwsUtilities.ewsAssert(member.getKey() == null, "GroupMemberCollection.Add", "member.Key is not null."); - EwsUtilities.ewsAssert(!this.contains(member), "GroupMemberCollection.Add", - "The member is already in the collection"); - - this.internalAdd(member); - } - - /** - * Adds multiple members to the collection. - * - * @param members the members - * @throws Exception the exception - */ - public void addRange(Iterator members) throws Exception { - EwsUtilities.validateParam(members, "members"); - while (members.hasNext()) { - this.add(members.next()); - - } - } - - /** - * Adds a member linked to a Contact Group. - * - * @param contactGroupId the contact group id - * @throws Exception the exception - */ - public void addContactGroup(ItemId contactGroupId) throws Exception { - this.add(new GroupMember(contactGroupId)); - } - - /** - * Adds a member linked to a specific contact?s e-mail address. - * - * @param contactId the contact id - * @param addressToLink the address to link - * @throws Exception the exception - */ - public void addPersonalContact(ItemId contactId, String addressToLink) - throws Exception { - this.add(new GroupMember(contactId, addressToLink)); - } - - /** - * Adds a member linked to a contact?s first available e-mail address. - * - * @param contactId the contact id - * @throws Exception the exception - */ - public void addPersonalContact(ItemId contactId) throws Exception { - this.addPersonalContact(contactId, null); - } - - /** - * Adds a member linked to an Active Directory user. - * - * @param smtpAddress the smtp address - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - public void addDirectoryUser(String smtpAddress) - throws ServiceLocalException, Exception { - this.addDirectoryUser(smtpAddress, new EmailAddress() - .getSmtpRoutingType()); - } - - /** - * Adds a member linked to an Active Directory user. - * - * @param address the address - * @param routingType the routing type - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - public void addDirectoryUser(String address, String routingType) - throws ServiceLocalException, Exception { - this.add(new GroupMember(address, routingType, MailboxType.Mailbox)); - } - - /** - * Adds a member linked to an Active Directory contact. - * - * @param smtpAddress the smtp address - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - public void addDirectoryContact(String smtpAddress) - throws ServiceLocalException, Exception { - this.addDirectoryContact(smtpAddress, new EmailAddress() - .getSmtpRoutingType()); - } - - /** - * Adds a member linked to an Active Directory contact. - * - * @param address the address - * @param routingType the routing type - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - public void addDirectoryContact(String address, String routingType) - throws ServiceLocalException, Exception { - this.add(new GroupMember(address, routingType, MailboxType.Contact)); - } - - /** - * Adds a member linked to a Public Group. - * - * @param smtpAddress the smtp address - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - public void addPublicGroup(String smtpAddress) - throws ServiceLocalException, Exception { - this.add(new GroupMember(smtpAddress, new EmailAddress() - .getSmtpRoutingType(), MailboxType.PublicGroup)); - } - - /** - * Adds a member linked to a mail-enabled Public Folder. - * - * @param smtpAddress the smtp address - * @throws ServiceLocalException the service local exception - * @throws Exception the exception - */ - public void addDirectoryPublicFolder(String smtpAddress) - throws ServiceLocalException, Exception { - this.add(new GroupMember(smtpAddress, new EmailAddress() - .getSmtpRoutingType(), MailboxType.PublicFolder)); - } - - /** - * Adds a one-off member. - * - * @param displayName the display name - * @param address the address - * @param routingType the routing type - * @throws Exception the exception - */ - public void addOneOff(String displayName, - String address, String routingType) - throws Exception { - this.add(new GroupMember(displayName, address, routingType)); - } - - /** - * Adds a one-off member. - * - * @param displayName the display name - * @param smtpAddress the smtp address - * @throws Exception the exception - */ - public void addOneOff(String displayName, String smtpAddress) - throws Exception { - this.addOneOff(displayName, smtpAddress, new EmailAddress() - .getSmtpRoutingType()); - } - - /** - * Adds a member that is linked to a specific e-mail address of a contact. - * - * @param contact the contact - * @param emailAddressKey the email address key - * @throws Exception the exception - */ - public void addContactEmailAddress(Contact contact, - EmailAddressKey emailAddressKey) throws Exception { - this.add(new GroupMember(contact, emailAddressKey)); - } - - /** - * Removes a member at the specified index. - * - * @param index the index - */ - public void removeAt(int index) { - if (index < 0 || index >= this.getCount()) { - throw new IllegalArgumentException("index", new Throwable("index is out of range.")); - - } - - this.internalRemoveAt(index); - } - - /** - * Removes a member from the collection. - * - * @param member the member - * @return True if the group member was successfully removed from the - * collection, false otherwise. - */ - public boolean remove(GroupMember member) { - return this.internalRemove(member); - } - - /** - * Writes the update to XML. - * - * @param writer the writer - * @param ownerObject the owner object - * @param propertyDefinition the property definition - * @return True if property generated serialization. - * @throws Exception the exception - */ - public boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ownerObject, PropertyDefinition propertyDefinition) - throws Exception { - if (this.collectionIsCleared) { - - if (!this.getAddedItems().isEmpty()) { // not visible - - // Delete the whole members collection - this.writeDeleteMembersCollectionToXml(writer); - } else { - // The collection is cleared, so Set - this.writeSetOrAppendMembersToXml(writer, this.getAddedItems(), - true); - } - } else { - // The collection is not cleared, i.e. dl.Members.Clear() is not - // called. - // Append AddedItems. - this.writeSetOrAppendMembersToXml(writer, this.getAddedItems(), - false); - - // Since member replacement is not supported by server - // Delete old ModifiedItems, then recreate new instead. - this.writeDeleteMembersToXml(writer, this.getModifiedItems()); - this.writeSetOrAppendMembersToXml(writer, this.getModifiedItems(), - false); - - // Delete RemovedItems. - this.writeDeleteMembersToXml(writer, this.getRemovedItems()); - } - - return true; - } - - /** - * Writes the deletion update to XML. - * - * @param writer the writer - * @param ewsObject the ews object - * @return True if property generated serialization. - */ - public boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject) { - return false; - } - - /** - * Creates a GroupMember object from an XML element name. - * - * @param xmlElementName the xml element name - * @return An GroupMember object - */ - protected GroupMember createComplexProperty(String xmlElementName) { - return new GroupMember(); - } - - /** - * Clears the change log. - */ - public void clearChangeLog() { - super.clearChangeLog(); - this.collectionIsCleared = false; - } - - /** - * Delete the whole members collection. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - private void writeDeleteMembersCollectionToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.DeleteItemField); - ContactGroupSchema.Members.writeToXml(writer); - writer.writeEndElement(); - } - - /** - * Generate XML to delete individual members. - * - * @param writer the writer - * @param members the members - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - private void writeDeleteMembersToXml(EwsServiceXmlWriter writer, - List members) throws XMLStreamException, - ServiceXmlSerializationException { - if (!members.isEmpty()) { - GroupMemberPropertyDefinition memberPropDef = - new GroupMemberPropertyDefinition(); - - for (GroupMember member : members) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.DeleteItemField); - - memberPropDef.setKey(member.getKey()); - memberPropDef.writeToXml(writer); - - writer.writeEndElement(); // DeleteItemField - } - } - } - - /** - * Write set or append members to xml. - * - * @param writer the writer - * @param members the members - * @param setMode the set mode - * @throws Exception the exception - */ - private void writeSetOrAppendMembersToXml(EwsServiceXmlWriter writer, - List members, boolean setMode) throws Exception { - if (!members.isEmpty()) { - writer.writeStartElement(XmlNamespace.Types, - setMode ? XmlElementNames.SetItemField - : XmlElementNames.AppendToItemField); - - ContactGroupSchema.Members.writeToXml(writer); - - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.DistributionList); - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.Members); - - for (GroupMember member : members) { - member.writeToXml(writer, XmlElementNames.Member); - } - - writer.writeEndElement(); // Members - writer.writeEndElement(); // Group - writer.writeEndElement(); // setMode ? SetItemField : - // AppendItemField - } - } - - /** - * Validates this instance. - * - * @throws Exception - */ - @Override - protected void internalValidate() throws Exception { - super.internalValidate(); - - for (GroupMember groupMember : this.getModifiedItems()) { - if (!(groupMember.getKey() == null || groupMember.getKey().isEmpty())) { - throw new ServiceValidationException("The contact group's Members property must be reloaded before " - + "newly-added members can be updated."); - } - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ImAddressDictionary.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ImAddressDictionary.java deleted file mode 100644 index 89774f010..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ImAddressDictionary.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.property.ImAddressKey; -import microsoft.exchange.webservices.data.misc.OutParam; - -/** - * Represents a dictionary of Instant Messaging addresses. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class ImAddressDictionary extends DictionaryProperty { - - /** - * Gets the field URI. - * - * @return Field URI. - */ - @Override - protected String getFieldURI() { - return "contacts:ImAddress"; - } - - /** - * Creates instance of dictionary entry. - * - * @return New instance. - */ - @Override - protected ImAddressEntry createEntryInstance() { - return new ImAddressEntry(); - } - - /** - * Gets the Instant Messaging address at the specified key. - * - * @param key the key - * @return The Instant Messaging address at the specified key. - */ - public String getImAddressKey(ImAddressKey key) { - return this.getEntries().get(key).getImAddress(); - } - - /** - * Sets the im address key. - * - * @param key the key - * @param value the value - */ - public void setImAddressKey(ImAddressKey key, String value) { - if (value == null) { - this.internalRemove(key); - } else { - ImAddressEntry entry; - - if (this.getEntries().containsKey(key)) { - entry = this.getEntries().get(key); - entry.setImAddress(value); - this.changed(); - } else { - entry = new ImAddressEntry(key, value); - this.internalAdd(entry); - } - } - } - - /** - * Tries to get the IM address associated with the specified key. - * - * @param key the key - * @param outParam the out param - * @return true if the Dictionary contains an IM address associated with the - * specified key; otherwise, false. - */ - public boolean tryGetValue(ImAddressKey key, OutParam outParam) { - ImAddressEntry entry = null; - - if (this.getEntries().containsKey(key)) { - entry = this.getEntries().get(key); - outParam.setParam(entry.getImAddress()); - - return true; - } else { - outParam = null; - return false; - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ImAddressEntry.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ImAddressEntry.java deleted file mode 100644 index 4f975eb55..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ImAddressEntry.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.property.ImAddressKey; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents an entry of an ImAddressDictionary. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class ImAddressEntry extends DictionaryEntryProperty { - - /** - * The im address. - */ - private String imAddress; - - /** - * Initializes a new instance of the "ImAddressEntry" class. - */ - protected ImAddressEntry() { - super(ImAddressKey.class); - } - - /** - * Initializes a new instance of the ="ImAddressEntry" class. - * - * @param key The key. - * @param imAddress The im address. - */ - protected ImAddressEntry(ImAddressKey key, String imAddress) { - super(ImAddressKey.class, key); - this.imAddress = imAddress; - } - - /** - * Gets the Instant Messaging address of the entry. - * - * @return imAddress - */ - public String getImAddress() { - return this.imAddress; - } - - /** - * Sets the Instant Messaging address of the entry. - * - * @param value the new im address - */ - public void setImAddress(Object value) { - - this.canSetFieldValue(this.imAddress, value); - } - - /** - * Reads the text value from XML. - * - * @param reader accepts EwsServiceXmlReader - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlDeserializationException the service xml deserialization exception - */ - @Override - public void readTextValueFromXml(EwsServiceXmlReader reader) - throws XMLStreamException, ServiceXmlDeserializationException { - this.imAddress = reader.readValue(); - } - - /** - * Writes elements to XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeValue(this.imAddress, XmlElementNames.ImAddress); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/InternetMessageHeader.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/InternetMessageHeader.java deleted file mode 100644 index a78bce0db..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/InternetMessageHeader.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Defines the EwsXmlReader class. - */ -public final class InternetMessageHeader extends ComplexProperty { - - /** - * The name. - */ - private String name; - - /** - * The value. - */ - private String value; - - /** - * Initializes a new instance of the EwsXmlReader class. - */ - protected InternetMessageHeader() { - } - - /** - * Reads the attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.name = reader.readAttributeValue(XmlAttributeNames.HeaderName); - } - - /** - * Reads the text value from XML. - * - * @param reader the reader - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlDeserializationException the service xml deserialization exception - */ - public void readTextValueFromXml(EwsServiceXmlReader reader) - throws XMLStreamException, ServiceXmlDeserializationException { - this.value = reader.readValue(); - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.HeaderName, this.name); - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeValue(this.value, this.name); - } - - /** - * Obtains a string representation of the header. - * - * @return The string representation of the header. - */ - public String toString() { - return String.format("%s=%s", this.name, this.value); - } - - /** - * The name of the header. - * - * @param name the new name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Gets the name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * The value of the header. - * - * @return the value - */ - public String getValue() { - return value; - } - - /** - * Sets the value. - * - * @param value the value to set - */ - public void setValue(String value) { - this.value = value; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/InternetMessageHeaderCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/InternetMessageHeaderCollection.java deleted file mode 100644 index 385a07828..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/InternetMessageHeaderCollection.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; - -/** - * Represents a collection of Internet message headers. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class InternetMessageHeaderCollection extends ComplexPropertyCollection { - /** - * Initializes a new instance of the "InternetMessageHeaderCollection" - * class. - */ - public InternetMessageHeaderCollection() { - super(); - } - - /** - * Creates the complex property. - * - * @param xmlElementName Name of the XML element. - * @return InternetMessageHeader instance - */ - @Override - protected InternetMessageHeader createComplexProperty( - String xmlElementName) { - return new InternetMessageHeader(); - } - - /** - * Gets the name of the collection item XML element. - * - * @param complexProperty The complex property. - * @return XML element name. - */ - @Override - protected String getCollectionItemXmlElementName( - InternetMessageHeader complexProperty) { - return XmlElementNames.InternetMessageHeader; - } - - /** - * Find a specific header in the collection. - * - * @param name The name of the header to locate. - * @return An InternetMessageHeader representing the header with the - * specified name; null if no header with the specified name was - * found. - */ - public InternetMessageHeader find(String name) { - for (InternetMessageHeader internetMessageHeader : this) { - if (name.compareTo(internetMessageHeader.getName()) == 0 && - name.equalsIgnoreCase(internetMessageHeader.getName())) { - return internetMessageHeader; - } - } - return null; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ItemAttachment.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ItemAttachment.java deleted file mode 100644 index e8f0040ee..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ItemAttachment.java +++ /dev/null @@ -1,255 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.property.BodyType; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinitionBase; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.Arrays; - -/** - * Represents an item attachment. - */ -public class ItemAttachment extends Attachment implements IServiceObjectChangedDelegate { - - private static final Log LOG = LogFactory.getLog(ItemAttachment.class); - - /** - * The item. - */ - private Item item; - - /** - * Initializes a new instance of the class. - * - * @param owner The owner of the attachment - */ - protected ItemAttachment(Item owner) { - super(owner); - } - - /** - * Gets the item associated with the attachment. - * - * @return the item - */ - public Item getItem() { - return this.item; - } - - /** - * Sets the item associated with the attachment. - * - * @param item the new item - */ - protected void setItem(Item item) { - this.throwIfThisIsNotNew(); - - if (this.item != null) { - - this.item.removeServiceObjectChangedEvent(this); - } - this.item = item; - if (this.item != null) { - this.item.addServiceObjectChangedEvent(this); - } - } - - /** - * Implements the OnChange event handler for the item associated with the - * attachment. - * - * @param serviceObject ,The service object that triggered the OnChange event. - */ - private void itemChanged(ServiceObject serviceObject) { - this.item.getPropertyBag().changed(); - } - - /** - * Obtains EWS XML element name for this object. - * - * @return The XML element name. - */ - @Override public String getXmlElementName() { - return XmlElementNames.ItemAttachment; - } - - /** - * Tries to read the element at the current position of the reader. - * - * @param reader the reader - * @return True if the element was read, false otherwise. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - boolean result = super.tryReadElementFromXml(reader); - - if (!result) { - this.item = EwsUtilities.createItemFromXmlElementName(this, reader.getLocalName()); - - if (this.item != null) { - try { - this.item.loadFromXml(reader, true /* clearPropertyBag */); - } catch (Exception e) { - LOG.error(e); - - } - } - } - - return result; - } - - /** - * For ItemAttachment, AttachmentId and Item should be patched. - * - * @param reader The reader. - *

- * True if element was read. - */ - public boolean tryReadElementFromXmlToPatch(EwsServiceXmlReader reader) throws Exception { - // update the attachment id. - super.tryReadElementFromXml(reader); - - reader.read(); - - String localName = reader.getLocalName(); - Class itemClass = EwsUtilities.getItemTypeFromXmlElementName(localName); - - if (itemClass != null) { - if (item == null || item.getClass() != itemClass) { - throw new ServiceLocalException( - "Attachment item type mismatch."); - } - - this.item.loadFromXml(reader, false /* clearPropertyBag */); - return true; - } - - return false; - } - - - /** - * Writes the property of this object as XML elements. - * - * @param writer ,The writer to write the elements to. - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - super.writeElementsToXml(writer); - try { - this.item.writeToXml(writer); - } catch (Exception e) { - LOG.error(e); - - } - } - - /** - * {@inheritDoc} - */ - @Override - protected void validate(int attachmentIndex) throws Exception { - if (this.getName() == null || this.getName().isEmpty()) { - throw new ServiceValidationException(String.format( - "The name of the item attachment at index %d must be set.", attachmentIndex)); - } - - // Recurse through any item attached to item attachment. - this.validate(); - } - - /** - * Loads this attachment. - * - * @param additionalProperties the additional property - * @throws Exception the exception - */ - public void load(PropertyDefinitionBase... additionalProperties) - throws Exception { - internalLoad(null /* bodyType */, Arrays.asList(additionalProperties)); - } - - /** - * Loads this attachment. - * - * @param additionalProperties the additional property - * @throws Exception the exception - */ - public void load(Iterable additionalProperties) - throws Exception { - this.internalLoad(null, additionalProperties); - } - - /** - * Loads this attachment. - * - * @param bodyType the body type - * @param additionalProperties the additional property - * @throws Exception the exception - */ - public void load(BodyType bodyType, - PropertyDefinitionBase... additionalProperties) throws Exception { - internalLoad(bodyType, Arrays.asList(additionalProperties)); - } - - /** - * Loads this attachment. - * - * @param bodyType the body type - * @param additionalProperties the additional property - * @throws Exception the exception - */ - public void load(BodyType bodyType, - Iterable additionalProperties) - throws Exception { - this.internalLoad(bodyType, additionalProperties); - } - - /** - * Service object changed. - * - * @param serviceObject accepts ServiceObject - */ - @Override - public void serviceObjectChanged(ServiceObject serviceObject) { - this.itemChanged(serviceObject); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ItemCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ItemCollection.java deleted file mode 100644 index 742943fa0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ItemCollection.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceObjectPropertyException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.security.XmlNodeType; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Represents a collection of item. - * - * @param the generic type. The type of item the collection contains. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class ItemCollection extends ComplexProperty - implements Iterable { - - private static final Log LOG = LogFactory.getLog(ItemCollection.class); - - /** - * The item. - */ - private List items = new ArrayList(); - - /** - * Initializes a new instance of the "ItemCollection<TItem>" class. - */ - public ItemCollection() { - super(); - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @param localElementName Name of the local element. - * @throws Exception the exception - */ - @Override public void loadFromXml(EwsServiceXmlReader reader, String localElementName) throws Exception { - reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, - localElementName); - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { - TItem item = EwsUtilities - .createEwsObjectFromXmlElementName(Item.class, reader.getService(), reader.getLocalName()); - - if (item == null) { - reader.skipCurrentElement(); - } else { - try { - item.loadFromXml(reader, - true /* clearPropertyBag */); - } catch (ServiceObjectPropertyException e) { - LOG.error(e); - } catch (ServiceVersionException e) { - LOG.error(e); - } - - this.items.add(item); - } - } - } while (!reader.isEndElement(XmlNamespace.Types, - localElementName)); - } else { - reader.read(); - } - } - - /** - * Gets the total number of item in the collection. - * - * @return the count - */ - public int getCount() { - return this.items.size(); - } - - /** - * Gets the item at the specified index. - * - * @param index The zero-based index of the item to get. - * @return The item at the specified index. - */ - public TItem getItem(int index) { - - if (index < 0 || index >= this.getCount()) { - throw new ArrayIndexOutOfBoundsException("index is out of range."); - } - return this.items.get(index); - } - - /** - * Gets an iterator that iterates through the elements of the collection. - * - * @return An Iterator for the collection. - */ - public Iterator getIterator() { - return this.items.iterator(); - } - - /** - * Returns an iterator over a set of elements of type T. - * - * @return an Iterator. - */ - @Override - public Iterator iterator() { - return this.items.iterator(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ItemId.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ItemId.java deleted file mode 100644 index 15ab7a558..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ItemId.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.XmlElementNames; - -/** - * Represents the Id of an Exchange item. - */ -public class ItemId extends ServiceId { - - /** - * Initializes a new instance. - */ - public ItemId() { - super(); - } - - /** - * Defines an implicit conversion between string and ItemId. - * - * @param uniqueId The unique Id to convert to ItemId. - * @return An ItemId initialized with the specified unique Id. - * @throws Exception the exception - */ - public static ItemId getItemIdFromString(String uniqueId) throws Exception { - return new ItemId(uniqueId); - } - - /** - * Initializes a new instance of ItemId. - * - * @param uniqueId The unique Id used to initialize the ItemId. - * @throws Exception the exception - */ - public ItemId(String uniqueId) throws Exception { - super(uniqueId); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override - public String getXmlElementName() { - return XmlElementNames.ItemId; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ItemIdCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ItemIdCollection.java deleted file mode 100644 index c23e5c04e..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ItemIdCollection.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -/** - * Represents a collection of item Ids. - */ -public final class ItemIdCollection extends ComplexPropertyCollection { - /** - * Initializes a new instance of the class. - */ - public ItemIdCollection() { - super(); - } - - /** - * Creates the complex property. - * - * @param xmlElementName Name of the XML element. - * @return ItemId. - */ - @Override - protected ItemId createComplexProperty(String xmlElementName) { - return new ItemId(); - } - - /** - * Gets the name of the collection item XML element. - * - * @param complexProperty The complex property. - * @return XML element name. - */ - @Override - protected String getCollectionItemXmlElementName(ItemId complexProperty) { - return complexProperty.getXmlElementName(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/Mailbox.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/Mailbox.java deleted file mode 100644 index 612e4e758..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/Mailbox.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents a mailbox reference. - */ -public class Mailbox extends ComplexProperty implements ISearchStringProvider { - - // Routing type - /** - * The routing type. - */ - private String routingType; - - // Email address - /** - * The address. - */ - private String address; - - /** - * Initializes a new instance of the Mailbox class. - */ - public Mailbox() { - super(); - } - - /** - * Initializes a new instance of the Mailbox class. - * - * @param smtpAddress the smtp address - */ - public Mailbox(String smtpAddress) { - this(); - this.setAddress(smtpAddress); - } - - /** - * Initializes a new instance of the Mailbox class. - * - * @param address the address - * @param routingType the routing type - */ - public Mailbox(String address, String routingType) { - this(address); - this.setRoutingType(routingType); - } - - /** - * Gets the address. - * - * @return the address - */ - public String getAddress() { - return address; - } - - /** - * Sets the address. - * - * @param address the new address - */ - public void setAddress(String address) { - this.address = address; - } - - /** - * True if this instance is valid, false otherthise. - * - * @return true if this instance is valid; otherwise false - */ - public boolean isValid() { - return !(this.getAddress() == null || this.getAddress().isEmpty()); - } - - /** - * Gets the routing type of the address used to refer to the user - * mailbox. - * - * @return the routing type - */ - public String getRoutingType() { - return routingType; - } - - /** - * Sets the routing type. - * - * @param routingType the new routing type - */ - public void setRoutingType(String routingType) { - this.routingType = routingType; - } - - /** - * Defines an implicit conversion between a string representing an SMTP - * address and Mailbox. - * - * @param smtpAddress the smtp address - * @return A Mailbox initialized with the specified SMTP address. - */ - public static Mailbox getMailboxFromString(String smtpAddress) { - return new Mailbox(smtpAddress); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName() - .equalsIgnoreCase(XmlElementNames.EmailAddress)) { - this.setAddress(reader.readElementValue()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.RoutingType)) { - this.setRoutingType(reader.readElementValue()); - return true; - } else { - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.EmailAddress, this.address); - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.RoutingType, this.routingType); - } - - /** - * Get a string representation for using this instance in a search filter. - * - * @return String representation of instance. - */ - public String getSearchString() { - return this.address; - } - - /** - * Validates this instance. - * - * @throws Exception - * @throws ServiceValidationException - */ - @Override - protected void internalValidate() - throws ServiceValidationException, Exception { - super.internalValidate(); - - EwsUtilities.validateNonBlankStringParamAllowNull(this.getAddress(), "address"); - EwsUtilities.validateNonBlankStringParamAllowNull( - this.getRoutingType(), "routingType"); - } - - - /** - * Determines whether the specified Object is equal to the current Object. - * - * @param obj the obj - * @return true if the specified Object is equal to the current Object - * otherwise, false. - */ - @Override - public boolean equals(Object obj) { - if (super.equals(obj)) { - return true; - } else { - if (!(obj instanceof Mailbox)) { - return false; - } else { - Mailbox other = (Mailbox) obj; - if (((this.address == null) && (other.address == null)) - || ((this.address != null) && this.address - .equalsIgnoreCase(other.address))) { - return ((this.routingType == null) && - (other.routingType == null)) - || ((this.routingType != null) && this.routingType - .equalsIgnoreCase(other.routingType)); - } else { - return false; - } - } - } - } - - /** - * Serves as a hash function for a particular type. - * - * @return A hash code for the current object - */ - @Override - public int hashCode() { - if (!(null == this.getAddress() || this.getAddress().isEmpty())) { - int hashCode = this.address.hashCode(); - - if (!(null == this.getRoutingType() || this.getRoutingType() - .isEmpty())) { - hashCode ^= this.routingType.hashCode(); - } - return hashCode; - } else { - return super.hashCode(); - } - } - - /** - * Returns a String that represents the current Object. - * - * @return A String that represents the current Object. - */ - @Override - public String toString() { - if (!this.isValid()) { - return ""; - } else if (!(this.routingType == null || this.routingType.isEmpty())) { - return this.routingType + ":" + this.address; - } else { - return this.address; - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ManagedFolderInformation.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ManagedFolderInformation.java deleted file mode 100644 index c9629593c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ManagedFolderInformation.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.misc.OutParam; - -/** - * Represents information for a managed folder. - */ -public final class ManagedFolderInformation extends ComplexProperty { - - /** - * The can delete. - */ - private Boolean canDelete; - - /** - * The can rename or move. - */ - private Boolean canRenameOrMove; - - /** - * The must display comment. - */ - private Boolean mustDisplayComment; - - /** - * The has quota. - */ - private Boolean hasQuota; - - /** - * The is managed folder root. - */ - private Boolean isManagedFoldersRoot; - - /** - * The managed folder id. - */ - private String managedFolderId; - - /** - * The comment. - */ - private String comment; - - /** - * The storage quota. - */ - private Integer storageQuota; - - /** - * The folder size. - */ - private Integer folderSize; - - /** - * The home page. - */ - private String homePage; - - /** - * Initializes a new instance of the ManagedFolderInformation class. - */ - public ManagedFolderInformation() { - super(); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.CanDelete)) { - this.canDelete = reader.readValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.CanRenameOrMove)) { - this.canRenameOrMove = reader.readValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.MustDisplayComment)) { - this.mustDisplayComment = reader.readValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.HasQuota)) { - this.hasQuota = reader.readValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.IsManagedFoldersRoot)) { - this.isManagedFoldersRoot = reader.readValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.ManagedFolderId)) { - this.managedFolderId = reader.readValue(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.Comment)) { - OutParam value = new OutParam(); - reader.tryReadValue(value); - this.comment = value.getParam(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.StorageQuota)) { - this.storageQuota = reader.readValue(Integer.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.FolderSize)) { - this.folderSize = reader.readValue(Integer.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.HomePage)) { - OutParam value = new OutParam(); - reader.tryReadValue(value); - this.homePage = value.getParam(); - return true; - } else { - return false; - } - - } - - /** - * Gets a value indicating whether the user can delete objects in the - * folder. - * - * @return the can delete - */ - public Boolean getCanDelete() { - return this.canDelete; - } - - /** - * Gets a value indicating whether the user can rename or move objects in - * the folder. - * - * @return the can rename or move - */ - public Boolean getCanRenameOrMove() { - return canRenameOrMove; - } - - /** - * Gets a value indicating whether the client application must display the - * Comment property to the user. - * - * @return the must display comment - */ - public Boolean getMustDisplayComment() { - return mustDisplayComment; - } - - /** - * Gets a value indicating whether the folder has a quota. - * - * @return the checks for quota - */ - public Boolean getHasQuota() { - return hasQuota; - } - - /** - * Gets a value indicating whether the folder is the root of the managed - * folder hierarchy. - * - * @return the checks if is managed folder root - */ - public Boolean getIsManagedFoldersRoot() { - return isManagedFoldersRoot; - } - - /** - * Gets the Managed Folder Id of the folder. - * - * @return the managed folder id - */ - public String getManagedFolderId() { - return managedFolderId; - } - - /** - * Gets the comment associated with the folder. - * - * @return the comment - */ - public String getComment() { - return comment; - } - - /** - * Gets the storage quota of the folder. - * - * @return the storage quota - */ - public Integer getStorageQuota() { - return storageQuota; - } - - /** - * Gets the size of the folder. - * - * @return the folder size - */ - public Integer getFolderSize() { - return folderSize; - } - - /** - * Gets the home page associated with the folder. - * - * @return the home page - */ - public String getHomePage() { - return homePage; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/MeetingTimeZone.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/MeetingTimeZone.java deleted file mode 100644 index c929423c8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/MeetingTimeZone.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.TimeSpan; -import microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Represents a time zone in which a meeting is defined. - */ -public final class MeetingTimeZone extends ComplexProperty { - - private static final Log LOG = LogFactory.getLog(MeetingTimeZone.class); - - /** - * The name. - */ - private String name; - - /** - * The base offset. - */ - private TimeSpan baseOffset; - - /** - * The standard. - */ - private TimeChange standard; - - /** - * The daylight. - */ - private TimeChange daylight; - - /** - * Initializes a new instance of the MeetingTimeZone class. - * - * @param timeZone The time zone used to initialize this instance. - */ - public MeetingTimeZone(TimeZoneDefinition timeZone) { - // Unfortunately, MeetingTimeZone does not support all the time - // transition types - // supported by TimeZoneInfo. That leaves us unable to accurately - // convert TimeZoneInfo - // into MeetingTimeZone. So we don't... Instead, we emit the time zone's - // Id and - // hope the server will find a match (which it should). - this.name = timeZone.getId(); - } - - /** - * Initializes a new instance of the MeetingTimeZone class. - */ - public MeetingTimeZone() { - super(); - } - - /** - * Initializes a new instance of the MeetingTimeZone class. - * - * @param name The name of the time zone. - */ - public MeetingTimeZone(String name) { - this(); - this.name = name; - } - - /** - * Gets the minimum required server version. - * - * @param reader the reader - * @return Earliest Exchange version in which this service object type is - * supported. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.BaseOffset)) { - this.baseOffset = EwsUtilities.getXSDurationToTimeSpan(reader.readElementValue()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Standard)) { - this.standard = new TimeChange(); - this.standard.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Daylight)) { - this.daylight = new TimeChange(); - this.daylight.loadFromXml(reader, reader.getLocalName()); - return true; - } else { - return false; - } - } - - /** - * Reads the attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.name = reader.readAttributeValue(XmlAttributeNames.TimeZoneName); - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.TimeZoneName, this - .getName()); - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - if (this.baseOffset != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.BaseOffset, EwsUtilities - .getTimeSpanToXSDuration(this.getBaseOffset())); - } - - if (this.getStandard() != null) { - this.getStandard().writeToXml(writer, XmlElementNames.Standard); - } - - if (this.getDaylight() != null) { - this.getDaylight().writeToXml(writer, XmlElementNames.Daylight); - } - } - - /** - * Converts this meeting time zone into a TimeZoneInfo structure. - * - * @return the time zone - */ - public TimeZoneDefinition toTimeZoneInfo() { - TimeZoneDefinition result = null; - - try { - result = new TimeZoneDefinition(); - //TimeZone.getTimeZone(this.getName()); - result.setId(this.getName()); - } catch (Exception e) { - // Could not find a time zone with that Id on the local system. - LOG.error(e); - } - - // Again, we cannot accurately convert MeetingTimeZone into TimeZoneInfo - // because TimeZoneInfo doesn't support absolute date transitions. So if - // there is no system time zone that has a matching Id, we return null. - return result; - } - - /** - * Gets the name of the time zone. - * - * @return the name - */ - public String getName() { - return this.name; - } - - /** - * Sets the name. - * - * @param value the new name - */ - public void setName(String value) { - if (this.canSetFieldValue(this.name, value)) { - this.name = value; - this.changed(); - } - } - - /** - * Gets the base offset of the time zone from the UTC time zone. - * - * @return the base offset - */ - public TimeSpan getBaseOffset() { - return this.baseOffset; - } - - /** - * Sets the base offset. - * - * @param value the new base offset - */ - public void setBaseOffset(TimeSpan value) { - if (this.canSetFieldValue(this.name, value)) { - this.baseOffset = value; - this.changed(); - } - } - - /** - * Gets a TimeChange defining when the time changes to Standard - * Time. - * - * @return the standard - */ - public TimeChange getStandard() { - return this.standard; - } - - /** - * Sets the standard. - * - * @param value the new standard - */ - public void setStandard(TimeChange value) { - if (this.canSetFieldValue(this.standard, value)) { - this.standard = value; - this.changed(); - } - } - - /** - * Gets a TimeChange defining when the time changes to Daylight - * Saving Time. - * - * @return the daylight - */ - public TimeChange getDaylight() { - return this.daylight; - } - - /** - * Sets the daylight. - * - * @param value the new daylight - */ - public void setDaylight(TimeChange value) { - if (this.canSetFieldValue(this.daylight, value)) { - this.daylight = value; - this.changed(); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/MessageBody.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/MessageBody.java deleted file mode 100644 index 0d84c1701..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/MessageBody.java +++ /dev/null @@ -1,218 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.BodyType; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents the body of a message. - */ -public final class MessageBody extends ComplexProperty { - - private static final Log log = LogFactory.getLog(MessageBody.class); - - /** - * The body type. - */ - private BodyType bodyType; - - /** - * The text. - */ - private String text; - - /** - * Initializes a new instance. - */ - public MessageBody() { - - } - - /** - * Initializes a new instance. - * - * @param bodyType The type of the message body's text. - * @param text The text of the message body. - */ - public MessageBody(BodyType bodyType, String text) { - this(); - this.bodyType = bodyType; - this.text = text; - } - - /** - * Initializes a new instance. - * - * @param text The text of the message body, assumed to be HTML. - */ - public MessageBody(String text) { - this(BodyType.HTML, text); - } - - /** - * Defines an implicit conversation between a string and MessageBody. - * - * @param textBody The string to convert to MessageBody, assumed to be HTML. - * @return A MessageBody initialized with the specified string. - */ - public static MessageBody getMessageBodyFromText(String textBody) { - return new MessageBody(BodyType.HTML, textBody); - } - - /** - * Defines an implicit conversion of MessageBody into a string. - * - * @param messageBody The MessageBody to convert to a string. - * @return A string containing the text of the MessageBody. - * @throws Exception the exception - */ - public static String getStringFromMessageBody(MessageBody messageBody) - throws Exception { - EwsUtilities.validateParam(messageBody, "messageBody"); - return messageBody.text; - } - - /** - * Reads attribute from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.bodyType = reader.readAttributeValue(BodyType.class, - XmlAttributeNames.BodyType); - } - - /** - * Reads text value from XML. - * - * @param reader the reader - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlDeserializationException the service xml deserialization exception - */ - @Override - public void readTextValueFromXml(EwsServiceXmlReader reader) - throws XMLStreamException, ServiceXmlDeserializationException { - if (log.isDebugEnabled()) { - log.debug("Reading text value from XML. BodyType = " + this.getBodyType() + - ", keepWhiteSpace = " + - ((this.getBodyType() == BodyType.Text) ? "true." : "false.")); - } - this.text = reader.readValue(this.getBodyType() == BodyType.Text); - if (log.isDebugEnabled()) { - log.debug("Text value read:\n---\n" + this.text + "\n---"); - } - } - - /** - * Writes attribute to XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.BodyType, this - .getBodyType()); - } - - /** - * Writes elements to XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - if (null != this.text && !this.text.isEmpty()) { - writer.writeValue(this.getText(), XmlElementNames.Body); - } - } - - /** - * Gets the type of the message body's text. - * - * @return BodyType enum - */ - public BodyType getBodyType() { - return this.bodyType; - } - - /** - * Sets the type of the message body's text. - * - * @param bodyType BodyType enum - */ - public void setBodyType(BodyType bodyType) { - if (this.canSetFieldValue(this.bodyType, bodyType)) { - this.bodyType = bodyType; - this.changed(); - } - } - - /** - * Gets the text of the message body. - * - * @return message body text - */ - private String getText() { - return this.text; - } - - /** - * Sets the text of the message body. - * - * @param text message body text - */ - public void setText(String text) { - if (this.canSetFieldValue(this.text, text)) { - this.text = text; - this.changed(); - } - } - - /** - * Returns a String that represents the current Object. - * - * @return the string - */ - @Override - public String toString() { - return (this.text == null) ? "" : this.text; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/MimeContent.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/MimeContent.java deleted file mode 100644 index 6170a1415..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/MimeContent.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import org.apache.commons.codec.binary.Base64; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents the MIME content of an item. - */ -public final class MimeContent extends ComplexProperty { - - /** - * The character set. - */ - private String characterSet; - - /** - * The content. - */ - private byte[] content; - - /** - * Initializes a new instance of the class. - */ - public MimeContent() { - } - - /** - * Initializes a new instance of the class. - * - * @param characterSet the character set - * @param content the content - */ - public MimeContent(String characterSet, byte[] content) { - this(); - this.characterSet = characterSet; - this.content = content; - } - - /** - * Reads attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.characterSet = reader.readAttributeValue(String.class, - XmlAttributeNames.CharacterSet); - } - - /** - * Reads text value from XML. - * - * @param reader the reader - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlDeserializationException the service xml deserialization exception - */ - @Override - public void readTextValueFromXml(EwsServiceXmlReader reader) - throws XMLStreamException, ServiceXmlDeserializationException { - this.content = Base64.decodeBase64(reader.readValue()); - } - - /** - * Writes attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.CharacterSet, - this.characterSet); - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException { - if (this.content != null && this.content.length > 0) { - writer.writeBase64ElementValue(this.content); - } - } - - /** - * Gets the character set of the content. - * - * @return the character set - */ - public String getCharacterSet() { - return this.characterSet; - } - - /** - * Sets the character set. - * - * @param characterSet the new character set - */ - public void setCharacterSet(String characterSet) { - this.canSetFieldValue(this.characterSet, characterSet); - } - - /** - * Gets the character set of the content. - * - * @return the content - */ - public byte[] getContent() { - return this.content; - } - - /** - * Sets the content. - * - * @param content the new content - */ - public void setContent(byte[] content) { - this.canSetFieldValue(this.content, content); - } - - /** - * Writes attribute to XML. - * - * @return the string - */ - @Override - public String toString() { - if (this.getContent() == null) { - return ""; - } else { - try { - - // Try to convert to original MIME content using specified - // charset. If this fails, - // return the Base64 representation of the content. - // Note: Encoding.GetString can throw DecoderFallbackException - // which is a subclass - // of ArgumentException. - String charSet = (this.getCharacterSet() == null || - this.getCharacterSet().isEmpty()) ? - "UTF-8" : this.getCharacterSet(); - return new String(this.getContent(), charSet); - } catch (Exception e) { - return Base64.encodeBase64String(this.getContent()); - } - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/OccurrenceInfo.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/OccurrenceInfo.java deleted file mode 100644 index 203f474b0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/OccurrenceInfo.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; - -import java.util.Date; - -/** - * Encapsulates information on the occurrence of a recurring appointment. - */ -public final class OccurrenceInfo extends ComplexProperty { - - /** - * The item id. - */ - private ItemId itemId; - - /** - * The start. - */ - private Date start; - - /** - * The end. - */ - private Date end; - - /** - * The original start. - */ - private Date originalStart; - - /** - * Initializes a new instance of the OccurrenceInfo class. - */ - public OccurrenceInfo() { - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return true, if successful - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.ItemId)) { - - this.itemId = new ItemId(); - this.itemId.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Start)) { - - this.start = reader.readElementValueAsDateTime(); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.End)) { - - this.end = reader.readElementValueAsDateTime(); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.OriginalStart)) { - - this.originalStart = reader.readElementValueAsDateTime(); - return true; - } else { - - return false; - } - } - - /** - * Gets the Id of the occurrence. - * - * @return the item id - */ - public ItemId getItemId() { - return itemId; - } - - /** - * Gets the start date and time of the occurrence. - * - * @return the start - */ - public Date getStart() { - return start; - } - - /** - * Gets the end date and time of the occurrence. - * - * @return the end - */ - public Date getEnd() { - return end; - } - - /** - * Gets the original start date and time of the occurrence. - * - * @return the original start - */ - public Date getOriginalStart() { - return originalStart; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/OccurrenceInfoCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/OccurrenceInfoCollection.java deleted file mode 100644 index 03f417055..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/OccurrenceInfoCollection.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; - -/** - * Represents a collection of OccurrenceInfo objects. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class OccurrenceInfoCollection extends ComplexPropertyCollection { - - /** - * Initializes a new instance of the - * class. - */ - public OccurrenceInfoCollection() { - } - - /** - * Creates the complex property. - * - * @param xmlElementName Name of the XML element - * @return OccuranceInfo instance - */ - @Override - protected OccurrenceInfo createComplexProperty(String xmlElementName) { - if (xmlElementName.equals(XmlElementNames.Occurrence)) { - return new OccurrenceInfo(); - } else { - return null; - } - } - - /** - * Gets the name of the collection item XML element. - * - * @param complexProperty The complex property. - * @return XML element name. - */ - @Override - protected String getCollectionItemXmlElementName( - OccurrenceInfo complexProperty) { - return XmlElementNames.Occurrence; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/PhoneNumberDictionary.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/PhoneNumberDictionary.java deleted file mode 100644 index e8357a31b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/PhoneNumberDictionary.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.property.PhoneNumberKey; -import microsoft.exchange.webservices.data.misc.OutParam; - -/** - * Represents a dictionary of phone numbers. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class PhoneNumberDictionary extends DictionaryProperty { - - /** - * Gets the field URI. - * - * @return Field URI. - */ - @Override - protected String getFieldURI() { - return "contacts:PhoneNumber"; - } - - /** - * Creates instance of dictionary entry. - * - * @return New instance. - */ - @Override - protected PhoneNumberEntry createEntryInstance() { - return new PhoneNumberEntry(); - } - - /** - * Gets the phone number at the specified key. - * - * @param key The phone number key. - * @return The phone number at the specified key if found; otherwise null. - */ - public String getPhoneNumber(PhoneNumberKey key) { - PhoneNumberEntry phoneNumberEntry = this.getEntries().get(key); - if (phoneNumberEntry == null) { - return null; - } - - return phoneNumberEntry.getPhoneNumber(); - } - - /** - * Sets the phone number. - * - * @param key the key - * @param value the value - */ - public void setPhoneNumber(PhoneNumberKey key, String value) { - if (value == null) { - this.internalRemove(key); - } else { - PhoneNumberEntry entry; - - if (this.getEntries().containsKey(key)) { - entry = this.getEntries().get(key); - entry.setPhoneNumber(value); - complexPropertyChanged(entry); - this.changed(); - } else { - entry = new PhoneNumberEntry(key, value); - this.internalAdd(entry); - } - } - } - - /** - * Tries to get the phone number associated with the specified key. - * - * @param key the key - * @param outparam the outparam - * @return true if the Dictionary contains a phone number associated with - * the specified key; otherwise, false. - */ - public boolean tryGetValue(PhoneNumberKey key, OutParam outparam) { - String phoneNumber = this.getPhoneNumber(key); - if (phoneNumber == null) { - return false; - } - - outparam.setParam(phoneNumber); - return true; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/PhoneNumberEntry.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/PhoneNumberEntry.java deleted file mode 100644 index ae4736684..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/PhoneNumberEntry.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.property.PhoneNumberKey; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -/** - * Represents an entry of a PhoneNumberDictionary. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class PhoneNumberEntry extends DictionaryEntryProperty { - - /** - * The phone number. - */ - private String phoneNumber; - - /** - * Initializes a new instance of the "PhoneNumberEntry" class. - */ - protected PhoneNumberEntry() { - super(PhoneNumberKey.class); - } - - /** - * Initializes a new instance of the class. - * - * @param key The key. - * @param phoneNumber The phone number. - */ - protected PhoneNumberEntry(PhoneNumberKey key, String phoneNumber) { - super(PhoneNumberKey.class, key); - this.phoneNumber = phoneNumber; - } - - /** - * Reads the text value from XML. - * - * @param reader accepts EwsServiceXmlReader - * @throws Exception throws Exception - */ - @Override - public void readTextValueFromXml(EwsServiceXmlReader reader) - throws Exception { - this.phoneNumber = reader.readValue(); - } - - /** - * Writes elements to XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeValue(this.phoneNumber, XmlElementNames.PhoneNumber); - } - - /** - * Gets the phone number of the entry. - * - * @return the phone number - */ - public String getPhoneNumber() { - return this.phoneNumber; - } - - /** - * Sets the phone number of the entry. - * - * @param value the new phone number - */ - public void setPhoneNumber(Object value) { - //this.canSetFieldValue((String) this.phoneNumber, value); - if (this.canSetFieldValue(this.phoneNumber, value)) { - this.phoneNumber = (String) value; - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/PhysicalAddressDictionary.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/PhysicalAddressDictionary.java deleted file mode 100644 index 7263ac362..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/PhysicalAddressDictionary.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.property.PhysicalAddressKey; -import microsoft.exchange.webservices.data.misc.OutParam; - -/** - * Represents a dictionary of physical addresses. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class PhysicalAddressDictionary extends - DictionaryProperty { - - /** - * Creates instance of dictionary entry. - * - * @return New instance. - */ - @Override - protected PhysicalAddressEntry createEntryInstance() { - return new PhysicalAddressEntry(); - } - - /** - * Gets the physical address at the specified key. - * - * @param key the key - * @return The physical address at the specified key. - */ - public PhysicalAddressEntry getPhysicalAddress(PhysicalAddressKey key) { - return this.getEntries().get(key); - } - - /** - * Sets the physical address. - * - * @param key the key - * @param value the value - */ - public void setPhysicalAddress(PhysicalAddressKey key, - PhysicalAddressEntry value) { - if (value == null) { - this.internalRemove(key); - } else { - value.setKey(key); - this.internalAddOrReplace(value); - } - } - - /** - * Tries to get the physical address associated with the specified key. - * - * @param key the key - * @param outparam the outparam - * @return true if the Dictionary contains a physical address associated - * with the specified key; otherwise, false. - */ - public boolean tryGetValue(PhysicalAddressKey key, - OutParam outparam) { - if (this.getEntries().containsKey(key)) { - outparam.setParam(this.getEntries().get(key)); - } - return this.getEntries().containsKey(key); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/PhysicalAddressEntry.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/PhysicalAddressEntry.java deleted file mode 100644 index a461a2825..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/PhysicalAddressEntry.java +++ /dev/null @@ -1,394 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ILazyMember; -import microsoft.exchange.webservices.data.core.LazyMember; -import microsoft.exchange.webservices.data.core.SimplePropertyBag; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.property.PhysicalAddressKey; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents an entry of an PhysicalAddressDictionary. - */ -public final class PhysicalAddressEntry extends DictionaryEntryProperty implements - IPropertyBagChangedDelegate { - - /** - * The property bag. - */ - private SimplePropertyBag propertyBag; - - /** - * Initializes a new instance of PhysicalAddressEntry. - */ - public PhysicalAddressEntry() { - super(PhysicalAddressKey.class); - this.propertyBag = new SimplePropertyBag(); - this.propertyBag.addOnChangeEvent(this); - } - - /** - * Property was changed. - * - * @param simplePropertyBag the simple property bag - */ - public void propertyBagChanged(SimplePropertyBag simplePropertyBag) { - this.changed(); - } - - /** - * Gets the street. - * - * @return the street - * @throws Exception the exception - */ - public String getStreet() throws Exception { - return (String) this.propertyBag - .getSimplePropertyBag(PhysicalAddressSchema.Street); - } - - /** - * Sets the street. - * - * @param value the new street - * @throws Exception the exception - */ - public void setStreet(String value) throws Exception { - this.propertyBag.setSimplePropertyBag(PhysicalAddressSchema.Street, - value); - - } - - /** - * Gets the city. - * - * @return the city - * @throws Exception the exception - */ - public String getCity() throws Exception { - return (String) this.propertyBag - .getSimplePropertyBag(PhysicalAddressSchema.City); - } - - /** - * Sets the city. - * - * @param value the new city - */ - public void setCity(String value) { - this.propertyBag - .setSimplePropertyBag(PhysicalAddressSchema.City, value); - } - - /** - * Gets the state. - * - * @return the state - * @throws Exception the exception - */ - public String getState() throws Exception { - return (String) this.propertyBag - .getSimplePropertyBag(PhysicalAddressSchema.State); - } - - /** - * Sets the state. - * - * @param value the new state - */ - public void setState(String value) { - this.propertyBag.setSimplePropertyBag(PhysicalAddressSchema.State, - value); - } - - /** - * Gets the country or region. - * - * @return the country or region - * @throws Exception the exception - */ - public String getCountryOrRegion() throws Exception { - return (String) this.propertyBag - .getSimplePropertyBag(PhysicalAddressSchema.CountryOrRegion); - } - - /** - * Sets the country or region. - * - * @param value the new country or region - */ - public void setCountryOrRegion(String value) { - this.propertyBag.setSimplePropertyBag( - PhysicalAddressSchema.CountryOrRegion, value); - } - - /** - * Gets the postal code. - * - * @return the postal code - */ - public String getPostalCode() { - return (String) this.propertyBag - .getSimplePropertyBag(PhysicalAddressSchema.PostalCode); - } - - /** - * Sets the postal code. - * - * @param value the new postal code - */ - public void setPostalCode(String value) { - this.propertyBag.setSimplePropertyBag(PhysicalAddressSchema.PostalCode, - value); - } - - /** - * Clears the change log. - */ - @Override public void clearChangeLog() { - this.propertyBag.clearChangeLog(); - } - - /** - * Writes elements to XML. - * - * @param reader the reader - * @return true, if successful - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (PhysicalAddressSchema.getXmlElementNames().contains( - reader.getLocalName())) { - this.propertyBag.setSimplePropertyBag(reader.getLocalName(), reader - .readElementValue()); - return true; - } else { - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - for (String xmlElementName : PhysicalAddressSchema.getXmlElementNames()) { - writer.writeElementValue(XmlNamespace.Types, xmlElementName, - this.propertyBag.getSimplePropertyBag(xmlElementName)); - - } - } - - /** - * Writes the update to XML. - * - * @param writer the writer - * @param ewsObject the ews object - * @param ownerDictionaryXmlElementName the owner dictionary xml element name - * @return true if update XML was written - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected boolean writeSetUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject, String ownerDictionaryXmlElementName) - throws XMLStreamException, ServiceXmlSerializationException { - List fieldsToSet = new ArrayList(); - - for (String xmlElementName : this.propertyBag.getAddedItems()) { - fieldsToSet.add(xmlElementName); - } - - for (String xmlElementName : this.propertyBag.getModifiedItems()) { - fieldsToSet.add(xmlElementName); - } - - for (String xmlElementName : fieldsToSet) { - writer.writeStartElement(XmlNamespace.Types, ewsObject - .getSetFieldXmlElementName()); - - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.IndexedFieldURI); - writer.writeAttributeValue(XmlAttributeNames.FieldURI, - getFieldUri(xmlElementName)); - writer.writeAttributeValue(XmlAttributeNames.FieldIndex, this - .getKey().toString()); - writer.writeEndElement(); // IndexedFieldURI - - writer.writeStartElement(XmlNamespace.Types, ewsObject - .getXmlElementName()); - writer.writeStartElement(XmlNamespace.Types, - ownerDictionaryXmlElementName); - writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Entry); - this.writeAttributesToXml(writer); - writer.writeElementValue(XmlNamespace.Types, xmlElementName, - this.propertyBag.getSimplePropertyBag(xmlElementName)); - writer.writeEndElement(); // Entry - writer.writeEndElement(); // ownerDictionaryXmlElementName - writer.writeEndElement(); // ewsObject.GetXmlElementName() - - writer.writeEndElement(); // ewsObject.GetSetFieldXmlElementName() - } - - for (String xmlElementName : this.propertyBag.getRemovedItems()) { - this.internalWriteDeleteFieldToXml(writer, ewsObject, - xmlElementName); - } - - return true; - } - - /** - * Writes the delete update to XML. - * - * @param writer the writer - * @param ewsObject the ews object - * @return true if update XML was written - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected boolean writeDeleteUpdateToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject) throws XMLStreamException, - ServiceXmlSerializationException { - for (String xmlElementName : PhysicalAddressSchema.getXmlElementNames()) { - this.internalWriteDeleteFieldToXml(writer, ewsObject, - xmlElementName); - } - return true; - } - - /** - * Gets the field URI. - * - * @param xmlElementName the xml element name - * @return Field URI. - */ - private static String getFieldUri(String xmlElementName) { - return "contacts:PhysicalAddress:" + xmlElementName; - } - - /** - * Write field deletion to XML. - * - * @param writer the writer - * @param ewsObject the ews object - * @param fieldXmlElementName the field xml element name - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - private void internalWriteDeleteFieldToXml(EwsServiceXmlWriter writer, - ServiceObject ewsObject, String fieldXmlElementName) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeStartElement(XmlNamespace.Types, ewsObject - .getDeleteFieldXmlElementName()); - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.IndexedFieldURI); - writer.writeAttributeValue(XmlAttributeNames.FieldURI, - getFieldUri(fieldXmlElementName)); - writer.writeAttributeValue(XmlAttributeNames.FieldIndex, this.getKey() - .toString()); - writer.writeEndElement(); // IndexedFieldURI - writer.writeEndElement(); // ewsObject.GetDeleteFieldXmlElementName() - } - - /** - * Schema definition for PhysicalAddress. - */ - private static class PhysicalAddressSchema { - - /** - * The Constant Street. - */ - public static final String Street = "Street"; - - /** - * The Constant City. - */ - public static final String City = "City"; - - /** - * The Constant State. - */ - public static final String State = "State"; - - /** - * The Constant CountryOrRegion. - */ - public static final String CountryOrRegion = "CountryOrRegion"; - - /** - * The Constant PostalCode. - */ - public static final String PostalCode = "PostalCode"; - - /** - * List of XML element names. - */ - private static LazyMember> xmlElementNames = - new LazyMember>( - - new ILazyMember>() { - @Override - public List createInstance() { - List result = new ArrayList(); - result.add(Street); - result.add(City); - result.add(State); - result.add(CountryOrRegion); - result.add(PostalCode); - return result; - } - }); - - /** - * Gets the XML element names. - * - * @return The XML element names. - */ - public static List getXmlElementNames() { - return xmlElementNames.getMember(); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/RecurringAppointmentMasterId.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/RecurringAppointmentMasterId.java deleted file mode 100644 index 8da78bf16..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/RecurringAppointmentMasterId.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -/** - * Represents the Id of an occurrence of a recurring appointment. - */ -public final class RecurringAppointmentMasterId extends ItemId { - - /** - * Represents the Id of an occurrence of a recurring appointment. - * - * @param occurrenceId the occurrence id - * @throws Exception the exception - */ - public RecurringAppointmentMasterId(String occurrenceId) throws Exception { - super(occurrenceId); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override - public String getXmlElementName() { - return XmlElementNames.RecurringMasterItemId; - } - - /** - * Writes attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.OccurrenceId, this - .getUniqueId()); - writer.writeAttributeValue(XmlAttributeNames.ChangeKey, this - .getChangeKey()); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/Rule.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/Rule.java deleted file mode 100644 index e862f3643..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/Rule.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -/** - * Represents a rule that automatically handles incoming messages. - * A rule consists of a set of conditions - * and exception that determine whether or - * not a set of actions should be executed on incoming messages. - */ -public final class Rule extends ComplexProperty { - - /** - * The rule ID. - */ - private String ruleId; - - /** - * The rule display name. - */ - private String displayName; - - /** - * The rule priority. - */ - private int priority; - - /** - * The rule status of enabled or not. - */ - private boolean isEnabled; - - /** - * The rule status of is supported or not. - */ - private boolean isNotSupported; - - /** - * The rule status of in error or not. - */ - private boolean isInError; - - /** - * The rule conditions. - */ - private RulePredicates conditions; - - /** - * The rule actions. - */ - private RuleActions actions; - - /** - * The rule exception. - */ - private RulePredicates exceptions; - - /** - * Initializes a new instance of the Rule class. - */ - public Rule() { - super(); - - /** - * New rule has priority as 0 by default - */ - this.priority = 1; - - /** - * New rule is enabled by default - */ - this.isEnabled = true; - this.conditions = new RulePredicates(); - this.actions = new RuleActions(); - this.exceptions = new RulePredicates(); - } - - - /** - * Gets or sets the Id of this rule. - */ - public String getId() { - - return this.ruleId; - } - - public void setId(String value) { - if (this.canSetFieldValue(this.ruleId, value)) { - this.ruleId = value; - this.changed(); - } - } - - /** - * Gets or sets the name of this rule as it should be displayed to the user. - */ - public String getDisplayName() { - return this.displayName; - } - - public void setDisplayName(String value) { - if (this.canSetFieldValue(this.displayName, value)) { - this.displayName = value; - this.changed(); - } - } - - - /** - * Gets or sets the priority of this rule, - * which determines its execution order. - */ - public int getPriority() { - return this.priority; - } - - public void setPriority(int value) { - if (this.canSetFieldValue(this.priority, value)) { - this.priority = value; - this.changed(); - } - } - - - /** - * Gets or sets a value indicating whether this rule is enabled. - */ - public boolean getIsEnabled() { - return this.isEnabled; - } - - public void setIsEnabled(boolean value) { - if (this.canSetFieldValue(this.isEnabled, value)) { - this.isEnabled = value; - this.changed(); - } - } - - /** - * Gets a value indicating whether this rule can be modified via EWS. - * If IsNotSupported is true, the rule cannot be modified via EWS. - */ - public boolean getIsNotSupported() { - return this.isNotSupported; - - } - - /** - * Gets or sets a value indicating whether - * this rule has errors. A rule that is in error - * cannot be processed unless it is updated and the error is corrected. - */ - public boolean getIsInError() { - return this.isInError; - } - - public void setIsInError(boolean value) { - if (this.canSetFieldValue(this.isInError, value)) { - this.isInError = value; - this.changed(); - } - } - - /** - * Gets the conditions that determine whether or not this rule should be - * executed against incoming messages. - */ - public RulePredicates getConditions() { - return this.conditions; - } - - /** - * Gets the actions that should be executed against incoming messages if the - * conditions evaluate as true. - */ - public RuleActions getActions() { - return this.actions; - - } - - /** - * Gets the exception that determine - * if this rule should be skipped even if - * its conditions evaluate to true. - */ - public RulePredicates getExceptions() { - return this.exceptions; - } - - /** - * Tries to read element from XML. - * - * @param reader The reader. - * @return True if element was read. - * @throws Exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader - reader) throws Exception { - - if (reader.getLocalName().equals(XmlElementNames.DisplayName)) { - this.displayName = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.RuleId)) { - this.ruleId = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Priority)) { - this.priority = reader.readElementValue(Integer.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.IsEnabled)) { - this.isEnabled = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.IsNotSupported)) { - this.isNotSupported = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.IsInError)) { - this.isInError = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Conditions)) { - this.conditions.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Actions)) { - this.actions.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Exceptions)) { - this.exceptions.loadFromXml(reader, reader.getLocalName()); - return true; - } else { - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer The writer. - * @throws Exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - if (!(getId() == null || getId().isEmpty())) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.RuleId, - this.getId()); - } - - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.DisplayName, - this.getDisplayName()); - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.Priority, - this.getPriority()); - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsEnabled, - this.getIsEnabled()); - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsInError, - this.getIsInError()); - this.getConditions().writeToXml(writer, XmlElementNames.Conditions); - this.getExceptions().writeToXml(writer, XmlElementNames.Exceptions); - this.getActions().writeToXml(writer, XmlElementNames.Actions); - } - - - /** - * Validates this instance. - */ - @Override - protected void internalValidate() throws Exception { - super.internalValidate(); - EwsUtilities.validateParam(this.displayName, "DisplayName"); - EwsUtilities.validateParam(this.conditions, "Conditions"); - EwsUtilities.validateParam(this.exceptions, "Exceptions"); - EwsUtilities.validateParam(this.actions, "Actions"); - } -} - diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleActions.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleActions.java deleted file mode 100644 index cccca3b56..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleActions.java +++ /dev/null @@ -1,535 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.Importance; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.MobilePhone; - -import java.util.ArrayList; -import java.util.Collection; - -/** - * Represents the set of actions available for a rule. - */ -public final class RuleActions extends ComplexProperty { - - /** - * SMS recipient address type. - */ - private static final String MobileType = "MOBILE"; - - /** - * The AssignCategories action. - */ - private StringList assignCategories; - - /** - * The CopyToFolder action. - */ - private FolderId copyToFolder; - - /** - * The Delete action. - */ - private boolean delete; - - /** - * The ForwardAsAttachmentToRecipients action. - */ - private EmailAddressCollection forwardAsAttachmentToRecipients; - - /** - * The ForwardToRecipients action. - */ - private EmailAddressCollection forwardToRecipients; - - /** - * The MarkImportance action. - */ - private Importance markImportance; - - /** - * The MarkAsRead action. - */ - private boolean markAsRead; - - /** - * The MoveToFolder action. - */ - private FolderId moveToFolder; - - /** - * The PermanentDelete action. - */ - private boolean permanentDelete; - - /** - * The RedirectToRecipients action. - */ - private EmailAddressCollection redirectToRecipients; - - /** - * The SendSMSAlertToRecipients action. - */ - private Collection sendSMSAlertToRecipients; - - /** - * The ServerReplyWithMessage action. - */ - private ItemId serverReplyWithMessage; - - /** - * The StopProcessingRules action. - */ - private boolean stopProcessingRules; - - /** - * Initializes a new instance of the RulePredicates class. - */ - protected RuleActions() { - super(); - this.assignCategories = new StringList(); - this.forwardAsAttachmentToRecipients = - new EmailAddressCollection(XmlElementNames.Address); - this.forwardToRecipients = - new EmailAddressCollection(XmlElementNames.Address); - this.redirectToRecipients = - new EmailAddressCollection(XmlElementNames.Address); - this.sendSMSAlertToRecipients = new ArrayList(); - } - - /** - * Gets the categories that should be stamped on incoming messages. - * To disable stamping incoming messages with categories, set - * AssignCategories to null. - */ - public StringList getAssignCategories() { - - return this.assignCategories; - - } - - /** - * Gets or sets the Id of the folder incoming messages should be copied to. - * To disable copying incoming messages - * to a folder, set CopyToFolder to null. - */ - public FolderId getCopyToFolder() { - return this.copyToFolder; - } - - public void setCopyToFolder(FolderId value) { - if (this.canSetFieldValue(this.copyToFolder, value)) { - this.copyToFolder = value; - this.changed(); - } - } - - /** - * Gets or sets a value indicating whether incoming messages should be - * automatically moved to the Deleted Items folder. - */ - public boolean getDelete() { - return this.delete; - } - - public void setDelete(boolean value) { - if (this.canSetFieldValue(this.delete, value)) { - this.delete = value; - this.changed(); - } - - } - - /** - * Gets the e-mail addresses to which incoming messages should be - * forwarded as attachments. To disable forwarding incoming messages - * as attachments, empty the ForwardAsAttachmentToRecipients list. - */ - public EmailAddressCollection getForwardAsAttachmentToRecipients() { - return this.forwardAsAttachmentToRecipients; - } - - /** - * Gets the e-mail addresses to which - * incoming messages should be forwarded. - * To disable forwarding incoming messages, - * empty the ForwardToRecipients list. - */ - public EmailAddressCollection getForwardToRecipients() { - return this.forwardToRecipients; - - } - - /** - * Gets or sets the importance that should be stamped on incoming - * messages. To disable the stamping of incoming messages with an - * importance, set MarkImportance to null. - */ - public Importance getMarkImportance() { - return this.markImportance; - } - - public void setMarkImportance(Importance value) { - if (this.canSetFieldValue(this.markImportance, value)) { - this.markImportance = value; - this.changed(); - } - } - - /** - * Gets or sets a value indicating whether - * incoming messages should be marked as read. - */ - public boolean getMarkAsRead() { - return this.markAsRead; - } - - public void setMarkAsRead(boolean value) { - if (this.canSetFieldValue(this.markAsRead, value)) { - this.markAsRead = value; - this.changed(); - } - } - - /** - * Gets or sets the Id of the folder to which incoming messages should be - * moved. To disable the moving of incoming messages to a folder, set - * CopyToFolder to null. - */ - public FolderId getMoveToFolder() { - return this.moveToFolder; - } - - public void setMoveToFolder(FolderId value) { - if (this.canSetFieldValue(this.moveToFolder, value)) { - this.moveToFolder = value; - this.changed(); - } - - } - - /** - * Gets or sets a value indicating whether incoming messages should be - * permanently deleted. When a message is permanently deleted, it is never - * saved into the recipient's mailbox. To delete a message after it has - * saved into the recipient's mailbox. To delete a message after it has - */ - public boolean getPermanentDelete() { - return this.permanentDelete; - } - - public void setPermanentDelete(boolean value) { - if (this.canSetFieldValue(this.permanentDelete, value)) { - this.permanentDelete = value; - this.changed(); - } - } - - /** - * Gets the e-mail addresses to which incoming messages should be - * redirecteded. To disable redirection of incoming messages, empty - * the RedirectToRecipients list. Unlike forwarded mail, redirected mail - * maintains the original sender and recipients. - */ - public EmailAddressCollection getRedirectToRecipients() { - return this.redirectToRecipients; - - } - - /** - * Gets the phone numbers to which an SMS alert should be sent. To disable - * sending SMS alerts for incoming messages, empty the - * SendSMSAlertToRecipients list. - */ - public Collection getSendSMSAlertToRecipients() { - return this.sendSMSAlertToRecipients; - - } - - /** - * Gets or sets the Id of the template message that should be sent - * as a reply to incoming messages. To disable automatic replies, set - * ServerReplyWithMessage to null. - */ - public ItemId getServerReplyWithMessage() { - return this.serverReplyWithMessage; - } - - public void setServerReplyWithMessage(ItemId value) { - if (this.canSetFieldValue(this.serverReplyWithMessage, value)) { - this.serverReplyWithMessage = value; - this.changed(); - } - } - - /** - * Gets or sets a value indicating whether - * subsequent rules should be evaluated. - */ - public boolean getStopProcessingRules() { - return this.stopProcessingRules; - } - - public void setStopProcessingRules(boolean value) { - if (this.canSetFieldValue(this.stopProcessingRules, value)) { - this.stopProcessingRules = value; - this.changed(); - } - - } - - /** - * Tries to read element from XML. - * - * @param reader The reader. - * @return True if element was read. - * @throws Exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader - reader) throws Exception { - if (reader.getLocalName().equals(XmlElementNames.CopyToFolder)) { - reader.readStartElement(XmlNamespace.NotSpecified, - XmlElementNames.FolderId); - this.copyToFolder = new FolderId(); - this.copyToFolder.loadFromXml(reader, XmlElementNames.FolderId); - reader.readEndElement(XmlNamespace.NotSpecified, - XmlElementNames.CopyToFolder); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.AssignCategories)) { - this.assignCategories.loadFromXml(reader, - reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Delete)) { - this.delete = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.ForwardAsAttachmentToRecipients)) { - this.forwardAsAttachmentToRecipients.loadFromXml(reader, - reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.ForwardToRecipients)) { - this.forwardToRecipients.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.MarkImportance)) { - this.markImportance = reader.readElementValue(Importance.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.MarkAsRead)) { - this.markAsRead = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.MoveToFolder)) { - reader.readStartElement(XmlNamespace.NotSpecified, - XmlElementNames.FolderId); - this.moveToFolder = new FolderId(); - this.moveToFolder.loadFromXml(reader, XmlElementNames.FolderId); - reader.readEndElement(XmlNamespace.NotSpecified, - XmlElementNames.MoveToFolder); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.PermanentDelete)) { - this.permanentDelete = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.RedirectToRecipients)) { - this.redirectToRecipients.loadFromXml(reader, - reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.SendSMSAlertToRecipients)) { - EmailAddressCollection smsRecipientCollection = - new EmailAddressCollection(XmlElementNames.Address); - smsRecipientCollection.loadFromXml(reader, reader.getLocalName()); - this.sendSMSAlertToRecipients = convertSMSRecipientsFromEmailAddressCollectionToMobilePhoneCollection( - smsRecipientCollection); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.ServerReplyWithMessage)) { - this.serverReplyWithMessage = new ItemId(); - this.serverReplyWithMessage.loadFromXml(reader, - reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.StopProcessingRules)) { - this.stopProcessingRules = reader.readElementValue(Boolean.class); - return true; - } else { - return false; - } - - } - - /** - * Writes elements to XML. - * - * @param writer The writer. - * @throws Exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - if (this.getAssignCategories().getSize() > 0) { - this.getAssignCategories().writeToXml(writer, - XmlElementNames.AssignCategories); - } - - if (this.getCopyToFolder() != null) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.CopyToFolder); - this.getCopyToFolder().writeToXml(writer); - writer.writeEndElement(); - } - - if (this.getDelete() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.Delete, - this.getDelete()); - } - - if (this.getForwardAsAttachmentToRecipients().getCount() > 0) { - this.getForwardAsAttachmentToRecipients().writeToXml(writer, - XmlElementNames.ForwardAsAttachmentToRecipients); - } - - if (this.getForwardToRecipients().getCount() > 0) { - this.getForwardToRecipients().writeToXml(writer, - XmlElementNames.ForwardToRecipients); - } - - if (this.getMarkImportance() != null) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.MarkImportance, - this.getMarkImportance()); - } - - if (this.getMarkAsRead() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.MarkAsRead, - this.getMarkAsRead()); - } - - if (this.getMoveToFolder() != null) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.MoveToFolder); - this.getMoveToFolder().writeToXml(writer); - writer.writeEndElement(); - } - - if (this.getPermanentDelete() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.PermanentDelete, - this.getPermanentDelete()); - } - - if (this.getRedirectToRecipients().getCount() > 0) { - this.getRedirectToRecipients().writeToXml(writer, - XmlElementNames.RedirectToRecipients); - } - - if (this.getSendSMSAlertToRecipients().size() > 0) { - EmailAddressCollection emailCollection = - convertSMSRecipientsFromMobilePhoneCollectionToEmailAddressCollection( - this.getSendSMSAlertToRecipients()); - emailCollection.writeToXml(writer, - XmlElementNames.SendSMSAlertToRecipients); - } - - if (this.getServerReplyWithMessage() != null) { - this.getServerReplyWithMessage().writeToXml(writer, - XmlElementNames.ServerReplyWithMessage); - } - - if (this.getStopProcessingRules() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.StopProcessingRules, - this.getStopProcessingRules()); - } - } - - /** - * Validates this instance. - * - * @throws Exception - */ - @Override - protected void internalValidate() throws Exception { - super.internalValidate(); - EwsUtilities.validateParam(this.forwardAsAttachmentToRecipients, "ForwardAsAttachmentToRecipients"); - EwsUtilities.validateParam(this.forwardToRecipients, - "ForwardToRecipients"); - EwsUtilities.validateParam(this.redirectToRecipients, - "RedirectToRecipients"); - for (MobilePhone sendSMSAlertToRecipient : this.sendSMSAlertToRecipients) { - EwsUtilities.validateParam(sendSMSAlertToRecipient, - "SendSMSAlertToRecipient"); - } - } - - /** - * Convert the SMS recipient list from - * EmailAddressCollection type to MobilePhone collection type. - * - * @return A MobilePhone collection object - * containing all SMS recipient in MobilePhone type. - */ - private static Collection convertSMSRecipientsFromEmailAddressCollectionToMobilePhoneCollection( - EmailAddressCollection emailCollection) { - Collection mobilePhoneCollection = - new ArrayList(); - for (EmailAddress emailAddress : emailCollection) { - mobilePhoneCollection.add(new MobilePhone(emailAddress.getName(), - emailAddress.getAddress())); - } - - return mobilePhoneCollection; - } - - /** - * Convert the SMS recipient list from MobilePhone - * collection type to EmailAddressCollection type. - * - * @return An EmailAddressCollection object - * containing recipients with "MOBILE" address type. - */ - private static EmailAddressCollection convertSMSRecipientsFromMobilePhoneCollectionToEmailAddressCollection( - Collection recipientCollection) { - EmailAddressCollection emailCollection = - new EmailAddressCollection(XmlElementNames.Address); - for (MobilePhone recipient : recipientCollection) { - EmailAddress emailAddress = new EmailAddress( - recipient.getName(), - recipient.getPhoneNumber(), - RuleActions.MobileType); - emailCollection.add(emailAddress); - } - - return emailCollection; - } - -} - diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleCollection.java deleted file mode 100644 index 8106e7fab..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleCollection.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentOutOfRangeException; - -import java.util.ArrayList; -import java.util.Iterator; - -/** - * Represents a collection of rules. - */ -public final class RuleCollection extends ComplexProperty implements Iterable { - - /** - * The OutlookRuleBlobExists flag. - */ - private boolean outlookRuleBlobExists; - - /** - * The rules in the rule collection. - */ - private ArrayList rules; - - /** - * Initializes a new instance of the RuleCollection class. - */ - public RuleCollection() { - super(); - this.rules = new ArrayList(); - } - - /** - * Gets a value indicating whether an Outlook rule blob exists in the user's - * mailbox. To update rules with EWS when the Outlook rule blob exists, call - * SetInboxRules passing true as the - * value of the removeOutlookBlob parameter. - */ - public boolean getOutlookRuleBlobExists() { - return this.outlookRuleBlobExists; - } - - public void setOutlookRuleBlobExists(boolean value) { - this.outlookRuleBlobExists = value; - } - - /** - * Gets the number of rules in this collection. - */ - public int getCount() { - return this.rules.size(); - } - - /** - * Gets the rule at the specified index in the collection. - * - * @param index The index of the rule to get. - * @return The rule at the specified index. - * @throws ArgumentOutOfRangeException - */ - public Rule getRule(int index) throws ArgumentOutOfRangeException { - if (index < 0 || index >= this.rules.size()) { - throw new ArgumentOutOfRangeException("Index"); - } - - return this.rules.get(index); - - } - - - /** - * Tries to read element from XML. - * - * @param reader The reader. - * @return True if element was read. - * @throws Exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.Rule)) { - Rule rule = new Rule(); - rule.loadFromXml(reader, XmlElementNames.Rule); - this.rules.add(rule); - return true; - } else { - return false; - } - } - - /** - * Get an enumerator for the collection - */ - @Override - public Iterator iterator() { - return this.rules.iterator(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleError.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleError.java deleted file mode 100644 index ef6767b61..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleError.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.error.RuleErrorCode; -import microsoft.exchange.webservices.data.core.enumeration.property.RuleProperty; - -/** - * Defines the RuleError class. - */ -public final class RuleError extends ComplexProperty { - - /** - * The Rule property. - */ - private RuleProperty ruleProperty; - - /** - * The Rule validation error code. - */ - private RuleErrorCode errorCode; - - /** - * The Error message. - */ - private String errorMessage; - - /** - * The Field value. - */ - private String value; - - /** - * The Initializes a new instance of the RuleError class. - */ - protected RuleError() { - super(); - } - - /** - * Gets the property which failed validation. - * - * @return ruleProperty - */ - public RuleProperty getRuleProperty() { - return this.ruleProperty; - } - - /** - * Gets the validation error code. - * - * @return ruleProperty - */ - public RuleErrorCode getErrorCode() { - return this.errorCode; - } - - /** - * Gets the error message. - * - * @return ruleProperty - */ - public String getErrorMessage() { - return this.errorMessage; - } - - /** - * Gets the value that failed validation. - */ - public String getValue() { - return this.value; - } - - /** - * Tries to read element from XML. - * - * @param reader The reader - * @return True if element was read - * @throws Exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.FieldURI)) { - this.ruleProperty = reader.readElementValue(RuleProperty.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.ErrorCode)) { - this.errorCode = reader.readElementValue(RuleErrorCode.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.ErrorMessage)) { - this.errorMessage = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.FieldValue)) { - this.value = reader.readElementValue(); - return true; - } else { - return false; - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleErrorCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleErrorCollection.java deleted file mode 100644 index 504c1e92c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleErrorCollection.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.XmlElementNames; - -/** - * Represents a collection of rule validation errors. - */ -public final class RuleErrorCollection extends ComplexPropertyCollection { - - /** - * Initializes a new instance of the RuleErrorCollection class. - */ - protected RuleErrorCollection() { - super(); - } - - /** - * Creates an RuleError object from an XML element name. - * - * @param xmlElementName The XML element name from - * which to create the RuleError object. - * @return A RuleError object. - */ - @Override - protected RuleError createComplexProperty(String xmlElementName) { - if (xmlElementName.equals(XmlElementNames.Error)) { - return new RuleError(); - } else { - return null; - } - } - - /** - * Retrieves the XML element name corresponding - * to the provided RuleError object. - * - * @param ruleValidationError The RuleError object from which - * to determine the XML element name. - * @return The XML element name corresponding - * to the provided RuleError object. - */ - @Override - protected String getCollectionItemXmlElementName(RuleError - ruleValidationError) { - return XmlElementNames.Error; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleOperationError.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleOperationError.java deleted file mode 100644 index 2c239f3cd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleOperationError.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentOutOfRangeException; - -import java.util.Iterator; - -/** - * Defines the RuleOperationError class. - */ -public final class RuleOperationError extends ComplexProperty implements Iterable { - /** - * Index of the operation mapping to the error. - */ - private int operationIndex; - - /** - * RuleOperation object mapping to the error. - */ - private RuleOperation operation; - - /** - * RuleError Collection. - */ - private RuleErrorCollection ruleErrors; - - /** - * Initializes a new instance of the RuleOperationError class. - */ - protected RuleOperationError() { - super(); - } - - /** - * Gets the operation that resulted in an error. - * - * @return operation - */ - public RuleOperation getOperation() { - return this.operation; - } - - /** - * Gets the number of rule errors in the list. - * - * @return count - */ - public int getCount() { - return this.ruleErrors.getCount(); - } - - /** - * Gets the rule error at the specified index. - * - * @return Index - * @throws ArgumentOutOfRangeException - */ - public RuleError getRuleError(int index) - throws ArgumentOutOfRangeException { - if (index < 0 || index >= this.getCount()) { - throw new ArgumentOutOfRangeException("index"); - } - - return this.ruleErrors.getPropertyAtIndex(index); - - } - - - /** - * Tries to read element from XML. - * - * @return true - * @throws Exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.OperationIndex)) { - this.operationIndex = reader.readElementValue(Integer.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.ValidationErrors)) { - this.ruleErrors = new RuleErrorCollection(); - this.ruleErrors.loadFromXml(reader, reader.getLocalName()); - return true; - } else { - return false; - } - } - - /** - * Set operation property by the index of a given opeation enumerator. - */ - public void setOperationByIndex(Iterator operations) { - for (int i = 0; i <= this.operationIndex; i++) { - operations.next(); - } - this.operation = operations.next(); - } - - /** - * Gets an iterator that iterates through the elements of the collection. - * - * @return An Iterator for the collection. - */ - public Iterator iterator() { - return this.ruleErrors.iterator(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleOperationErrorCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleOperationErrorCollection.java deleted file mode 100644 index e7a04ece1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/RuleOperationErrorCollection.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.XmlElementNames; - -/** - * Represents a collection of rule operation errors. - */ -public final class RuleOperationErrorCollection extends ComplexPropertyCollection { - - /** - * Initializes a new instance of the - * class. - */ - public RuleOperationErrorCollection() { - super(); - } - - /** - * Creates an RuleOperationError object from an XML element name. - * - * @param xmlElementName The XML element name from which - * to create the RuleOperationError object. - * @return A RuleOperationError object. - */ - @Override - protected RuleOperationError createComplexProperty(String xmlElementName) { - if (xmlElementName.equals(XmlElementNames.RuleOperationError)) { - return new RuleOperationError(); - } else { - return null; - } - } - - /** - * Retrieves the XML element name corresponding - * to the provided RuleOperationError object. - * - * @param operationError The RuleOperationError object - * from which to determine the XML element name. - * @return The XML element name corresponding - * to the provided RuleOperationError object. - */ - @Override - protected String getCollectionItemXmlElementName(RuleOperationError - operationError) { - return XmlElementNames.RuleOperationError; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/RulePredicateDateRange.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/RulePredicateDateRange.java deleted file mode 100644 index bf9edca17..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/RulePredicateDateRange.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -import java.util.Date; - -/** - * Represents the date and time range within which messages have been received. - */ -public final class RulePredicateDateRange extends ComplexProperty { - - /** - * The end DateTime. - */ - private Date start; - - /** - * The end DateTime. - */ - private Date end; - - /** - * Initializes a new instance of the RulePredicateDateRange class. - */ - protected RulePredicateDateRange() { - super(); - } - - /** - * Gets or sets the range start date and time. - * If Start is set to null, no start date applies. - */ - public Date getStart() { - return this.start; - } - - public void setStart(Date value) { - if (this.canSetFieldValue(this.start, value)) { - this.start = value; - this.changed(); - } - } - - /** - * Gets or sets the range end date and time. - * If End is set to null, no end date applies. - */ - public Date getEnd() { - return this.end; - } - - public void setEnd(Date value) { - if (this.canSetFieldValue(this.end, value)) { - this.end = value; - this.changed(); - } - } - - /** - * Tries to read element from XML. - * - * @param reader The reader. - * @return True if element was read. - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader - reader) throws Exception { - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.StartDateTime)) { - this.start = reader.readElementValueAsDateTime(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.EndDateTime)) { - this.end = reader.readElementValueAsDateTime(); - return true; - } else { - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - if (this.getStart() != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.StartDateTime, this.getStart()); - } - if (this.getEnd() != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.EndDateTime, this.getEnd()); - } - } - - /** - * Validates this instance. - */ - @Override - protected void internalValidate() - throws ServiceValidationException, Exception { - super.internalValidate(); - if (this.start != null && - this.end != null && - this.start.after(this.end)) { - throw new ServiceValidationException( - "Start date time cannot be bigger than end date time."); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/RulePredicateSizeRange.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/RulePredicateSizeRange.java deleted file mode 100644 index 82df767df..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/RulePredicateSizeRange.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents the minimum and maximum size of a message. - */ -public final class RulePredicateSizeRange extends ComplexProperty { - /** - * Minimum Size. - */ - private Integer minimumSize; - - /** - * Mamixmum Size. - */ - private Integer maximumSize; - - /** - * Initializes a new instance of the RulePredicateSizeRange class. - */ - protected RulePredicateSizeRange() { - super(); - } - - /** - * Gets or sets the minimum size, in kilobytes. - * If MinimumSize is set to null, no minimum size applies. - */ - public Integer getMinimumSize() { - - return this.minimumSize; - } - - public void setMinimumSize(Integer value) { - if (this.canSetFieldValue(this.minimumSize, value)) { - this.minimumSize = value; - this.changed(); - } - } - - /** - * Gets or sets the maximum size, in kilobytes. - * If MaximumSize is set to null, no maximum size applies. - */ - public Integer getMaximumSize() { - return this.maximumSize; - } - - public void setMaximumSize(Integer value) { - if (this.canSetFieldValue(this.maximumSize, value)) { - this.maximumSize = value; - this.changed(); - } - - } - - - /** - * Tries to read element from XML. - * - * @param reader The reader. - * @return True if element was read. - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.MinimumSize)) { - this.minimumSize = reader.readElementValue(Integer.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.MaximumSize)) { - this.maximumSize = reader.readElementValue(Integer.class); - return true; - } else { - return false; - } - - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - if (this.getMinimumSize() != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.MinimumSize, this.getMinimumSize()); - } - if (this.getMaximumSize() != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.MaximumSize, this.getMaximumSize()); - } - } - - /** - * Validates this instance. - */ - @Override - protected void internalValidate() - throws ServiceValidationException, Exception { - super.internalValidate(); - if (this.minimumSize != null && - this.maximumSize != null && - this.minimumSize > this.maximumSize) { - throw new ServiceValidationException( - "MinimumSize cannot be larger than MaximumSize."); - } - } -} - - - diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/RulePredicates.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/RulePredicates.java deleted file mode 100644 index f284230ea..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/RulePredicates.java +++ /dev/null @@ -1,1053 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.FlaggedForAction; -import microsoft.exchange.webservices.data.core.enumeration.property.Importance; -import microsoft.exchange.webservices.data.core.enumeration.property.Sensitivity; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -/** - * Represents the set of conditions and exception available for a rule. - */ -public final class RulePredicates extends ComplexProperty { - - /** - * The HasCategories predicate. - */ - private StringList categories; - - /** - * The ContainsBodyStrings predicate. - */ - private StringList containsBodyStrings; - /** - * The ContainsHeaderStrings predicate. - */ - private StringList containsHeaderStrings; - - /** - * The ContainsRecipientStrings predicate. - */ - private StringList containsRecipientStrings; - - /** - * The ContainsSenderStrings predicate. - */ - private StringList containsSenderStrings; - - /** - * The ContainsSubjectOrBodyStrings predicate. - */ - private StringList containsSubjectOrBodyStrings; - - /** - * The ContainsSubjectStrings predicate. - */ - private StringList containsSubjectStrings; - - /** - * The FlaggedForAction predicate. - */ - private FlaggedForAction flaggedForAction; - - /** - * The FromAddresses predicate. - */ - private EmailAddressCollection fromAddresses; - - /** - * The FromConnectedAccounts predicate. - */ - private StringList fromConnectedAccounts; - - /** - * The HasAttachments predicate. - */ - private boolean hasAttachments; - - /** - * The Importance predicate. - */ - private Importance importance; - - /** - * The IsApprovalRequest predicate. - */ - private boolean isApprovalRequest; - - /** - * The IsAutomaticForward predicate. - */ - private boolean isAutomaticForward; - - /** - * The IsAutomaticReply predicate. - */ - private boolean isAutomaticReply; - - /** - * The IsEncrypted predicate. - */ - private boolean isEncrypted; - - /** - * The IsMeetingRequest predicate. - */ - private boolean isMeetingRequest; - - /** - * The IsMeetingResponse predicate. - */ - private boolean isMeetingResponse; - - /** - * The IsNDR predicate. - */ - private boolean isNonDeliveryReport; - - /** - * The IsPermissionControlled predicate. - */ - private boolean isPermissionControlled; - - /** - * The IsSigned predicate. - */ - private boolean isSigned; - - /** - * The IsVoicemail predicate. - */ - private boolean isVoicemail; - - /** - * The IsReadReceipt predicate. - */ - private boolean isReadReceipt; - - /** - * ItemClasses predicate. - */ - private StringList itemClasses; - - /** - * The MessageClassifications predicate. - */ - private StringList messageClassifications; - - /** - * The NotSentToMe predicate. - */ - private boolean notSentToMe; - - /** - * SentCcMe predicate. - */ - private boolean sentCcMe; - - /** - * The SentOnlyToMe predicate. - */ - private boolean sentOnlyToMe; - - /** - * The SentToAddresses predicate. - */ - private EmailAddressCollection sentToAddresses; - - /** - * The SentToMe predicate. - */ - private boolean sentToMe; - - /** - * The SentToOrCcMe predicate. - */ - private boolean sentToOrCcMe; - - /** - * The Sensitivity predicate. - */ - private Sensitivity sensitivity; - - /** - * The Sensitivity predicate. - */ - private RulePredicateDateRange withinDateRange; - - /** - * The Sensitivity predicate. - */ - private RulePredicateSizeRange withinSizeRange; - - /** - * Initializes a new instance of the RulePredicates class. - */ - protected RulePredicates() { - super(); - this.categories = new StringList(); - this.containsBodyStrings = new StringList(); - this.containsHeaderStrings = new StringList(); - this.containsRecipientStrings = new StringList(); - this.containsSenderStrings = new StringList(); - this.containsSubjectOrBodyStrings = new StringList(); - this.containsSubjectStrings = new StringList(); - this.fromAddresses = - new EmailAddressCollection(XmlElementNames.Address); - this.fromConnectedAccounts = new StringList(); - this.itemClasses = new StringList(); - this.messageClassifications = new StringList(); - this.sentToAddresses = - new EmailAddressCollection(XmlElementNames.Address); - this.withinDateRange = new RulePredicateDateRange(); - this.withinSizeRange = new RulePredicateSizeRange(); - } - - /** - * Gets the categories that an incoming message - * should be stamped with for the condition or exception to apply. - * To disable this predicate, empty the list. - */ - public StringList getCategories() { - return this.categories; - } - - /** - * Gets the strings that should appear in the body of - * incoming messages for the condition or exception to apply. - * To disable this predicate, empty the list. - */ - public StringList getContainsBodyStrings() { - return this.containsBodyStrings; - } - - /** - * Gets the strings that should appear in the - * headers of incoming messages for the condition or - * exception to apply. To disable this predicate, empty the list. - */ - public StringList getContainsHeaderStrings() { - return this.containsHeaderStrings; - } - - /** - * Gets the strings that should appear in either the - * To or Cc fields of incoming messages for the condition - * or exception to apply. To disable this predicate, empty the list. - */ - public StringList getContainsRecipientStrings() { - return this.containsRecipientStrings; - } - - /** - * Gets the strings that should appear - * in the From field of incoming messages - * for the condition or exception to apply. - * To disable this predicate, empty the list. - */ - public StringList getContainsSenderStrings() { - return this.containsSenderStrings; - } - - /** - * Gets the strings that should appear in either - * the body or the subject of incoming messages for the - * condition or exception to apply. - * To disable this predicate, empty the list. - */ - public StringList getContainsSubjectOrBodyStrings() { - return this.containsSubjectOrBodyStrings; - } - - /** - * Gets the strings that should appear in the subject - * of incoming messages for the condition or exception - * to apply. To disable this predicate, empty the list. - */ - public StringList getContainsSubjectStrings() { - return this.containsSubjectStrings; - } - - /** - * Gets or sets the flag for action value that should - * appear on incoming messages for the condition or execption to apply. - * To disable this predicate, set it to null. - */ - public FlaggedForAction getFlaggedForAction() { - - return this.flaggedForAction; - } - - public void setFlaggedForAction(FlaggedForAction value) { - if (this.canSetFieldValue(this.flaggedForAction, value)) { - this.flaggedForAction = value; - this.changed(); - } - } - - /** - * Gets the e-mail addresses of the senders of incoming - * messages for the condition or exception to apply. - * To disable this predicate, empty the list. - */ - public EmailAddressCollection getFromAddresses() { - return this.fromAddresses; - } - - /** - * Gets or sets a value indicating whether incoming messages must have - * attachments for the condition or exception to apply. - */ - public boolean getHasAttachments() { - return this.hasAttachments; - } - - public void setHasAttachments(boolean value) { - if (this.canSetFieldValue(this.hasAttachments, value)) { - this.hasAttachments = value; - this.changed(); - } - } - - /** - * Gets or sets the importance that should be stamped on incoming messages - * for the condition or exception to apply. - * To disable this predicate, set it to null. - */ - public Importance getImportance() { - return this.importance; - } - - public void setImportance(Importance value) { - if (this.canSetFieldValue(this.importance, value)) { - this.importance = value; - this.changed(); - } - } - - /** - * Gets or sets a value indicating whether incoming messages must be - * approval request for the condition or exception to apply. - */ - public boolean getIsApprovalRequest() { - return this.isApprovalRequest; - } - - public void setIsApprovalRequest(boolean value) { - if (this.canSetFieldValue(this.isApprovalRequest, value)) { - - this.isApprovalRequest = value; - this.changed(); - } - } - - /** - * Gets or sets a value indicating whether incoming messages must be - * automatic forwards for the condition or exception to apply. - */ - public boolean getIsAutomaticForward() { - return this.isAutomaticForward; - } - - public void setIsAutomaticForward(boolean value) { - if (this.canSetFieldValue(this.isAutomaticForward, value)) { - this.isAutomaticForward = value; - this.changed(); - } - } - - /** - * Gets or sets a value indicating whether incoming messages must be - * automatic replies for the condition or exception to apply. - */ - public boolean getIsAutomaticReply() { - return this.isAutomaticReply; - } - - public void setIsAutomaticReply(boolean value) { - if (this.canSetFieldValue(this.isAutomaticReply, value)) { - this.isAutomaticReply = value; - this.changed(); - } - } - - - /** - * Gets or sets a value indicating whether incoming messages must be - * S/MIME encrypted for the condition or exception to apply. - */ - public boolean getIsEncrypted() { - return this.isEncrypted; - } - - public void setIsEncrypted(boolean value) { - if (this.canSetFieldValue(this.isEncrypted, value)) { - this.isEncrypted = value; - this.changed(); - } - } - - /** - * Gets or sets a value indicating whether incoming messages must be - * meeting request for the condition or exception to apply. - */ - public boolean getIsMeetingRequest() { - return this.isMeetingRequest; - } - - public void setIsMeetingRequest(boolean value) { - if (this.canSetFieldValue(this.isEncrypted, value)) { - - this.isEncrypted = value; - this.changed(); - } - - } - - - /** - * Gets or sets a value indicating whether incoming messages must be - * meeting response for the condition or exception to apply. - */ - public boolean getIsMeetingResponse() { - - return this.isMeetingResponse; - } - - public void setIsMeetingResponse(boolean value) { - if (this.canSetFieldValue(this.isMeetingResponse, value)) { - this.isMeetingResponse = value; - this.changed(); - } - } - - /** - * Gets or sets a value indicating whether incoming messages must be - * non-delivery reports (NDR) for the condition or exception to apply. - */ - public boolean getIsNonDeliveryReport() { - return this.isNonDeliveryReport; - } - - public void setIsNonDeliveryReport(boolean value) { - if (this.canSetFieldValue(this.isNonDeliveryReport, value)) { - this.isNonDeliveryReport = value; - this.changed(); - } - } - - /** - * Gets or sets a value indicating whether incoming messages must be - * permission controlled (RMS protected) for the condition or exception - * to apply. - */ - public boolean getIsPermissionControlled() { - return this.isPermissionControlled; - } - - public void setIsPermissionControlled(boolean value) { - if (this.canSetFieldValue(this.isPermissionControlled, value)) { - this.isPermissionControlled = value; - this.changed(); - } - } - - - /** - * Gets or sets a value indicating whether incoming messages must be - * S/MIME signed for the condition or exception to apply. - */ - public boolean getIsSigned() { - return this.isSigned; - } - - public void setIsSigned(boolean value) { - if (this.canSetFieldValue(this.isSigned, value)) { - this.isSigned = value; - this.changed(); - } - } - - - /** - * Gets or sets a value indicating whether incoming messages must be - * voice mails for the condition or exception to apply. - */ - public boolean getIsVoicemail() { - return this.isVoicemail; - } - - public void setIsVoicemail(boolean value) { - if (this.canSetFieldValue(this.isVoicemail, value)) { - this.isVoicemail = value; - this.changed(); - } - } - - - /** - * Gets or sets a value indicating whether incoming messages must be - * read receipts for the condition or exception to apply. - */ - public boolean getIsReadReceipt() { - return this.isReadReceipt; - } - - public void setIsReadReceipt(boolean value) { - if (this.canSetFieldValue(this.isReadReceipt, value)) { - this.isReadReceipt = value; - this.changed(); - } - } - - /** - * Gets the e-mail account names from which incoming messages must have - * been aggregated for the condition or exception to apply. To disable - * this predicate, empty the list. - */ - public StringList getFromConnectedAccounts() { - return this.fromConnectedAccounts; - } - - /** - * Gets the item classes that must be stamped on incoming messages for - * the condition or exception to apply. To disable this predicate, - * empty the list. - */ - public StringList getItemClasses() { - return this.itemClasses; - } - - /** - * Gets the message classifications that - * must be stamped on incoming messages - * for the condition or exception to apply. To disable this predicate, - * empty the list. - */ - public StringList getMessageClassifications() { - - return this.messageClassifications; - - } - - /** - * Gets or sets a value indicating whether the owner of the mailbox must - * NOT be a To recipient of the incoming messages for the condition or - * exception to apply. - */ - - public boolean getNotSentToMe() { - return this.notSentToMe; - } - - public void setNotSentToMe(boolean value) { - if (this.canSetFieldValue(this.notSentToMe, value)) { - this.notSentToMe = value; - this.changed(); - } - } - - - /** - * Gets or sets a value indicating whether the owner of the mailbox must be - * a Cc recipient of incoming messages - * for the condition or exception to apply. - */ - public boolean getSentCcMe() { - return this.sentCcMe; - } - - public void setSentCcMe(boolean value) { - if (this.canSetFieldValue(this.sentCcMe, value)) { - this.sentCcMe = value; - this.changed(); - } - } - - - /** - * Gets or sets a value indicating whether the owner of the mailbox must be - * the only To recipient of incoming - * messages for the condition or exception - * to apply. - */ - public boolean getSentOnlyToMe() { - return this.sentOnlyToMe; - } - - public void setSentOnlyToMe(boolean value) { - if (this.canSetFieldValue(this.sentOnlyToMe, value)) { - this.sentOnlyToMe = value; - this.changed(); - } - } - - - /** - * Gets the e-mail addresses incoming messages must have been sent to for - * the condition or exception to apply. To disable this predicate, empty - * the list. - */ - public EmailAddressCollection getSentToAddresses() { - return this.sentToAddresses; - - } - - /** - * Gets or sets a value indicating whether the owner of the mailbox must be - * a To recipient of incoming messages - * for the condition or exception to apply. - */ - public boolean getSentToMe() { - return this.sentToMe; - } - - public void setSentToMe(boolean value) { - if (this.canSetFieldValue(this.sentToMe, value)) { - this.sentToMe = value; - this.changed(); - } - } - - - /** - * Gets or sets a value indicating whether the owner of the mailbox must be - * either a To or Cc recipient of incoming messages for the condition or - * exception to apply. - */ - public boolean getSentToOrCcMe() { - return this.sentToOrCcMe; - } - - public void setSentToOrCcMe(boolean value) { - if (this.canSetFieldValue(this.sentToOrCcMe, value)) { - this.sentToOrCcMe = value; - this.changed(); - } - } - - - /** - * Gets or sets the sensitivity that must be stamped on incoming messages - * for the condition or exception to apply. - * To disable this predicate, set it - * to null. - */ - public Sensitivity getSensitivity() { - return this.sensitivity; - } - - public void setSensitivity(Sensitivity value) { - if (this.canSetFieldValue(this.sensitivity, value)) { - this.sensitivity = value; - this.changed(); - } - } - - /** - * Gets the date range within which - * incoming messages must have been received - * for the condition or exception to apply. - * To disable this predicate, set both - * its Start and End property to null. - */ - public RulePredicateDateRange getWithinDateRange() { - return this.withinDateRange; - - } - - /** - * Gets the minimum and maximum sizes incoming messages must have for the - * condition or exception to apply. To disable this predicate, set both its - * MinimumSize and MaximumSize property to null. - */ - public RulePredicateSizeRange getWithinSizeRange() { - return this.withinSizeRange; - - } - - /** - * Tries to read element from XML. - * - * @param reader The reader - * @return True if element was read. - * @throws Exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader - reader) throws Exception { - - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Categories)) { - this.categories.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsBodyStrings)) { - this.containsBodyStrings.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsHeaderStrings)) { - this.containsHeaderStrings.loadFromXml(reader, - reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsRecipientStrings)) { - this.containsRecipientStrings.loadFromXml(reader, - reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsSenderStrings)) { - this.containsSenderStrings.loadFromXml(reader, - reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsSubjectOrBodyStrings)) { - this.containsSubjectOrBodyStrings.loadFromXml(reader, - reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsSubjectStrings)) { - this.containsSubjectStrings.loadFromXml(reader, - reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.FlaggedForAction)) { - this.flaggedForAction = reader. - readElementValue(FlaggedForAction.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.FromAddresses)) { - this.fromAddresses.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.FromConnectedAccounts)) { - this.fromConnectedAccounts.loadFromXml(reader, - reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.HasAttachments)) { - this.hasAttachments = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Importance)) { - this.importance = reader.readElementValue(Importance.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsApprovalRequest)) { - this.isApprovalRequest = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsAutomaticForward)) { - this.isAutomaticForward = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsAutomaticReply)) { - this.isAutomaticReply = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsEncrypted)) { - this.isEncrypted = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsMeetingRequest)) { - this.isMeetingRequest = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsMeetingResponse)) { - this.isMeetingResponse = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsNDR)) { - this.isNonDeliveryReport = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsPermissionControlled)) { - this.isPermissionControlled = reader. - readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsSigned)) { - this.isSigned = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsVoicemail)) { - this.isVoicemail = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsReadReceipt)) { - this.isReadReceipt = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ItemClasses)) { - this.itemClasses.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.MessageClassifications)) { - this.messageClassifications.loadFromXml(reader, - reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.NotSentToMe)) { - this.notSentToMe = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentCcMe)) { - this.sentCcMe = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentOnlyToMe)) { - this.sentOnlyToMe = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentToAddresses)) { - this.sentToAddresses.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentToMe)) { - this.sentToMe = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentToOrCcMe)) { - this.sentToOrCcMe = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Sensitivity)) { - this.sensitivity = reader.readElementValue(Sensitivity.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.WithinDateRange)) { - this.withinDateRange.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.WithinSizeRange)) { - this.withinSizeRange.loadFromXml(reader, reader.getLocalName()); - return true; - } else { - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer The writer. - * @throws Exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - if (this.getCategories().getSize() > 0) { - this.getCategories().writeToXml(writer, XmlElementNames.Categories); - } - - if (this.getContainsBodyStrings().getSize() > 0) { - this.getContainsBodyStrings().writeToXml(writer, - XmlElementNames.ContainsBodyStrings); - } - - if (this.getContainsHeaderStrings().getSize() > 0) { - this.getContainsHeaderStrings().writeToXml(writer, - XmlElementNames.ContainsHeaderStrings); - } - - if (this.getContainsRecipientStrings().getSize() > 0) { - this.getContainsRecipientStrings().writeToXml(writer, - XmlElementNames.ContainsRecipientStrings); - } - - if (this.getContainsSenderStrings().getSize() > 0) { - this.getContainsSenderStrings().writeToXml(writer, - XmlElementNames.ContainsSenderStrings); - } - - if (this.getContainsSubjectOrBodyStrings().getSize() > 0) { - this.getContainsSubjectOrBodyStrings().writeToXml(writer, - XmlElementNames.ContainsSubjectOrBodyStrings); - } - - if (this.getContainsSubjectStrings().getSize() > 0) { - this.getContainsSubjectStrings().writeToXml(writer, - XmlElementNames.ContainsSubjectStrings); - } - - if (this.getFlaggedForAction() != null) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.FlaggedForAction, - this.getFlaggedForAction().values()); - } - - if (this.getFromAddresses().getCount() > 0) { - this.getFromAddresses().writeToXml(writer, - XmlElementNames.FromAddresses); - } - - if (this.getFromConnectedAccounts().getSize() > 0) { - this.getFromConnectedAccounts().writeToXml(writer, - XmlElementNames.FromConnectedAccounts); - } - - if (this.getHasAttachments() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.HasAttachments, - this.getHasAttachments()); - } - - if (this.getImportance() != null) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.Importance, - this.getImportance()); - } - - if (this.getIsApprovalRequest() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsApprovalRequest, - this.getIsApprovalRequest()); - } - - if (this.getIsAutomaticForward() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsAutomaticForward, - this.getIsAutomaticForward()); - } - - if (this.getIsAutomaticReply() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsAutomaticReply, - this.getIsAutomaticReply()); - } - - if (this.getIsEncrypted() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsEncrypted, - this.getIsEncrypted()); - } - - if (this.getIsMeetingRequest() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsMeetingRequest, - this.getIsMeetingRequest()); - } - - if (this.getIsMeetingResponse() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsMeetingResponse, - this.getIsMeetingResponse()); - } - - if (this.getIsNonDeliveryReport() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsNDR, - this.getIsNonDeliveryReport()); - } - - if (this.getIsPermissionControlled() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsPermissionControlled, - this.getIsPermissionControlled()); - } - - if (this.getIsReadReceipt() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsReadReceipt, - this.getIsReadReceipt()); - } - - if (this.getIsSigned() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsSigned, - this.getIsSigned()); - } - - if (this.getIsVoicemail() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.IsVoicemail, - this.getIsVoicemail()); - } - - if (this.getItemClasses().getSize() > 0) { - this.getItemClasses().writeToXml(writer, - XmlElementNames.ItemClasses); - } - - if (this.getMessageClassifications().getSize() > 0) { - this.getMessageClassifications().writeToXml(writer, - XmlElementNames.MessageClassifications); - } - - if (this.getNotSentToMe() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.NotSentToMe, - this.getNotSentToMe()); - } - - if (this.getSentCcMe() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.SentCcMe, - this.getSentCcMe()); - } - - if (this.getSentOnlyToMe() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.SentOnlyToMe, - this.getSentOnlyToMe()); - } - - if (this.getSentToAddresses().getCount() > 0) { - this.getSentToAddresses().writeToXml(writer, - XmlElementNames.SentToAddresses); - } - - if (this.getSentToMe() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.SentToMe, - this.getSentToMe()); - } - - if (this.getSentToOrCcMe() != false) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.SentToOrCcMe, - this.getSentToOrCcMe()); - } - - if (this.getSensitivity() != null) { - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.Sensitivity, - this.getSensitivity().values()); - } - - if (this.getWithinDateRange().getStart() != null || this.getWithinDateRange().getEnd() != null) { - this.getWithinDateRange().writeToXml(writer, - XmlElementNames.WithinDateRange); - } - - if (this.getWithinSizeRange().getMaximumSize() != null - || this.getWithinSizeRange().getMinimumSize() != null) { - this.getWithinSizeRange().writeToXml(writer, - XmlElementNames.WithinSizeRange); - } - } - - /** - * Validates this instance. - */ - @Override - protected void internalValidate() throws Exception { - super.internalValidate(); - EwsUtilities.validateParam(this.fromAddresses, "FromAddresses"); - EwsUtilities.validateParam(this.sentToAddresses, "SentToAddresses"); - EwsUtilities.validateParam(this.withinDateRange, "WithinDateRange"); - EwsUtilities.validateParam(this.withinSizeRange, "WithinSizeRange"); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/SearchFolderParameters.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/SearchFolderParameters.java deleted file mode 100644 index cbcf808c8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/SearchFolderParameters.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.search.SearchFolderTraversal; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.search.filter.SearchFilter; - -/** - * Represents the parameters associated with a search folder. - */ -public final class SearchFolderParameters extends ComplexProperty implements IComplexPropertyChangedDelegate { - - /** - * The traversal. - */ - private SearchFolderTraversal traversal; - - /** - * The root folder ids. - */ - private FolderIdCollection rootFolderIds = new FolderIdCollection(); - - /** - * The search filter. - */ - private SearchFilter searchFilter; - - /** - * Initializes a new instance of the SearchFolderParameters class. - */ - public SearchFolderParameters() { - super(); - this.rootFolderIds.addOnChangeEvent(this); - } - - /** - * Complex property changed. - * - * @param complexProperty the complex property - */ - @Override - public void complexPropertyChanged(ComplexProperty complexProperty) { - this.propertyChanged(complexProperty); - } - - /** - * Property changed. - * - * @param complexProperty the complex property - */ - private void propertyChanged(ComplexProperty complexProperty) { - this.changed(); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.BaseFolderIds)) { - this.rootFolderIds.internalClear(); - this.rootFolderIds.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.Restriction)) { - reader.read(); - this.searchFilter = SearchFilter.loadFromXml(reader); - return true; - } else { - return false; - } - } - - /** - * Reads the attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.traversal = reader.readAttributeValue(SearchFolderTraversal.class, - XmlAttributeNames.Traversal); - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.Traversal, this.traversal); - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - if (this.searchFilter != null) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.Restriction); - this.searchFilter.writeToXml(writer); - writer.writeEndElement(); // Restriction - } - - this.rootFolderIds.writeToXml(writer, XmlElementNames.BaseFolderIds); - } - - /** - * Validates this instance. - * - * @throws Exception - */ - public void validate() throws Exception { - // Search folder must have at least one root folder id. - if (this.rootFolderIds.getCount() == 0) { - throw new ServiceValidationException("SearchParameters must contain at least one folder id."); - } - - // Validate the search filter - if (this.searchFilter != null) { - this.searchFilter.internalValidate(); - } - } - - /** - * Gets the traversal mode for the search folder. - * - * @return the traversal - */ - public SearchFolderTraversal getTraversal() { - return traversal; - } - - /** - * Sets the traversal. - * - * @param traversal the new traversal - */ - public void setTraversal(SearchFolderTraversal traversal) { - if (this.canSetFieldValue(this.traversal, traversal)) { - this.traversal = traversal; - this.changed(); - } - } - - /** - * Gets the list of root folder the search folder searches in. - * - * @return the root folder ids - */ - public FolderIdCollection getRootFolderIds() { - return rootFolderIds; - } - - /** - * Gets the search filter associated with the search folder. - * Available search filter classes include SearchFilter.IsEqualTo, - * SearchFilter.ContainsSubstring and SearchFilter.SearchFilterCollection. - * - * @return the search filter - */ - public SearchFilter getSearchFilter() { - return searchFilter; - } - - /** - * Sets the search filter. - * - * @param searchFilter the new search filter - */ - public void setSearchFilter(SearchFilter searchFilter) { - - if (this.searchFilter != null) { - this.searchFilter.removeChangeEvent(this); - } - - if (this.canSetFieldValue(this.searchFilter, searchFilter)) { - this.searchFilter = searchFilter; - this.changed(); - } - if (this.searchFilter != null) { - this.searchFilter.addOnChangeEvent(this); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/ServiceId.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/ServiceId.java deleted file mode 100644 index be673debf..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/ServiceId.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import org.apache.commons.lang3.StringUtils; - -/** - * Represents the Id of an Exchange object. - */ -public abstract class ServiceId extends ComplexProperty { - - /** - * The change key. - */ - private String changeKey; - - /** - * The unique id. - */ - private String uniqueId; - - /** - * Initializes a new instance. - */ - public ServiceId() { - super(); - } - - /** - * Initializes a new instance. - * - * @param uniqueId The unique id. - * @throws Exception the exception - */ - public ServiceId(String uniqueId) throws Exception { - this(); - EwsUtilities.validateParam(uniqueId, "uniqueId"); - this.uniqueId = uniqueId; - } - - /** - * Read attribute from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - @Override - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.uniqueId = reader.readAttributeValue(XmlAttributeNames.Id); - this.changeKey = reader.readAttributeValue(XmlAttributeNames.ChangeKey); - - } - - /** - * Writes attribute to XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.Id, this.getUniqueId()); - writer.writeAttributeValue(XmlAttributeNames.ChangeKey, this - .getChangeKey()); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - public abstract String getXmlElementName(); - - /** - * Writes to XML. - * - * @param writer The writer. - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer) throws Exception { - this.writeToXml(writer, this.getXmlElementName()); - } - - /** - * Assigns from existing id. - * - * @param source The source. - */ - public void assign(ServiceId source) { - this.uniqueId = source.getUniqueId(); - this.changeKey = source.getChangeKey(); - } - - /** - * True if this instance is valid, false otherthise. - * - * @return true if this instance is valid; otherwise,false - */ - public boolean isValid() { - return (null != this.uniqueId && !this.uniqueId.isEmpty()); - } - - /** - * Gets the unique Id of the Exchange object. - * - * @return unique Id of the Exchange object. - */ - public String getUniqueId() { - return uniqueId; - } - - /** - * Sets the unique Id of the Exchange object. - * - * @param uniqueId unique Id of the Exchange object. - */ - public void setUniqueId(String uniqueId) { - this.uniqueId = uniqueId; - } - - /** - * Gets the change key associated with the Exchange object. The change key - * represents the version of the associated item or folder. - * - * @return change key associated with the Exchange object. - */ - public String getChangeKey() { - return changeKey; - } - - /** - * Sets the change key associated with the Exchange object. The change key - * represents the version of the associated item or folder. - * - * @param changeKey change key associated with the Exchange object. - */ - public void setChangeKey(String changeKey) { - this.changeKey = changeKey; - } - - /** - * Determines whether two ServiceId instances are equal (including - * ChangeKeys). - * - * @param other The ServiceId to compare with the current ServiceId. - * @return true if equal otherwise false. - */ - public boolean sameIdAndChangeKey(final ServiceId other) { - return this.equals(other) && StringUtils.equals(this.getChangeKey(), other.getChangeKey()); - } - - /** - * Determines whether the specified instance is equal to the current - * instance. We do not consider the ChangeKey for ServiceId.Equals. - * - * @param obj The object to compare with the current instance - * @return true if the specified object is equal to the current instance, - * otherwise, false. - */ - @Override - public boolean equals(Object obj) { - if (super.equals(obj)) { - return true; - } else { - if (!(obj instanceof ServiceId)) { - return false; - } else { - ServiceId other = (ServiceId) obj; - if (!(this.isValid() && other.isValid())) { - return false; - } else { - return this.getUniqueId().equals(other.getUniqueId()); - } - } - } - } - - /** - * Serves as a hash function for a particular type. We do not consider the - * change key in the hash code computation. - * - * @return A hash code for the current - */ - @Override - public int hashCode() { - return this.isValid() ? this.getUniqueId().hashCode() : super - .hashCode(); - } - - /** - * Returns a string that represents the current instance. - * - * @return A string that represents the current instance. - */ - @Override - public String toString() { - return (this.uniqueId == null) ? "" : this.uniqueId; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/SetRuleOperation.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/SetRuleOperation.java deleted file mode 100644 index 49d551891..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/SetRuleOperation.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; - -/** - * Represents an operation to update an existing rule. - */ -public class SetRuleOperation extends RuleOperation { - /** - * Inbox rule to be updated. - */ - private Rule rule; - - /** - * Initializes a new instance of the SetRuleOperation class. - */ - public SetRuleOperation() { - super(); - } - - /** - * Initializes a new instance of the SetRuleOperation class. - * - * @param rule The rule - * The inbox rule to update. - */ - public SetRuleOperation(Rule rule) { - super(); - this.rule = rule; - } - - /** - * Gets the rule to be updated. - */ - public Rule getRule() { - return this.rule; - } - - /** - * Sets the rule to be updated. - */ - public void setRule(Rule value) { - if (this.canSetFieldValue(this.rule, value)) { - this.rule = value; - this.changed(); - } - } - - /** - * Tries to read element from XML. - * - * @param reader The reader - * @return True if element was read. - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.Rule)) { - this.rule = new Rule(); - this.rule.loadFromXml(reader, reader.getLocalName()); - return true; - } else { - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer The writer. - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.rule.writeToXml(writer, XmlElementNames.Rule); - } - - /** - * Validates this instance. - * - * @throws Exception - */ - @Override - protected void internalValidate() throws Exception { - EwsUtilities.validateParam(this.rule, "Rule"); - } - - /** - * Gets the Xml element name of the SetRuleOperation object. - */ - @Override public String getXmlElementName() { - return XmlElementNames.SetRuleOperation; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/StringList.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/StringList.java deleted file mode 100644 index 6268d3fab..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/StringList.java +++ /dev/null @@ -1,347 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Represents a list of strings. - */ -public class StringList extends ComplexProperty implements Iterable { - - /** - * The item. - */ - private List items = new ArrayList(); - - /** - * The item xml element name. - */ - private String itemXmlElementName = XmlElementNames.String; - - /** - * Initializes a new instance of the "StringList" class. - */ - public StringList() { - } - - /** - * Initializes a new instance of the class. - * - * @param strings The strings. - */ - public StringList(Iterable strings) { - this.addRange(strings); - } - - /** - * Initializes a new instance of the "StringList" class. - * - * @param itemXmlElementName Name of the item XML element. - */ - public StringList(String itemXmlElementName) { - this.itemXmlElementName = itemXmlElementName; - } - - /** - * Tries to read element from XML. - * - * @param reader accepts EwsServiceXmlReader - * @return True if element was read - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlDeserializationException the service xml deserialization exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws XMLStreamException, ServiceXmlDeserializationException { - boolean returnValue = false; - if (reader.getLocalName().equals(this.itemXmlElementName)) { - if (!reader.isEmptyElement()) { - this.add(reader.readValue()); - returnValue = true; - } else { - reader.read(); - - returnValue = true; - } - - } - return returnValue; - } - - /** - * Writes elements to XML. - * - * @param writer accepts EwsServiceXmlWriter - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws XMLStreamException the XML stream exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - for (String item : this.items) { - writer.writeStartElement(XmlNamespace.Types, - this.itemXmlElementName); - writer.writeValue(item, this.itemXmlElementName); - writer.writeEndElement(); - } - } - - /** - * Adds a string to the list. - * - * @param s The string to add. - */ - public void add(String s) { - this.items.add(s); - this.changed(); - } - - /** - * Adds multiple strings to the list. - * - * @param strings The strings to add. - */ - public void addRange(Iterable strings) { - boolean changed = false; - - for (String s : strings) { - if (!this.contains(s)) { - this.items.add(s); - changed = true; - } - } - if (changed) { - this.changed(); - } - } - - /** - * Determines whether the list contains a specific string. - * - * @param s The string to check the presence of. - * @return True if s is present in the list, false otherwise. - */ - public boolean contains(String s) { - return this.items.contains(s); - } - - /** - * Removes a string from the list. - * - * @param s The string to remove. - * @return True is s was removed, false otherwise. - */ - public boolean remove(String s) { - boolean result = this.items.remove(s); - if (result) { - this.changed(); - } - return result; - } - - /** - * Removes the string at the specified position from the list. - * - * @param index The index of the string to remove. - */ - public void removeAt(int index) { - if (index < 0 || index >= this.getSize()) { - throw new ArrayIndexOutOfBoundsException("index is out of range."); - } - this.items.remove(index); - this.changed(); - } - - /** - * Clears the list. - */ - public void clearList() { - this.items.clear(); - this.changed(); - } - - /** - * Returns a string representation of the object. In general, the - * toString method returns a string that "textually represents" - * this object. The result should be a concise but informative - * representation that is easy for a person to read. It is recommended that - * all subclasses override this method. - *

- * The toString method for class Object returns a - * string consisting of the name of the class of which the object is an - * instance, the at-sign character `@', and the unsigned - * hexadecimal representation of the hash code of the object. In other - * words, this method returns a string equal to the value of:

- *

- *

-   * getClass().getName() + '@' + Integer.toHexString(hashCode())
-   * 
- *

- *

- * - * @return a string representation of the object. - */ - @Override - public String toString() { - StringBuffer temp = new StringBuffer(); - for (String str : this.items) { - temp.append(str.concat(",")); - } - String tempString = temp.toString(); - return tempString; - } - - /** - * Gets the number of strings in the list. - * - * @return the size - */ - public int getSize() { - return this.items.size(); - } - - /** - * Gets the string at the specified index. - * - * @param index The index of the string to get or set. - * @return The string at the specified index. - */ - public String getString(int index) { - if (index < 0 || index >= this.getSize()) { - throw new ArrayIndexOutOfBoundsException("index is out of range."); - } - return this.items.get(index); - } - - /** - * Sets the string at the specified index. - * - * @param index The index - * @param object The object. - */ - public void setString(int index, Object object) { - if (index < 0 || index >= this.getSize()) { - throw new ArrayIndexOutOfBoundsException("index is out of range."); - } - - if (this.items.get(index) != object) { - this.items.set(index, (String) object); - this.changed(); - } - } - - /** - * Gets an iterator that iterates through the elements of the collection. - * - * @return An Iterator for the collection. - */ - public Iterator getIterator() { - return this.items.iterator(); - } - - /** - * Indicates whether some other object is "equal to" this one. - *

- * The equals method implements an equivalence relation on - * non-null object references: - *

    - *
  • It is reflexive: for any non-null reference value - * x, x.equals(x) should return true. - *
  • It is symmetric: for any non-null reference values - * x and y, x.equals(y) should return - * true if and only if y.equals(x) returns - * true. - *
  • It is transitive: for any non-null reference values - * x, y, and z, if - * x.equals(y) returns true and - * y.equals(z) returns true, then - * x.equals(z) should return true. - *
  • It is consistent: for any non-null reference values - * x and y, multiple invocations of - * x.equals(y) consistently return true or - * consistently return false, provided no information used in - * equals comparisons on the objects is modified. - *
  • For any non-null reference value x, - * x.equals(null) should return false. - *
- *

- * The equals method for class Object implements the - * most discriminating possible equivalence relation on objects; that is, - * for any non-null reference values x and y, this - * method returns true if and only if x and - * y refer to the same object (x == y has the - * value true). - *

- * Note that it is generally necessary to override the hashCode - * method whenever this method is overridden, so as to maintain the general - * contract for the hashCode method, which states that equal - * objects must have equal hash codes. - * - * @param obj the reference object with which to compare. - * @return if this object is the same as the obj argument; otherwise. - * @see #hashCode() - * @see java.util.Hashtable - */ - @Override - public boolean equals(Object obj) { - if (obj instanceof StringList) { - StringList other = (StringList) obj; - return this.toString().equals(other.toString()); - } else { - return false; - } - } - - /** - * Serves as a hash function for a particular type. - * - * @return A hash code for the current "T:System.Object". - */ - @Override - public int hashCode() { - return this.toString().hashCode(); - } - - /** - * Returns an iterator over a set of elements of type T. - * - * @return an Iterator. - */ - @Override - public Iterator iterator() { - return items.iterator(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/TimeChange.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/TimeChange.java deleted file mode 100644 index b1186cf73..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/TimeChange.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.Time; -import microsoft.exchange.webservices.data.misc.TimeSpan; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; - -import javax.xml.bind.DatatypeConverter; - -/** - * Represents a change of time for a time zone. - */ -public final class TimeChange extends ComplexProperty { - - private static final Log LOG = LogFactory.getLog(TimeChange.class); - - /** - * The time zone name. - */ - private String timeZoneName; - - /** - * The offset. - */ - private TimeSpan offset; - - /** - * The time. - */ - private Time time; - - /** - * The absolute date. - */ - private Date absoluteDate; - - /** - * The recurrence. - */ - private TimeChangeRecurrence recurrence; - - /** - * Initializes a new instance of the "TimeChange" class. - */ - public TimeChange() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param offset The offset since the beginning of the year when the change - * occurs. - */ - public TimeChange(TimeSpan offset) { - this(); - this.offset = offset; - } - - /** - * Initializes a new instance of the "TimeChange" class. - * - * @param offset The offset since the beginning of the year when the change - * occurs. - * @param time The time at which the change occurs. - */ - public TimeChange(TimeSpan offset, Time time) { - this(offset); - this.time = time; - } - - /** - * Gets the name of the associated time zone. - * - * @return the timeZoneName - */ - public String getTimeZoneName() { - return timeZoneName; - } - - /** - * Sets the name of the associated time zone. - * - * @param timeZoneName the timeZoneName to set - */ - public void setTimeZoneName(String timeZoneName) { - this.timeZoneName = timeZoneName; - } - - /** - * Gets the offset since the beginning of the year when the change occurs. - * - * @return the offset - */ - public TimeSpan getOffset() { - return offset; - } - - /** - * Sets the offset since the beginning of the year when the change occurs. - * - * @param offset the offset to set - */ - public void setOffset(TimeSpan offset) { - this.offset = offset; - } - - /** - * Gets the time. - * - * @return the time - */ - public Time getTime() { - return time; - } - - /** - * Sets the time. - * - * @param time the time to set - */ - public void setTime(Time time) { - this.time = time; - } - - /** - * Gets the absolute date. - * - * @return the absoluteDate - */ - public Date getAbsoluteDate() { - return absoluteDate; - } - - /** - * Sets the absolute date. - * - * @param absoluteDate the absoluteDate to set - */ - public void setAbsoluteDate(Date absoluteDate) { - this.absoluteDate = absoluteDate; - if (absoluteDate != null) { - this.recurrence = null; - } - } - - /** - * Gets the recurrence. - * - * @return the recurrence - */ - public TimeChangeRecurrence getRecurrence() { - return recurrence; - } - - /** - * Sets the recurrence. - * - * @param recurrence the recurrence to set - */ - public void setRecurrence(TimeChangeRecurrence recurrence) { - this.recurrence = recurrence; - if (this.recurrence != null) { - this.absoluteDate = null; - } - } - - /** - * Tries to read element from XML. - * - * @param reader accepts EwsServiceXmlReader - * @return True if element was read - * @throws Exception throws Exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Offset)) { - this.offset = EwsUtilities.getXSDurationToTimeSpan(reader.readElementValue()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.RelativeYearlyRecurrence)) { - this.recurrence = new TimeChangeRecurrence(); - this.recurrence.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.AbsoluteDate)) { - Calendar cal = DatatypeConverter.parseDate(reader.readElementValue()); - cal.setTimeZone(TimeZone.getTimeZone("UTC")); - this.absoluteDate = cal.getTime(); - return true; - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Time)) { - Calendar cal = DatatypeConverter.parseTime(reader.readElementValue()); - this.time = new Time(cal.getTime()); - return true; - } else { - return false; - } - } - - /** - * Reads the attribute from XML. - * - * @param reader accepts EwsServiceXmlReader - * @throws Exception throws Exception - */ - @Override - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.timeZoneName = reader - .readAttributeValue(XmlAttributeNames.TimeZoneName); - } - - /** - * Writes the attribute to XML. - * - * @param writer accepts EwsServiceXmlWriter - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) { - try { - writer.writeAttributeValue(XmlAttributeNames.TimeZoneName, - this.timeZoneName); - } catch (ServiceXmlSerializationException e) { - LOG.error(e); - } - } - - /** - * Writes elements to XML. - * - * @param writer accepts EwsServiceXmlWriter - * @throws Exception throws Exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - if (this.offset != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.Offset, EwsUtilities - .getTimeSpanToXSDuration(this.getOffset())); - } - - if (this.recurrence != null) { - this.recurrence.writeToXml(writer, - XmlElementNames.RelativeYearlyRecurrence); - } - - if (this.absoluteDate != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.AbsoluteDate, EwsUtilities - .dateTimeToXSDate(this.getAbsoluteDate())); - } - - if (this.time != null) { - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Time, - this.getTime().toXSTime()); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/TimeChangeRecurrence.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/TimeChangeRecurrence.java deleted file mode 100644 index 91ddfe369..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/TimeChangeRecurrence.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.time.DayOfTheWeek; -import microsoft.exchange.webservices.data.core.enumeration.property.time.DayOfTheWeekIndex; -import microsoft.exchange.webservices.data.core.enumeration.property.time.Month; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents a recurrence pattern for a time change in a time zone. - */ -final class TimeChangeRecurrence extends ComplexProperty { - - /** - * The day of the week. - */ - private DayOfTheWeek dayOfTheWeek; - - /** - * The day of the week index. - */ - private DayOfTheWeekIndex dayOfTheWeekIndex; - - /** - * The month. - */ - private Month month; - - /** - * Initializes a new instance of the TimeChangeRecurrence class. - */ - public TimeChangeRecurrence() { - super(); - } - - /** - * Initializes a new instance of the TimeChangeRecurrence class. - * - * @param dayOfTheWeekIndex the day of the week index - * @param dayOfTheWeek the day of the week - * @param month the month - */ - public TimeChangeRecurrence(DayOfTheWeekIndex dayOfTheWeekIndex, - DayOfTheWeek dayOfTheWeek, Month month) { - this(); - this.dayOfTheWeekIndex = dayOfTheWeekIndex; - this.dayOfTheWeek = dayOfTheWeek; - this.month = month; - } - - /** - * Gets the day of the week the time change occurs. - * - * @return the day of the week - */ - public DayOfTheWeek getDayOfTheWeek() { - return dayOfTheWeek; - } - - /** - * Sets the day of the week. - * - * @param dayOfTheWeek the new day of the week - */ - public void setDayOfTheWeek(DayOfTheWeek dayOfTheWeek) { - if (this.canSetFieldValue(this.dayOfTheWeek, dayOfTheWeek)) { - this.dayOfTheWeek = dayOfTheWeek; - this.changed(); - } - } - - /** - * Gets the index of the day in the month at which the time change - * occurs. - * - * @return the day of the week index - */ - public DayOfTheWeekIndex getDayOfTheWeekIndex() { - return dayOfTheWeekIndex; - } - - /** - * Sets the day of the week index. - * - * @param dayOfTheWeekIndex the new day of the week index - */ - public void setDayOfTheWeekIndex(DayOfTheWeekIndex dayOfTheWeekIndex) { - if (this.canSetFieldValue(this.dayOfTheWeekIndex, dayOfTheWeekIndex)) { - this.dayOfTheWeekIndex = dayOfTheWeekIndex; - this.changed(); - } - } - - /** - * Gets the month the time change occurs. - * - * @return the month - */ - public Month getMonth() { - return month; - } - - /** - * Sets the month. - * - * @param month the new month - */ - public void setMonth(Month month) { - if (this.canSetFieldValue(this.month, month)) { - this.month = month; - this.changed(); - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - if (this.dayOfTheWeek != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.DaysOfWeek, this.dayOfTheWeek); - } - - if (this.dayOfTheWeekIndex != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.DayOfWeekIndex, this.dayOfTheWeekIndex); - } - - if (this.month != null) { - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Month, - this.month); - } - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.DaysOfWeek)) { - - this.dayOfTheWeek = reader.readElementValue(DayOfTheWeek.class); - return true; - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.DayOfWeekIndex)) { - this.dayOfTheWeekIndex = reader - .readElementValue(DayOfTheWeekIndex.class); - return true; - } else if (reader.getLocalName() - .equalsIgnoreCase(XmlElementNames.Month)) { - this.month = reader.readElementValue(Month.class); - return true; - } else { - return false; - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/UniqueBody.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/UniqueBody.java deleted file mode 100644 index 93c5874ce..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/UniqueBody.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.BodyType; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents the body part of an item that is unique to the conversation the - * item is part of. - */ -public final class UniqueBody extends ComplexProperty { - - /** - * The body type. - */ - private BodyType bodyType; - - /** - * The text. - */ - private String text; - - /** - * Initializes a new instance. - */ - public UniqueBody() { - } - - /** - * Defines an implicit conversion of UniqueBody into a string. - * - * @param messageBody the message body - * @return string containing the text of the UniqueBody - * @throws Exception the exception - */ - public static String getStringFromUniqueBody(UniqueBody messageBody) - throws Exception { - EwsUtilities.validateParam(messageBody, "messageBody"); - return messageBody.text; - } - - /** - * Reads attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.bodyType = reader.readAttributeValue(BodyType.class, - XmlAttributeNames.BodyType); - } - - /** - * Reads attribute from XML. - * - * @param reader the reader - * @throws XMLStreamException the xml stream exception - * @throws ServiceXmlDeserializationException the service xml deserialization exception - */ - public void readTextValueFromXml(EwsServiceXmlReader reader) - throws XMLStreamException, ServiceXmlDeserializationException { - this.text = reader.readValue(); - } - - /** - * Writes attributes from XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.BodyType, this.bodyType); - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - if (!(this.text == null || this.text.isEmpty())) { - writer.writeValue(this.text, XmlElementNames.UniqueBody); - } - } - - /** - * Gets the type of the unique body's text. - * - * @return bodytype - */ - public BodyType getBodyType() { - return this.bodyType; - } - - /** - * Gets the text of the unique body. - * - * @return text - */ - public String getText() { - return this.text; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return (this.getText() == null) ? "" : this.getText(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/UserConfigurationDictionary.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/UserConfigurationDictionary.java deleted file mode 100644 index 6eaee6997..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/UserConfigurationDictionary.java +++ /dev/null @@ -1,743 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.property.UserConfigurationDictionaryObjectType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.util.DateTimeUtils; -import org.apache.commons.codec.binary.Base64; - -import javax.xml.stream.XMLStreamException; - -import java.lang.reflect.Array; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -/** - * Represents a user configuration's Dictionary property. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public final class UserConfigurationDictionary extends ComplexProperty - implements Iterable { - - // TODO: Consider implementing IsDirty mechanism in ComplexProperty. - - /** - * The dictionary. - */ - private Map dictionary; - - /** - * The is dirty. - */ - private boolean isDirty = false; - - /** - * Initializes a new instance of "UserConfigurationDictionary" class. - */ - public UserConfigurationDictionary() { - super(); - this.dictionary = new HashMap(); - } - - /** - * Gets the element with the specified key. - * - * @param key The key of the element to get or set. - * @return The element with the specified key. - */ - public Object getElements(Object key) { - return this.dictionary.get(key); - } - - /** - * Sets the element with the specified key. - * - * @param key The key of the element to get or set - * @param value the value - * @throws Exception the exception - */ - public void setElements(Object key, Object value) throws Exception { - this.validateEntry(key, value); - this.dictionary.put(key, value); - this.changed(); - } - - /** - * Adds an element with the provided key and value to the user configuration - * dictionary. - * - * @param key The object to use as the key of the element to add. - * @param value The object to use as the value of the element to add. - * @throws Exception the exception - */ - public void addElement(Object key, Object value) throws Exception { - this.validateEntry(key, value); - this.dictionary.put(key, value); - this.changed(); - } - - /** - * Determines whether the user configuration dictionary contains an element - * with the specified key. - * - * @param key The key to locate in the user configuration dictionary. - * @return true if the user configuration dictionary contains an element - * with the key; otherwise false. - */ - public boolean containsKey(Object key) { - return this.dictionary.containsKey(key); - } - - /** - * Removes the element with the specified key from the user configuration - * dictionary. - * - * @param key The key of the element to remove. - * @return true if the element is successfully removed; otherwise false. - */ - public boolean remove(Object key) { - boolean isRemoved = false; - if (key != null) { - this.dictionary.remove(key); - isRemoved = true; - } - - if (isRemoved) { - this.changed(); - } - - return isRemoved; - } - - /** - * Gets the value associated with the specified key. - * - * @param key The key whose value to get. - * @param value When this method returns, the value associated with the - * specified key, if the key is found; otherwise, null. - * @return true if the user configuration dictionary contains the key; - * otherwise false. - */ - public boolean tryGetValue(Object key, OutParam value) { - if (this.dictionary.containsKey(key)) { - value.setParam(this.dictionary.get(key)); - return true; - } else { - value.setParam(null); - return false; - } - - } - - /** - * Gets the number of elements in the user configuration dictionary. - * - * @return the count - */ - public int getCount() { - return this.dictionary.size(); - } - - /** - * Removes all item from the user configuration dictionary. - */ - public void clear() { - if (this.dictionary.size() != 0) { - this.dictionary.clear(); - - this.changed(); - } - } - - /** - * Gets the enumerator. - * - * @return the enumerator - */ - - /** - * Returns an enumerator that iterates through - * the user configuration dictionary. - * - * @return An IEnumerator that can be used - * to iterate through the user configuration dictionary. - */ - public Iterator getEnumerator() { - return (this.dictionary.values().iterator()); - } - - /** - * Gets the isDirty flag. - * - * @return the checks if is dirty - */ - public boolean getIsDirty() { - return this.isDirty; - } - - /** - * Sets the isDirty flag. - * - * @param value the new checks if is dirty - */ - public void setIsDirty(boolean value) { - this.isDirty = value; - } - - /** - * Instance was changed. - */ - @Override public void changed() { - super.changed(); - this.isDirty = true; - } - - /** - * Writes elements to XML. - * - * @param writer accepts EwsServiceXmlWriter - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - EwsUtilities.ewsAssert(writer != null, "UserConfigurationDictionary.WriteElementsToXml", "writer is null"); - Iterator> it = this.dictionary.entrySet() - .iterator(); - while (it.hasNext()) { - Entry dictionaryEntry = it.next(); - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.DictionaryEntry); - this.writeObjectToXml(writer, XmlElementNames.DictionaryKey, - dictionaryEntry.getKey()); - this.writeObjectToXml(writer, XmlElementNames.DictionaryValue, - dictionaryEntry.getValue()); - writer.writeEndElement(); - } - } - - /** - * Writes a dictionary object (key or value) to Xml. - * - * @param writer the writer - * @param xmlElementName the Xml element name - * @param dictionaryObject the object to write - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - private void writeObjectToXml(EwsServiceXmlWriter writer, - String xmlElementName, Object dictionaryObject) - throws XMLStreamException, ServiceXmlSerializationException { - EwsUtilities.ewsAssert(writer != null, "UserConfigurationDictionary.WriteObjectToXml", "writer is null"); - EwsUtilities.ewsAssert(xmlElementName != null, "UserConfigurationDictionary.WriteObjectToXml", - "xmlElementName is null"); - writer.writeStartElement(XmlNamespace.Types, xmlElementName); - - if (dictionaryObject == null) { - EwsUtilities.ewsAssert((!xmlElementName.equals(XmlElementNames.DictionaryKey)), - "UserConfigurationDictionary.WriteObjectToXml", "Key is null"); - - writer.writeAttributeValue( - EwsUtilities.EwsXmlSchemaInstanceNamespacePrefix, - XmlAttributeNames.Nil, EwsUtilities.XSTrue); - } else { - this.writeObjectValueToXml(writer, dictionaryObject); - } - - writer.writeEndElement(); - } - - /** - * Writes a dictionary Object's value to Xml. - * - * @param writer The writer. - * @param dictionaryObject The dictionary object to write.
- * Object values are either:
- * an array of strings, an array of bytes (which will be encoded into base64)
- * or a single value. Single values can be:
- * - datetime, boolean, byte, int, long, string - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - private void writeObjectValueToXml(final EwsServiceXmlWriter writer, - final Object dictionaryObject) throws XMLStreamException, - ServiceXmlSerializationException { - // Preconditions - if (dictionaryObject == null) { - throw new NullPointerException("DictionaryObject must not be null"); - } - if (writer == null) { - throw new NullPointerException( - "EwsServiceXmlWriter must not be null"); - } - - // Processing - final UserConfigurationDictionaryObjectType dictionaryObjectType; - if (dictionaryObject instanceof String[]) { - dictionaryObjectType = UserConfigurationDictionaryObjectType.StringArray; - this.writeEntryTypeToXml(writer, dictionaryObjectType); - - for (String arrayElement : (String[]) dictionaryObject) { - this.writeEntryValueToXml(writer, arrayElement); - } - } else { - final String valueAsString; - if (dictionaryObject instanceof String) { - dictionaryObjectType = UserConfigurationDictionaryObjectType.String; - valueAsString = String.valueOf(dictionaryObject); - } else if (dictionaryObject instanceof Boolean) { - dictionaryObjectType = UserConfigurationDictionaryObjectType.Boolean; - valueAsString = EwsUtilities - .boolToXSBool((Boolean) dictionaryObject); - } else if (dictionaryObject instanceof Byte) { - dictionaryObjectType = UserConfigurationDictionaryObjectType.Byte; - valueAsString = String.valueOf(dictionaryObject); - } else if (dictionaryObject instanceof Date) { - dictionaryObjectType = UserConfigurationDictionaryObjectType.DateTime; - valueAsString = writer.getService() - .convertDateTimeToUniversalDateTimeString( - (Date) dictionaryObject); - } else if (dictionaryObject instanceof Integer) { - // removed unsigned integer because in Java, all types are - // signed, there are no unsigned versions - dictionaryObjectType = UserConfigurationDictionaryObjectType.Integer32; - valueAsString = String.valueOf(dictionaryObject); - } else if (dictionaryObject instanceof Long) { - // removed unsigned integer because in Java, all types are - // signed, there are no unsigned versions - dictionaryObjectType = UserConfigurationDictionaryObjectType.Integer64; - valueAsString = String.valueOf(dictionaryObject); - } else if (dictionaryObject instanceof byte[]) { - dictionaryObjectType = UserConfigurationDictionaryObjectType.ByteArray; - valueAsString = Base64.encodeBase64String((byte[]) dictionaryObject); - } else if (dictionaryObject instanceof Byte[]) { - dictionaryObjectType = UserConfigurationDictionaryObjectType.ByteArray; - - // cast Byte[] to byte[] - Byte[] from = (Byte[]) dictionaryObject; - byte[] to = new byte[from.length]; - for (int currentIndex = 0; currentIndex < from.length; currentIndex++) { - to[currentIndex] = (byte) from[currentIndex]; - } - - valueAsString = Base64.encodeBase64String(to); - } else { - throw new IllegalArgumentException(String.format( - "Unsupported type: %s", dictionaryObject.getClass() - .toString())); - } - this.writeEntryTypeToXml(writer, dictionaryObjectType); - this.writeEntryValueToXml(writer, valueAsString); - } - } - - - /** - * Writes a dictionary entry type to Xml. - * - * @param writer the writer - * @param dictionaryObjectType type to write - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - private void writeEntryTypeToXml(EwsServiceXmlWriter writer, - UserConfigurationDictionaryObjectType dictionaryObjectType) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Type); - writer - .writeValue(dictionaryObjectType.toString(), - XmlElementNames.Type); - writer.writeEndElement(); - } - - /** - * Writes a dictionary entry value to Xml. - * - * @param writer the writer - * @param value value to write - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - private void writeEntryValueToXml(EwsServiceXmlWriter writer, String value) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeStartElement(XmlNamespace.Types, XmlElementNames.Value); - - // While an entry value can't be null, if the entry is an array, an - // element of the array can be null. - if (value != null) { - writer.writeValue(value, XmlElementNames.Value); - } - - writer.writeEndElement(); - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.ComplexProperty#loadFromXml(microsoft. - * exchange.webservices.EwsServiceXmlReader, - * microsoft.exchange.webservices.XmlNamespace, java.lang.String) - */ - @Override - /** - * Loads this dictionary from the specified reader. - * @param reader The reader. - * @param xmlNamespace The dictionary's XML namespace. - * @param xmlElementName Name of the XML element - * representing the dictionary. - */ public void loadFromXml(EwsServiceXmlReader reader, XmlNamespace xmlNamespace, String xmlElementName) throws Exception { - super.loadFromXml(reader, xmlNamespace, xmlElementName); - - this.isDirty = false; - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices.ComplexProperty#tryReadElementFromXml( - * microsoft.exchange.webservices.EwsServiceXmlReader) - */ - @Override - /** - * Tries to read element from XML. - * @param reader The reader. - * @return True if element was read. - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - reader.ensureCurrentNodeIsStartElement(this.getNamespace(), - XmlElementNames.DictionaryEntry); - this.loadEntry(reader); - return true; - } - - /** - * Loads an entry, consisting of a key value pair, into this dictionary from - * the specified reader. - * - * @param reader The reader. - * @throws Exception the exception - */ - private void loadEntry(EwsServiceXmlReader reader) throws Exception { - EwsUtilities.ewsAssert(reader != null, "UserConfigurationDictionary.LoadEntry", "reader is null"); - - Object key; - Object value = null; - - // Position at DictionaryKey - reader.readStartElement(this.getNamespace(), - XmlElementNames.DictionaryKey); - - key = this.getDictionaryObject(reader); - - // Position at DictionaryValue - reader.readStartElement(this.getNamespace(), - XmlElementNames.DictionaryValue); - - String nil = reader.readAttributeValue(XmlNamespace.XmlSchemaInstance, - XmlAttributeNames.Nil); - boolean hasValue = (nil == null) - || (!nil.getClass().equals(Boolean.TYPE)); - if (hasValue) { - value = this.getDictionaryObject(reader); - } - this.dictionary.put(key, value); - } - - /** - * Extracts a dictionary object (key or entry value) from the specified - * reader. - * - * @param reader The reader. - * @return Dictionary object. - * @throws Exception the exception - */ - private Object getDictionaryObject(EwsServiceXmlReader reader) - throws Exception { - EwsUtilities.ewsAssert(reader != null, "UserConfigurationDictionary.loadFromXml", "reader is null"); - UserConfigurationDictionaryObjectType type = this.getObjectType(reader); - List values = this.getObjectValue(reader, type); - return this.constructObject(type, values, reader); - } - - /** - * Extracts a dictionary object (key or entry value) as a string list from - * the specified reader. - * - * @param reader The reader. - * @param type The object type. - * @return String list representing a dictionary object. - * @throws Exception the exception - */ - private List getObjectValue(EwsServiceXmlReader reader, - UserConfigurationDictionaryObjectType type) throws Exception { - EwsUtilities.ewsAssert(reader != null, "UserConfigurationDictionary.loadFromXml", "reader is null"); - - List values = new ArrayList(); - - reader.readStartElement(this.getNamespace(), XmlElementNames.Value); - - do { - String value = null; - - if (reader.isEmptyElement()) { - // Only string types can be represented with empty values. - if (type.equals(UserConfigurationDictionaryObjectType.String) - || type - .equals(UserConfigurationDictionaryObjectType. - StringArray)) { - value = ""; - } else { - EwsUtilities - .ewsAssert(false, "UserConfigurationDictionary." + "GetObjectValue", - "Empty element passed for type: " + type.toString()); - - } - - } else { - value = reader.readElementValue(); - } - - values.add(value); - reader.read(); // Position at next element or - // DictionaryKey/DictionaryValue end element - } while (reader.isStartElement(this.getNamespace(), - XmlElementNames.Value)); - return values; - } - - /** - * Extracts the dictionary object (key or entry value) type from the - * specified reader. - * - * @param reader The reader. - * @return Dictionary object type. - * @throws Exception the exception - */ - private UserConfigurationDictionaryObjectType getObjectType( - EwsServiceXmlReader reader) throws Exception { - EwsUtilities.ewsAssert(reader != null, "UserConfigurationDictionary.loadFromXml", "reader is null"); - - reader.readStartElement(this.getNamespace(), XmlElementNames.Type); - - String type = reader.readElementValue(); - return UserConfigurationDictionaryObjectType.valueOf(type); - } - - /** - * Constructs a dictionary object (key or entry value) from the specified - * type and string list. - * - * @param type Object type to construct. - * @param value Value of the dictionary object as a string list - * @param reader The reader. - * @return Dictionary object. - */ - private Object constructObject(UserConfigurationDictionaryObjectType type, - List value, EwsServiceXmlReader reader) { - EwsUtilities.ewsAssert(value != null, "UserConfigurationDictionary.ConstructObject", "value is null"); - EwsUtilities - .ewsAssert((value.size() == 1 || type == UserConfigurationDictionaryObjectType.StringArray), - - "UserConfigurationDictionary.ConstructObject", - "value is array but type is not StringArray"); - EwsUtilities - .ewsAssert(reader != null, "UserConfigurationDictionary.ConstructObject", "reader is null"); - - Object dictionaryObject = null; - if (type.equals(UserConfigurationDictionaryObjectType.Boolean)) { - dictionaryObject = Boolean.parseBoolean(value.get(0)); - } else if (type.equals(UserConfigurationDictionaryObjectType.Byte)) { - dictionaryObject = Byte.parseByte(value.get(0)); - } else if (type.equals(UserConfigurationDictionaryObjectType.ByteArray)) { - dictionaryObject = Base64.decodeBase64(value.get(0)); - } else if (type.equals(UserConfigurationDictionaryObjectType.DateTime)) { - Date dateTime = DateTimeUtils.convertDateTimeStringToDate(value.get(0)); - if (dateTime != null) { - dictionaryObject = dateTime; - } else { - EwsUtilities.ewsAssert(false, "UserConfigurationDictionary.ConstructObject", "DateTime is null"); - } - } else if (type.equals(UserConfigurationDictionaryObjectType.Integer32)) { - dictionaryObject = Integer.parseInt(value.get(0)); - } else if (type.equals(UserConfigurationDictionaryObjectType.Integer64)) { - dictionaryObject = Long.parseLong(value.get(0)); - } else if (type.equals(UserConfigurationDictionaryObjectType.String)) { - dictionaryObject = String.valueOf(value.get(0)); - } else if (type - .equals(UserConfigurationDictionaryObjectType.StringArray)) { - dictionaryObject = value.toArray(); - } else if (type - .equals(UserConfigurationDictionaryObjectType. - UnsignedInteger32)) { - dictionaryObject = Integer.parseInt(value.get(0)); - } else if (type - .equals(UserConfigurationDictionaryObjectType. - UnsignedInteger64)) { - dictionaryObject = Long.parseLong(value.get(0)); - } else { - EwsUtilities.ewsAssert(false, "UserConfigurationDictionary.ConstructObject", - "Type not recognized: " + type.toString()); - } - - return dictionaryObject; - } - - /** - * Validates the specified key and value. - * - * @param key The key. - * @param value The diction dictionary entry key.ary entry value. - * @throws Exception the exception - */ - private void validateEntry(Object key, Object value) throws Exception { - this.validateObject(key); - this.validateObject(value); - - } - - /** - * Validates the dictionary object (key or entry value). - * - * @param dictionaryObject Object to validate. - * @throws Exception the exception - */ - private void validateObject(Object dictionaryObject) throws Exception { - // Keys may not be null but we rely on the internal dictionary to throw - // if the key is null. - if (dictionaryObject != null) { - if (dictionaryObject.getClass().isArray()) { - int length = Array.getLength(dictionaryObject); - Class wrapperType = Array.get(dictionaryObject, 0).getClass(); - Object[] newArray = (Object[]) Array. - newInstance(wrapperType, length); - for (int i = 0; i < length; i++) { - newArray[i] = Array.get(dictionaryObject, i); - } - this.validateArrayObject(newArray); - } else { - this.validateObjectType(dictionaryObject); - - } - - } else { - throw new NullPointerException(); - } - } - - /** - * Validate the array object. - * - * @param dictionaryObjectAsArray Object to validate - * @throws ServiceLocalException the service local exception - */ - private void validateArrayObject(Object[] dictionaryObjectAsArray) - throws ServiceLocalException { - // This logic is based on - // Microsoft.Exchange.Data.Storage.ConfigurationDictionary. - // CheckElementSupportedType(). - // if (dictionaryObjectAsArray is string[]) - - if (dictionaryObjectAsArray instanceof String[]) { - if (dictionaryObjectAsArray.length > 0) { - for (Object arrayElement : dictionaryObjectAsArray) { - if (arrayElement == null) { - throw new ServiceLocalException("The array contains at least one null element."); - } - } - } else { - throw new ServiceLocalException("The array must contain at least one element."); - } - } else if (dictionaryObjectAsArray instanceof Byte[]) { - if (dictionaryObjectAsArray.length <= 0) { - throw new ServiceLocalException("The array must contain at least one element."); - } - } else { - throw new ServiceLocalException(String.format( - "Objects of type %s can't be added to the dictionary. The following types are supported: string array, byte array, boolean, byte, DateTime, integer, long, string, unsigned integer, and unsigned long.", dictionaryObjectAsArray - .getClass())); - } - } - - /** - * Validates the dictionary object type. - * - * @param theObject Object to validate. - * @throws ServiceLocalException the service local exception - */ - private void validateObjectType(Object theObject) throws ServiceLocalException { - // This logic is based on - // Microsoft.Exchange.Data.Storage.ConfigurationDictionary. - // CheckElementSupportedType(). - boolean isValidType = false; - if (theObject != null) { - if (theObject instanceof String || - theObject instanceof Boolean || - theObject instanceof Byte || - theObject instanceof Long || - theObject instanceof Date || - theObject instanceof Integer) { - isValidType = true; - } - } - - if (!isValidType) { - throw new ServiceLocalException( - String.format( - "Objects of type %s can't be added to the dictionary. The following types are supported: string array, byte array, boolean, byte, DateTime, integer, long, string, unsigned integer, and unsigned long.", (theObject != null ? - theObject.getClass().toString() : "null"))); - } - } - - /* - * (non-Javadoc) - * - * @see java.lang.Iterable#iterator() - */ - @Override - public Iterator iterator() { - return this.dictionary.values().iterator(); - - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/UserId.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/UserId.java deleted file mode 100644 index e0c5c685a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/UserId.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.StandardUser; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents the Id of a user. - */ -public class UserId extends ComplexProperty { - - /** - * The s id. - */ - private String sID; - - /** - * The primary smtp address. - */ - private String primarySmtpAddress; - - /** - * The display name. - */ - private String displayName; - - /** - * The standard user. - */ - private StandardUser standardUser; - - /** - * Initializes a new instance. - */ - public UserId() { - super(); - } - - /** - * Initializes a new instance. - * - * @param primarySmtpAddress the primary smtp address - */ - public UserId(String primarySmtpAddress) { - - this.primarySmtpAddress = primarySmtpAddress; - } - - /** - * Initializes a new instance. - * - * @param standardUser the standard user - */ - public UserId(StandardUser standardUser) { - this(); - this.standardUser = standardUser; - } - - /** - * Determines whether this instance is valid. - * - * @return true, if this instance is valid. Else, false - */ - protected boolean isValid() { - return (this.standardUser != null || - !(this.primarySmtpAddress == null || this.primarySmtpAddress - .isEmpty()) || !(this.sID == null || - this.sID.isEmpty())); - } - - /** - * Gets the SID of the user. - * - * @return the sID - */ - public String getSID() { - return this.sID; - } - - /** - * Sets the sID. - * - * @param sID the new sID - */ - public void setSID(String sID) { - if (this.canSetFieldValue(this.sID, sID)) { - this.sID = sID; - this.changed(); - } - } - - /** - * Gets the primary SMTP address or the user. - * - * @return the primary smtp address - */ - public String getPrimarySmtpAddress() { - return this.primarySmtpAddress; - } - - /** - * Sets the primary smtp address. - * - * @param primarySmtpAddress the new primary smtp address - */ - public void setPrimarySmtpAddress(String primarySmtpAddress) { - if (this.canSetFieldValue(this.primarySmtpAddress, primarySmtpAddress)) { - this.primarySmtpAddress = primarySmtpAddress; - this.changed(); - } - - } - - /** - * Gets the display name of the user. - * - * @return the display name - */ - public String getDisplayName() { - return this.displayName; - } - - /** - * Sets the display name. - * - * @param displayName the new display name - */ - public void setDisplayName(String displayName) { - if (this.canSetFieldValue(this.displayName, displayName)) { - this.displayName = displayName; - this.changed(); - } - } - - /** - * Gets a value indicating which standard user the user - * represents. - * - * @return the standard user - */ - public StandardUser getstandardUser() { - return this.standardUser; - } - - /** - * Sets the standard user. - * - * @param standardUser the new standard user - */ - public void setStandardUser(StandardUser standardUser) { - if (this.canSetFieldValue(this.standardUser, standardUser)) { - this.standardUser = standardUser; - this.changed(); - } - } - - /** - * Implements an implicit conversion between a string representing a - * primary SMTP address and UserId. - * - * @param primarySmtpAddress the primary smtp address - * @return A UserId initialized with the specified primary SMTP address - */ - public static UserId getUserId(String primarySmtpAddress) { - return new UserId(primarySmtpAddress); - } - - /** - * Implements an implicit conversion between StandardUser and UserId. - * - * @param standardUser the standard user - * @return A UserId initialized with the specified standard user value - */ - public static UserId getUserIdFromStandardUser(StandardUser standardUser) { - return new UserId(standardUser); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.SID)) { - this.sID = reader.readValue(); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.PrimarySmtpAddress)) { - this.primarySmtpAddress = reader.readValue(); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.DisplayName)) { - this.displayName = reader.readValue(); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.DistinguishedUser)) { - this.standardUser = reader.readValue(StandardUser.class); - return true; - } else { - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.SID, - this.sID); - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.PrimarySmtpAddress, this.primarySmtpAddress); - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.DisplayName, this.displayName); - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.DistinguishedUser, this.standardUser); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/CalendarEvent.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/CalendarEvent.java deleted file mode 100644 index 7d2cb75cc..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/CalendarEvent.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.availability; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.LegacyFreeBusyStatus; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -import java.util.Date; - -/** - * Represents an event in a calendar. - */ -public final class CalendarEvent extends ComplexProperty { - - /** - * The start time. - */ - private Date startTime; - - /** - * The end time. - */ - private Date endTime; - - /** - * The free busy status. - */ - private LegacyFreeBusyStatus freeBusyStatus; - - /** - * The details. - */ - private CalendarEventDetails details; - - /** - * Initializes a new instance of the CalendarEvent class. - */ - public CalendarEvent() { - super(); - } - - /** - * Gets the start date and time of the event. - * - * @return the start time - */ - public Date getStartTime() { - return startTime; - } - - /** - * Gets the end date and time of the event. - * - * @return the end time - */ - public Date getEndTime() { - return endTime; - } - - /** - * Gets the free/busy status associated with the event. - * - * @return the free busy status - */ - public LegacyFreeBusyStatus getFreeBusyStatus() { - return freeBusyStatus; - } - - /** - * Gets the details of the calendar event. Details is null if the user - * requsting them does no have the appropriate rights. - * - * @return the details - */ - public CalendarEventDetails getDetails() { - return details; - } - - /** - * Attempts to read the element at the reader's current position. - * - * @param reader the reader - * @return True if the element was read, false otherwise. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.StartTime)) { - this.startTime = reader - .readElementValueAsUnbiasedDateTimeScopedToServiceTimeZone(); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.EndTime)) { - this.endTime = reader - .readElementValueAsUnbiasedDateTimeScopedToServiceTimeZone(); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.BusyType)) { - this.freeBusyStatus = reader - .readElementValue(LegacyFreeBusyStatus.class); - return true; - } - if (reader.getLocalName().equals(XmlElementNames.CalendarEventDetails)) { - this.details = new CalendarEventDetails(); - this.details.loadFromXml(reader, reader.getLocalName()); - return true; - } else { - return false; - } - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/CalendarEventDetails.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/CalendarEventDetails.java deleted file mode 100644 index 1e84cdbb6..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/CalendarEventDetails.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.availability; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -/** - * Represents the details of a calendar event as returned by the - * GetUserAvailability operation. - */ -public final class CalendarEventDetails extends ComplexProperty { - - /** - * The store id. - */ - private String storeId; - - /** - * The subject. - */ - private String subject; - - /** - * The location. - */ - private String location; - - /** - * The is meeting. - */ - private boolean isMeeting; - - /** - * The is recurring. - */ - private boolean isRecurring; - - /** - * The is exception. - */ - private boolean isException; - - /** - * The is reminder set. - */ - private boolean isReminderSet; - - /** - * The is private. - */ - private boolean isPrivate; - - /** - * Initializes a new instance of the CalendarEventDetails class. - */ - protected CalendarEventDetails() { - super(); - } - - /** - * Attempts to read the element at the reader's current position. - * - * @param reader the reader - * @return True if the element was read, false otherwise. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.ID)) { - this.storeId = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Subject)) { - this.subject = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Location)) { - this.location = reader.readElementValue(); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.IsMeeting)) { - this.isMeeting = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.IsRecurring)) { - this.isRecurring = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.IsException)) { - this.isException = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.IsReminderSet)) { - - this.isReminderSet = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.IsPrivate)) { - this.isPrivate = reader.readElementValue(Boolean.class); - return true; - } else { - return false; - } - - } - - /** - * Gets the store Id of the calendar event. - * - * @return the store id - */ - public String getStoreId() { - return this.storeId; - } - - /** - * Gets the subject of the calendar event. - * - * @return the subject - */ - public String getSubject() { - return subject; - } - - /** - * Gets the location of the calendar event. - * - * @return the location - */ - public String getLocation() { - return location; - } - - /** - * Gets a value indicating whether the calendar event is a meeting. - * - * @return true, if is meeting - */ - public boolean isMeeting() { - return isMeeting; - } - - /** - * Gets a value indicating whether the calendar event is recurring. - * - * @return true, if is recurring - */ - public boolean isRecurring() { - return isRecurring; - } - - /** - * Gets a value indicating whether the calendar event is an exception in a - * recurring series. - * - * @return true, if is exception - */ - public boolean isException() { - return isException; - } - - /** - * Gets a value indicating whether the calendar event has a reminder set. - * - * @return true, if is reminder set - */ - public boolean isReminderSet() { - return isReminderSet; - } - - /** - * Gets a value indicating whether the calendar event is private. - * - * @return true, if is private - */ - public boolean isPrivate() { - return isPrivate; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/Conflict.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/Conflict.java deleted file mode 100644 index 3c00efd43..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/Conflict.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.availability; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.ConflictType; -import microsoft.exchange.webservices.data.core.enumeration.property.LegacyFreeBusyStatus; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -/** - * Represents a conflict in a meeting time suggestion. - */ -public final class Conflict extends ComplexProperty { - - /** - * The conflict type. - */ - private ConflictType conflictType; - - /** - * The number of members. - */ - private int numberOfMembers; - - /** - * The number of members available. - */ - private int numberOfMembersAvailable; - - /** - * The number of members with conflict. - */ - private int numberOfMembersWithConflict; - - /** - * The number of members with no data. - */ - private int numberOfMembersWithNoData; - - /** - * The free busy status. - */ - private LegacyFreeBusyStatus freeBusyStatus; - - /** - * Initializes a new instance of the Conflict class. - * - * @param conflictType the conflict type - */ - protected Conflict(ConflictType conflictType) { - super(); - this.conflictType = conflictType; - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if appropriate element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.NumberOfMembers)) { - this.numberOfMembers = reader.readElementValue(Integer.class); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.NumberOfMembersAvailable)) { - this.numberOfMembersAvailable = reader - .readElementValue(Integer.class); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.NumberOfMembersWithConflict)) { - this.numberOfMembersWithConflict = reader - .readElementValue(Integer.class); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.NumberOfMembersWithNoData)) { - this.numberOfMembersWithNoData = reader - .readElementValue(Integer.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.BusyType)) { - this.freeBusyStatus = reader - .readElementValue(LegacyFreeBusyStatus.class); - return true; - } else { - return false; - } - } - - /** - * Gets the type of the conflict. - * - * @return the conflict type - */ - public ConflictType getConflictType() { - return conflictType; - } - - /** - * Gets the number of users, resources, and rooms in the conflicting group. - * The value of this property is only meaningful when ConflictType is equal - * to ConflictType.GroupConflict. - * - * @return the number of members - */ - public int getNumberOfMembers() { - return numberOfMembers; - } - - /** - * Gets the number of members who are available (whose status is Free) in - * the conflicting group. The value of this property is only meaningful when - * ConflictType is equal to ConflictType.GroupConflict. - * - * @return the number of members available - */ - public int getNumberOfMembersAvailable() { - return numberOfMembersAvailable; - } - - /** - * Gets the number of members who have a conflict (whose status is Busy, OOF - * or Tentative) in the conflicting group. The value of this property is - * only meaningful when ConflictType is equal to ConflictType.GroupConflict. - * - * @return the number of members with conflict - */ - public int getNumberOfMembersWithConflict() { - return numberOfMembersWithConflict; - } - - /** - * Gets the number of members who do not have published free/busy data in - * the conflicting group. The value of this property is only meaningful when - * ConflictType is equal to ConflictType.GroupConflict. - * - * @return the number of members with no data - */ - public int getNumberOfMembersWithNoData() { - return numberOfMembersWithNoData; - } - - /** - * Gets the free/busy status of the conflicting attendee. The value of this - * property is only meaningful when ConflictType is equal to - * ConflictType.IndividualAttendee. - * - * @return the free busy status - */ - public LegacyFreeBusyStatus getFreeBusyStatus() { - return freeBusyStatus; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/OofSettings.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/OofSettings.java deleted file mode 100644 index aa974de27..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/OofSettings.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.availability; - -import microsoft.exchange.webservices.data.ISelfValidate; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.OofExternalAudience; -import microsoft.exchange.webservices.data.core.enumeration.property.OofState; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.availability.OofReply; -import microsoft.exchange.webservices.data.misc.availability.TimeWindow; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents a user's Out of Office (OOF) settings. - */ -public final class OofSettings extends ComplexProperty implements ISelfValidate { - - /** - * The state. - */ - private OofState state = OofState.Disabled; - - /** - * The external audience. - */ - private OofExternalAudience externalAudience = OofExternalAudience.None; - - /** - * The allow external oof. - */ - private OofExternalAudience allowExternalOof = OofExternalAudience.None; - - /** - * The duration. - */ - private TimeWindow duration; - - /** - * The internal reply. - */ - private OofReply internalReply; - - /** - * The external reply. - */ - private OofReply externalReply; - - /** - * Serializes an OofReply. Emits an empty OofReply in case the one passed in - * is null. - * - * @param oofReply The oof reply - * @param writer The writer - * @param xmlElementName Name of the xml element - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - private void serializeOofReply(OofReply oofReply, - EwsServiceXmlWriter writer, String xmlElementName) - throws XMLStreamException, ServiceXmlSerializationException { - if (oofReply != null) { - oofReply.writeToXml(writer, xmlElementName); - } else { - OofReply.writeEmptyReplyToXml(writer, xmlElementName); - } - } - - /** - * Initializes a new instance of OofSettings. - */ - public OofSettings() - - { - super(); - } - - /** - * Tries to read element from XML. - * - * @param reader The reader - * @return True if appropriate element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.OofState)) { - this.state = reader.readValue(OofState.class); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.ExternalAudience)) { - this.externalAudience = reader.readValue(OofExternalAudience.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Duration)) { - this.duration = new TimeWindow(); - this.duration.loadFromXml(reader); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.InternalReply)) { - this.internalReply = new OofReply(); - this.internalReply.loadFromXml(reader, reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.ExternalReply)) { - this.externalReply = new OofReply(); - this.externalReply.loadFromXml(reader, reader.getLocalName()); - return true; - } else { - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer The writer - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - super.writeElementsToXml(writer); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.OofState, - this.getState()); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.ExternalAudience, this.getExternalAudience()); - - if (this.getDuration() != null && this.getState() == OofState.Scheduled) { - this.getDuration().writeToXml(writer, XmlElementNames.Duration); - } - - this.serializeOofReply(this.getInternalReply(), writer, - XmlElementNames.InternalReply); - this.serializeOofReply(this.getExternalReply(), writer, - XmlElementNames.ExternalReply); - } - - /** - * Gets the user's OOF state. - * - * @return The user's OOF state. - */ - public OofState getState() { - return state; - } - - /** - * Sets the user's OOF state. - * - * @param state the new state - */ - public void setState(OofState state) { - this.state = state; - } - - /** - * Gets a value indicating who should receive external OOF messages. - * - * @return the external audience - */ - public OofExternalAudience getExternalAudience() { - return externalAudience; - } - - /** - * Sets a value indicating who should receive external OOF messages. - * - * @param externalAudience the new external audience - */ - public void setExternalAudience(OofExternalAudience externalAudience) { - this.externalAudience = externalAudience; - } - - /** - * Gets the duration of the OOF status when State is set to - * OofState.Scheduled. - * - * @return the duration - */ - public TimeWindow getDuration() { - return duration; - } - - /** - * Sets the duration of the OOF status when State is set to - * OofState.Scheduled. - * - * @param duration the new duration - */ - public void setDuration(TimeWindow duration) { - this.duration = duration; - } - - /** - * Gets the OOF response sent other users in the user's domain or trusted - * domain. - * - * @return the internal reply - */ - public OofReply getInternalReply() { - return internalReply; - } - - /** - * Sets the OOF response sent other users in the user's domain or trusted - * domain. - * - * @param internalReply the new internal reply - */ - public void setInternalReply(OofReply internalReply) { - this.internalReply = internalReply; - } - - /** - * Gets the OOF response sent to addresses outside the user's domain or - * trusted domain. - * - * @return the external reply - */ - public OofReply getExternalReply() { - return externalReply; - } - - /** - * Sets the OOF response sent to addresses outside the user's domain or - * trusted domain. - * - * @param externalReply the new external reply - */ - public void setExternalReply(OofReply externalReply) { - this.externalReply = externalReply; - } - - /** - * Gets a value indicating the authorized external OOF notification. - * - * @return the allow external oof - */ - public OofExternalAudience getAllowExternalOof() { - return allowExternalOof; - } - - /** - * Sets a value indicating the authorized external OOF notification. - * - * @param allowExternalOof the new allow external oof - */ - public void setAllowExternalOof(OofExternalAudience allowExternalOof) { - this.allowExternalOof = allowExternalOof; - } - - /** - * Validates this instance. - * - * @throws Exception the exception - */ - @Override - public void validate() throws Exception { - if (this.getState() == OofState.Scheduled) { - if (this.getDuration() == null) { - throw new ArgumentException("Duration must be specified when State is equal to Scheduled."); - } - - EwsUtilities.validateParam(this.getDuration(), "Duration"); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/Suggestion.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/Suggestion.java deleted file mode 100644 index 180fbec66..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/Suggestion.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.availability; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.availability.SuggestionQuality; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; - -/** - * Represents a suggestion for a specific date. - */ -public final class Suggestion extends ComplexProperty { - - /** - * The date. - */ - private Date date; - - /** - * The quality. - */ - private SuggestionQuality quality; - - /** - * The time suggestions. - */ - private Collection timeSuggestions = - new ArrayList(); - - /** - * Initializes a new instance of the Suggestion class. - */ - public Suggestion() { - super(); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if appropriate element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception { - if (reader.getLocalName().equals(XmlElementNames.Date)) { - SimpleDateFormat sdfin = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss"); - this.date = sdfin.parse(reader.readElementValue()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.DayQuality)) { - this.quality = reader.readElementValue(SuggestionQuality.class); - return true; - } else if (reader.getLocalName() - .equals(XmlElementNames.SuggestionArray)) { - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.Suggestion)) { - TimeSuggestion timeSuggestion = new TimeSuggestion(); - - timeSuggestion.loadFromXml(reader, reader - .getLocalName()); - - this.timeSuggestions.add(timeSuggestion); - } - } while (!reader.isEndElement(XmlNamespace.Types, - XmlElementNames.SuggestionArray)); - } - - return true; - } else { - return false; - } - - } - - /** - * Gets the date and time of the suggestion. - * - * @return the date - */ - public Date getDate() { - return date; - } - - /** - * Gets the quality of the suggestion. - * - * @return the quality - */ - public SuggestionQuality getQuality() { - return quality; - } - - /** - * Gets a collection of suggested times within the suggested day. - * - * @return the time suggestions - */ - public Collection getTimeSuggestions() { - return timeSuggestions; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/TimeSuggestion.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/TimeSuggestion.java deleted file mode 100644 index ae2f0b9e3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/TimeSuggestion.java +++ /dev/null @@ -1,181 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.availability; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.ConflictType; -import microsoft.exchange.webservices.data.core.enumeration.availability.SuggestionQuality; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; - -/** - * Represents an availability time suggestion. - */ -public final class TimeSuggestion extends ComplexProperty { - - /** - * The meeting time. - */ - private Date meetingTime; - - /** - * The is work time. - */ - private boolean isWorkTime; - - /** - * The quality. - */ - private SuggestionQuality quality; - - /** - * The conflicts. - */ - private Collection conflicts = new ArrayList(); - - /** - * Initializes a new instance of the TimeSuggestion class. - */ - protected TimeSuggestion() { - super(); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if appropriate element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.MeetingTime)) { - this.meetingTime = reader - .readElementValueAsUnbiasedDateTimeScopedToServiceTimeZone(); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.IsWorkTime)) { - this.isWorkTime = reader.readElementValue(Boolean.class); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.SuggestionQuality)) { - this.quality = reader.readElementValue(SuggestionQuality.class); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.AttendeeConflictDataArray)) { - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.isStartElement()) { - Conflict conflict = null; - - if (reader.getLocalName().equals( - XmlElementNames.UnknownAttendeeConflictData)) { - conflict = new Conflict( - ConflictType.UnknownAttendeeConflict); - } else if (reader - .getLocalName() - .equals( - XmlElementNames. - TooBigGroupAttendeeConflictData)) { - conflict = new Conflict( - ConflictType.GroupTooBigConflict); - } else if (reader.getLocalName().equals( - XmlElementNames. - IndividualAttendeeConflictData)) { - conflict = new Conflict( - ConflictType.IndividualAttendeeConflict); - } else if (reader.getLocalName().equals( - XmlElementNames.GroupAttendeeConflictData)) { - conflict = new Conflict(ConflictType.GroupConflict); - } else { - EwsUtilities - .ewsAssert(false, "TimeSuggestion." + "TryReadElementFromXml", - String.format("The %s element name " + - "does not map " + - "to any AttendeeConflict " + - "descendant.", reader.getLocalName())); - - // The following line to please the compiler - } - conflict.loadFromXml(reader, reader.getLocalName()); - - this.conflicts.add(conflict); - } - } while (!reader.isEndElement(XmlNamespace.Types, - XmlElementNames.AttendeeConflictDataArray)); - } - - return true; - } else { - return false; - } - - } - - /** - * Gets the suggested time. - * - * @return the meeting time - */ - public Date getMeetingTime() { - return meetingTime; - } - - /** - * Gets a value indicating whether the suggested time is within working - * hours. - * - * @return true, if is work time - */ - public boolean isWorkTime() { - return isWorkTime; - } - - /** - * Gets the quality of the suggestion. - * - * @return the quality - */ - public SuggestionQuality getQuality() { - return quality; - } - - /** - * Gets a collection of conflicts at the suggested time. - * - * @return the conflicts - */ - public Collection getConflicts() { - return conflicts; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/WorkingHours.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/WorkingHours.java deleted file mode 100644 index 04302faf5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/WorkingHours.java +++ /dev/null @@ -1,178 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.availability; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.time.DayOfTheWeek; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.misc.availability.LegacyAvailabilityTimeZone; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; -import microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * Represents the working hours for a specific time zone. - */ -public final class WorkingHours extends ComplexProperty { - - /** - * The time zone. - */ - private TimeZoneDefinition timeZone; - - /** - * The days of the week. - */ - private Collection daysOfTheWeek = - new ArrayList(); - - /** - * The start time. - */ - private long startTime; - - /** - * The end time. - */ - private long endTime; - - /** - * Instantiates a new working hours. - */ - public WorkingHours() { - super(); - } - - /** - * Tries to read element from XML. - * - * @param reader accepts EwsServiceXmlReader - * @return True if element was read - * @throws Exception throws Exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.TimeZone)) { - LegacyAvailabilityTimeZone legacyTimeZone = - new LegacyAvailabilityTimeZone(); - legacyTimeZone.loadFromXml(reader, reader.getLocalName()); - - this.timeZone = legacyTimeZone.toTimeZoneInfo(); - - return true; - } - if (reader.getLocalName().equals(XmlElementNames.WorkingPeriodArray)) { - List workingPeriods = new ArrayList(); - - do { - reader.read(); - - if (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.WorkingPeriod)) { - WorkingPeriod workingPeriod = new WorkingPeriod(); - - workingPeriod.loadFromXml(reader, reader.getLocalName()); - - workingPeriods.add(workingPeriod); - } - } while (!reader.isEndElement(XmlNamespace.Types, - XmlElementNames.WorkingPeriodArray)); - - // Availability supports a structure that can technically represent - // different working - // times for each day of the week. This is apparently how the - // information is stored in - // Exchange. However, no client (Outlook, OWA) either will let you - // specify different - // working times for each day of the week, and Outlook won't either - // honor that complex - // structure if it happens to be in Exchange (OWA goes through XSO - // which doesn't either - // honor the structure). - // So here we'll do what Outlook and OWA do: we'll use the start and - // end times of the - // first working period, but we'll use the week days of all the - // periods. - - this.startTime = workingPeriods.get(0).getStartTime(); - this.endTime = workingPeriods.get(0).getEndTime(); - - for (WorkingPeriod workingPeriod : workingPeriods) { - for (DayOfTheWeek dayOfWeek : workingPeriods.get(0) - .getDaysOfWeek()) { - if (!this.daysOfTheWeek.contains(dayOfWeek)) { - this.daysOfTheWeek.add(dayOfWeek); - } - } - } - - return true; - } else { - return false; - } - - } - - /** - * Gets the time zone to which the working hours apply. - * - * @return the time zone - */ - public TimeZoneDefinition getTimeZone() { - return timeZone; - } - - /** - * Gets the working days of the attendees. - * - * @return the days of the week - */ - public Collection getDaysOfTheWeek() { - return daysOfTheWeek; - } - - /** - * Gets the time of the day the attendee starts working. - * - * @return the start time - */ - public long getStartTime() { - return startTime; - } - - /** - * Gets the time of the day the attendee stops working. - * - * @return the end time - */ - public long getEndTime() { - return endTime; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/WorkingPeriod.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/WorkingPeriod.java deleted file mode 100644 index 65ecbbf25..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/availability/WorkingPeriod.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.availability; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.time.DayOfTheWeek; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a working period. - */ -final class WorkingPeriod extends ComplexProperty { - - /** - * The days of week. - */ - private List daysOfWeek = new ArrayList(); - - /** - * The start time. - */ - private long startTime; - - /** - * The end time. - */ - private long endTime; - - /** - * Initializes a new instance of the WorkingPeriod class. - */ - protected WorkingPeriod() { - super(); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return true, if successful - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.DayOfWeek)) { - EwsUtilities.parseEnumValueList(DayOfTheWeek.class, this.daysOfWeek, reader.readElementValue(), ' '); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.StartTimeInMinutes)) { - this.startTime = reader.readElementValue(Integer.class); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.EndTimeInMinutes)) { - this.endTime = reader.readElementValue(Integer.class); - return true; - } else { - return false; - } - - } - - /** - * Gets a collection of work days. - * - * @return the days of week - */ - protected List getDaysOfWeek() { - return daysOfWeek; - } - - /** - * Gets the start time of the period. - * - * @return the start time - */ - protected long getStartTime() { - return startTime; - } - - /** - * Gets the end time of the period. - * - * @return the end time - */ - protected long getEndTime() { - return endTime; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/DayOfTheWeekCollection.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/DayOfTheWeekCollection.java deleted file mode 100644 index fd0624442..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/DayOfTheWeekCollection.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.recurrence; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.time.DayOfTheWeek; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentOutOfRangeException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; -import org.apache.commons.lang3.StringUtils; - -import javax.xml.stream.XMLStreamException; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Represents a collection of DayOfTheWeek values. - */ -public final class DayOfTheWeekCollection extends ComplexProperty implements - Iterable { - - /** - * The item. - */ - private List items = new ArrayList(); - - /** - * Initializes a new instance of the class. - */ - public DayOfTheWeekCollection() { - } - - /** - * Convert to string. - * - * @param separator the separator - * @return String representation of collection. - */ - private String toString(String separator) { - if (this.getCount() == 0) { - return ""; - } else { - // String[] daysOfTheWeekArray = new String[this.getCount()]; - StringBuilder daysOfTheWeekstr = new StringBuilder(); - - for (int i = 0; i < this.getCount(); i++) { - // daysOfTheWeekArray[i] = item.get(i).toString(); - if (daysOfTheWeekstr.length() == 0) { - daysOfTheWeekstr.append(items.get(i).toString()); - } else { - daysOfTheWeekstr.append(separator); - daysOfTheWeekstr.append(items.get(i).toString()); - } - } - - return daysOfTheWeekstr.toString(); - } - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @param xmlElementName Name of the XML element. - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader, String xmlElementName) - throws Exception { - reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, - xmlElementName); - EwsUtilities.parseEnumValueList(DayOfTheWeek.class, this.items, reader.readElementValue(), ' '); - } - - /** - * Gets the request version. - * - * @param writer the writer - * @param xmlElementName the xml element name - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override public void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) - throws XMLStreamException, ServiceXmlSerializationException { - String daysOfWeekAsString = this.toString(" "); - - if (!StringUtils.isEmpty(daysOfWeekAsString)) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.DaysOfWeek, daysOfWeekAsString); - } - } - - /** - * Builds string representation of the collection. - * - * @return A comma-delimited string representing the collection. - */ - @Override - public String toString() { - return this.toString(","); - } - - /** - * Adds a day to the collection if it is not already present. - * - * @param dayOfTheWeek The day to add. - */ - public void add(DayOfTheWeek dayOfTheWeek) { - if (!this.items.contains(dayOfTheWeek)) { - this.items.add(dayOfTheWeek); - this.changed(); - } - } - - /** - * Adds multiple days to the collection if they are not already present. - * - * @param daysOfTheWeek The days to add. - */ - public void addRange(Iterator daysOfTheWeek) { - while (daysOfTheWeek.hasNext()) { - this.add(daysOfTheWeek.next()); - } - } - - /** - * Clears the collection. - */ - public void clear() { - if (this.getCount() > 0) { - this.items.clear(); - this.changed(); - } - } - - /** - * Remove a specific day from the collection. - * - * @param dayOfTheWeek the day of the week - * @return True if the day was removed from the collection, false otherwise. - */ - public boolean remove(DayOfTheWeek dayOfTheWeek) { - boolean result = this.items.remove(dayOfTheWeek); - - if (result) { - this.changed(); - } - return result; - } - - /** - * Removes the day at a specific index. - * - * @param index the index - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public void removeAt(int index) throws ArgumentOutOfRangeException { - if (index < 0 || index >= this.getCount()) { - throw new ArgumentOutOfRangeException("index", "index is out of range."); - } - - this.items.remove(index); - this.changed(); - } - - /** - * Gets the DayOfTheWeek at a specific index in the collection. - * - * @param index the index - * @return DayOfTheWeek at index - */ - public DayOfTheWeek getWeekCollectionAtIndex(int index) { - return this.items.get(index); - } - - /** - * Gets the number of days in the collection. - * - * @return the count - */ - public int getCount() { - return this.items.size(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Iterable#iterator() - */ - @Override - public Iterator iterator() { - return this.items.iterator(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/pattern/Recurrence.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/pattern/Recurrence.java deleted file mode 100644 index 0eec2d065..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/pattern/Recurrence.java +++ /dev/null @@ -1,1512 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.recurrence.pattern; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.time.DayOfTheWeek; -import microsoft.exchange.webservices.data.core.enumeration.property.time.DayOfTheWeekIndex; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.time.Month; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentOutOfRangeException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; -import microsoft.exchange.webservices.data.property.complex.IComplexPropertyChangedDelegate; -import microsoft.exchange.webservices.data.property.complex.recurrence.DayOfTheWeekCollection; -import microsoft.exchange.webservices.data.property.complex.recurrence.range.EndDateRecurrenceRange; -import microsoft.exchange.webservices.data.property.complex.recurrence.range.NoEndRecurrenceRange; -import microsoft.exchange.webservices.data.property.complex.recurrence.range.NumberedRecurrenceRange; -import microsoft.exchange.webservices.data.property.complex.recurrence.range.RecurrenceRange; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.Date; -import java.util.Iterator; - -/** - * Represents a recurrence pattern, as used by Appointment and Task item. - */ -public abstract class Recurrence extends ComplexProperty { - - /** - * The start date. - */ - private Date startDate; - - /** - * The number of occurrences. - */ - private Integer numberOfOccurrences; - - /** - * The end date. - */ - private Date endDate; - - /** - * Initializes a new instance. - */ - public Recurrence() { - super(); - } - - /** - * Initializes a new instance. - * - * @param startDate the start date - */ - public Recurrence(Date startDate) { - this(); - this.startDate = startDate; - } - - /** - * Gets the name of the XML element. - * - * @return the xml element name - */ - public abstract String getXmlElementName(); - - /** - * Gets a value indicating whether this instance is regeneration pattern. - * - * @return true, if is regeneration pattern - */ - public boolean isRegenerationPattern() { - return false; - } - - /** - * Write property to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) throws Exception { - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public final void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - writer.writeStartElement(XmlNamespace.Types, this.getXmlElementName()); - this.internalWritePropertiesToXml(writer); - writer.writeEndElement(); - - RecurrenceRange range = null; - - if (!this.hasEnd()) { - range = new NoEndRecurrenceRange(this.getStartDate()); - } else if (this.getNumberOfOccurrences() != null) { - range = new NumberedRecurrenceRange(this.startDate, - this.numberOfOccurrences); - } else { - if (this.getEndDate() != null) { - range = new EndDateRecurrenceRange(this.getStartDate(), this - .getEndDate()); - } - } - if (range != null) { - range.writeToXml(writer, range.getXmlElementName()); - } - - } - - /** - * Gets a property value or throw if null. * - * - * @param the generic type - * @param cls the cls - * @param value the value - * @param name the name - * @return Property value - * @throws ServiceValidationException the service validation exception - */ - public T getFieldValueOrThrowIfNull(Class cls, Object value, - String name) throws ServiceValidationException { - if (value != null) { - return (T) value; - } else { - throw new ServiceValidationException(String.format( - "The recurrence pattern's %s property must be specified.", - name)); - } - } - - /** - * Gets the date and time when the recurrence start. - * - * @return Date - * @throws ServiceValidationException the service validation exception - */ - public Date getStartDate() throws ServiceValidationException { - return this.getFieldValueOrThrowIfNull(Date.class, this.startDate, - "StartDate"); - - } - - /** - * sets the date and time when the recurrence start. - * - * @param value the new start date - */ - public void setStartDate(Date value) { - this.startDate = value; - } - - /** - * Gets a value indicating whether the pattern has a fixed number of - * occurrences or an end date. - * - * @return boolean - */ - public boolean hasEnd() { - - return ((this.numberOfOccurrences != null) || (this.endDate != null)); - } - - /** - * Sets up this recurrence so that it never ends. Calling NeverEnds is - * equivalent to setting both NumberOfOccurrences and EndDate to null. - */ - public void neverEnds() { - this.numberOfOccurrences = null; - this.endDate = null; - this.changed(); - } - - /** - * Validates this instance. - * - * @throws Exception - */ - @Override - public void internalValidate() throws Exception { - super.internalValidate(); - - if (this.startDate == null) { - throw new ServiceValidationException("The recurrence pattern's StartDate property must be specified."); - } - } - - /** - * Gets the number of occurrences after which the recurrence ends. - * Setting NumberOfOccurrences resets EndDate. - * - * @return the number of occurrences - */ - public Integer getNumberOfOccurrences() { - return this.numberOfOccurrences; - - } - - /** - * Gets the number of occurrences after which the recurrence ends. - * Setting NumberOfOccurrences resets EndDate. - * - * @param value the new number of occurrences - * @throws ArgumentException the argument exception - */ - public void setNumberOfOccurrences(Integer value) throws ArgumentException { - if (value < 1) { - throw new ArgumentException("NumberOfOccurrences must be greater than 0."); - } - - if (this.canSetFieldValue(this.numberOfOccurrences, value)) { - numberOfOccurrences = value; - this.changed(); - } - - this.endDate = null; - - } - - /** - * Gets the date after which the recurrence ends. Setting EndDate resets - * NumberOfOccurrences. - * - * @return the end date - */ - public Date getEndDate() { - - return this.endDate; - } - - /** - * sets the date after which the recurrence ends. Setting EndDate resets - * NumberOfOccurrences. - * - * @param value the new end date - */ - public void setEndDate(Date value) { - - if (this.canSetFieldValue(this.endDate, value)) { - this.endDate = value; - this.changed(); - } - - this.numberOfOccurrences = null; - - } - - /** - * Represents a recurrence pattern where each occurrence happens a specific - * number of days after the previous one. - */ - public final static class DailyPattern extends IntervalPattern { - - /** - * Gets the name of the XML element. - * - * @return the xml element name - */ - @Override - public String getXmlElementName() { - return XmlElementNames.DailyRecurrence; - } - - /** - * Initializes a new instance of the DailyPattern class. - */ - - public DailyPattern() { - super(); - } - - /** - * Initializes a new instance of the DailyPattern class. - * - * @param startDate The date and time when the recurrence starts. - * @param interval The number of days between each occurrence. - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public DailyPattern(Date startDate, int interval) - throws ArgumentOutOfRangeException { - super(startDate, interval); - } - - } - - - /** - * Represents a regeneration pattern, as used with recurring tasks, where - * each occurrence happens a specified number of days after the previous one - * is completed. - */ - - public final static class DailyRegenerationPattern extends IntervalPattern { - - /** - * Initializes a new instance of the DailyRegenerationPattern class. - */ - public DailyRegenerationPattern() { - super(); - } - - /** - * Initializes a new instance of the DailyRegenerationPattern class. - * - * @param startDate The date and time when the recurrence starts. - * @param interval The number of days between each occurrence. - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public DailyRegenerationPattern(Date startDate, int interval) - throws ArgumentOutOfRangeException { - super(startDate, interval); - - } - - /** - * Gets the name of the XML element. - * - * @return the xml element name - */ - public String getXmlElementName() { - return XmlElementNames.DailyRegeneration; - } - - /** - * Gets a value indicating whether this instance is a regeneration - * pattern. - * - * @return true, if is regeneration pattern - */ - public boolean isRegenerationPattern() { - return true; - } - - } - - - /** - * Represents a recurrence pattern where each occurrence happens at a - * specific interval after the previous one. - * [EditorBrowsable(EditorBrowsableState.Never)] - */ - @EditorBrowsable(state = EditorBrowsableState.Never) - public abstract static class IntervalPattern extends Recurrence { - - /** - * The interval. - */ - private int interval = 1; - - /** - * Initializes a new instance of the IntervalPattern class. - */ - public IntervalPattern() { - super(); - } - - /** - * Initializes a new instance of the IntervalPattern class. - * - * @param startDate The date and time when the recurrence starts. - * @param interval The number of days between each occurrence. - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public IntervalPattern(Date startDate, int interval) - throws ArgumentOutOfRangeException { - - super(startDate); - if (interval < 1) { - throw new ArgumentOutOfRangeException("interval", "The interval must be greater than or equal to 1."); - } - - this.setInterval(interval); - } - - /** - * Write property to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) throws Exception { - super.internalWritePropertiesToXml(writer); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.Interval, this.getInterval()); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return true, if successful - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (super.tryReadElementFromXml(reader)) { - return true; - } else { - - if (reader.getLocalName().equals(XmlElementNames.Interval)) { - this.interval = reader.readElementValue(Integer.class); - return true; - } else { - return false; - } - } - } - - /** - * Gets the interval between occurrences. - * - * @return the interval - */ - public int getInterval() { - return this.interval; - } - - /** - * Sets the interval. - * - * @param value the new interval - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public void setInterval(int value) throws ArgumentOutOfRangeException { - - if (value < 1) { - throw new ArgumentOutOfRangeException("value", "The interval must be greater than or equal to 1."); - } - - if (this.canSetFieldValue(this.interval, value)) { - this.interval = value; - this.changed(); - } - - } - - } - - - /** - * Represents a recurrence pattern where each occurrence happens on a - * specific day a specific number of months after the previous one. - */ - - public final static class MonthlyPattern extends IntervalPattern { - - /** - * The day of month. - */ - private Integer dayOfMonth; - - /** - * Initializes a new instance of the MonthlyPattern class. - */ - public MonthlyPattern() { - super(); - - } - - /** - * Initializes a new instance of the MonthlyPattern class. - * - * @param startDate the start date - * @param interval the interval - * @param dayOfMonth the day of month - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public MonthlyPattern(Date startDate, int interval, int dayOfMonth) - throws ArgumentOutOfRangeException { - super(startDate, interval); - - this.setDayOfMonth(dayOfMonth); - } - - // / Gets the name of the XML element. - - /* - * (non-Javadoc) - * - * @see microsoft.exchange.webservices.Recurrence#getXmlElementName() - */ - @Override - public String getXmlElementName() { - return XmlElementNames.AbsoluteMonthlyRecurrence; - } - - /** - * Write property to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) - throws Exception { - super.internalWritePropertiesToXml(writer); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.DayOfMonth, this.getDayOfMonth()); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if appropriate element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (super.tryReadElementFromXml(reader)) { - return true; - } else { - if (reader.getLocalName().equals(XmlElementNames.DayOfMonth)) { - this.dayOfMonth = reader.readElementValue(Integer.class); - return true; - } else { - return false; - } - } - } - - /** - * Validates this instance. - * - * @throws Exception - */ - @Override - public void internalValidate() throws Exception { - super.internalValidate(); - - if (this.dayOfMonth == null) { - throw new ServiceValidationException("DayOfMonth must be between 1 and 31."); - } - } - - /** - * Gets the day of month. - * - * @return the day of month - * @throws ServiceValidationException the service validation exception - */ - public int getDayOfMonth() throws ServiceValidationException { - return this.getFieldValueOrThrowIfNull(Integer.class, this.dayOfMonth, - "DayOfMonth"); - - } - - /** - * Sets the day of month. - * - * @param value the new day of month - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public void setDayOfMonth(int value) - throws ArgumentOutOfRangeException { - if (value < 1 || value > 31) { - throw new ArgumentOutOfRangeException("DayOfMonth", "DayOfMonth must be between 1 and 31."); - } - - if (this.canSetFieldValue(this.dayOfMonth, value)) { - this.dayOfMonth = value; - this.changed(); - } - } - } - - - /** - * Represents a regeneration pattern, as used with recurring tasks, where - * each occurrence happens a specified number of months after the previous - * one is completed. - */ - public final static class MonthlyRegenerationPattern extends - IntervalPattern { - - /** - * Instantiates a new monthly regeneration pattern. - */ - public MonthlyRegenerationPattern() { - super(); - - } - - /** - * Instantiates a new monthly regeneration pattern. - * - * @param startDate the start date - * @param interval the interval - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public MonthlyRegenerationPattern(Date startDate, int interval) - throws ArgumentOutOfRangeException { - super(startDate, interval); - - } - - /** - * Gets the name of the XML element. The name of the XML - * element. - * - * @return the xml element name - */ - @Override - public String getXmlElementName() { - return XmlElementNames.MonthlyRegeneration; - } - - /** - * Gets a value indicating whether this instance is regeneration - * pattern. true if this instance is regeneration - * pattern; otherwise, false. - * - * @return true, if is regeneration pattern - */ - public boolean isRegenerationPattern() { - return true; - } - } - - - /** - * Represents a recurrence pattern where each occurrence happens on a - * relative day a specific number of months after the previous one. - */ - public final static class RelativeMonthlyPattern extends IntervalPattern { - - /** - * The day of the week. - */ - private DayOfTheWeek dayOfTheWeek; - - /** - * The day of the week index. - */ - private DayOfTheWeekIndex dayOfTheWeekIndex; - - // / Initializes a new instance of the class. - - /** - * Instantiates a new relative monthly pattern. - */ - public RelativeMonthlyPattern() { - super(); - } - - /** - * Instantiates a new relative monthly pattern. - * - * @param startDate the start date - * @param interval the interval - * @param dayOfTheWeek the day of the week - * @param dayOfTheWeekIndex the day of the week index - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public RelativeMonthlyPattern(Date startDate, int interval, - DayOfTheWeek dayOfTheWeek, DayOfTheWeekIndex dayOfTheWeekIndex) - throws ArgumentOutOfRangeException { - super(startDate, interval); - - this.setDayOfTheWeek(dayOfTheWeek); - this.setDayOfTheWeekIndex(dayOfTheWeekIndex); - } - - /** - * Gets the name of the XML element. - * - * @return the xml element name - */ - @Override - public String getXmlElementName() { - return XmlElementNames.RelativeMonthlyRecurrence; - } - - /** - * Write property to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) - throws Exception { - super.internalWritePropertiesToXml(writer); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.DaysOfWeek, this.getDayOfTheWeek()); - - writer - .writeElementValue(XmlNamespace.Types, - XmlElementNames.DayOfWeekIndex, this - .getDayOfTheWeekIndex()); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if appropriate element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (super.tryReadElementFromXml(reader)) { - return true; - } else { - if (reader.getLocalName().equals(XmlElementNames.DaysOfWeek)) { - - this.dayOfTheWeek = reader - .readElementValue(DayOfTheWeek.class); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.DayOfWeekIndex)) { - - this.dayOfTheWeekIndex = reader - .readElementValue(DayOfTheWeekIndex.class); - return true; - } else { - - return false; - } - } - } - - /** - * Validates this instance. - * - * @throws Exception - */ - @Override - public void internalValidate() throws Exception { - super.internalValidate(); - - if (this.dayOfTheWeek == null) { - throw new ServiceValidationException( - "The recurrence pattern's property DayOfTheWeek must be specified."); - } - - if (this.dayOfTheWeekIndex == null) { - throw new ServiceValidationException( - "The recurrence pattern's DayOfWeekIndex property must be specified."); - } - } - - /** - * Day of the week index. - * - * @return the day of the week index - * @throws ServiceValidationException the service validation exception - */ - public DayOfTheWeekIndex getDayOfTheWeekIndex() - throws ServiceValidationException { - return this.getFieldValueOrThrowIfNull(DayOfTheWeekIndex.class, - this.dayOfTheWeekIndex, "DayOfTheWeekIndex"); - } - - /** - * Day of the week index. - * - * @param value the value - */ - public void setDayOfTheWeekIndex(DayOfTheWeekIndex value) { - if (this.canSetFieldValue(this.dayOfTheWeekIndex, value)) { - this.dayOfTheWeekIndex = value; - this.changed(); - } - - } - - /** - * Gets the day of the week. - * - * @return the day of the week - * @throws ServiceValidationException the service validation exception - */ - public DayOfTheWeek getDayOfTheWeek() - throws ServiceValidationException { - return this.getFieldValueOrThrowIfNull(DayOfTheWeek.class, - this.dayOfTheWeek, "DayOfTheWeek"); - - } - - /** - * Sets the day of the week. - * - * @param value the new day of the week - */ - public void setDayOfTheWeek(DayOfTheWeek value) { - - if (this.canSetFieldValue(this.dayOfTheWeek, value)) { - this.dayOfTheWeek = value; - this.changed(); - } - } - } - - - /** - * The Class RelativeYearlyPattern. - */ - public final static class RelativeYearlyPattern extends Recurrence { - - /** - * The day of the week. - */ - private DayOfTheWeek dayOfTheWeek; - - /** - * The day of the week index. - */ - private DayOfTheWeekIndex dayOfTheWeekIndex; - - /** - * The month. - */ - private Month month; - - /** - * Gets the name of the XML element. The name of the XML - * element. - * - * @return the xml element name - */ - @Override - public String getXmlElementName() { - return XmlElementNames.RelativeYearlyRecurrence; - } - - /** - * Write property to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) - throws Exception { - super.internalWritePropertiesToXml(writer); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.DaysOfWeek, this.dayOfTheWeek); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.DayOfWeekIndex, this.dayOfTheWeekIndex); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Month, - this.month); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (super.tryReadElementFromXml(reader)) { - return true; - } else { - if (reader.getLocalName().equals(XmlElementNames.DaysOfWeek)) { - - this.dayOfTheWeek = reader - .readElementValue(DayOfTheWeek.class); - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.DayOfWeekIndex)) { - - this.dayOfTheWeekIndex = reader - .readElementValue(DayOfTheWeekIndex.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Month)) { - - this.month = reader.readElementValue(Month.class); - return true; - } else { - - return false; - } - } - } - - /** - * Instantiates a new relative yearly pattern. - */ - public RelativeYearlyPattern() { - super(); - - } - - /** - * Instantiates a new relative yearly pattern. - * - * @param startDate the start date - * @param month the month - * @param dayOfTheWeek the day of the week - * @param dayOfTheWeekIndex the day of the week index - */ - public RelativeYearlyPattern(Date startDate, Month month, - DayOfTheWeek dayOfTheWeek, - DayOfTheWeekIndex dayOfTheWeekIndex) { - super(startDate); - - this.month = month; - this.dayOfTheWeek = dayOfTheWeek; - this.dayOfTheWeekIndex = dayOfTheWeekIndex; - } - - /** - * Validates this instance. - * - * @throws Exception - */ - @Override - public void internalValidate() throws Exception { - super.internalValidate(); - - if (this.dayOfTheWeekIndex == null) { - throw new ServiceValidationException( - "The recurrence pattern's DayOfWeekIndex property must be specified."); - } - - if (this.dayOfTheWeek == null) { - throw new ServiceValidationException( - "The recurrence pattern's property DayOfTheWeek must be specified."); - } - - if (this.month == null) { - throw new ServiceValidationException("The recurrence pattern's Month property must be specified."); - } - } - - /** - * Gets the relative position of the day specified in DayOfTheWeek - * within the month. - * - * @return the day of the week index - * @throws ServiceValidationException the service validation exception - */ - public DayOfTheWeekIndex getDayOfTheWeekIndex() - throws ServiceValidationException { - - return this.getFieldValueOrThrowIfNull(DayOfTheWeekIndex.class, - this.dayOfTheWeekIndex, "DayOfTheWeekIndex"); - } - - /** - * Sets the relative position of the day specified in DayOfTheWeek - * within the month. - * - * @param value the new day of the week index - */ - public void setDayOfTheWeekIndex(DayOfTheWeekIndex value) { - - if (this.canSetFieldValue(this.dayOfTheWeekIndex, value)) { - this.dayOfTheWeekIndex = value; - this.changed(); - } - } - - /** - * Gets the day of the week. - * - * @return the day of the week - * @throws ServiceValidationException the service validation exception - */ - public DayOfTheWeek getDayOfTheWeek() - throws ServiceValidationException { - - return this.getFieldValueOrThrowIfNull(DayOfTheWeek.class, - this.dayOfTheWeek, "DayOfTheWeek"); - } - - /** - * Sets the day of the week. - * - * @param value the new day of the week - */ - public void setDayOfTheWeek(DayOfTheWeek value) { - - if (this.canSetFieldValue(this.dayOfTheWeek, value)) { - this.dayOfTheWeek = value; - this.changed(); - } - } - - /** - * Gets the month. - * - * @return the month - * @throws ServiceValidationException the service validation exception - */ - public Month getMonth() throws ServiceValidationException { - - return this.getFieldValueOrThrowIfNull(Month.class, this.month, - "Month"); - - } - - /** - * Sets the month. - * - * @param value the new month - */ - public void setMonth(Month value) { - - if (this.canSetFieldValue(this.month, value)) { - this.month = value; - this.changed(); - } - } - } - - - /** - * Represents a recurrence pattern where each occurrence happens on specific - * days a specific number of weeks after the previous one. - */ - public final static class WeeklyPattern extends IntervalPattern implements IComplexPropertyChangedDelegate { - - /** - * The days of the week. - */ - private DayOfTheWeekCollection daysOfTheWeek = - new DayOfTheWeekCollection(); - - private Calendar firstDayOfWeek; - - /** - * Initializes a new instance of the WeeklyPattern class. specific days - * a specific number of weeks after the previous one. - */ - public WeeklyPattern() { - super(); - - this.daysOfTheWeek.addOnChangeEvent(this); - } - - /** - * Initializes a new instance of the WeeklyPattern class. - * - * @param startDate the start date - * @param interval the interval - * @param daysOfTheWeek the days of the week - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public WeeklyPattern(Date startDate, int interval, - DayOfTheWeek... daysOfTheWeek) - throws ArgumentOutOfRangeException { - super(startDate, interval); - - ArrayList toProcess = new ArrayList( - Arrays.asList(daysOfTheWeek)); - Iterator idaysOfTheWeek = toProcess.iterator(); - this.daysOfTheWeek.addRange(idaysOfTheWeek); - } - - /** - * Change event handler. - * - * @param complexProperty the complex property - */ - private void daysOfTheWeekChanged(ComplexProperty complexProperty) { - this.changed(); - } - - /** - * Gets the name of the XML element. The name of the XML - * element. - * - * @return the xml element name - */ - @Override - public String getXmlElementName() { - return XmlElementNames.WeeklyRecurrence; - } - - /** - * Write property to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) - throws Exception { - super.internalWritePropertiesToXml(writer); - - this.getDaysOfTheWeek().writeToXml(writer, - XmlElementNames.DaysOfWeek); - if (this.firstDayOfWeek != null) { - - EwsUtilities - .validatePropertyVersion((ExchangeService) writer.getService(), ExchangeVersion.Exchange2010_SP1, - "FirstDayOfWeek"); - - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.FirstDayOfWeek, - this.firstDayOfWeek); - } - - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if appropriate element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (super.tryReadElementFromXml(reader)) { - return true; - } else { - if (reader.getLocalName().equals(XmlElementNames.DaysOfWeek)) { - - this.getDaysOfTheWeek().loadFromXml(reader, - reader.getLocalName()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.FirstDayOfWeek)) { - this.firstDayOfWeek = reader. - readElementValue(Calendar.class, - XmlNamespace.Types, - XmlElementNames.FirstDayOfWeek); - return true; - } else { - - return false; - } - } - } - - /** - * Validates this instance. - * - * @throws Exception - */ - @Override - public void internalValidate() throws Exception { - super.internalValidate(); - - if (this.getDaysOfTheWeek().getCount() == 0) { - throw new ServiceValidationException( - "The recurrence pattern's property DaysOfTheWeek must contain at least one day of the week."); - } - } - - /** - * Gets the list of the days of the week when occurrences happen. - * - * @return the days of the week - */ - public DayOfTheWeekCollection getDaysOfTheWeek() { - return this.daysOfTheWeek; - } - - public Calendar getFirstDayOfWeek() throws ServiceValidationException { - return this.getFieldValueOrThrowIfNull(Calendar.class, - this.firstDayOfWeek, "FirstDayOfWeek"); - } - - public void setFirstDayOfWeek(Calendar value) { - if (this.canSetFieldValue(this.firstDayOfWeek, value)) { - this.firstDayOfWeek = value; - this.changed(); - } - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices. - * ComplexPropertyChangedDelegateInterface# - * complexPropertyChanged(microsoft.exchange.webservices.ComplexProperty - * ) - */ - @Override - public void complexPropertyChanged(ComplexProperty complexProperty) { - this.daysOfTheWeekChanged(complexProperty); - } - - } - - - /** - * Represents a regeneration pattern, as used with recurring tasks, where - * each occurrence happens a specified number of weeks after the previous - * one is completed. - */ - public final static class WeeklyRegenerationPattern extends - IntervalPattern { - - /** - * Initializes a new instance of the WeeklyRegenerationPattern class. - */ - public WeeklyRegenerationPattern() { - - super(); - } - - /** - * Initializes a new instance of the WeeklyRegenerationPattern class. - * - * @param startDate the start date - * @param interval the interval - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public WeeklyRegenerationPattern(Date startDate, int interval) - throws ArgumentOutOfRangeException { - super(startDate, interval); - - } - - /** - * Gets the name of the XML element. The name of the XML - * element. - * - * @return the xml element name - */ - @Override - public String getXmlElementName() { - return XmlElementNames.WeeklyRegeneration; - } - - /** - * Gets a value indicating whether this instance is regeneration - * pattern. true if this instance is regeneration - * pattern; otherwise, false. - * - * @return true, if is regeneration pattern - */ - public boolean isRegenerationPattern() { - return true; - } - } - - - /** - * Represents a recurrence pattern where each occurrence happens on a - * specific day every year. - */ - public final static class YearlyPattern extends Recurrence { - - /** - * The month. - */ - private Month month; - - /** - * The day of month. - */ - private Integer dayOfMonth; - - /** - * Initializes a new instance of the YearlyPattern class. - */ - public YearlyPattern() { - super(); - - } - - /** - * Initializes a new instance of the YearlyPattern class. - * - * @param startDate the start date - * @param month the month - * @param dayOfMonth the day of month - */ - public YearlyPattern(Date startDate, Month month, int dayOfMonth) { - super(startDate); - - this.month = month; - this.dayOfMonth = dayOfMonth; - } - - /** - * Gets the name of the XML element. The name of the XML - * element. - * - * @return the xml element name - */ - @Override - public String getXmlElementName() { - return XmlElementNames.AbsoluteYearlyRecurrence; - } - - /** - * Write property to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void internalWritePropertiesToXml(EwsServiceXmlWriter writer) - throws Exception { - super.internalWritePropertiesToXml(writer); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.DayOfMonth, this.getDayOfMonth()); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Month, - this.getMonth()); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (super.tryReadElementFromXml(reader)) { - return true; - } else { - if (reader.getLocalName().equals(XmlElementNames.DayOfMonth)) { - - this.dayOfMonth = reader.readElementValue(Integer.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Month)) { - - this.month = reader.readElementValue(Month.class); - return true; - } else { - - return false; - } - } - } - - /** - * Validates this instance. - * - * @throws Exception - */ - @Override - public void internalValidate() throws Exception { - super.internalValidate(); - - if (this.month == null) { - throw new ServiceValidationException("The recurrence pattern's Month property must be specified."); - } - - if (this.dayOfMonth == null) { - throw new ServiceValidationException( - "The recurrence pattern's DayOfMonth property must be specified."); - } - } - - /** - * Gets the month of the year when each occurrence happens. - * - * @return the month - * @throws ServiceValidationException the service validation exception - */ - public Month getMonth() throws ServiceValidationException { - return this.getFieldValueOrThrowIfNull(Month.class, this.month, - "Month"); - } - - /** - * Sets the month. - * - * @param value the new month - */ - public void setMonth(Month value) { - - if (this.canSetFieldValue(this.month, value)) { - this.month = value; - this.changed(); - } - } - - /** - * Gets the day of the month when each occurrence happens. DayOfMonth - * must be between 1 and 31. - * - * @return the day of month - * @throws ServiceValidationException the service validation exception - */ - public int getDayOfMonth() throws ServiceValidationException { - - return this.getFieldValueOrThrowIfNull(Integer.class, this.dayOfMonth, - "DayOfMonth"); - - } - - /** - * Sets the day of the month when each occurrence happens. DayOfMonth - * must be between 1 and 31. - * - * @param value the new day of month - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public void setDayOfMonth(int value) - throws ArgumentOutOfRangeException { - - if (value < 1 || value > 31) { - throw new ArgumentOutOfRangeException("DayOfMonth", "DayOfMonth must be between 1 and 31."); - } - - if (this.canSetFieldValue(this.dayOfMonth, value)) { - this.dayOfMonth = value; - this.changed(); - } - } - } - - - /** - * Represents a regeneration pattern, as used with recurring tasks, where - * each occurrence happens a specified number of years after the previous - * one is completed. - */ - public final static class YearlyRegenerationPattern extends - IntervalPattern { - - /** - * Gets the name of the XML element. The name of the XML - * element. - * - * @return the xml element name - */ - @Override - public String getXmlElementName() { - return XmlElementNames.YearlyRegeneration; - } - - /** - * Gets a value indicating whether this instance is regeneration - * pattern. - * - * @return true, if is regeneration pattern - */ - public boolean isRegenerationPattern() { - return true; - } - - /** - * Initializes a new instance of the YearlyRegenerationPattern class. - */ - public YearlyRegenerationPattern() { - super(); - - } - - /** - * Initializes a new instance of the YearlyRegenerationPattern class. - * - * @param startDate the start date - * @param interval the interval - * @throws ArgumentOutOfRangeException the argument out of range exception - */ - public YearlyRegenerationPattern(Date startDate, int interval) - throws ArgumentOutOfRangeException { - super(startDate, interval); - - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/range/EndDateRecurrenceRange.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/range/EndDateRecurrenceRange.java deleted file mode 100644 index e69c5be2a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/range/EndDateRecurrenceRange.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.recurrence.range; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence; - -import javax.xml.stream.XMLStreamException; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * Represents recurrent range with an end date. - */ -public final class EndDateRecurrenceRange extends RecurrenceRange { - - /** - * The end date. - */ - private Date endDate; - - /** - * Initializes a new instance. - */ - public EndDateRecurrenceRange() { - super(); - } - - /** - * Initializes a new instance. - * - * @param startDate the start date - * @param endDate the end date - */ - public EndDateRecurrenceRange(Date startDate, Date endDate) { - super(startDate); - this.endDate = endDate; - } - - /** - * Gets the name of the XML element. - * - * @return The name of the XML element - */ - public String getXmlElementName() { - return XmlElementNames.EndDateRecurrence; - } - - /** - * Setups the recurrence. - * - * @param recurrence the new up recurrence - * @throws Exception the exception - */ - public void setupRecurrence(Recurrence recurrence) throws Exception { - super.setupRecurrence(recurrence); - recurrence.setEndDate(this.endDate); - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - Date d = this.endDate; - DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - String formattedString = df.format(d); - - super.writeElementsToXml(writer); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.EndDate, - formattedString); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (super.tryReadElementFromXml(reader)) { - return true; - } else { - if (reader.getLocalName().equals(XmlElementNames.EndDate)) { - - Date temp = reader.readElementValueAsUnspecifiedDate(); - - if (temp != null) { - this.endDate = temp; - } - return true; - } else { - return false; - } - } - } - - /** - * Gets the end date. - * - * @return endDate - */ - public Date getEndDate() { - return this.endDate; - } - - /** - * sets the end date. - * - * @param value the new end date - */ - public void setEndDate(Date value) { - this.canSetFieldValue(this.endDate, value); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/range/NoEndRecurrenceRange.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/range/NoEndRecurrenceRange.java deleted file mode 100644 index 2eb3d3449..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/range/NoEndRecurrenceRange.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.recurrence.range; - -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence; - -import java.util.Date; - -/** - * Represents recurrence range with no end date. - */ -public final class NoEndRecurrenceRange extends RecurrenceRange { - - /** - * Initializes a new instance. - */ - public NoEndRecurrenceRange() { - super(); - } - - /** - * Initializes a new instance. - * - * @param startDate the start date - */ - public NoEndRecurrenceRange(Date startDate) { - super(startDate); - } - - /** - * Gets the name of the XML element. - * - * @return The name of the XML element - */ - public String getXmlElementName() { - return XmlElementNames.NoEndRecurrence; - } - - /** - * Setups the recurrence. - * - * @param recurrence the new up recurrence - * @throws Exception the exception - */ - public void setupRecurrence(Recurrence recurrence) throws Exception { - super.setupRecurrence(recurrence); - - recurrence.neverEnds(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/range/NumberedRecurrenceRange.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/range/NumberedRecurrenceRange.java deleted file mode 100644 index 949b4db60..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/range/NumberedRecurrenceRange.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.recurrence.range; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence; - -import javax.xml.stream.XMLStreamException; - -import java.util.Date; - -/** - * The Class NumberedRecurrenceRange. - */ -public final class NumberedRecurrenceRange extends RecurrenceRange { - - /** - * The number of occurrences. - */ - private Integer numberOfOccurrences; - - /** - * Initializes a new instance. - */ - public NumberedRecurrenceRange() { - super(); - } - - /** - * Initializes a new instance. - * - * @param startDate the start date - * @param numberOfOccurrences the number of occurrences - */ - public NumberedRecurrenceRange(Date startDate, - Integer numberOfOccurrences) { - super(startDate); - this.numberOfOccurrences = numberOfOccurrences; - } - - /** - * Gets the name of the XML element. - * - * @return The name of the XML element - */ - public String getXmlElementName() { - return XmlElementNames.NumberedRecurrence; - } - - /** - * Setups the recurrence. - * - * @param recurrence the new up recurrence - * @throws Exception the exception - */ - public void setupRecurrence(Recurrence recurrence) throws Exception { - super.setupRecurrence(recurrence); - recurrence.setNumberOfOccurrences(this.numberOfOccurrences); - } - - /** - * Writes the elements to XML.. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - super.writeElementsToXml(writer); - - if (this.numberOfOccurrences != null) { - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.NumberOfOccurrences, - this.numberOfOccurrences); - } - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (super.tryReadElementFromXml(reader)) { - return true; - } else { - if (reader.getLocalName().equals( - XmlElementNames.NumberOfOccurrences)) { - this.numberOfOccurrences = reader - .readElementValue(Integer.class); - return true; - } else { - return false; - } - } - } - - /** - * Gets the number of occurrences. - * - * @return numberOfOccurrences - */ - - public Integer getNumberOfOccurrences() { - return this.numberOfOccurrences; - } - - /** - * sets the number of occurrences. - * - * @param value the new number of occurrences - */ - public void setNumberOfOccurrences(Integer value) { - this.canSetFieldValue(this.numberOfOccurrences, value); - - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/range/RecurrenceRange.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/range/RecurrenceRange.java deleted file mode 100644 index b82395ec8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/range/RecurrenceRange.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.recurrence.range; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; -import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence; - -import javax.xml.stream.XMLStreamException; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * Represents recurrence range with start and end dates. - */ -public abstract class RecurrenceRange extends ComplexProperty { - - /** - * The start date. - */ - private Date startDate; - - /** - * The recurrence. - */ - private Recurrence recurrence; - - /** - * Initializes a new instance. - */ - protected RecurrenceRange() { - super(); - } - - /** - * Initializes a new instance. - * - * @param startDate the start date - */ - protected RecurrenceRange(Date startDate) { - this(); - this.startDate = startDate; - } - - /** - * Changes handler. - */ - public void changed() { - if (this.recurrence != null) { - this.recurrence.changed(); - } - } - - /** - * Setup the recurrence. - * - * @param recurrence the new up recurrence - * @throws Exception the exception - */ - public void setupRecurrence(Recurrence recurrence) throws Exception { - recurrence.setStartDate(this.getStartDate()); - } - - /** - * Writes elements to XML.. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - Date d = this.startDate; - DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - String formattedString = df.format(d); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.StartDate, - formattedString); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read - * @throws Exception the exception - */ - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.StartDate)) { - //this.startDate = reader.readElementValueAsDateTime(); - Date startDate = reader.readElementValueAsUnspecifiedDate(); - if (startDate != null) { - this.startDate = startDate; - return true; - } - return false; - } else { - return false; - } - } - - /** - * Gets the name of the XML element. - * - * @return recurrence - */ - public abstract String getXmlElementName(); - - /** - * Gets or sets the recurrence. - * - * @return recurrence - */ - protected Recurrence getRecurrence() { - return this.recurrence; - } - - /** - * Sets the recurrence. - * - * @param value the new recurrence - */ - protected void setRecurrence(Recurrence value) { - this.recurrence = value; - } - - /** - * Gets the start date. - * - * @return startDate - */ - protected Date getStartDate() { - return this.startDate; - - } - - /** - * Sets the start date. - * - * @param value the new start date - */ - protected void setStartDate(Date value) { - this.canSetFieldValue(this.startDate, value); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/AbsoluteDateTransition.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/time/AbsoluteDateTransition.java deleted file mode 100644 index 5b8d64fbd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/AbsoluteDateTransition.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.time; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * Represents a time zone period transition that occurs on a fixed (absolute) - * date. - */ -public class AbsoluteDateTransition extends TimeZoneTransition { - - /** - * The date time. - */ - private Date dateTime; - - /** - * Gets the XML element name associated with the transition. - * - * @return The XML element name associated with the transition. - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.AbsoluteDateTransition; - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws java.text.ParseException the parse exception - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws ParseException, Exception { - boolean result = super.tryReadElementFromXml(reader); - - if (!result) { - if (reader.getLocalName().equals(XmlElementNames.DateTime)) { - SimpleDateFormat sdfin = new SimpleDateFormat( - "yyyy-MM-dd'T'HH:mm:ss"); - this.dateTime = sdfin.parse(reader.readElementValue()); - - result = true; - } - } - - return result; - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws XMLStreamException the XML stream exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - super.writeElementsToXml(writer); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.DateTime, - this.dateTime); - } - - /** - * Initializes a new instance of the AbsoluteDateTransition class. - * - * @param timeZoneDefinition , The time zone definition the transition will belong to. - */ - protected AbsoluteDateTransition(TimeZoneDefinition timeZoneDefinition) { - super(timeZoneDefinition); - } - - /** - * Initializes a new instance of the AbsoluteDateTransition class. - * - * @param timeZoneDefinition The time zone definition the transition will belong to. - * @param targetGroup the target group - */ - protected AbsoluteDateTransition(TimeZoneDefinition timeZoneDefinition, - TimeZoneTransitionGroup targetGroup) { - super(timeZoneDefinition, targetGroup); - } - - /** - * Gets the absolute date and time when the transition occurs. - * - * @return the date time - */ - public Date getDateTime() { - return dateTime; - } - - /** - * Sets the date time. - * - * @param dateTime the new date time - */ - protected void setDateTime(Date dateTime) { - this.dateTime = dateTime; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/AbsoluteDayOfMonthTransition.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/time/AbsoluteDayOfMonthTransition.java deleted file mode 100644 index bf7371817..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/AbsoluteDayOfMonthTransition.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.time; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents a time zone period transition that occurs on a specific day of a - * specific month. - */ -class AbsoluteDayOfMonthTransition extends AbsoluteMonthTransition { - - /** - * The day of month. - */ - private int dayOfMonth; - - /** - * Gets the XML element name associated with the transition. - * - * @return The XML element name associated with the transition. - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.RecurringDateTransition; - } - - /** - * Tries to read element from XML. - * - * @param reader returns True if element was read. - * @return true - * @throws Exception throws Exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (super.tryReadElementFromXml(reader)) { - return true; - } else { - if (reader.getLocalName().equals(XmlElementNames.Day)) { - this.dayOfMonth = reader.readElementValue(Integer.class); - - EwsUtilities.ewsAssert(this.dayOfMonth > 0 && this.dayOfMonth <= 31, - "AbsoluteDayOfMonthTransition.TryReadElementFromXml", - "dayOfMonth is not in the valid 1 - 31 range."); - - return true; - } else { - return false; - } - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws XMLStreamException the XML stream exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - super.writeElementsToXml(writer); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Day, - this.dayOfMonth); - } - - /** - * Initializes a new instance of the AbsoluteDayOfMonthTransition class. - * - * @param timeZoneDefinition the time zone definition - */ - protected AbsoluteDayOfMonthTransition(TimeZoneDefinition timeZoneDefinition) { - super(timeZoneDefinition); - } - - /** - * Initializes a new instance of the AbsoluteDayOfMonthTransition class. - * - * @param timeZoneDefinition the time zone definition - * @param targetPeriod the target period - */ - - protected AbsoluteDayOfMonthTransition( - TimeZoneDefinition timeZoneDefinition, TimeZonePeriod targetPeriod) { - super(timeZoneDefinition, targetPeriod); - } - - /** - * Gets the day of then month when this transition occurs. - * - * @return the day of month - */ - protected int getDayOfMonth() { - return this.dayOfMonth; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/AbsoluteMonthTransition.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/time/AbsoluteMonthTransition.java deleted file mode 100644 index f2b77d385..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/AbsoluteMonthTransition.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.time; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.TimeSpan; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents the base class for all recurring time zone period transitions. - */ -abstract class AbsoluteMonthTransition extends TimeZoneTransition { - - /** - * The time offset. - */ - private TimeSpan timeOffset; - - /** - * The month. - */ - private int month; - - /** - * Tries to read element from XML. - * - * @param reader accepts EwsServiceXmlReader - * @return True if element was read - * @throws Exception throws Exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (super.tryReadElementFromXml(reader)) { - return true; - } else { - if (reader.getLocalName().equals(XmlElementNames.TimeOffset)) { - this.timeOffset = EwsUtilities.getXSDurationToTimeSpan(reader.readElementValue()); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Month)) { - this.month = reader.readElementValue(Integer.class); - - EwsUtilities.ewsAssert(this.month > 0 && this.month <= 12, - "AbsoluteMonthTransition.TryReadElementFromXml", - "month is not in the valid 1 - 12 range."); - - return true; - } else { - return false; - } - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws XMLStreamException the XML stream exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - super.writeElementsToXml(writer); - - writer.writeElementValue(XmlNamespace.Types, - XmlElementNames.TimeOffset, EwsUtilities - .getTimeSpanToXSDuration(this.timeOffset)); - - writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Month, - this.month); - } - - /** - * Initializes a new instance of the AbsoluteMonthTransition class. - * - * @param timeZoneDefinition the time zone definition - */ - protected AbsoluteMonthTransition(TimeZoneDefinition timeZoneDefinition) { - super(timeZoneDefinition); - } - - /** - * Initializes a new instance of the AbsoluteMonthTransition class. - * - * @param timeZoneDefinition the time zone definition - * @param targetPeriod the target period - */ - protected AbsoluteMonthTransition(TimeZoneDefinition timeZoneDefinition, - TimeZonePeriod targetPeriod) { - super(timeZoneDefinition, targetPeriod); - } - - /** - * Gets the time offset from midnight when the transition occurs. - * - * @return the time offset - */ - protected TimeSpan getTimeOffset() { - return this.timeOffset; - } - - /** - * Gets the month when the transition occurs. - * - * @return the month - */ - protected int getMonth() { - return this.month; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/OlsonTimeZoneDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/time/OlsonTimeZoneDefinition.java deleted file mode 100644 index 188844a8e..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/OlsonTimeZoneDefinition.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.time; - - -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.util.TimeZoneUtils; - -import java.util.Date; -import java.util.TimeZone; - -/** - * A TimeZoneDefinition class that allows mapping from a Java/Olson TimeZone to a MS TimeZone. - */ -public class OlsonTimeZoneDefinition extends TimeZoneDefinition { - - /** - * Create a TimeZoneDefinition compatible with java.util.TimeZone - * @param timeZone a java time zone object, will be converted to Microsoft timezone. - */ - public OlsonTimeZoneDefinition(TimeZone timeZone) { - final String microsoftTimeZoneName = TimeZoneUtils.getMicrosoftTimeZoneName(timeZone); - if (microsoftTimeZoneName != null) { - this.id = microsoftTimeZoneName; - } - this.name = timeZone.getDisplayName(timeZone.inDaylightTime(new Date()), TimeZone.LONG); - } - - @Override - public void validate() throws ServiceLocalException { - if (this.id == null) { - throw new ServiceLocalException("Invalid TimeZone (" + this.name + ") Specified"); - } - } -} \ No newline at end of file diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/RelativeDayOfMonthTransition.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/time/RelativeDayOfMonthTransition.java deleted file mode 100644 index b71ad87d8..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/RelativeDayOfMonthTransition.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.time; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.time.DayOfTheWeek; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents a time zone period transition that occurs on a relative day of a - * specific month. - */ -class RelativeDayOfMonthTransition extends AbsoluteMonthTransition { - - /** - * The day of the week. - */ - private DayOfTheWeek dayOfTheWeek; - - /** - * The week index. - */ - private int weekIndex; - - /** - * Gets the XML element name associated with the transition. - * - * @return The XML element name associated with the transition. - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.RecurringDayTransition; - } - - /** - * Tries to read element from XML. - * - * @param reader accepts EwsServiceXmlReader - * @return True if element was read. - * @throws Exception throws Exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (super.tryReadElementFromXml(reader)) { - return true; - } else { - if (reader.getLocalName().equals(XmlElementNames.DayOfWeek)) { - this.dayOfTheWeek = reader.readElementValue(DayOfTheWeek.class); - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Occurrence)) { - this.weekIndex = reader.readElementValue(Integer.class); - return true; - } else { - return false; - } - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws XMLStreamException the XML stream exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - super.writeElementsToXml(writer); - - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.DayOfWeek, - this.dayOfTheWeek); - - writer.writeElementValue( - XmlNamespace.Types, - XmlElementNames.Occurrence, - this.weekIndex); - } - - /** - * Initializes a new instance of the "RelativeDayOfMonthTransition class. - * - * @param timeZoneDefinition the time zone definition - */ - protected RelativeDayOfMonthTransition( - TimeZoneDefinition timeZoneDefinition) { - super(timeZoneDefinition); - } - - /** - * Initializes a new instance of the "RelativeDayOfMonthTransition class. - * - * @param timeZoneDefinition the time zone definition - * @param targetPeriod the target period - */ - protected RelativeDayOfMonthTransition( - TimeZoneDefinition timeZoneDefinition, - TimeZonePeriod targetPeriod) { - super(timeZoneDefinition, targetPeriod); - } - - /** - * Gets the day of the week when the transition occurs. - * - * @return the day of the week - */ - protected DayOfTheWeek getDayOfTheWeek() { - return this.dayOfTheWeek; - } - - /** - * Gets the index of the week in the month when the transition occurs. - * - * @return the week index - */ - protected int getWeekIndex() { - return this.weekIndex; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/TimeZoneDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/time/TimeZoneDefinition.java deleted file mode 100644 index 1b2eb64ab..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/TimeZoneDefinition.java +++ /dev/null @@ -1,440 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.time; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.enumeration.property.time.DayOfTheWeek; -import microsoft.exchange.webservices.data.core.exception.service.local.InvalidOrUnsupportedTimeZoneDefinitionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * Represents a time zone as defined by the EWS schema. - */ -public class TimeZoneDefinition extends ComplexProperty implements Comparator { - - /** - * Prefix for generated ids. - */ - private static String NoIdPrefix = "NoId_"; - - /** - * The Standard period id. - */ - protected final String StandardPeriodId = "Std"; - - /** - * The Standard period name. - */ - protected final String StandardPeriodName = "Standard"; - - /** - * The Daylight period id. - */ - protected final String DaylightPeriodId = "Dlt"; - - /** - * The Daylight period name. - */ - protected final String DaylightPeriodName = "Daylight"; - - /** - * The name. - */ - public String name; - - /** - * The id. - */ - public String id; - - /** - * The periods. - */ - private Map periods = - new HashMap(); - - /** - * The transition groups. - */ - private Map transitionGroups = - new HashMap(); - - /** - * The transitions. - */ - private List transitions = - new ArrayList(); - - /** - * Compares the transitions. - * - * @param x The first transition. - * @param y The second transition. - * @return A negative number if x is less than y, 0 if x and y are equal, a - * positive number if x is greater than y. - */ - @Override - public int compare(final TimeZoneTransition x, final TimeZoneTransition y) { - if (x == y) { - return 0; - } else if (x != null && y != null) { - if (x instanceof AbsoluteDateTransition && y instanceof AbsoluteDateTransition) { - final AbsoluteDateTransition firstTransition = (AbsoluteDateTransition) x; - final AbsoluteDateTransition secondTransition = (AbsoluteDateTransition) y; - - final Date firstDateTime = firstTransition.getDateTime(); - final Date secondDateTime = secondTransition.getDateTime(); - - return firstDateTime.compareTo(secondDateTime); - - } else if (y instanceof TimeZoneTransition) { - return 1; - } - } else if (y == null) { - return 1; - } - return -1; - } - - /** - * Initializes a new instance of the TimeZoneDefinition class. - */ - public TimeZoneDefinition() { - super(); - } - - - /** - * Adds a transition group with a single transition to the specified period. - * - * @param timeZonePeriod the time zone period - * @return A TimeZoneTransitionGroup. - */ - private TimeZoneTransitionGroup createTransitionGroupToPeriod( - TimeZonePeriod timeZonePeriod) { - TimeZoneTransition transitionToPeriod = new TimeZoneTransition(this, - timeZonePeriod); - - TimeZoneTransitionGroup transitionGroup = new TimeZoneTransitionGroup( - this, String.valueOf(this.transitionGroups.size())); - transitionGroup.getTransitions().add(transitionToPeriod); - this.transitionGroups.put(transitionGroup.getId(), transitionGroup); - return transitionGroup; - } - - /** - * Reads the attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.name = reader.readAttributeValue(XmlAttributeNames.Name); - this.id = reader.readAttributeValue(XmlAttributeNames.Id); - - // E14:319057 -- EWS can return a TimeZone definition with no Id. Generate a new Id in this case. - if (this.id == null || this.id.isEmpty()) { - String nameValue = (this.getName() == null || this. - getName().isEmpty()) ? "" : this.getName(); - this.setId(NoIdPrefix + Math.abs(nameValue.hashCode())); - } - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - // The Name attribute is only supported in Exchange 2010 and above. - if (writer.getService().getRequestedServerVersion() != ExchangeVersion.Exchange2007_SP1) { - writer.writeAttributeValue(XmlAttributeNames.Name, this.name); - } - - writer.writeAttributeValue(XmlAttributeNames.Id, this.id); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.Periods)) { - do { - reader.read(); - if (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.Period)) { - TimeZonePeriod period = new TimeZonePeriod(); - period.loadFromXml(reader); - - this.periods.put(period.getId(), period); - } - } while (!reader.isEndElement(XmlNamespace.Types, - XmlElementNames.Periods)); - - return true; - } else if (reader.getLocalName().equals( - XmlElementNames.TransitionsGroups)) { - do { - reader.read(); - if (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.TransitionsGroup)) { - TimeZoneTransitionGroup transitionGroup = - new TimeZoneTransitionGroup( - this); - - transitionGroup.loadFromXml(reader); - - this.transitionGroups.put(transitionGroup.getId(), - transitionGroup); - } - } while (!reader.isEndElement(XmlNamespace.Types, - XmlElementNames.TransitionsGroups)); - - return true; - } else if (reader.getLocalName().equals(XmlElementNames.Transitions)) { - do { - reader.read(); - if (reader.isStartElement()) { - TimeZoneTransition transition = TimeZoneTransition.create( - this, reader.getLocalName()); - - transition.loadFromXml(reader); - - this.transitions.add(transition); - } - } while (!reader.isEndElement(XmlNamespace.Types, - XmlElementNames.Transitions)); - - return true; - } else { - return false; - } - } - - /** - * Loads from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader) throws Exception { - this.loadFromXml(reader, XmlElementNames.TimeZoneDefinition); - Collections.sort(this.transitions, new TimeZoneDefinition()); - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - // We only emit the full time zone definition against Exchange 2010 - // servers and above. - if (writer.getService().getRequestedServerVersion() != ExchangeVersion.Exchange2007_SP1) { - if (this.periods.size() > 0) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.Periods); - - Iterator it = this.periods.values().iterator(); - while (it.hasNext()) { - it.next().writeToXml(writer); - } - - writer.writeEndElement(); // Periods - } - - if (this.transitionGroups.size() > 0) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.TransitionsGroups); - for (int i = 0; i < this.transitionGroups.size(); i++) { - Object key[] = this.transitionGroups.keySet().toArray(); - this.transitionGroups.get(key[i]).writeToXml(writer); - } - writer.writeEndElement(); // TransitionGroups - } - - if (this.transitions.size() > 0) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.Transitions); - - for (TimeZoneTransition transition : this.transitions) { - transition.writeToXml(writer); - } - - writer.writeEndElement(); // Transitions - } - } - } - - /** - * Writes to XML. - * - * @param writer The writer. - * @throws Exception the exception - */ - protected void writeToXml(EwsServiceXmlWriter writer) throws Exception { - this.writeToXml(writer, XmlElementNames.TimeZoneDefinition); - } - - /** - * Validates this time zone definition. - * - * @throws InvalidOrUnsupportedTimeZoneDefinitionException thrown when time zone definition is not valid. - */ - public void validate() throws ServiceLocalException { - // The definition must have at least one period, one transition group - // and one transition, - // and there must be as many transitions as there are transition groups. - if (this.periods.size() < 1 || this.transitions.size() < 1 - || this.transitionGroups.size() < 1 - || this.transitionGroups.size() != this.transitions.size()) { - throw new InvalidOrUnsupportedTimeZoneDefinitionException(); - } - - // The first transition must be of type TimeZoneTransition. - if (this.transitions.get(0).getClass() != TimeZoneTransition.class) { - throw new InvalidOrUnsupportedTimeZoneDefinitionException(); - } - - // All transitions must be to transition groups and be either - // TimeZoneTransition or - // AbsoluteDateTransition instances. - for (TimeZoneTransition transition : this.transitions) { - Class transitionType = transition.getClass(); - - if (transitionType != TimeZoneTransition.class - && transitionType != AbsoluteDateTransition.class) { - throw new InvalidOrUnsupportedTimeZoneDefinitionException(); - } - - if (transition.getTargetGroup() == null) { - throw new InvalidOrUnsupportedTimeZoneDefinitionException(); - } - } - - // All transition groups must be valid. - for (TimeZoneTransitionGroup transitionGroup : this.transitionGroups - .values()) { - transitionGroup.validate(); - } - } - - /** - * Gets the name of this time zone definition. - * - * @return the name - */ - public String getName() { - return this.name; - } - - /** - * Sets the name. - * - * @param name the new name - */ - protected void setName(String name) { - this.name = name; - } - - /** - * Gets the Id of this time zone definition. - * - * @return the id - */ - public String getId() { - return this.id; - } - - /** - * Sets the id. - * - * @param id the new id - */ - public void setId(String id) { - this.id = id; - } - - /** - * Adds a transition group with a single transition to the specified period. - * - * @return A TimeZoneTransitionGroup. - */ - public Map getPeriods() { - return this.periods; - } - - /** - * Gets the transition groups associated with this time zone definition, - * indexed by Id. - * - * @return the transition groups - */ - public Map getTransitionGroups() { - return this.transitionGroups; - } - - /** - * Writes to XML. - * - * @param writer accepts EwsServiceXmlWriter - * @param xmlElementName accepts String - * @throws Exception throws Exception - */ - public void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) - throws Exception { - this.writeToXml(writer, this.getNamespace(), xmlElementName); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/TimeZonePeriod.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/time/TimeZonePeriod.java deleted file mode 100644 index 657c9fb2d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/TimeZonePeriod.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.time; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.TimeSpan; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -/** - * Represents a time zone period as defined in the EWS schema. - */ -public class TimeZonePeriod extends ComplexProperty { - - /** - * The Constant StandardPeriodId. - */ - protected final static String StandardPeriodId = "Std"; - - /** - * The Constant StandardPeriodName. - */ - protected final static String StandardPeriodName = "Standard"; - - /** - * The Constant DaylightPeriodId. - */ - protected final static String DaylightPeriodId = "Dlt"; - - /** - * The Constant DaylightPeriodName. - */ - protected final static String DaylightPeriodName = "Daylight"; - - /** - * The bias. - */ - private TimeSpan bias; - - /** - * The name. - */ - private String name; - - /** - * The id. - */ - private String id; - - /** - * Reads the attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.id = reader.readAttributeValue(XmlAttributeNames.Id); - this.name = reader.readAttributeValue(XmlAttributeNames.Name); - this.bias = EwsUtilities.getXSDurationToTimeSpan(reader.readAttributeValue(XmlAttributeNames.Bias)); - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.Bias, EwsUtilities - .getTimeSpanToXSDuration(this.bias)); - writer.writeAttributeValue(XmlAttributeNames.Name, this.name); - writer.writeAttributeValue(XmlAttributeNames.Id, this.id); - } - - /** - * Loads from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader) throws Exception { - this.loadFromXml(reader, XmlElementNames.Period); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer) throws Exception { - this.writeToXml(writer, XmlElementNames.Period); - } - - /** - * Initializes a new instance of the TimeZonePeriod class. - */ - public TimeZonePeriod() { - super(); - } - - /** - * Gets a value indicating whether this period represents the Standard - * period. - * - * @return true if this instance is standard period; otherwise, false - */ - protected boolean isStandardPeriod() { - return this.name.equals(TimeZonePeriod.StandardPeriodName); - } - - /** - * Gets the bias to UTC associated with this period. - * - * @return the bias - */ - protected TimeSpan getBias() { - return bias; - } - - /** - * Sets the bias. - * - * @param bias the new bias - */ - protected void setBias(TimeSpan bias) { - this.bias = bias; - } - - /** - * Gets the name of this period. - * - * @return the name - */ - protected String getName() { - return name; - } - - /** - * Sets the name. - * - * @param name the new name - */ - protected void setName(String name) { - this.name = name; - } - - /** - * Gets the id of this period. - * - * @return the id - */ - public String getId() { - return id; - } - - /** - * Sets the id. - * - * @param id the new id - */ - protected void setId(String id) { - this.id = id; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/TimeZoneTransition.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/time/TimeZoneTransition.java deleted file mode 100644 index 695cb2064..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/TimeZoneTransition.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.time; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents the base class for all time zone transitions. - */ -public class TimeZoneTransition extends ComplexProperty { - - /** - * The Period target. - */ - private final String PeriodTarget = "Period"; - - /** - * The Group target. - */ - private final String GroupTarget = "Group"; - - /** - * The time zone definition. - */ - private TimeZoneDefinition timeZoneDefinition; - - /** - * The target period. - */ - private TimeZonePeriod targetPeriod; - - /** - * The target group. - */ - private TimeZoneTransitionGroup targetGroup; - - /** - * Creates a time zone period transition of the appropriate type given an - * XML element name. - * - * @param timeZoneDefinition the time zone definition - * @param xmlElementName the xml element name - * @return A TimeZonePeriodTransition instance. - * @throws ServiceLocalException the service local exception - */ - public static TimeZoneTransition create(TimeZoneDefinition timeZoneDefinition, String xmlElementName) - throws ServiceLocalException { - if (xmlElementName.equals(XmlElementNames.AbsoluteDateTransition)) { - return new AbsoluteDateTransition(timeZoneDefinition); - } else if (xmlElementName - .equals(XmlElementNames.AbsoluteDateTransition)) { - return new AbsoluteDateTransition(timeZoneDefinition); - } else if (xmlElementName - .equals(XmlElementNames.RecurringDayTransition)) { - return new RelativeDayOfMonthTransition(timeZoneDefinition); - } else if (xmlElementName - .equals(XmlElementNames.RecurringDateTransition)) { - return new AbsoluteDayOfMonthTransition(timeZoneDefinition); - } else if (xmlElementName.equals(XmlElementNames.Transition)) { - return new TimeZoneTransition(timeZoneDefinition); - } else { - throw new ServiceLocalException(String - .format("Unknown time zone transition type: %s", - xmlElementName)); - } - } - - /** - * Gets the XML element name associated with the transition. - * - * @return The XML element name associated with the transition. - */ - protected String getXmlElementName() { - return XmlElementNames.Transition; - } - - /** - * Tries to read element from XML.The reader. - * - * @param reader The - * reader. - * @return True if element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - if (reader.getLocalName().equals(XmlElementNames.To)) { - String targetKind = reader - .readAttributeValue(XmlAttributeNames.Kind); - String targetId = reader.readElementValue(); - if (targetKind.equals(PeriodTarget)) { - if (!this.timeZoneDefinition.getPeriods().containsKey(targetId)) { - - throw new ServiceLocalException(String.format( - "Invalid transition. A period with the specified Id couldn't be found: %s", targetId)); - } else { - this.targetPeriod = this.timeZoneDefinition.getPeriods() - .get(targetId); - } - } else if (targetKind.equals(GroupTarget)) { - if (!this.timeZoneDefinition.getTransitionGroups().containsKey( - targetId)) { - - throw new ServiceLocalException(String.format( - "Invalid transition. A transition group with the specified ID couldn't be found: %s", targetId)); - } else { - this.targetGroup = this.timeZoneDefinition - .getTransitionGroups().get(targetId); - } - } else { - throw new ServiceLocalException("The time zone transition target isn't supported."); - } - - return true; - } else { - return false; - } - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws XMLStreamException the XML stream exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - writer.writeStartElement(XmlNamespace.Types, XmlElementNames.To); - - if (this.targetPeriod != null) { - writer.writeAttributeValue(XmlAttributeNames.Kind, PeriodTarget); - writer.writeValue(this.targetPeriod.getId(), XmlElementNames.To); - } else if (this.targetGroup != null) { - writer.writeAttributeValue(XmlAttributeNames.Kind, GroupTarget); - writer.writeValue(this.targetGroup.getId(), XmlElementNames.To); - } - - writer.writeEndElement(); // To - } - - /** - * Loads from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader) throws Exception { - this.loadFromXml(reader, this.getXmlElementName()); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer) throws Exception { - this.writeToXml(writer, this.getXmlElementName()); - } - - /** - * Initializes a new instance of the class. - * - * @param timeZoneDefinition the time zone definition - */ - protected TimeZoneTransition(TimeZoneDefinition timeZoneDefinition) { - super(); - this.timeZoneDefinition = timeZoneDefinition; - } - - /** - * Initializes a new instance of the class. - * - * @param timeZoneDefinition the time zone definition - * @param targetGroup the target group - */ - protected TimeZoneTransition(TimeZoneDefinition timeZoneDefinition, - TimeZoneTransitionGroup targetGroup) { - this(timeZoneDefinition); - this.targetGroup = targetGroup; - } - - /** - * Initializes a new instance of the class. - * - * @param timeZoneDefinition the time zone definition - * @param targetPeriod the target period - */ - public TimeZoneTransition(TimeZoneDefinition timeZoneDefinition, TimeZonePeriod targetPeriod) { - this(timeZoneDefinition); - this.targetPeriod = targetPeriod; - } - - /** - * Gets the target period of the transition. - * - * @return the target period - */ - protected TimeZonePeriod getTargetPeriod() { - return this.targetPeriod; - } - - /** - * Gets the target transition group of the transition. - * - * @return the target group - */ - public TimeZoneTransitionGroup getTargetGroup() { - return this.targetGroup; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/TimeZoneTransitionGroup.java b/src/main/java/microsoft/exchange/webservices/data/property/complex/time/TimeZoneTransitionGroup.java deleted file mode 100644 index e918486cd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/complex/time/TimeZoneTransitionGroup.java +++ /dev/null @@ -1,430 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex.time; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.exception.service.local.InvalidOrUnsupportedTimeZoneDefinitionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.TimeSpan; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a group of time zone period transitions. - */ -public class TimeZoneTransitionGroup extends ComplexProperty { - - /** - * The time zone definition. - */ - private TimeZoneDefinition timeZoneDefinition; - - /** - * The id. - */ - private String id; - - /** - * The transitions. - */ - private List transitions = - new ArrayList(); - - /** - * The transition to standard. - */ - private TimeZoneTransition transitionToStandard; - - /** - * The transition to daylight. - */ - private TimeZoneTransition transitionToDaylight; - - /** - * The Constant PeriodTarget. - */ - private final static String PeriodTarget = "Period"; - - /** - * The Constant GroupTarget. - */ - private final static String GroupTarget = "Group"; - - - /** - * Loads from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader) throws Exception { - this.loadFromXml(reader, XmlElementNames.TransitionsGroup); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer) throws Exception { - this.writeToXml(writer, XmlElementNames.TransitionsGroup); - } - - /** - * Reads the attribute from XML. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - this.id = reader.readAttributeValue(XmlAttributeNames.Id); - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.Id, this.id); - } - - /** - * Writes the attribute to XML. - * - * @param reader the reader - * @return true, if successful - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - reader.ensureCurrentNodeIsStartElement(); - - TimeZoneTransition transition = TimeZoneTransition.create( - this.timeZoneDefinition, reader.getLocalName()); - - transition.loadFromXml(reader); - - EwsUtilities - .ewsAssert(transition.getTargetPeriod() != null, "TimeZoneTransitionGroup.TryReadElementFromXml", - "The transition's target period is null."); - - this.transitions.add(transition); - - return true; - } - - /** - * Writes elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - for (TimeZoneTransition transition : this.transitions) { - transition.writeToXml(writer); - } - } - - /** - * Validates this transition group. - * - * @throws InvalidOrUnsupportedTimeZoneDefinitionException thrown when time zone definition is not valid. - */ - public void validate() throws ServiceLocalException { - // There must be exactly one or two transitions in the group. - if (this.transitions.size() < 1 || this.transitions.size() > 2) { - throw new InvalidOrUnsupportedTimeZoneDefinitionException(); - } - - // If there is only one transition, it must be of type - // TimeZoneTransition - if (this.transitions.size() == 1 - && !(this.transitions.get(0).getClass() == - TimeZoneTransition.class)) { - throw new InvalidOrUnsupportedTimeZoneDefinitionException(); - } - - // If there are two transitions, none of them should be of type - // TimeZoneTransition - if (this.transitions.size() == 2) { - for (TimeZoneTransition transition : this.transitions) { - if (transition.getClass() == TimeZoneTransition.class) { - throw new InvalidOrUnsupportedTimeZoneDefinitionException(); - } - } - } - - // All the transitions in the group must be to a period. - for (TimeZoneTransition transition : this.transitions) { - if (transition.getTargetPeriod() == null) { - throw new InvalidOrUnsupportedTimeZoneDefinitionException(); - } - } - } - - /** - * The Class CustomTimeZoneCreateParams. - */ - protected static class CustomTimeZoneCreateParams { - - /** - * The base offset to utc. - */ - private TimeSpan baseOffsetToUtc; - - /** - * The standard display name. - */ - private String standardDisplayName; - - /** - * The daylight display name. - */ - private String daylightDisplayName; - - /** - * Initializes a new instance of the class. - */ - protected CustomTimeZoneCreateParams() { - } - - /** - * Gets the base offset to UTC. - * - * @return the base offset to utc - */ - protected TimeSpan getBaseOffsetToUtc() { - return this.baseOffsetToUtc; - } - - /** - * Sets the base offset to utc. - * - * @param baseOffsetToUtc the new base offset to utc - */ - protected void setBaseOffsetToUtc(TimeSpan baseOffsetToUtc) { - this.baseOffsetToUtc = baseOffsetToUtc; - } - - /** - * Gets the display name of the standard period. - * - * @return the standard display name - */ - protected String getStandardDisplayName() { - return this.standardDisplayName; - } - - /** - * Sets the standard display name. - * - * @param standardDisplayName the new standard display name - */ - protected void setStandardDisplayName(String standardDisplayName) { - this.standardDisplayName = standardDisplayName; - } - - /** - * Gets the display name of the daylight period. - * - * @return the daylight display name - */ - protected String getDaylightDisplayName() { - return this.daylightDisplayName; - } - - /** - * Sets the daylight display name. - * - * @param daylightDisplayName the new daylight display name - */ - protected void setDaylightDisplayName(String daylightDisplayName) { - this.daylightDisplayName = daylightDisplayName; - } - - /** - * Gets a value indicating whether the custom time zone should have a - * daylight period. true if the custom time zone should - * have a daylight period; otherwise, false. - * - * @return the checks for daylight period - */ - protected boolean getHasDaylightPeriod() { - return (!(this.daylightDisplayName == null || - this.daylightDisplayName.isEmpty())); - } - } - - /** - * Gets a value indicating whether this group contains a transition to the - * Daylight period. true if this group contains a transition - * to daylight; otherwise, false. - * - * @return the supports daylight - */ - protected boolean getSupportsDaylight() { - return this.transitions.size() == 2; - } - - /** - * Initializes the private members holding references to the transitions to - * the Daylight and Standard periods. - * - * @throws InvalidOrUnsupportedTimeZoneDefinitionException thrown when time zone definition is not valid. - */ - private void initializeTransitions() throws ServiceLocalException { - if (this.transitionToStandard == null) { - for (TimeZoneTransition transition : this.transitions) { - if (transition.getTargetPeriod().isStandardPeriod() || - (this.transitions.size() == 1)) { - this.transitionToStandard = transition; - } else { - this.transitionToDaylight = transition; - } - } - } - - // If we didn't find a Standard period, this is an invalid time zone - // group. - if (this.transitionToStandard == null) { - throw new InvalidOrUnsupportedTimeZoneDefinitionException(); - } - } - - /** - * Gets the transition to the Daylight period. - * - * @return the transition to daylight - * @throws ServiceLocalException the service local exception - */ - private TimeZoneTransition getTransitionToDaylight() - throws ServiceLocalException { - this.initializeTransitions(); - return this.transitionToDaylight; - } - - /** - * Gets the transition to the Standard period. - * - * @return the transition to standard - * @throws ServiceLocalException the service local exception - */ - private TimeZoneTransition getTransitionToStandard() - throws ServiceLocalException { - this.initializeTransitions(); - return this.transitionToStandard; - } - - /** - * Gets the offset to UTC based on this group's transitions. - * - * @return the custom time zone creation params - */ - protected CustomTimeZoneCreateParams getCustomTimeZoneCreationParams() { - CustomTimeZoneCreateParams result = new CustomTimeZoneCreateParams(); - - if (this.transitionToDaylight != null) { - result.setDaylightDisplayName(this.transitionToDaylight - .getTargetPeriod().getName()); - } - - result.setStandardDisplayName(this.transitionToStandard - .getTargetPeriod().getName()); - - // Assume that the standard period's offset is the base offset to UTC. - // EWS returns a positive offset for time zones that are behind UTC, and - // a negative one for time zones ahead of UTC. TimeZoneInfo does it the - // other - // way around. - // result.BaseOffsetToUtc = - // -this.TransitionToStandard.TargetPeriod.Bias; - - return result; - } - - /** - * Initializes a new instance of the class. - * - * @param timeZoneDefinition the time zone definition - */ - public TimeZoneTransitionGroup(TimeZoneDefinition timeZoneDefinition) { - super(); - this.timeZoneDefinition = timeZoneDefinition; - } - - /** - * Initializes a new instance of the class. - * - * @param timeZoneDefinition the time zone definition - * @param id the id - */ - public TimeZoneTransitionGroup(TimeZoneDefinition timeZoneDefinition, String id) { - this(timeZoneDefinition); - this.id = id; - } - - /** - * Gets the id of this group. - * - * @return the id - */ - public String getId() { - return this.id; - } - - /** - * Sets the id. - * - * @param id the new id - */ - public void setId(String id) { - this.id = id; - } - - /** - * Gets the transitions in this group. - * - * @return the transitions - */ - public List getTransitions() { - return this.transitions; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/AttachmentsPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/AttachmentsPropertyDefinition.java deleted file mode 100644 index 4dc8c02b5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/AttachmentsPropertyDefinition.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.AttachmentCollection; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; - -import java.util.EnumSet; - -/** - * Represents base Attachments property type. - */ -public final class AttachmentsPropertyDefinition extends - ComplexPropertyDefinition { - - private static final EnumSet Exchange2010SP2PropertyDefinitionFlags = EnumSet - .of(PropertyDefinitionFlags.AutoInstantiateOnRead, - PropertyDefinitionFlags.CanSet, - PropertyDefinitionFlags.ReuseInstance, - PropertyDefinitionFlags.UpdateCollectionItems); - - public AttachmentsPropertyDefinition() { - super(null, XmlElementNames.Attachments, "item:Attachments", - EnumSet - .of(PropertyDefinitionFlags.AutoInstantiateOnRead), - ExchangeVersion.Exchange2007_SP1, - new ICreateComplexPropertyDelegate() { - public AttachmentCollection createComplexProperty() { - return new AttachmentCollection(); - } - }); - - } - - /** - * Determines whether the specified flag is set. - * - * @param flag The flag. - * @param version Requested version. - * @return true/false if the specified flag is set,otherwise false. - */ - @Override public boolean hasFlag(PropertyDefinitionFlags flag, ExchangeVersion version) { - if (version != null - && this.getVersion() - .compareTo(ExchangeVersion.Exchange2010_SP2) >= 0) { - if (AttachmentsPropertyDefinition.Exchange2010SP2PropertyDefinitionFlags - .contains(flag)) { - return true; - } else { - return false; - } - } - return super.hasFlag(flag, version); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/BoolPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/BoolPropertyDefinition.java deleted file mode 100644 index 793636b1c..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/BoolPropertyDefinition.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; - -import java.util.EnumSet; - -/** - * Represents Boolean property definition. - */ -public final class BoolPropertyDefinition extends GenericPropertyDefinition { - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param version The version. - */ - public BoolPropertyDefinition(String xmlElementName, String uri, - ExchangeVersion version) { - super(Boolean.class, xmlElementName, uri, version); - } - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - */ - public BoolPropertyDefinition(String xmlElementName, String uri, EnumSet flags, - ExchangeVersion version) { - super(Boolean.class, xmlElementName, uri, flags, version); - } - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - * @param isNullable Indicates that this property definition is for a nullable - * property. - */ - public BoolPropertyDefinition(String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version, - boolean isNullable) { - super(Boolean.class, xmlElementName, uri, flags, version, isNullable); - } - - /** - * Convert instance to string. - * - * @param value The value. - * @return String representation of property value. - */ - @Override - /** - * Convert instance to string. - * @param value The value. - * @return String representation of Boolean property. - */ - protected String toString(Boolean value) { - return EwsUtilities.boolToXSBool((Boolean) value); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/ByteArrayPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/ByteArrayPropertyDefinition.java deleted file mode 100644 index 365a54c8d..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/ByteArrayPropertyDefinition.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import org.apache.commons.codec.binary.Base64; - -import java.util.EnumSet; - -/** - * Represents byte array property definition. - */ -public final class ByteArrayPropertyDefinition extends TypedPropertyDefinition { - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - */ - public ByteArrayPropertyDefinition(String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version) { - super(xmlElementName, uri, flags, version); - } - - /** - * Parses the specified value. - * - * @param value accepts String - * @return value - */ - @Override - protected byte[] parse(String value) { - return Base64.decodeBase64(value); - } - - /** - * Converts byte array property to a string. - * - * @param value accepts Object - * @return value - */ - @Override - protected String toString(byte[] value) { - return Base64.encodeBase64String(value); - } - - /** - * Gets a value indicating whether this property definition is for a - * nullable type (ref, int?, bool?...). - * - * @return True - */ - @Override public boolean isNullable() { - return true; - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return Byte.class; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/ComplexPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/ComplexPropertyDefinition.java deleted file mode 100644 index 793e5ea61..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/ComplexPropertyDefinition.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; -import microsoft.exchange.webservices.data.property.complex.IOwnedProperty; - -import java.util.EnumSet; - -/** - * Represents base complex property type. - * - * @param The type of the complex property. - */ -public class ComplexPropertyDefinition - extends ComplexPropertyDefinitionBase { - - private Class instance; - /** - * The property creation delegate. - */ - private ICreateComplexPropertyDelegate propertyCreationDelegate; - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param flags The flags. - * @param version The version. - * @param propertyCreationDelegate Delegate used to create instances of ComplexProperty. - */ - public ComplexPropertyDefinition( - Class cls, - String xmlElementName, - EnumSet flags, - ExchangeVersion version, - ICreateComplexPropertyDelegate - propertyCreationDelegate) { - super(xmlElementName, flags, version); - this.instance = cls; - EwsUtilities.ewsAssert(propertyCreationDelegate != null, "ComplexPropertyDefinition ctor", - "CreateComplexPropertyDelegate cannot be null"); - - this.propertyCreationDelegate = propertyCreationDelegate; - } - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param version The version. - * @param propertyCreationDelegate Delegate used to create instances of ComplexProperty. - */ - public ComplexPropertyDefinition( - Class cls, - String xmlElementName, - String uri, - ExchangeVersion version, - ICreateComplexPropertyDelegate - propertyCreationDelegate) { - super(xmlElementName, uri, version); - this.instance = cls; - this.propertyCreationDelegate = propertyCreationDelegate; - } - - public ComplexPropertyDefinition(String xmlElementName, String uri, ExchangeVersion version, - ICreateComplexPropertyDelegate propertyCreationDelegate) { - super(xmlElementName, uri, version); - this.propertyCreationDelegate = propertyCreationDelegate; - } - - /** - * Instantiates a new complex property definition. - * - * @param xmlElementName the xml element name - * @param uri the uri - * @param flags the flags - * @param version the version - * @param propertyCreationDelegate the property creation delegate - */ - public ComplexPropertyDefinition(Class cls, String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version, - ICreateComplexPropertyDelegate propertyCreationDelegate) { - super(xmlElementName, uri, flags, version); - this.instance = cls; - this.propertyCreationDelegate = propertyCreationDelegate; - } - - - /** - * Instantiates a new complex property definition. - * - * @param xmlElementName the xml element name - * @param attachments the attachments - * @param flags the flags - * @param version the version - * @param propertyCreationDelegate the property creation delegate - */ - public ComplexPropertyDefinition( - String attachments, - String xmlElementName, - ExchangeVersion version, - EnumSet flags, - ICreateComplexPropertyDelegate propertyCreationDelegate) { - // TODO Auto-generated constructor stub - super(xmlElementName, attachments, flags, version); - this.propertyCreationDelegate = propertyCreationDelegate; - } - - /** - * Creates the property instance. - * - * @param owner The owner. - * @return ComplexProperty instance. - */ - @Override public ComplexProperty createPropertyInstance(ServiceObject owner) { - TComplexProperty complexProperty = this.propertyCreationDelegate - .createComplexProperty(); - if (complexProperty instanceof IOwnedProperty) { - IOwnedProperty ownedProperty = (IOwnedProperty) complexProperty; - ownedProperty.setOwner(owner); - } - return complexProperty; - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - /*ParameterizedType parameterizedType = - (ParameterizedType) getClass().getGenericSuperclass(); - return (Class) parameterizedType.getActualTypeArguments()[0]; - - instance = ((Class)((ParameterizedType)this.getClass(). - getGenericSuperclass()).getActualTypeArguments()[0]). - newInstance(); */ - /*return ((Class)((ParameterizedType)this.getClass(). - getGenericSuperclass()).getActualTypeArguments()[0]). - newInstance();*/ - //return ComplexProperty.class; - return this.instance; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/ComplexPropertyDefinitionBase.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/ComplexPropertyDefinitionBase.java deleted file mode 100644 index cf8a13853..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/ComplexPropertyDefinitionBase.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertyBag; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; - -import java.util.EnumSet; - -/** - * Represents abstract complex property definition. - */ -public abstract class ComplexPropertyDefinitionBase extends PropertyDefinition { - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param flags The flags. - * @param version The version. - */ - protected ComplexPropertyDefinitionBase(String xmlElementName, - EnumSet flags, ExchangeVersion version) { - super(xmlElementName, flags, version); - } - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param version The version. - */ - protected ComplexPropertyDefinitionBase(String xmlElementName, String uri, - ExchangeVersion version) { - super(xmlElementName, uri, version); - } - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - */ - protected ComplexPropertyDefinitionBase(String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version) { - super(xmlElementName, uri, flags, version); - } - - /** - * Creates the property instance. - * - * @param owner The owner. - * @return ComplexProperty. - */ - public abstract ComplexProperty createPropertyInstance(ServiceObject owner); - - /** - * Internals the load from XML. - * - * @param reader The reader. - * @param propertyBag The property bag. - * @throws Exception the exception - */ - protected void internalLoadFromXml( - final EwsServiceXmlReader reader, final PropertyBag propertyBag - ) throws Exception { - final OutParam complexProperty = new OutParam(); - final boolean justCreated = getPropertyInstance(propertyBag, complexProperty); - - if (!justCreated && this.hasFlag(PropertyDefinitionFlags.UpdateCollectionItems, - propertyBag.getOwner().getService().getRequestedServerVersion())) { - final ComplexProperty c = complexProperty.getParam(); - c.updateFromXml(reader, reader.getLocalName()); - } else { - final ComplexProperty c = complexProperty.getParam(); - c.loadFromXml(reader, reader.getLocalName()); - } - - propertyBag.setObjectFromPropertyDefinition(this, complexProperty - .getParam()); - } - - - - /** - * Gets the property instance. - * - * @param propertyBag The property bag. - * @param complexProperty The property instance. - * @return True if the instance is newly created. - */ - private boolean getPropertyInstance( - final PropertyBag propertyBag, final OutParam complexProperty - ) { - final ServiceObject owner = propertyBag.getOwner(); - final ExchangeService service = owner.getService(); - - if (!propertyBag.tryGetValue(this, complexProperty) - || !hasFlag(PropertyDefinitionFlags.ReuseInstance, service.getRequestedServerVersion())) { - complexProperty.setParam(createPropertyInstance(owner)); - return true; - } - return false; - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @param propertyBag The property bag. - * @throws Exception the exception - */ - @Override public void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws Exception { - reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, this - .getXmlElement()); - - if (!reader.isEmptyElement() || reader.hasAttributes()) { - this.internalLoadFromXml(reader, propertyBag); - } - reader.readEndElementIfNecessary(XmlNamespace.Types, this - .getXmlElement()); - } - - /** - * Writes to XML. - * - * @param writer The writer. - * @param propertyBag The property bag. - * @param isUpdateOperation Indicates whether the context is an update operation. - * @throws Exception the exception - */ - @Override public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, - boolean isUpdateOperation) - throws Exception { - ComplexProperty complexProperty = - propertyBag.getObjectFromPropertyDefinition(this); - if (complexProperty != null) { - complexProperty.writeToXml(writer, this.getXmlElement()); - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/ContainedPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/ContainedPropertyDefinition.java deleted file mode 100644 index af1973516..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/ContainedPropertyDefinition.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.PropertyBag; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; -import microsoft.exchange.webservices.data.property.complex.ICreateComplexPropertyDelegate; - -import java.util.EnumSet; - -/** - * Represents contained property definition. - * - * @param The type of the complex property. - */ -public class ContainedPropertyDefinition - extends ComplexPropertyDefinition { - - /** - * The contained xml element name. - */ - private String containedXmlElementName; - - /** - * Initializes a new instance of. ContainedPropertyDefinition - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param containedXmlElementName Name of the contained XML element. - * @param flags The flags. - * @param version The version. - * @param propertyCreationDelegate Delegate used to create instances of ComplexProperty. - */ - public ContainedPropertyDefinition(Class cls, String xmlElementName, String uri, - String containedXmlElementName, EnumSet flags, ExchangeVersion version, - ICreateComplexPropertyDelegate propertyCreationDelegate) { - super(cls, xmlElementName, uri, flags, version, - propertyCreationDelegate); - this.containedXmlElementName = containedXmlElementName; - } - - /** - * Load from XML. - * - * @param reader the reader - * @param propertyBag the property bag - * @throws Exception the exception - */ - @Override - protected void internalLoadFromXml(EwsServiceXmlReader reader, - PropertyBag propertyBag) throws Exception { - reader.readStartElement(XmlNamespace.Types, - this.containedXmlElementName); - super.internalLoadFromXml(reader, propertyBag); - reader.readEndElementIfNecessary(XmlNamespace.Types, - this.containedXmlElementName); - - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param propertyBag the property bag - * @param isUpdateOperation the is update operation - * @throws Exception the exception - */ - @Override public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, - boolean isUpdateOperation) - throws Exception { - - Object o = propertyBag.getObjectFromPropertyDefinition(this); - if (o instanceof ComplexProperty) { - ComplexProperty complexProperty = (ComplexProperty) o; - writer.writeStartElement(XmlNamespace.Types, this.getXmlElement()); - complexProperty.writeToXml(writer, this.containedXmlElementName); - writer.writeEndElement(); // this.XmlElementName - } - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/DateTimePropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/DateTimePropertyDefinition.java deleted file mode 100644 index 8c21159c2..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/DateTimePropertyDefinition.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.PropertyBag; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.util.DateTimeUtils; - -import java.util.Date; -import java.util.EnumSet; - -/** - * Represents DateTime property definition. - */ -public class DateTimePropertyDefinition extends PropertyDefinition { - - /** - * The is nullable. - */ - private boolean isNullable; - - /** - * Initializes a new instance of the DateTimePropertyDefinition class. - * - * @param xmlElementName the xml element name - * @param uri the uri - * @param version the version - */ - public DateTimePropertyDefinition(String xmlElementName, String uri, ExchangeVersion version) { - super(xmlElementName, uri, version); - } - - /** - * Initializes a new instance of the DateTimePropertyDefinition class. - * - * @param xmlElementName the xml element name - * @param uri the uri - * @param flags the flags - * @param version the version - */ - public DateTimePropertyDefinition(String xmlElementName, String uri, EnumSet flags, - ExchangeVersion version) { - super(xmlElementName, uri, flags, version); - } - - /** - * Initializes a new instance of the DateTimePropertyDefinition class. - * - * @param xmlElementName the xml element name - * @param uri the uri - * @param flags the flags - * @param version the version - * @param isNullable the is nullable - */ - public DateTimePropertyDefinition(String xmlElementName, String uri, EnumSet flags, - ExchangeVersion version, boolean isNullable) { - super(xmlElementName, uri, flags, version); - this.isNullable = isNullable; - } - - /** - * Loads from XML. - * - * @param reader the reader - * @param propertyBag the property bag - * @throws Exception the exception - */ - public void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) - throws Exception { - String value = reader.readElementValue(XmlNamespace.Types, getXmlElement()); - propertyBag.setObjectFromPropertyDefinition(this, DateTimeUtils.convertDateTimeStringToDate(value)); - } - - - /** - * Writes the property value to XML. - * - * @param writer accepts EwsServiceXmlWriter - * @param propertyBag accepts PropertyBag - * @param isUpdateOperation accepts boolean whether the context is an update operation. - * @throws Exception throws Exception - */ - public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, - boolean isUpdateOperation) - throws Exception { - Object value = propertyBag.getObjectFromPropertyDefinition(this); - - if (value != null) { - writer.writeStartElement(XmlNamespace.Types, getXmlElement()); - // No need of changing the date time zone to UTC as Java takes - // default timezone as UTC - Date dateTime = (Date) value; - writer.writeValue(EwsUtilities.dateTimeToXSDateTime(dateTime), - getName()); - - writer.writeEndElement(); - } - } - - /** - * Gets a value indicating whether this property definition is for a - * nullable type (ref, int?, bool?...). - * - * @return true, if is nullable - */ - public boolean isNullable() { - return isNullable; - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return Date.class; - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/DoublePropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/DoublePropertyDefinition.java deleted file mode 100644 index 39408de47..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/DoublePropertyDefinition.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; - -import java.util.EnumSet; - -/** - * Represents double-precision floating point property definition. - */ -public final class DoublePropertyDefinition extends - GenericPropertyDefinition { - - /** - * Initializes a new instance of the "DoublePropertyDefinition" class. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - */ - public DoublePropertyDefinition(String xmlElementName, String uri, EnumSet flags, - ExchangeVersion version) { - super(Double.class, xmlElementName, uri, flags, version); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/EffectiveRightsPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/EffectiveRightsPropertyDefinition.java deleted file mode 100644 index 44bca2935..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/EffectiveRightsPropertyDefinition.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.PropertyBag; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.service.EffectiveRights; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -import java.util.EnumSet; - -/** - * Represents effective rights property definition. - */ -public final class EffectiveRightsPropertyDefinition extends PropertyDefinition { - - /** - * Initializes a new instance of the EffectiveRightsPropertyDefinition. - * - * @param xmlElementName the xml element name - * @param uri the uri - * @param flags the flags - * @param version the version - */ - public EffectiveRightsPropertyDefinition(String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version) { - super(xmlElementName, uri, flags, version); - - } - - /** - * Loads from XML. - * - * @param reader the reader - * @param propertyBag the property bag - * @throws Exception the exception - */ - public void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws Exception { - EnumSet value = EnumSet.noneOf(EffectiveRights.class); - value.add(EffectiveRights.None); - - reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, this - .getXmlElement()); - - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.isStartElement()) { - - if (reader.getLocalName().equals( - XmlElementNames.CreateAssociated)) { - - if (reader.readElementValue(Boolean.class)) { - value.add(EffectiveRights.CreateAssociated); - } - } else if (reader.getLocalName().equals( - XmlElementNames.CreateContents)) { - - if (reader.readElementValue(Boolean.class)) { - value.add(EffectiveRights.CreateContents); - } - } else if (reader.getLocalName().equals( - XmlElementNames.CreateHierarchy)) { - - if (reader.readElementValue(Boolean.class)) { - value.add(EffectiveRights.CreateHierarchy); - } - } else if (reader.getLocalName().equals( - XmlElementNames.Delete)) { - - if (reader.readElementValue(Boolean.class)) { - value.add(EffectiveRights.Delete); - } - } else if (reader.getLocalName().equals( - XmlElementNames.Modify)) { - - if (reader.readElementValue(Boolean.class)) { - value.add(EffectiveRights.Modify); - } - } else if (reader.getLocalName().equals(XmlElementNames.Read)) { - if (reader.readElementValue(Boolean.class)) { - value.add(EffectiveRights.Read); - } else if (reader.getLocalName().equals(XmlElementNames.ViewPrivateItems)) { - if (reader.readElementValue(Boolean.class)) { - value.add(EffectiveRights.ViewPrivateItems); - } - } - - } - } - - } while (!reader.isEndElement(XmlNamespace.Types, this - .getXmlElement())); - } - propertyBag.setObjectFromPropertyDefinition(this, value); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param propertyBag the property bag - * @param isUpdateOperation the is update operation - */ - public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, - boolean isUpdateOperation) { - // EffectiveRights is a read-only property, no need to implement this. - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return EffectiveRights.class; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/ExtendedPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/ExtendedPropertyDefinition.java deleted file mode 100644 index 5839aef87..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/ExtendedPropertyDefinition.java +++ /dev/null @@ -1,480 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.property.DefaultExtendedPropertySet; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.MapiPropertyType; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.MapiTypeConverter; - -import java.util.UUID; - -/** - * Represents the definition of an extended property. - */ -public final class ExtendedPropertyDefinition extends PropertyDefinitionBase { - - /** - * The property set. - */ - private DefaultExtendedPropertySet propertySet; - - /** - * The property set id. - */ - private UUID propertySetId; - - /** - * The tag. - */ - private Integer tag; - - /** - * The name. - */ - private String name; - - /** - * The id. - */ - private Integer id; - - /** - * The mapi type. - */ - private MapiPropertyType mapiType; - - /** - * The Constant FieldFormat. - */ - private final static String FieldFormat = "%s: %s "; - - /** - * The Property set field name. - */ - private static final String PropertySetFieldName = "PropertySet"; - - /** - * The Property set id field name. - */ - private static final String PropertySetIdFieldName = "PropertySetId"; - - /** - * The Tag field name. - */ - private static final String TagFieldName = "Tag"; - - /** - * The Name field name. - */ - private static final String NameFieldName = "Name"; - - /** - * The Id field name. - */ - private static final String IdFieldName = "Id"; - - /** - * The Mapi type field name. - */ - private static final String MapiTypeFieldName = "MapiType"; - - /** - * Initializes a new instance. - */ - public ExtendedPropertyDefinition() { - super(); - this.mapiType = MapiPropertyType.String; - } - - /** - * Initializes a new instance. - * - * @param mapiType The MAPI type of the extended property. - */ - protected ExtendedPropertyDefinition(MapiPropertyType mapiType) { - this(); - this.mapiType = mapiType; - } - - /** - * Initializes a new instance. - * - * @param tag The tag of the extended property. - * @param mapiType The MAPI type of the extended property. - */ - public ExtendedPropertyDefinition(int tag, MapiPropertyType mapiType) { - this(mapiType); - if (tag < 0) { - throw new IllegalArgumentException("Argument out of range : tag " + "The extended property tag value must be in the range of 0 to 65,535."); - } - this.tag = tag; - } - - /** - * Initializes a new instance. - * - * @param propertySet The extended property set of the extended property. - * @param name The name of the extended property. - * @param mapiType The MAPI type of the extended property. - * @throws Exception the exception - */ - public ExtendedPropertyDefinition(DefaultExtendedPropertySet propertySet, - String name, MapiPropertyType mapiType) throws Exception { - this(mapiType); - EwsUtilities.validateParam(name, "name"); - - this.propertySet = propertySet; - this.name = name; - } - - /** - * Initializes a new instance. - * - * @param propertySet The property set of the extended property. - * @param id The Id of the extended property. - * @param mapiType The MAPI type of the extended property. - */ - public ExtendedPropertyDefinition(DefaultExtendedPropertySet propertySet, - int id, MapiPropertyType mapiType) { - this(mapiType); - this.propertySet = propertySet; - this.id = id; - } - - /** - * Initializes a new instance. - * - * @param propertySetId The property set Id of the extended property. - * @param name The name of the extended property. - * @param mapiType The MAPI type of the extended property. - * @throws Exception the exception - */ - public ExtendedPropertyDefinition(UUID propertySetId, String name, - MapiPropertyType mapiType) throws Exception { - this(mapiType); - EwsUtilities.validateParam(name, "name"); - - this.propertySetId = propertySetId; - this.name = name; - } - - /** - * Initializes a new instance. - * - * @param propertySetId The property set Id of the extended property. - * @param id The Id of the extended property. - * @param mapiType The MAPI type of the extended property. - */ - public ExtendedPropertyDefinition(UUID propertySetId, int id, - MapiPropertyType mapiType) { - this(mapiType); - this.propertySetId = propertySetId; - this.id = id; - } - - /** - * Determines whether two specified instances of ExtendedPropertyDefinition are equal. - * - * @param extPropDef1 First extended property definition. - * @param extPropDef2 Second extended property definition. - * @return True if extended property definitions are equal. - */ - protected static boolean isEqualTo(ExtendedPropertyDefinition extPropDef1, - ExtendedPropertyDefinition extPropDef2) { - if (extPropDef1 == extPropDef2) { - return true; - } - - if (extPropDef1 == null || extPropDef2 == null) { - return false; - } - - if (extPropDef1.getId() != null) { - if (!extPropDef1.getId().equals(extPropDef2.getId())) { - return false; - } - } else if (extPropDef2.getId() != null) { - return false; - } - - if (extPropDef1.getMapiType() != extPropDef2.getMapiType()) { - return false; - } - - if (extPropDef1.getTag() != null) { - if (!extPropDef1.getTag().equals(extPropDef2.getTag())) { - return false; - } - } else if (extPropDef2.getTag() != null) { - return false; - } - - if (extPropDef1.getName() != null) { - if (!extPropDef1.getName().equals(extPropDef2.getName())) { - return false; - } - } else if (extPropDef2.getName() != null) { - return false; - } - - if (extPropDef1.getPropertySet() != extPropDef2.getPropertySet()) { - return false; - } - - if (extPropDef1.propertySetId != null) { - if (!extPropDef1.propertySetId.equals(extPropDef2.propertySetId)) { - return false; - } - } else if (extPropDef2.propertySetId != null) { - return false; - } - - return true; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.ExtendedFieldURI; - } - - /** - * Gets the minimum Exchange version that supports this extended property. - * - * @return The version. - */ - @Override - public ExchangeVersion getVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Writes the attribute to XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - if (this.propertySet != null) { - writer.writeAttributeValue( - XmlAttributeNames.DistinguishedPropertySetId, - this.propertySet); - } - if (this.propertySetId != null) { - writer.writeAttributeValue(XmlAttributeNames.PropertySetId, - this.propertySetId.toString()); - } - if (this.tag != null) { - writer.writeAttributeValue(XmlAttributeNames.PropertyTag, this.tag); - } - if (null != this.name && !this.name.isEmpty()) { - writer.writeAttributeValue(XmlAttributeNames.PropertyName, - this.name); - } - if (this.id != null) { - writer.writeAttributeValue(XmlAttributeNames.PropertyId, this.id); - } - writer.writeAttributeValue(XmlAttributeNames.PropertyType, - this.mapiType); - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @throws Exception the exception - */ - public void loadFromXml(EwsServiceXmlReader reader) throws Exception { - String attributeValue; - - attributeValue = reader - .readAttributeValue(XmlAttributeNames. - DistinguishedPropertySetId); - if (null != attributeValue && !attributeValue.isEmpty()) { - this.propertySet = DefaultExtendedPropertySet - .valueOf(attributeValue); - } - - attributeValue = reader - .readAttributeValue(XmlAttributeNames.PropertySetId); - if (null != attributeValue && !attributeValue.isEmpty()) { - this.propertySetId = UUID.fromString(attributeValue); - } - - attributeValue = reader - .readAttributeValue(XmlAttributeNames.PropertyTag); - if (null != attributeValue && !attributeValue.isEmpty()) { - - this.tag = Integer.decode(attributeValue); - } - - this.name = reader.readAttributeValue(XmlAttributeNames.PropertyName); - attributeValue = reader - .readAttributeValue(XmlAttributeNames.PropertyId); - if (null != attributeValue && !attributeValue.isEmpty()) { - this.id = Integer.parseInt(attributeValue); - } - - this.mapiType = reader.readAttributeValue(MapiPropertyType.class, - XmlAttributeNames.PropertyType); - } - - - /** - * Determines whether two specified instances of ExtendedPropertyDefinition - * are equal. - * - * @param obj the obj - * @return True if extended property definitions are equal. - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof ExtendedPropertyDefinition) { - return ExtendedPropertyDefinition.isEqualTo(this, - (ExtendedPropertyDefinition) obj); - } else { - return false; - } - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return this.getPrintableName().hashCode(); - } - - /** - * Gets the property definition's printable name. - * - * @return The property definition's printable name. - */ - @Override public String getPrintableName() { - StringBuilder sb = new StringBuilder(); - sb.append("{"); - sb.append(formatField(NameFieldName, this.getName())); - sb.append(formatField(MapiTypeFieldName, this.getMapiType())); - sb.append(formatField(IdFieldName, this.getId())); - sb.append(formatField(PropertySetFieldName, this.getPropertySet())); - sb.append(formatField(PropertySetIdFieldName, this.getPropertySetId())); - sb.append(formatField(TagFieldName, this.getTag())); - sb.append("}"); - return sb.toString(); - } - - /** - * Formats the field. - * - * @param Type of the field. - * @param name The name. - * @param fieldValue The field value. - * @return the string - */ - protected String formatField(String name, T fieldValue) { - return (fieldValue != null) ? String.format(FieldFormat, name, - fieldValue.toString()) : ""; - } - - /** - * Gets the property set of the extended property. - * - * @return property set of the extended property. - */ - public DefaultExtendedPropertySet getPropertySet() { - return this.propertySet; - } - - /** - * Gets the property set Id or the extended property. - * - * @return property set Id or the extended property. - */ - public UUID getPropertySetId() { - return this.propertySetId; - } - - /** - * Gets the extended property's tag. - * - * @return The extended property's tag. - */ - public Integer getTag() { - return this.tag; - } - - /** - * Gets the name of the extended property. - * - * @return The name of the extended property. - */ - public String getName() { - return this.name; - } - - /** - * Gets the Id of the extended property. - * - * @return The Id of the extended property. - */ - public Integer getId() { - return this.id; - } - - /** - * Gets the MAPI type of the extended property. - * - * @return The MAPI type of the extended property. - */ - public MapiPropertyType getMapiType() { - return this.mapiType; - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return MapiTypeConverter.getMapiTypeConverterMap(). - get(getMapiType()).getType(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/GenericPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/GenericPropertyDefinition.java deleted file mode 100644 index b4b74e705..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/GenericPropertyDefinition.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; - -import java.io.Serializable; -import java.text.ParseException; -import java.util.EnumSet; - -/** - * Represents generic property definition. - * - * @param Property type. - */ -public class GenericPropertyDefinition extends - TypedPropertyDefinition { - - private Class instance; - - /** - * Initializes a new instance of the "GenericPropertyDefinition<T>" - * class. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param version The version. - */ - public GenericPropertyDefinition(Class cls, String xmlElementName, String uri, - ExchangeVersion version) { - super(xmlElementName, uri, version); - this.instance = cls; - } - - /** - * Initializes a new instance of the "GenericPropertyDefinition<T>" - * class. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - */ - public GenericPropertyDefinition(Class cls, String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version) { - super(xmlElementName, uri, flags, version); - this.instance = cls; - } - - /** - * Initializes a new instance of the GenericPropertyDefinition class. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - * @param isNullable if set to true, property value is nullable. - */ - protected GenericPropertyDefinition( - Class cls, - String xmlElementName, - String uri, - EnumSet flags, - ExchangeVersion version, - boolean isNullable) { - super(xmlElementName, uri, flags, version, isNullable); - this.instance = cls; - } - - - /** - * Parses the specified value. - * - * @param value The value - * @return Double value from parsed value. - * @throws java.text.ParseException - * @throws IllegalAccessException - * @throws InstantiationException - */ - @Override - protected TPropertyValue parse(String value) throws InstantiationException, - IllegalAccessException, ParseException { - - return EwsUtilities.parse(instance, value); - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return instance; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/GroupMemberPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/GroupMemberPropertyDefinition.java deleted file mode 100644 index 6d563ac62..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/GroupMemberPropertyDefinition.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -/** - * Represents the definition of the GroupMember property. - */ -public final class GroupMemberPropertyDefinition extends - ServiceObjectPropertyDefinition { - - // / FieldUri of IndexedFieldURI for a group member. - /** - * The Constant FIELDURI. - */ - private final static String FIELDURI = "distributionlist:Members:Member"; - - // / Member key. - // / Maps to the Index attribute of IndexedFieldURI element. - /** - * The key. - */ - private String key; - - /** - * Initializes a new instance of the GroupMemberPropertyDefinition class. - * - * @param key the key - */ - public GroupMemberPropertyDefinition(String key) { - super(FIELDURI); - this.key = key; - } - - /** - * Initializes a new instance of the GroupMemberPropertyDefinition class - * without key. - */ - public GroupMemberPropertyDefinition() { - super(FIELDURI); - } - - /** - * Gets the key. - * - * @return the key - */ - public String getKey() { - return key; - } - - /** - * Sets the key. - * - * @param key the new key - */ - public void setKey(String key) { - this.key = key; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - protected String getXmlElementName() { - return XmlElementNames.IndexedFieldURI; - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - writer.writeAttributeValue(XmlAttributeNames.FieldIndex, this.key); - } - - /** - * Gets the property definition's printable name. - * - * @return The property definition's printable name. - */ - @Override public String getPrintableName() { - return String.format("%s:%s", FIELDURI, this.key); - } - - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return String.class; - } - - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/IDateTimePropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/IDateTimePropertyDefinition.java deleted file mode 100644 index 908ad4f82..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/IDateTimePropertyDefinition.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -/** - * The Interface DateTimePropertyDefinitionInterface. - */ -interface IDateTimePropertyDefinition { - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/IndexedPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/IndexedPropertyDefinition.java deleted file mode 100644 index 237f80af4..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/IndexedPropertyDefinition.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -/** - * Represents an indexed property definition. - */ -public final class IndexedPropertyDefinition extends - ServiceObjectPropertyDefinition { - - // Index attribute of IndexedFieldURI element. - /** - * The index. - */ - private String index; - - /** - * Initializes a new instance of the IndexedPropertyDefinition class. - * - * @param uri The FieldURI attribute of the IndexedFieldURI element. - * @param index The Index attribute of the IndexedFieldURI element. - */ - public IndexedPropertyDefinition(String uri, String index) { - super(uri); - this.index = index; - } - - /** - * Determines whether two specified instances of IndexedPropertyDefinition - * are equal. - * - * @param idxPropDef1 First indexed property definition. - * @param idxPropDef2 Second indexed property definition. - * @return True if indexed property definitions are equal. - */ - protected static boolean isEqualTo(IndexedPropertyDefinition idxPropDef1, - IndexedPropertyDefinition idxPropDef2) { - return (idxPropDef1 == idxPropDef2) || - (idxPropDef1 != null && - idxPropDef2 != null && - idxPropDef1.getUri().equalsIgnoreCase( - idxPropDef2.getUri()) && idxPropDef1.index - .equalsIgnoreCase(idxPropDef2.index)); - } - - /** - * Gets the index of the property. - * - * @return The index string of the property. - */ - public String getIndex() { - return this.index; - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - writer.writeAttributeValue(XmlAttributeNames.FieldIndex, this - .getIndex()); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.IndexedFieldURI; - } - - /** - * Gets the property definition's printable name. - * - * @return The property definition's printable name. - */ - @Override public String getPrintableName() { - return String.format("%s:%s", this.getUri(), this.getIndex()); - } - - - /** - * Determines whether a given indexed property definition is equal to this - * indexed property definition. - * - * @param obj The - * object to check for equality. - * @return True if the property definitions define the same indexed - * property. - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof IndexedPropertyDefinition) { - return IndexedPropertyDefinition.isEqualTo( - (IndexedPropertyDefinition) obj, this); - } else { - return false; - } - } - - /** - * Serves as a hash function for a particular type. - * - * @return A hash code for the current System.Object - */ - @Override - public int hashCode() { - return this.getUri().hashCode() ^ this.getIndex().hashCode(); - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return String.class; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/IntPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/IntPropertyDefinition.java deleted file mode 100644 index b76fe2047..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/IntPropertyDefinition.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; - -import java.util.EnumSet; - -/** - * Represents Integer property defintion. - */ -public class IntPropertyDefinition extends GenericPropertyDefinition { - - /** - * Initializes a new instance of the "IntPropertyDefinition" class. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param version The version. - */ - public IntPropertyDefinition(String xmlElementName, String uri, ExchangeVersion version) { - super(Integer.class, xmlElementName, uri, version); - } - - /** - * Initializes a new instance of the "IntPropertyDefinition" class. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - */ - public IntPropertyDefinition(String xmlElementName, String uri, EnumSet flags, - ExchangeVersion version) { - super(Integer.class, xmlElementName, uri, flags, version); - } - - /** - * Initializes a new instance of the "IntPropertyDefinition" class. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - * @param isNullable Indicates that this property definition is for a nullable - * property. - */ - public IntPropertyDefinition(String xmlElementName, String uri, EnumSet flags, - ExchangeVersion version, boolean isNullable) { - super(Integer.class, xmlElementName, uri, flags, version, isNullable); - } - - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/MeetingTimeZonePropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/MeetingTimeZonePropertyDefinition.java deleted file mode 100644 index c31d236e7..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/MeetingTimeZonePropertyDefinition.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.PropertyBag; -import microsoft.exchange.webservices.data.core.service.schema.AppointmentSchema; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.MeetingTimeZone; - -import java.util.EnumSet; - -/** - * Represents the definition for the meeting time zone property. - */ -public class MeetingTimeZonePropertyDefinition extends PropertyDefinition { - - /** - * Initializes a new instance of the MeetingTimeZonePropertyDefinition - * class. - * - * @param xmlElementName the xml element name - * @param uri the uri - * @param flags the flags - * @param version the version - */ - public MeetingTimeZonePropertyDefinition(String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version) { - super(xmlElementName, uri, flags, version); - - } - - /** - * Loads from XML. - * - * @param reader the reader - * @param propertyBag the property bag - * @throws Exception the exception - */ - public final void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws Exception { - MeetingTimeZone meetingTimeZone = new MeetingTimeZone(); - meetingTimeZone.loadFromXml(reader, this.getXmlElement()); - - propertyBag.setObjectFromPropertyDefinition( - AppointmentSchema.StartTimeZone, meetingTimeZone - .toTimeZoneInfo()); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param propertyBag the property bag - * @param isUpdateOperation the is update operation - * @throws Exception the exception - */ - public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, - boolean isUpdateOperation) - throws Exception { - MeetingTimeZone value = propertyBag.getObjectFromPropertyDefinition(this); - - if (value != null) { - value.writeToXml(writer, this.getXmlElement()); - } - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return MeetingTimeZone.class; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/PermissionSetPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/PermissionSetPropertyDefinition.java deleted file mode 100644 index 3ca27c1b1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/PermissionSetPropertyDefinition.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; -import microsoft.exchange.webservices.data.property.complex.FolderPermissionCollection; - -import java.util.EnumSet; - -/** - * Represents permission set property definition. - */ -public class PermissionSetPropertyDefinition extends ComplexPropertyDefinitionBase { - - /** - * Initializes a new instance of the PermissionSetPropertyDefinition class. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - */ - public PermissionSetPropertyDefinition(String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version) { - super(xmlElementName, uri, flags, version); - } - - /** - * Creates the property instance. - * - * @param owner The owner. - * @return ComplexProperty. - */ - @Override public ComplexProperty createPropertyInstance(ServiceObject owner) { - Folder folder = (Folder) owner; - - EwsUtilities.ewsAssert(folder != null, "PermissionCollectionPropertyDefinition.CreatePropertyInstance", - "The owner parameter is not of type Folder or a derived class."); - - return new FolderPermissionCollection(folder); - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return FolderPermissionCollection.class; - } -} - diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/PropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/PropertyDefinition.java deleted file mode 100644 index 5ef379654..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/PropertyDefinition.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.PropertyBag; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; - -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.List; - -/** - * Represents the definition of a folder or item property. - */ -public abstract class PropertyDefinition extends - ServiceObjectPropertyDefinition { - - /** - * The xml element name. - */ - private String xmlElementName; - - /** - * The flags. - */ - private EnumSet flags; - - /** - * The name. - */ - private String name; - - /** - * The version. - */ - private ExchangeVersion version; - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param version The version. - */ - protected PropertyDefinition(String xmlElementName, String uri, - ExchangeVersion version) { - super(uri); - this.xmlElementName = xmlElementName; - this.flags = EnumSet.of(PropertyDefinitionFlags.None); - this.version = version; - } - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param flags The flags. - * @param version The version. - */ - protected PropertyDefinition(String xmlElementName, - EnumSet flags, ExchangeVersion version) { - super(); - this.xmlElementName = xmlElementName; - this.flags = flags; - this.version = version; - } - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - */ - protected PropertyDefinition(String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version) { - this(xmlElementName, uri, version); - this.flags = flags; - } - - /** - * Determines whether the specified flag is set. - * - * @param flag The flag. - * @return true if the specified flag is set; otherwise, false. - */ - public boolean hasFlag(PropertyDefinitionFlags flag) { - return this.hasFlag(flag, null); - } - - /** - * Determines whether the specified flag is set. - * - * @param flag The flag. - * @return true if the specified flag is set; otherwise, false. - */ - public boolean hasFlag(PropertyDefinitionFlags flag, ExchangeVersion version) { - return this.flags.contains(flag); - } - - /** - * Registers associated internal property. - * - * @param properties The list in which to add the associated property. - */ - protected void registerAssociatedInternalProperties( - List properties) { - } - - /** - * Gets a list of associated internal property. - * - * @return A list of PropertyDefinition objects. This is a hack. It is here - * (currently) solely to help the API register the MeetingTimeZone - * property definition that is internal. - */ - public List getAssociatedInternalProperties() { - List properties = new - ArrayList(); - this.registerAssociatedInternalProperties(properties); - return properties; - } - - /** - * Gets the minimum Exchange version that supports this property. - * - * @return The version. - */ - public ExchangeVersion getVersion() { - return version; - } - - /** - * Gets a value indicating whether this property definition is for a - * nullable type. - * - * @return always true - */ - public boolean isNullable() { - return true; - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @param propertyBag The property bag. - * @throws Exception the exception - */ - public abstract void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) - throws Exception; - - /** - * Writes the property value to XML. - * - * @param writer the writer - * @param propertyBag the property bag - * @param isUpdateOperation indicates whether the context is an update operation - * @throws Exception the exception - */ - public abstract void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, - boolean isUpdateOperation) throws Exception; - - /** - * Gets the name of the XML element. - * - * @return The name of the XML element. - */ - public String getXmlElement() { - return this.xmlElementName; - } - - /** - * Gets the name of the property. - * - * @return Name of the property. - */ - public String getName() { - - if (null == this.name || this.name.isEmpty()) { - ServiceObjectSchema.initializeSchemaPropertyNames(); - } - return name; - } - - /** - * Sets the name of the property. - * - * @param name name of the property - */ - public void setName(String name) { - this.name = name; - } - - /** - * Gets the property definition's printable name. - * - * @return The property definition's printable name. - */ - @Override public String getPrintableName() { - return this.getName(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/PropertyDefinitionBase.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/PropertyDefinitionBase.java deleted file mode 100644 index fad7d93ec..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/PropertyDefinitionBase.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.schema.ServiceObjectSchema; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.OutParam; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents the base class for all property definitions. - */ -public abstract class PropertyDefinitionBase { - - /** - * Initializes a new instance. - */ - protected PropertyDefinitionBase() { - super(); - } - - /** - * Tries to load from XML. - * - * @param reader The reader. - * @param propertyDefinition The property definition. - * @return True if property was loaded. - * @throws Exception the exception - */ - public static boolean tryLoadFromXml(EwsServiceXmlReader reader, - OutParam propertyDefinition) - throws Exception { - String strLocalName = reader.getLocalName(); - if (strLocalName.equals(XmlElementNames.FieldURI)) { - PropertyDefinitionBase p = ServiceObjectSchema - .findPropertyDefinition(reader.readAttributeValue(XmlAttributeNames.FieldURI)); - propertyDefinition.setParam(p); - return true; - } else if (strLocalName.equals(XmlElementNames.IndexedFieldURI)) { - reader.skipCurrentElement(); - return true; - } else if (strLocalName.equals(XmlElementNames.ExtendedFieldURI)) { - ExtendedPropertyDefinition p = new ExtendedPropertyDefinition(); - p.loadFromXml(reader); - propertyDefinition.setParam(p); - return true; - } else { - return false; - } - - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - protected abstract String getXmlElementName(); - - /** - * Writes the attribute to XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected abstract void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException; - - /** - * Gets the minimum Exchange version that supports this property. - * - * @return The version. - */ - public abstract ExchangeVersion getVersion(); - - /** - * Gets the property definition's printable name. - * - * @return The property definition's printable name. - */ - public abstract String getPrintableName(); - - /** - * Gets the type of the property. - */ - public abstract Class getType(); - - /** - * Writes to XML. - * - * @param writer The writer. - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer.writeStartElement(XmlNamespace.Types, this.getXmlElementName()); - this.writeAttributesToXml(writer); - writer.writeEndElement(); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - @Override - /** - * Returns a string that represents the current object. - * @return A string that represents the current object. - */ - public String toString() { - return this.getPrintableName(); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/RecurrencePropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/RecurrencePropertyDefinition.java deleted file mode 100644 index d45eece23..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/RecurrencePropertyDefinition.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.PropertyBag; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence; -import microsoft.exchange.webservices.data.property.complex.recurrence.range.EndDateRecurrenceRange; -import microsoft.exchange.webservices.data.property.complex.recurrence.range.NoEndRecurrenceRange; -import microsoft.exchange.webservices.data.property.complex.recurrence.range.NumberedRecurrenceRange; -import microsoft.exchange.webservices.data.property.complex.recurrence.range.RecurrenceRange; -import microsoft.exchange.webservices.data.security.XmlNodeType; - -import java.util.EnumSet; - -/** - * Represenrs recurrence property definition. - */ -public class RecurrencePropertyDefinition extends PropertyDefinition { - - /** - * Initializes a new instance of the RecurrencePropertyDefinition class. - * - * @param xmlElementName the xml element name - * @param uri the uri - * @param flags the flags - * @param version the version - */ - public RecurrencePropertyDefinition(String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version) { - - super(xmlElementName, uri, flags, version); - - } - - /** - * Loads from XML. - * - * @param reader the reader - * @param propertyBag the property bag - * @throws Exception the exception - */ - public void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws Exception { - reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, - XmlElementNames.Recurrence); - - Recurrence recurrence = null; - - reader.read(new XmlNodeType(XmlNodeType.START_ELEMENT)); // This is the - // pattern - // element - - if (reader.getLocalName().equals( - XmlElementNames.RelativeYearlyRecurrence)) { - - recurrence = new Recurrence.RelativeYearlyPattern(); - } else if (reader.getLocalName().equals( - XmlElementNames.AbsoluteYearlyRecurrence)) { - - recurrence = new Recurrence.YearlyPattern(); - } else if (reader.getLocalName().equals( - XmlElementNames.RelativeMonthlyRecurrence)) { - - recurrence = new Recurrence.RelativeMonthlyPattern(); - } else if (reader.getLocalName().equals( - XmlElementNames.AbsoluteMonthlyRecurrence)) { - - recurrence = new Recurrence.MonthlyPattern(); - } else if (reader.getLocalName() - .equals(XmlElementNames.DailyRecurrence)) { - - recurrence = new Recurrence.DailyPattern(); - } else if (reader.getLocalName().equals( - XmlElementNames.DailyRegeneration)) { - - recurrence = new Recurrence.DailyRegenerationPattern(); - } else if (reader.getLocalName().equals( - XmlElementNames.WeeklyRecurrence)) { - - recurrence = new Recurrence.WeeklyPattern(); - } else if (reader.getLocalName().equals( - XmlElementNames.WeeklyRegeneration)) { - - recurrence = new Recurrence.WeeklyRegenerationPattern(); - } else if (reader.getLocalName().equals( - XmlElementNames.MonthlyRegeneration)) { - - recurrence = new Recurrence.MonthlyRegenerationPattern(); - } else if (reader.getLocalName().equals( - XmlElementNames.YearlyRegeneration)) { - - recurrence = new Recurrence.YearlyRegenerationPattern(); - } else { - - throw new ServiceXmlDeserializationException(String.format("Invalid recurrence pattern: (%s).", reader.getLocalName())); - } - - recurrence.loadFromXml(reader, reader.getLocalName()); - - reader.read(new XmlNodeType(XmlNodeType.START_ELEMENT)); // This is the - // range - // element - - RecurrenceRange range; - - if (reader.getLocalName().equals(XmlElementNames.NoEndRecurrence)) { - - range = new NoEndRecurrenceRange(); - } else if (reader.getLocalName().equals( - XmlElementNames.EndDateRecurrence)) { - - range = new EndDateRecurrenceRange(); - } else if (reader.getLocalName().equals( - XmlElementNames.NumberedRecurrence)) { - - range = new NumberedRecurrenceRange(); - } else { - throw new ServiceXmlDeserializationException(String.format("Invalid recurrence range: (%s).", reader.getLocalName())); - } - - range.loadFromXml(reader, reader.getLocalName()); - range.setupRecurrence(recurrence); - - reader.readEndElementIfNecessary(XmlNamespace.Types, - XmlElementNames.Recurrence); - - propertyBag.setObjectFromPropertyDefinition(this, recurrence); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param propertyBag the property bag - * @param isUpdateOperation the is update operation - * @throws Exception the exception - */ - public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, - boolean isUpdateOperation) - throws Exception { - Recurrence value = propertyBag.getObjectFromPropertyDefinition(this); - - if (value != null) { - value.writeToXml(writer, XmlElementNames.Recurrence); - } - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return Recurrence.class; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/ResponseObjectsPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/ResponseObjectsPropertyDefinition.java deleted file mode 100644 index 9ba69bf52..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/ResponseObjectsPropertyDefinition.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.PropertyBag; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.service.ResponseActions; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; - -import java.util.EnumSet; - -/** - * Represents response object property defintion. - */ -public class ResponseObjectsPropertyDefinition extends PropertyDefinition { - - /** - * Initializes a new instance of the ResponseObjectsPropertyDefinition - * class. - * - * @param xmlElementName the xml element name - * @param uri the uri - * @param version the version - */ - public ResponseObjectsPropertyDefinition(String xmlElementName, String uri, ExchangeVersion version) { - super(xmlElementName, uri, version); - - } - - /** - * Loads from XML. - * - * @param reader the reader - * @param propertyBag the property bag - * @throws Exception the exception - */ - public final void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws Exception { - EnumSet value = EnumSet.noneOf(ResponseActions.class); - value.add(ResponseActions.None); - - reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, this - .getXmlElement()); - - if (!reader.isEmptyElement()) { - do { - reader.read(); - - if (reader.isStartElement()) { - - if (reader.getLocalName() - .equals(XmlElementNames.AcceptItem)) { - - value.add(ResponseActions.Accept); - } else if (reader.getLocalName().equals( - XmlElementNames.TentativelyAcceptItem)) { - - value.add(ResponseActions.TentativelyAccept); - } else if (reader.getLocalName().equals( - XmlElementNames.DeclineItem)) { - - value.add(ResponseActions.Decline); - } else if (reader.getLocalName().equals( - XmlElementNames.ReplyToItem)) { - - value.add(ResponseActions.Reply); - } else if (reader.getLocalName().equals( - XmlElementNames.ForwardItem)) { - - value.add(ResponseActions.Forward); - } else if (reader.getLocalName().equals( - XmlElementNames.ReplyAllToItem)) { - - value.add(ResponseActions.ReplyAll); - } else if (reader.getLocalName().equals( - XmlElementNames.CancelCalendarItem)) { - - value.add(ResponseActions.Cancel); - } else if (reader.getLocalName().equals( - XmlElementNames.RemoveItem)) { - - value.add(ResponseActions.RemoveFromCalendar); - } else if (reader.getLocalName().equals( - XmlElementNames.SuppressReadReceipt)) { - - value.add(ResponseActions.SuppressReadReceipt); - } else if (reader.getLocalName().equals( - XmlElementNames.PostReplyItem)) { - - value.add(ResponseActions.PostReply); - } - } - - } while (!reader.isEndElement(XmlNamespace.Types, this - .getXmlElement())); - } else { - reader.read(); - } - - propertyBag.setObjectFromPropertyDefinition(this, value); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param propertyBag the property bag - * @param isUpdateOperation the is update operation - */ - public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, - boolean isUpdateOperation) { - // ResponseObjects is a read-only property, no need to implement this. - } - - /** - * Gets a value indicating whether this property - * definition is for a nullable type (ref, int?, bool?...). - */ - @Override public boolean isNullable() { - return false; - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return ResponseActions.class; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/ServiceObjectPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/ServiceObjectPropertyDefinition.java deleted file mode 100644 index c26185609..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/ServiceObjectPropertyDefinition.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -/** - * Represents a property definition for a service object. - */ -public abstract class ServiceObjectPropertyDefinition extends - PropertyDefinitionBase { - - /** - * The uri. - */ - private String uri; - - /** - * Gets the name of the XML element. - * - * @return the name of the XML element. - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.FieldURI; - } - - /** - * Gets the minimum Exchange version that supports this property. - * - * @return The minimum Exchange version that supports this property. - */ - @Override - public ExchangeVersion getVersion() { - return ExchangeVersion.Exchange2007_SP1; - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.FieldURI, this.getUri()); - } - - /** - * Initializes a new instance. - */ - protected ServiceObjectPropertyDefinition() { - super(); - } - - /** - * Initializes a new instance. - * - * @param uri The URI. - */ - protected ServiceObjectPropertyDefinition(String uri) { - this(); - EwsUtilities.ewsAssert(!(uri == null || uri.isEmpty()), "ServiceObjectPropertyDefinition.ctor", - "uri is null or empty"); - this.uri = uri; - } - - /** - * Gets the URI of the property definition. - * - * @return The URI of the property definition. - */ - public String getUri() { - return uri; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/StartTimeZonePropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/StartTimeZonePropertyDefinition.java deleted file mode 100644 index ed0d37c85..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/StartTimeZonePropertyDefinition.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.PropertyBag; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.service.schema.AppointmentSchema; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.complex.MeetingTimeZone; -import microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition; - -import javax.xml.stream.XMLStreamException; - -import java.util.EnumSet; -import java.util.List; - -/** - * Represents a property definition for property of type TimeZoneInfo. - */ -public class StartTimeZonePropertyDefinition extends TimeZonePropertyDefinition { - - /** - * Initializes a new instance of the StartTimeZonePropertyDefinition - * class. - * - * @param xmlElementName the xml element name - * @param uri the uri - * @param flags the flags - * @param version the version - */ - public StartTimeZonePropertyDefinition(String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version) { - super(xmlElementName, uri, flags, version); - } - - /** - * Registers associated internal property. - * - * @param properties the property - */ - protected void registerAssociatedInternalProperties( - List properties) { - super.registerAssociatedInternalProperties(properties); - - properties.add(AppointmentSchema.MeetingTimeZone); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param propertyBag the property bag - * @param isUpdateOperation the is update operation - * @throws Exception the exception - */ - public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, - boolean isUpdateOperation) - throws Exception { - Object value = propertyBag.getObjectFromPropertyDefinition(this); - - if (value != null) { - final ExchangeService service = (ExchangeService) writer.getService(); - if (service.getRequestedServerVersion() == ExchangeVersion.Exchange2007_SP1) { - if (!service.getExchange2007CompatibilityMode()) { - MeetingTimeZone meetingTimeZone = new MeetingTimeZone((TimeZoneDefinition) value); - meetingTimeZone.writeToXml(writer, XmlElementNames.MeetingTimeZone); - } - } else { - super.writePropertyValueToXml(writer, propertyBag, isUpdateOperation); - } - } - } - - /** - * Writes to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - if (writer.getService().getRequestedServerVersion() == ExchangeVersion.Exchange2007_SP1) { - AppointmentSchema.MeetingTimeZone.writeToXml(writer); - } else { - super.writeToXml(writer); - } - } - - /** - * Determines whether the specified flag is set. - * - * @param flag The flag. - * @param version Requested version. - * @return true if the specified - * flag is set; otherwise, false. - */ - @Override public boolean hasFlag(PropertyDefinitionFlags flag, ExchangeVersion version) { - if (version != null && (version == ExchangeVersion.Exchange2007_SP1)) { - return AppointmentSchema.MeetingTimeZone.hasFlag(flag, version); - } else { - return super.hasFlag(flag, version); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/StringPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/StringPropertyDefinition.java deleted file mode 100644 index 918218beb..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/StringPropertyDefinition.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; - -import java.util.EnumSet; - -/** - * Represents String property definition. - */ -public class StringPropertyDefinition extends TypedPropertyDefinition { - - /** - * Initializes a new instance of the "StringPropertyDefinition" class. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - */ - public StringPropertyDefinition(String xmlElementName, String uri, EnumSet flags, - ExchangeVersion version) { - super(xmlElementName, uri, flags, version); - } - - /** - * Parses the specified value. - * - * @param value The value. - * @return Typed value. - */ - @Override - protected String parse(String value) { - return value; - } - - /** - * Gets a value indicating whether this property definition is for a - * nullable type (ref, int?, bool?...). - * - * @return True - */ - @Override public boolean isNullable() { - return true; - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return String.class; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/TaskDelegationStatePropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/TaskDelegationStatePropertyDefinition.java deleted file mode 100644 index a1356d0eb..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/TaskDelegationStatePropertyDefinition.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.core.enumeration.property.TaskDelegationState; - -import java.util.EnumSet; - -/** - * Represents a task delegation property definition. - */ -public final class TaskDelegationStatePropertyDefinition extends - GenericPropertyDefinition { - /** - * The No match. - */ - private static final String NoMatch = "NoMatch"; - - /** - * The Own new. - */ - private static final String OwnNew = "OwnNew"; - - /** - * The Owned. - */ - private static final String Owned = "Owned"; - - /** - * The Accepted. - */ - private static final String Accepted = "Accepted"; - - /** - * Initializes a new instance of the "TaskDelegationStatePropertyDefinition" - * class. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - */ - public TaskDelegationStatePropertyDefinition(String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version) { - super(TaskDelegationState.class, xmlElementName, uri, flags, version); - } - - /** - * The Enum Status. - */ - public enum Status { - - /** - * The No match. - */ - NoMatch, - /** - * The Own new. - */ - OwnNew, - /** - * The Owned. - */ - Owned, - /** - * The Accepted. - */ - Accepted; - } - - /** - * Parses the specified value. - * - * @param value The value. - * @return Typed value. - */ - @Override - protected TaskDelegationState parse(String value) { - switch (Status.valueOf(value)) { - case NoMatch: - return TaskDelegationState.NoDelegation; - case OwnNew: - return TaskDelegationState.Unknown; - case Owned: - return TaskDelegationState.Accepted; - case Accepted: - return TaskDelegationState.Declined; - default: - EwsUtilities.ewsAssert(false, "TaskDelegationStatePropertyDefinition.Parse", - String.format("TaskDelegationStatePropertyDefinition." + - "Parse():" + - " value %s cannot be handled.", value)); - - return null; // To keep the compiler happy - } - } - - /** - * Convert instance to string. - * - * @param value The value. - * @return String representation of property value. - */ - @Override - protected String toString(TaskDelegationState value) { - if (value.equals(TaskDelegationState.NoDelegation)) { - return NoMatch; - } else if (value.equals(TaskDelegationState.Unknown)) { - return OwnNew; - } else if (value.equals(TaskDelegationState.Accepted)) { - return Owned; - } - if (value.equals(TaskDelegationState.Declined)) { - return Accepted; - } else { - EwsUtilities.ewsAssert(false, "TaskDelegationStatePropertyDefinition.ToString", - "Invalid TaskDelegationState value."); - return null; // To keep the compiler happy - } - - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/TimeSpanPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/TimeSpanPropertyDefinition.java deleted file mode 100644 index 8a979eb4b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/TimeSpanPropertyDefinition.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.misc.TimeSpan; - -import java.util.EnumSet; - -/** - * Represents TimeSpan property definition. - */ -public class TimeSpanPropertyDefinition extends GenericPropertyDefinition { - - - /** - * Initializes a new instance of the "TimeSpanPropertyDefinition" class. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - */ - public TimeSpanPropertyDefinition(String xmlElementName, String uri, EnumSet flags, - ExchangeVersion version) { - super(TimeSpan.class, xmlElementName, uri, flags, version); - } - - /** - * Parses the specified value. - * - * @param value The value. - * @return Typed value. - */ - @Override - protected TimeSpan parse(String value) { - return EwsUtilities.getXSDurationToTimeSpan(value); - } - - /** - * Convert instance to string. - * - * @param value The value. - * @return String representation of property value. - */ - @Override - protected String toString(TimeSpan value) { - return EwsUtilities.getTimeSpanToXSDuration(value); - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/TimeZonePropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/TimeZonePropertyDefinition.java deleted file mode 100644 index 015ea502b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/TimeZonePropertyDefinition.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.PropertyBag; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.property.complex.time.TimeZoneDefinition; - -import java.util.EnumSet; -import java.util.TimeZone; - -/** - * Represents a property definition for property of type TimeZoneInfo. - */ -public class TimeZonePropertyDefinition extends PropertyDefinition { - - /** - * Initializes a new instance of the TimeZonePropertyDefinition class. - * - * @param xmlElementName the xml element name - * @param uri the uri - * @param flags the flags - * @param version the version - */ - public TimeZonePropertyDefinition(String xmlElementName, String uri, EnumSet flags, - ExchangeVersion version) { - super(xmlElementName, uri, flags, version); - } - - /** - * Loads from XML. - * - * @param reader the reader - * @param propertyBag the property bag - * @throws Exception the exception - */ - public void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws Exception { - TimeZoneDefinition timeZoneDefinition = new TimeZoneDefinition(); - timeZoneDefinition.loadFromXml(reader, this.getXmlElement()); - propertyBag.setObjectFromPropertyDefinition(this, timeZoneDefinition); - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param propertyBag the property bag - * @param isUpdateOperation the is update operation - * @throws Exception the exception - */ - public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, - boolean isUpdateOperation) throws Exception { - TimeZoneDefinition timeZoneDefinition = propertyBag.getObjectFromPropertyDefinition(this); - - if (timeZoneDefinition != null) { - // We emit time zone property only if we have not emitted the time - // zone SOAP header - // or if this time zone is different from that of the service - // through which the request - // is being emitted. - if (!writer.isTimeZoneHeaderEmitted())// || value != - // writer.getService().getTimeZone()) - { - timeZoneDefinition.writeToXml(writer, this.getXmlElement()); - } - } - } - - /** - * Gets the property type. - */ - @Override - public Class getType() { - return TimeZone.class; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/property/definition/TypedPropertyDefinition.java b/src/main/java/microsoft/exchange/webservices/data/property/definition/TypedPropertyDefinition.java deleted file mode 100644 index 1d4d917ed..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/property/definition/TypedPropertyDefinition.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.definition; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.PropertyBag; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.enumeration.property.PropertyDefinitionFlags; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; - -import javax.xml.stream.XMLStreamException; - -import java.io.Serializable; -import java.text.ParseException; -import java.util.EnumSet; - -/** - * Represents typed property definition. - */ -abstract class TypedPropertyDefinition extends PropertyDefinition { - - /** - * The is nullable. - */ - private boolean isNullable; - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param version The version. - */ - protected TypedPropertyDefinition(String xmlElementName, String uri, - ExchangeVersion version) { - super(xmlElementName, uri, version); - this.isNullable = false; - } - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - */ - protected TypedPropertyDefinition(String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version) { - super(xmlElementName, uri, flags, version); - } - - /** - * Initializes a new instance. - * - * @param xmlElementName Name of the XML element. - * @param uri The URI. - * @param flags The flags. - * @param version The version. - * @param isNullable Indicates that this property definition is for a nullable - * property. - */ - protected TypedPropertyDefinition(String xmlElementName, String uri, - EnumSet flags, ExchangeVersion version, - boolean isNullable) { - super(xmlElementName, uri, flags, version); - this.isNullable = isNullable; - } - - /** - * Parses the specified value. - * - * @param value The value. - * @return Typed value. - * @throws java.text.ParseException - * @throws IllegalAccessException - * @throws InstantiationException - */ - protected abstract T parse(String value) throws InstantiationException, - IllegalAccessException, ParseException; - - /** - * Gets a value indicating whether this property definition is for a - * nullable type. - * - * @return always true - */ - @Override public boolean isNullable() { - return this.isNullable; - } - - /** - * Convert instance to string. - * - * @param value The value. - * @return String representation of property value. - */ - protected String toString(T value) { - return value.toString(); - } - - /** - * Loads from XML. - * - * @param reader The reader. - * @param propertyBag The property bag. - * @throws Exception the exception - */ - @Override public void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag) throws Exception { - String value = reader.readElementValue(XmlNamespace.Types, this - .getXmlElement()); - - if (value != null && !value.isEmpty()) { - propertyBag.setObjectFromPropertyDefinition(this, this.parse(value)); - } - } - - /** - * Writes the property value to XML. - * - * @param writer The writer. - * @param propertyBag The property bag. - * @param isUpdateOperation Indicates whether the context is an update operation. - * @throws XMLStreamException the XML stream exception - * @throws ServiceLocalException the service local exception - */ - @Override public void writePropertyValueToXml(EwsServiceXmlWriter writer, PropertyBag propertyBag, - boolean isUpdateOperation) throws XMLStreamException, ServiceLocalException { - T value = propertyBag.getObjectFromPropertyDefinition(this); - - if (value != null) { - writer.writeElementValue(XmlNamespace.Types, this.getXmlElement(), - this.getName(), value); - } - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/CalendarView.java b/src/main/java/microsoft/exchange/webservices/data/search/CalendarView.java deleted file mode 100644 index d1efcc924..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/CalendarView.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.request.ServiceRequestBase; -import microsoft.exchange.webservices.data.core.enumeration.search.ItemTraversal; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import java.util.Date; - -/** - * Represents a date range view of appointments in calendar folder search - * operations. - */ -public final class CalendarView extends ViewBase { - - /** - * The traversal. - */ - private ItemTraversal traversal = ItemTraversal.Shallow; - - /** - * The max item returned. - */ - private Integer maxItemsReturned; - - /** - * The start date. - */ - private Date startDate; - - /** - * The end date. - */ - private Date endDate; - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.Traversal, this - .getTraversal()); - } - - /** - * Writes the search settings to XML. - * - * @param writer the writer - * @param groupBy the group by - */ - protected void internalWriteSearchSettingsToXml(EwsServiceXmlWriter writer, - Grouping groupBy) { - // No search settings for calendar views. - } - - /** - * Writes OrderBy property to XML. - * - * @param writer the writer - */ - public void writeOrderByToXml(EwsServiceXmlWriter writer) { - // No OrderBy for calendar views. - } - - /** - * Gets the type of service object this view applies to. - * - * @return A ServiceObjectType value. - */ - protected ServiceObjectType getServiceObjectType() { - return ServiceObjectType.Item; - } - - /** - * Initializes a new instance of CalendarView. - * - * @param startDate the start date - * @param endDate the end date - */ - public CalendarView(Date startDate, Date endDate) { - super(); - this.startDate = startDate; - this.endDate = endDate; - } - - /** - * Initializes a new instance of CalendarView. - * - * @param startDate the start date - * @param endDate the end date - * @param maxItemsReturned the max item returned - */ - public CalendarView(Date startDate, Date endDate, int maxItemsReturned) { - this(startDate, endDate); - this.maxItemsReturned = maxItemsReturned; - } - - /** - * Validate instance. - * - * @param request the request - * @throws ServiceVersionException the service version exception - * @throws ServiceValidationException the service validation exception - */ - public void internalValidate(ServiceRequestBase request) - throws ServiceVersionException, ServiceValidationException { - super.internalValidate(request); - - if (this.endDate.compareTo(this.startDate) < 0) { - throw new ServiceValidationException("EndDate must be greater than StartDate."); - } - } - - /** - * Write to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - protected void internalWriteViewToXml(EwsServiceXmlWriter writer) - throws Exception { - super.internalWriteViewToXml(writer); - - writer.writeAttributeValue(XmlAttributeNames.StartDate, this.startDate); - writer.writeAttributeValue(XmlAttributeNames.EndDate, this.endDate); - } - - /** - * Gets the name of the view XML element. - * - * @return XML element name - */ - protected String getViewXmlElementName() { - return XmlElementNames.CalendarView; - } - - /** - * Gets the maximum number of item or folder the search operation should - * return. - * - * @return The maximum number of item the search operation should return. - */ - protected Integer getMaxEntriesReturned() { - return this.maxItemsReturned; - } - - /** - * Gets the start date. - * - * @return the start date - */ - public Date getStartDate() { - return this.startDate; - } - - /** - * Sets the start date. - * - * @param startDate the new start date - */ - public void setStartDate(Date startDate) { - this.startDate = startDate; - } - - /** - * Gets the end date. - * - * @return the end date - */ - public Date getEndDate() { - return this.endDate; - } - - /** - * Sets the end date. - * - * @param endDate the new end date - */ - public void setEndDate(Date endDate) { - this.endDate = endDate; - } - - /** - * The maximum number of item the search operation should return. - * - * @return the max item returned - */ - public Integer getMaxItemsReturned() { - - return this.maxItemsReturned; - } - - /** - * Sets the max item returned. - * - * @param maxItemsReturned the new max item returned - * @throws ArgumentException the argument exception - */ - public void setMaxItemsReturned(Integer maxItemsReturned) - throws ArgumentException { - if (maxItemsReturned != null) { - if (maxItemsReturned.intValue() <= 0) { - throw new ArgumentException("The value must be greater than 0."); - } - } - - this.maxItemsReturned = maxItemsReturned; - } - - /** - * Gets the search traversal mode. Defaults to - * ItemTraversal.Shallow. - * - * @return the traversal - */ - public ItemTraversal getTraversal() { - return this.traversal; - - } - - /** - * Sets the traversal. - * - * @param traversal the new traversal - */ - public void setTraversal(ItemTraversal traversal) { - this.traversal = traversal; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/ConversationIndexedItemView.java b/src/main/java/microsoft/exchange/webservices/data/search/ConversationIndexedItemView.java deleted file mode 100644 index 1c14b8e7a..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/ConversationIndexedItemView.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.request.ServiceRequestBase; -import microsoft.exchange.webservices.data.core.enumeration.search.OffsetBasePoint; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents the view settings in a folder search operation. - */ -public final class ConversationIndexedItemView extends PagedView { - - private OrderByCollection orderBy = new OrderByCollection(); - - - /** - * Gets the type of service object this view applies to. - * - * @return A ServiceObjectType value. - */ - @Override - protected ServiceObjectType getServiceObjectType() { - return ServiceObjectType.Conversation; - } - - /** - * Writes the attribute to XML. - * - * @param writer The writer. - */ - @Override public void writeAttributesToXml(EwsServiceXmlWriter writer) { - // Do nothing - } - - /** - * Gets the name of the view XML element. - * - * @return XML element name. - */ - @Override - protected String getViewXmlElementName() { - return XmlElementNames.IndexedPageItemView; - } - - /** - * Validates this view. - * - * @param request The request using this view. - */ - @Override public void internalValidate(ServiceRequestBase request) - throws ServiceVersionException, ServiceValidationException { - super.internalValidate(request); - } - - /** - * Internals the write search settings to XML. - * - * @param writer The writer. - * @param groupBy The group by. - */ - @Override - protected void internalWriteSearchSettingsToXml(EwsServiceXmlWriter writer, - Grouping groupBy) throws ServiceXmlSerializationException, - XMLStreamException { - super.internalWriteSearchSettingsToXml(writer, groupBy); - } - - /** - * Writes OrderBy property to XML. - * - * @param writer The writer - */ - @Override public void writeOrderByToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, XMLStreamException { - this.orderBy.writeToXml(writer, XmlElementNames.SortOrder); - } - - /** - * Writes to XML. - * - * @param writer The writer - */ - public void writeToXml(EwsServiceXmlWriter writer) throws Exception { - writer.writeStartElement(XmlNamespace.Messages, - this.getViewXmlElementName()); - - this.internalWriteViewToXml(writer); - - writer.writeEndElement(); // this.GetViewXmlElementName() - } - - /** - * Initializes a new instance of the class. - * - * @param pageSize The maximum number of elements the search operation should return. - */ - public ConversationIndexedItemView(int pageSize) { - super(pageSize); - } - - /** - * Initializes a new instance of the ItemView class. - * - * @param pageSize The maximum number of elements the search operation should return. - * @param offset The offset of the view from the base point. - */ - public ConversationIndexedItemView(int pageSize, int offset) { - super(pageSize, offset); - this.setOffset(offset); - } - - /** - * Initializes a new instance of the ItemView class. - * - * @param pageSize The maximum number of elements the search operation should return. - * @param offset The offset of the view from the base point. - * @param offsetBasePoint The base point of the offset. - */ - public ConversationIndexedItemView( - int pageSize, - int offset, - OffsetBasePoint offsetBasePoint) { - super(pageSize, offset, offsetBasePoint); - - } - - /** - * Gets the property against which the returned item should be ordered. - */ - public OrderByCollection getOrderBy() { - return this.orderBy; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/FindFoldersResults.java b/src/main/java/microsoft/exchange/webservices/data/search/FindFoldersResults.java deleted file mode 100644 index 463112713..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/FindFoldersResults.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search; - -import microsoft.exchange.webservices.data.core.service.folder.Folder; - -import java.util.ArrayList; -import java.util.Iterator; - -/** - * Represents the results of a folder search operation. - */ -public final class FindFoldersResults implements Iterable { - - /** - * The total count. - */ - private int totalCount; - - /** - * The next page offset. - */ - private Integer nextPageOffset; - - /** - * The more available. - */ - private boolean moreAvailable; - - /** - * The folder. - */ - private ArrayList folders = new ArrayList(); - - /** - * Initializes a new instance of the class. - */ - public FindFoldersResults() { - - } - - /** - * Gets the total number of folder matching the search criteria available - * in the searched folder. - * - * @return the total count - */ - public int getTotalCount() { - return totalCount; - } - - /** - * Sets the total number of folder. - * - * @param totalCount the new total count - */ - public void setTotalCount(int totalCount) { - this.totalCount = totalCount; - } - - /** - * Gets the offset that should be used with FolderView to retrieve the next - * page of folder in a FindFolders operation. - * - * @return the next page offset - */ - public Integer getNextPageOffset() { - return nextPageOffset; - } - - /** - * Sets the offset that should be used with FolderView to retrieve the next - * page of folder in a FindFolders operation. - * - * @param nextPageOffset the new next page offset - */ - public void setNextPageOffset(Integer nextPageOffset) { - this.nextPageOffset = nextPageOffset; - } - - /** - * Gets a value indicating whether more folder matching the search - * criteria. are available in the searched folder. - * - * @return true, if is more available - */ - public boolean isMoreAvailable() { - return moreAvailable; - } - - /** - * Sets a value indicating whether more folder matching the search - * criteria. are available in the searched folder. - * - * @param moreAvailable the new more available - */ - public void setMoreAvailable(boolean moreAvailable) { - this.moreAvailable = moreAvailable; - } - - /** - * Gets a collection containing the folder that were found by the search - * operation. - * - * @return the folder - */ - public ArrayList getFolders() { - return folders; - } - - /** - * Returns an iterator that iterates through a collection. - * - * @return the iterator - */ - @Override - public Iterator iterator() { - return this.folders.iterator(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/FindItemsResults.java b/src/main/java/microsoft/exchange/webservices/data/search/FindItemsResults.java deleted file mode 100644 index 57920c6e9..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/FindItemsResults.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search; - -import microsoft.exchange.webservices.data.core.service.item.Item; - -import java.util.ArrayList; -import java.util.Iterator; - -/** - * Represents the results of an item search operation. - * - * @param The type of item returned by the search operation. - */ -public final class FindItemsResults implements - Iterable { - - /** - * The total count. - */ - private int totalCount; - - /** - * The next page offset. - */ - private Integer nextPageOffset; - - /** - * The more available. - */ - private boolean moreAvailable; - - /** - * The item. - */ - private ArrayList items = new ArrayList(); - - /** - * Initializes a new instance of the FindItemsResults class. - */ - public FindItemsResults() { - } - - /** - * Gets the total number of item matching the search criteria available in - * the searched folder. - * - * @return the total count - */ - public int getTotalCount() { - return this.totalCount; - } - - /** - * Sets the total number of item matching the search criteria available in - * the searched folder. - * - * @param totalCount the new total count - */ - public void setTotalCount(int totalCount) { - this.totalCount = totalCount; - } - - /** - * Gets the offset that should be used with ItemView to retrieve the next - * page of item in a FindItems operation. - * - * @return the next page offset - */ - public Integer getNextPageOffset() { - return nextPageOffset; - } - - /** - * Sets the offset that should be used with ItemView to retrieve the next - * page of item in a FindItems operation. - * - * @param nextPageOffset the new next page offset - */ - public void setNextPageOffset(Integer nextPageOffset) { - this.nextPageOffset = nextPageOffset; - } - - /** - * Gets a value indicating whether more item matching the search criteria - * are available in the searched folder. - * - * @return true, if is more available - */ - public boolean isMoreAvailable() { - return moreAvailable; - } - - /** - * Sets a value indicating whether more item matching the search criteria - * are available in the searched folder. - * - * @param moreAvailable the new more available - */ - public void setMoreAvailable(boolean moreAvailable) { - this.moreAvailable = moreAvailable; - } - - /** - * Gets a collection containing the item that were found by the search - * operation. - * - * @return the item - */ - public ArrayList getItems() { - return this.items; - } - - /** - * Returns an iterator that iterates through the collection. - * - * @return the iterator - */ - @Override - public Iterator iterator() { - return items.iterator(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/FolderView.java b/src/main/java/microsoft/exchange/webservices/data/search/FolderView.java deleted file mode 100644 index 68e82e1a5..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/FolderView.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.search.FolderTraversal; -import microsoft.exchange.webservices.data.core.enumeration.search.OffsetBasePoint; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Represents the view settings in a folder search operation. - */ -public final class FolderView extends PagedView { - - private static final Log LOG = LogFactory.getLog(FolderView.class); - - /** - * The traversal. - */ - private FolderTraversal traversal = FolderTraversal.Shallow; - - /** - * Gets the name of the view XML element. - * - * @return Xml Element name - */ - @Override - protected String getViewXmlElementName() { - return XmlElementNames.IndexedPageFolderView; - } - - /** - * Gets the type of service object this view applies to. - * - * @return A ServiceObjectType value. - */ - @Override - protected ServiceObjectType getServiceObjectType() { - return ServiceObjectType.Folder; - } - - /** - * Writes the attribute to XML. - * - * @param writer The writer - */ - @Override public void writeAttributesToXml(EwsServiceXmlWriter writer) { - try { - writer.writeAttributeValue(XmlAttributeNames.Traversal, this - .getTraversal()); - } catch (ServiceXmlSerializationException e) { - LOG.error(e); - } - } - - /** - * Initializes a new instance of the FolderView class. - * - * @param pageSize The maximum number of elements the search operation should - * return. - */ - public FolderView(int pageSize) { - super(pageSize); - } - - /** - * Initializes a new instance of the FolderView class. - * - * @param pageSize The maximum number of elements the search operation should - * return. - * @param offset The offset of the view from the base point. - */ - public FolderView(int pageSize, int offset) { - super(pageSize, offset); - } - - /** - * Initializes a new instance of the FolderView class. - * - * @param pageSize The maximum number of elements the search operation should - * return. - * @param offset The offset of the view from the base point. - * @param offsetBasePoint The base point of the offset. - */ - public FolderView(int pageSize, int offset, - OffsetBasePoint offsetBasePoint) { - super(pageSize, offset, offsetBasePoint); - } - - /** - * Gets the search traversal mode. Defaults to FolderTraversal.Shallow. - * - * @return the traversal - */ - public FolderTraversal getTraversal() { - return traversal; - } - - /** - * Sets the search traversal mode. Defaults to FolderTraversal.Shallow. - * - * @param traversal the new traversal - */ - public void setTraversal(FolderTraversal traversal) { - this.traversal = traversal; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/GroupedFindItemsResults.java b/src/main/java/microsoft/exchange/webservices/data/search/GroupedFindItemsResults.java deleted file mode 100644 index 2489bbdd1..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/GroupedFindItemsResults.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search; - -import microsoft.exchange.webservices.data.core.service.item.Item; - -import java.util.ArrayList; -import java.util.Iterator; - -/** - * Represents the results of an item search operation. - * - * @param The type of item returned by the search operation. - */ -public final class GroupedFindItemsResults implements - Iterable> { - - /** - * The total count. - */ - private int totalCount; - - /** - * The next page offset. - */ - private Integer nextPageOffset; - - /** - * The more available. - */ - private boolean moreAvailable; - - /** - * List of ItemGroups. - */ - private ArrayList> itemGroups = - new ArrayList>(); - - /** - * Initializes a new instance of the GroupedFindItemsResults class. - */ - public GroupedFindItemsResults() { - } - - /** - * Gets the total number of item matching the search criteria available in - * the searched folder. - * - * @return the total count - */ - public int getTotalCount() { - return totalCount; - } - - /** - * Gets the total number of item matching the search criteria available in - * the searched folder. - * - * @param totalCount Total number of item - */ - public void setTotalCount(int totalCount) { - this.totalCount = totalCount; - } - - /** - * Gets the offset that should be used with ItemView to retrieve the next - * page of item in a FindItems operation. - * - * @return the next page offset - */ - public Integer getNextPageOffset() { - return nextPageOffset; - } - - /** - * Sets the offset that should be used with ItemView to retrieve the next - * page of item in a FindItems operation. - * - * @param nextPageOffset the new next page offset - */ - public void setNextPageOffset(Integer nextPageOffset) { - this.nextPageOffset = nextPageOffset; - } - - /** - * Gets a value indicating whether more item corresponding to the search - * criteria are available in the searched folder. - * - * @return true, if is more available - */ - public boolean isMoreAvailable() { - return moreAvailable; - } - - /** - * Sets a value indicating whether more item corresponding to the search - * criteria are available in the searched folder. - * - * @param moreAvailable the new more available - */ - public void setMoreAvailable(boolean moreAvailable) { - this.moreAvailable = moreAvailable; - } - - /** - * Gets the item groups returned by the search operation. - * - * @return the item groups - */ - public ArrayList> getItemGroups() { - return itemGroups; - } - - /** - * Returns an iterator that iterates through the collection. - * - * @return the iterator - */ - @Override - public Iterator> iterator() { - return this.itemGroups.iterator(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/Grouping.java b/src/main/java/microsoft/exchange/webservices/data/search/Grouping.java deleted file mode 100644 index 0e5cc8e8f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/Grouping.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search; - -import microsoft.exchange.webservices.data.ISelfValidate; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.search.AggregateType; -import microsoft.exchange.webservices.data.core.enumeration.search.SortDirection; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinitionBase; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents grouping options in item search operations. - */ -public final class Grouping implements ISelfValidate { - - private static final Log LOG = LogFactory.getLog(Grouping.class); - - /** - * The sort direction. - */ - private SortDirection sortDirection = SortDirection.Ascending; - - /** - * The group on. - */ - private PropertyDefinitionBase groupOn; - - /** - * The aggregate on. - */ - private PropertyDefinitionBase aggregateOn; - - /** - * The aggregate type. - */ - private AggregateType aggregateType = AggregateType.Minimum; - - /** - * Validates this grouping. - * - * @throws Exception the exception - */ - private void internalValidate() throws Exception { - EwsUtilities.validateParam(this.groupOn, "GroupOn"); - EwsUtilities.validateParam(this.aggregateOn, "AggregateOn"); - } - - /** - * Initializes a new instance of the "Grouping" class. - */ - public Grouping() { - - } - - /** - * Initializes a new instance of the "Grouping" class. - * - * @param groupOn The property to group on - * @param sortDirection The sort direction. - * @param aggregateOn The property to aggregate on. - * @param aggregateType The type of aggregate to calculate. - * @throws Exception the exception - */ - public Grouping(PropertyDefinitionBase groupOn, - SortDirection sortDirection, PropertyDefinitionBase aggregateOn, - AggregateType aggregateType) throws Exception { - this(); - EwsUtilities.validateParam(groupOn, "groupOn"); - EwsUtilities.validateParam(aggregateOn, "aggregateOn"); - - this.groupOn = groupOn; - this.sortDirection = sortDirection; - this.aggregateOn = aggregateOn; - this.aggregateType = aggregateType; - } - - /** - * Writes to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected void writeToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - writer - .writeStartElement(XmlNamespace.Messages, - XmlElementNames.GroupBy); - writer.writeAttributeValue(XmlAttributeNames.Order, this.sortDirection); - - this.groupOn.writeToXml(writer); - - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.AggregateOn); - writer.writeAttributeValue(XmlAttributeNames.Aggregate, - this.aggregateType); - - this.aggregateOn.writeToXml(writer); - - writer.writeEndElement(); // AggregateOn - - writer.writeEndElement(); // GroupBy - } - - /** - * Gets the Sort Direction. - * - * @return the sort direction - */ - public SortDirection getSortDirection() { - return sortDirection; - } - - /** - * Sets the Sort Direction. - * - * @param sortDirection the new sort direction - */ - public void setSortDirection(SortDirection sortDirection) { - this.sortDirection = sortDirection; - } - - /** - * Gets the property to group on. - * - * @return the group on - */ - public PropertyDefinitionBase getGroupOn() { - return groupOn; - } - - /** - * sets the property to group on. - * - * @param groupOn the new group on - */ - public void setGroupOn(PropertyDefinitionBase groupOn) { - this.groupOn = groupOn; - } - - /** - * Gets the property to aggregateOn. - * - * @return the aggregate on - */ - public PropertyDefinitionBase getAggregateOn() { - return aggregateOn; - } - - /** - * Sets the property to aggregateOn. - * - * @param aggregateOn the new aggregate on - */ - public void setAggregateOn(PropertyDefinitionBase aggregateOn) { - this.aggregateOn = aggregateOn; - } - - /** - * Gets the types of aggregate to calculate. - * - * @return the aggregate type - */ - public AggregateType getAggregateType() { - return aggregateType; - } - - /** - * Sets the types of aggregate to calculate. - * - * @param aggregateType the new aggregate type - */ - public void setAggregateType(AggregateType aggregateType) { - this.aggregateType = aggregateType; - } - - /** - * Implements ISelfValidate.Validate. Validates this grouping. - */ - @Override - public void validate() { - try { - this.internalValidate(); - } catch (Exception e) { - LOG.error(e); - } - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/ItemGroup.java b/src/main/java/microsoft/exchange/webservices/data/search/ItemGroup.java deleted file mode 100644 index c1aa3b5bd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/ItemGroup.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.service.item.Item; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -/** - * Represents a group of item as returned by grouped item search operations. - * - * @param the generic type - */ -public final class ItemGroup { - - /** - * The group index. - */ - private String groupIndex; - - /** - * The item. - */ - private Collection items; - - /** - * Initializes a new instance of the class. - * - * @param groupIndex the group index - * @param items the item - */ - public ItemGroup(String groupIndex, List items) { - EwsUtilities.ewsAssert(groupIndex != null, "ItemGroup.ctor", "groupIndex is null"); - EwsUtilities - .ewsAssert(items != null, "ItemGroup.ctor", "item is null"); - - this.groupIndex = groupIndex; - this.items = new ArrayList(items); - } - - /** - * Gets an index identifying the group. - * - * @return the group index - */ - public String getGroupIndex() { - return this.groupIndex; - } - - /** - * Sets an index identifying the group. - */ - private void setGroupIndex(String value) { - this.groupIndex = value; - } - - /** - * Gets a collection of the item in this group. - * - * @return the item - */ - public Collection getItems() { - return this.items; - } - - /** - * Sets a collection of the item in this group. - */ - private void setItems(Collection value) { - this.items = value; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/ItemView.java b/src/main/java/microsoft/exchange/webservices/data/search/ItemView.java deleted file mode 100644 index 7522f9082..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/ItemView.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.request.ServiceRequestBase; -import microsoft.exchange.webservices.data.core.enumeration.search.ItemTraversal; -import microsoft.exchange.webservices.data.core.enumeration.search.OffsetBasePoint; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents the view settings in a folder search operation. - */ -public final class ItemView extends PagedView { - - /** - * The traversal. - */ - private ItemTraversal traversal = ItemTraversal.Shallow; - - /** - * The order by. - */ - private OrderByCollection orderBy = new OrderByCollection(); - - /** - * Gets the name of the view XML element. - * - * @return XML element name. - */ - @Override - protected String getViewXmlElementName() { - return XmlElementNames.IndexedPageItemView; - } - - /** - * Gets the type of service object this view applies to. - * - * @return A ServiceObjectType value. - */ - @Override - protected ServiceObjectType getServiceObjectType() { - return ServiceObjectType.Item; - } - - /** - * Validates this view. - * - * @param request the request - * @throws ServiceVersionException the service version exception - * @throws ServiceValidationException the service validation exception - */ - @Override public void internalValidate(ServiceRequestBase request) - throws ServiceVersionException, ServiceValidationException { - super.internalValidate(request); - - EwsUtilities.validateEnumVersionValue(this.traversal, request.getService().getRequestedServerVersion()); - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - writer.writeAttributeValue(XmlAttributeNames.Traversal, this.traversal); - } - - /** - * Internals the write search settings to XML. - * - * @param writer the writer - * @param groupBy the group by - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void internalWriteSearchSettingsToXml(EwsServiceXmlWriter writer, - Grouping groupBy) throws XMLStreamException, - ServiceXmlSerializationException { - super.internalWriteSearchSettingsToXml(writer, groupBy); - } - - /** - * Writes OrderBy property to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override public void writeOrderByToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - this.orderBy.writeToXml(writer, XmlElementNames.SortOrder); - } - - /** - * Initializes a new instance of the ItemView class. - * - * @param pageSize the page size - */ - public ItemView(int pageSize) { - super(pageSize); - } - - /** - * Initializes a new instance of the ItemView class. - * - * @param pageSize the page size - * @param offset the offset - */ - public ItemView(int pageSize, int offset) { - super(pageSize, offset); - this.setOffset(offset); - } - - /** - * Initializes a new instance of the ItemView class. - * - * @param pageSize the page size - * @param offset the offset - * @param offsetBasePoint the offset base point - */ - public ItemView(int pageSize, int offset, OffsetBasePoint offsetBasePoint) { - super(pageSize, offset, offsetBasePoint); - } - - /** - * Gets the search traversal mode. Defaults to - * ItemTraversal.Shallow. - * - * @return the traversal - */ - public ItemTraversal getTraversal() { - return this.traversal; - } - - /** - * Sets the traversal. - * - * @param value the new traversal - */ - public void setTraversal(ItemTraversal value) { - this.traversal = value; - } - - /** - * Gets the property against which the returned item should be ordered. - * - * @return the order by - */ - public OrderByCollection getOrderBy() { - return this.orderBy; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/OrderByCollection.java b/src/main/java/microsoft/exchange/webservices/data/search/OrderByCollection.java deleted file mode 100644 index 22c4d7bb3..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/OrderByCollection.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search; - -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.search.SortDirection; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinitionBase; - -import javax.xml.stream.XMLStreamException; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * Represents an ordered collection of property definitions qualified with a - * sort direction. - */ -public final class OrderByCollection implements - Iterable> { - - /** - * The prop def sort order pair list. - */ - private List> propDefSortOrderPairList; - - /** - * Initializes a new instance of the OrderByCollection class. - */ - protected OrderByCollection() { - this.propDefSortOrderPairList = new - ArrayList>(); - } - - /** - * Adds the specified property definition / sort direction pair to the - * collection. - * - * @param propertyDefinition the property definition - * @param sortDirection the sort direction - * @throws ServiceLocalException the service local exception - */ - public void add(PropertyDefinitionBase propertyDefinition, - SortDirection sortDirection) throws ServiceLocalException { - if (this.contains(propertyDefinition)) { - throw new ServiceLocalException(String.format("Property %s already exists in OrderByCollection.", - propertyDefinition.getPrintableName())); - } - Map propertyDefinitionSortDirectionPair = new - HashMap(); - propertyDefinitionSortDirectionPair.put(propertyDefinition, - sortDirection); - this.propDefSortOrderPairList.add(propertyDefinitionSortDirectionPair); - } - - /** - * Removes all elements from the collection. - */ - public void clear() { - this.propDefSortOrderPairList.clear(); - } - - /** - * Determines whether the collection contains the specified property - * definition. - * - * @param propertyDefinition the property definition - * @return True if the collection contains the specified property - * definition; otherwise, false. - */ - protected boolean contains(PropertyDefinitionBase propertyDefinition) { - for (Map propDefSortOrderPair : propDefSortOrderPairList) { - return propDefSortOrderPair.containsKey(propertyDefinition); - } - return false; - } - - /** - * Gets the number of elements contained in the collection. - * - * @return the int - */ - public int count() { - return this.propDefSortOrderPairList.size(); - } - - /** - * Removes the specified property definition from the collection. - * - * @param propertyDefinition the property definition - * @return True if the property definition is successfully removed; - * otherwise, false - */ - public boolean remove(PropertyDefinitionBase propertyDefinition) { - List> removeList = new - ArrayList>(); - for (Map propDefSortOrderPair : propDefSortOrderPairList) { - if (propDefSortOrderPair.containsKey(propertyDefinition)) { - removeList.add(propDefSortOrderPair); - } - } - this.propDefSortOrderPairList.removeAll(removeList); - return removeList.size() > 0; - } - - /** - * Removes the element at the specified index from the collection. - * - * @param index the index - */ - public void removeAt(int index) { - this.propDefSortOrderPairList.remove(index); - } - - /** - * Tries to get the value for a property definition in the collection. - * - * @param propertyDefinition the property definition - * @param sortDirection the sort direction - * @return True if collection contains property definition, otherwise false. - */ - public boolean tryGetValue(PropertyDefinitionBase propertyDefinition, - OutParam sortDirection) { - for (Map pair : this.propDefSortOrderPairList) { - - if (pair.containsKey(propertyDefinition)) { - sortDirection.setParam(pair.get(propertyDefinition)); - return true; - } - } - sortDirection.setParam(SortDirection.Ascending); // out parameter has to - // be set to some - // value. - return false; - } - - /** - * Writes to XML. - * - * @param writer the writer - * @param xmlElementName the xml element name - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected void writeToXml(EwsServiceXmlWriter writer, String xmlElementName) - throws XMLStreamException, ServiceXmlSerializationException { - if (this.count() > 0) { - writer.writeStartElement(XmlNamespace.Messages, xmlElementName); - - for (Map keyValuePair : this.propDefSortOrderPairList) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.FieldOrder); - - writer.writeAttributeValue(XmlAttributeNames.Order, - keyValuePair.values().iterator().next()); - keyValuePair.keySet().iterator().next().writeToXml(writer); - - writer.writeEndElement(); // FieldOrder - } - - writer.writeEndElement(); - } - } - - /* - * (non-Javadoc) - * - * @see java.lang.Iterable#iterator() - */ - @Override - public Iterator> iterator() { - return this.propDefSortOrderPairList.iterator(); - } - - /** - * Gets the element at the specified index from the collection. - * - * @param index the index - * @return the property definition sort direction pair - */ - public Map getPropertyDefinitionSortDirectionPair( - int index) { - return this.propDefSortOrderPairList.get(index); - } - - /** - * Returns an enumerator that iterates through the collection. - * - * @return A Iterator that can be used to iterate through the collection. - */ - public Iterator> getEnumerator() { - return (this.propDefSortOrderPairList.iterator()); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/PagedView.java b/src/main/java/microsoft/exchange/webservices/data/search/PagedView.java deleted file mode 100644 index f406b84fd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/PagedView.java +++ /dev/null @@ -1,228 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.request.ServiceRequestBase; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.search.OffsetBasePoint; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents a view settings that support paging in a search operation. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class PagedView extends ViewBase { - - /** - * The page size. - */ - private int pageSize; - - /** - * The offset base point. - */ - private OffsetBasePoint offsetBasePoint = OffsetBasePoint.Beginning; - - /** - * The offset. - */ - private int offset; - - /** - * Write to XML. - * - * @param writer The Writer - * @throws Exception the exception - */ - @Override - protected void internalWriteViewToXml(EwsServiceXmlWriter writer) - throws Exception { - super.internalWriteViewToXml(writer); - - writer.writeAttributeValue(XmlAttributeNames.Offset, this.getOffset()); - writer.writeAttributeValue(XmlAttributeNames.BasePoint, this - .getOffsetBasePoint()); - } - - /** - * Gets the maximum number of item or folder the search operation should - * return. - * - * @return The maximum number of item or folder that should be returned by - * the search operation. - */ - @Override - protected Integer getMaxEntriesReturned() { - return this.getPageSize(); - } - - /** - * Internals the write search settings to XML. - * - * @param writer the writer - * @param groupBy the group by clause - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - protected void internalWriteSearchSettingsToXml(EwsServiceXmlWriter writer, - Grouping groupBy) throws XMLStreamException, - ServiceXmlSerializationException { - if (groupBy != null) { - groupBy.writeToXml(writer); - } - } - - /** - * Writes OrderBy property to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override public void writeOrderByToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - // No order by for paged view - } - - /** - * Validates this view. - * - * @param request The request using this view. - * @throws ServiceVersionException the service version exception - * @throws ServiceValidationException the service validation exception - */ - @Override public void internalValidate(ServiceRequestBase request) - throws ServiceVersionException, ServiceValidationException { - super.internalValidate(request); - } - - /** - * Initializes a new instance of the "PagedView" class. - * - * @param pageSize The maximum number of elements the search operation should - * return. - */ - protected PagedView(int pageSize) { - super(); - this.setPageSize(pageSize); - } - - /** - * Initializes a new instance of the "PagedView" class. - * - * @param pageSize The maximum number of elements the search operation should - * return. - * @param offset The offset of the view from the base point. - */ - protected PagedView(int pageSize, int offset) { - this(pageSize); - this.setOffset(offset); - } - - /** - * Initializes a new instance of the "PagedView" class. - * - * @param pageSize The maximum number of elements the search operation should - * return. - * @param offset The offset of the view from the base point. - * @param offsetBasePoint The base point of the offset. - */ - protected PagedView(int pageSize, int offset, - OffsetBasePoint offsetBasePoint) { - this(pageSize, offset); - this.setOffsetBasePoint(offsetBasePoint); - } - - /** - * Gets the maximum number of item or folder the search operation should - * return. - * - * @return the page size - */ - public int getPageSize() { - return pageSize; - } - - /** - * Sets the maximum number of item or folder the search operation should - * return. - * - * @param pageSize the new page size - */ - public void setPageSize(int pageSize) { - if (pageSize <= 0) { - throw new IllegalArgumentException("The value must be greater than 0."); - } - this.pageSize = pageSize; - } - - /** - * Gets the base point of the offset. - * - * @return the offset base point - */ - public OffsetBasePoint getOffsetBasePoint() { - return offsetBasePoint; - } - - /** - * Sets the base point of the offset. - * - * @param offsetBasePoint the new offset base point - */ - public void setOffsetBasePoint(OffsetBasePoint offsetBasePoint) { - this.offsetBasePoint = offsetBasePoint; - } - - /** - * Gets the offset. - * - * @return the offset - */ - public int getOffset() { - return offset; - } - - /** - * Sets the offset. - * - * @param offset the new offset - */ - public void setOffset(int offset) { - if (offset >= 0) { - this.offset = offset; - } else { - throw new IllegalArgumentException("The offset must be greater than 0."); - } - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/ViewBase.java b/src/main/java/microsoft/exchange/webservices/data/search/ViewBase.java deleted file mode 100644 index 9fb5d62ef..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/ViewBase.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.PropertySet; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.request.ServiceRequestBase; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; - -import javax.xml.stream.XMLStreamException; - -/** - * Represents the base view class for search operations. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class ViewBase { - - /** - * The property set. - */ - private PropertySet propertySet; - - /** - * Initializes a new instance of the "ViewBase" class. - */ - ViewBase() { - } - - /** - * Validates this view. - * - * @param request The request using this view. - * @throws ServiceValidationException the service validation exception - * @throws ServiceVersionException the service version exception - */ - public void internalValidate(ServiceRequestBase request) - throws ServiceValidationException, ServiceVersionException { - if (this.getPropertySet() != null) { - this.getPropertySet().internalValidate(); - this.getPropertySet().validateForRequest( - request, - true /* summaryPropertiesOnly */); - } - } - - /** - * Writes this view to XML. - * - * @param writer The writer - * @throws ServiceXmlSerializationException the service xml serialization exception - * @throws Exception the exception - */ - protected void internalWriteViewToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException, Exception { - Integer maxEntriesReturned = this.getMaxEntriesReturned(); - - if (maxEntriesReturned != null) { - writer.writeAttributeValue(XmlAttributeNames.MaxEntriesReturned, - maxEntriesReturned); - } - } - - /** - * Writes the search settings to XML. - * - * @param writer the writer - * @param groupBy the group by clause - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - protected abstract void internalWriteSearchSettingsToXml( - EwsServiceXmlWriter writer, Grouping groupBy) - throws XMLStreamException, ServiceXmlSerializationException; - - /** - * Writes OrderBy property to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public abstract void writeOrderByToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException; - - /** - * Gets the name of the view XML element. - * - * @return TheXml Element name - */ - protected abstract String getViewXmlElementName(); - - /** - * Gets the maximum number of item or folder the search operation should - * return. - * - * @return The maximum number of item or folder that should be returned by - * the search operation. - */ - protected abstract Integer getMaxEntriesReturned(); - - /** - * Gets the type of service object this view applies to. - * - * @return A ServiceObjectType value. - */ - protected abstract ServiceObjectType getServiceObjectType(); - - /** - * Writes the attribute to XML. - * - * @param writer The writer. - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - public abstract void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException; - - /** - * Writes to XML. - * - * @param writer The writer. - * @param groupBy The group by clause. - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer, Grouping groupBy) - throws Exception { - this.getPropertySetOrDefault().writeToXml(writer, - this.getServiceObjectType()); - writer.writeStartElement(XmlNamespace.Messages, this - .getViewXmlElementName()); - this.internalWriteViewToXml(writer); - writer.writeEndElement(); // this.GetViewXmlElementName() - this.internalWriteSearchSettingsToXml(writer, groupBy); - } - - /** - * Gets the property set or the default. - * - * @return PropertySet - */ - public PropertySet getPropertySetOrDefault() { - if (this.getPropertySet() == null) { - return PropertySet.getFirstClassProperties(); - } else { - return this.getPropertySet(); - } - } - - /** - * Gets the property set. PropertySet determines which property will be - * loaded on found item. If PropertySet is null, all first class property - * are loaded on found item. - * - * @return the property set - */ - public PropertySet getPropertySet() { - return propertySet; - } - - /** - * Sets the property set. PropertySet determines which property will be - * loaded on found item. If PropertySet is null, all first class property - * are loaded on found item. - * - * @param propertySet The property set - */ - public void setPropertySet(PropertySet propertySet) { - this.propertySet = propertySet; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/search/filter/SearchFilter.java b/src/main/java/microsoft/exchange/webservices/data/search/filter/SearchFilter.java deleted file mode 100644 index 2bd0d0f26..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/search/filter/SearchFilter.java +++ /dev/null @@ -1,1542 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.search.filter; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlAttributeNames; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.search.ComparisonMode; -import microsoft.exchange.webservices.data.core.enumeration.search.ContainmentMode; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.enumeration.search.LogicalOperator; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlDeserializationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.complex.ComplexProperty; -import microsoft.exchange.webservices.data.property.complex.IComplexPropertyChangedDelegate; -import microsoft.exchange.webservices.data.property.complex.ISearchStringProvider; -import microsoft.exchange.webservices.data.property.definition.PropertyDefinitionBase; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.xml.stream.XMLStreamException; - -import java.util.ArrayList; -import java.util.Iterator; - -/** - * Represents the base search filter class. Use descendant search filter classes - * such as SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection to define search filter. - */ -public abstract class SearchFilter extends ComplexProperty { - - private static final Log LOG = LogFactory.getLog(SearchFilter.class); - - /** - * Initializes a new instance of the SearchFilter class. - */ - protected SearchFilter() { - } - - /** - * The search. - * - * @param reader the reader - * @return the search filter - * @throws Exception the exception - */ - //static SearchFilter search; - - /** - * Loads from XML. - * - * @param reader the reader - * @return SearchFilter - * @throws Exception the exception - */ - public static SearchFilter loadFromXml(EwsServiceXmlReader reader) - throws Exception { - reader.ensureCurrentNodeIsStartElement(); - - SearchFilter searchFilter = null; - - if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Exists)) { - searchFilter = new Exists(); - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.Contains)) { - searchFilter = new ContainsSubstring(); - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.Excludes)) { - searchFilter = new ExcludesBitmask(); - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Not)) { - searchFilter = new Not(); - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.And)) { - searchFilter = new SearchFilterCollection( - LogicalOperator.And); - } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Or)) { - searchFilter = new SearchFilterCollection( - LogicalOperator.Or); - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.IsEqualTo)) { - searchFilter = new IsEqualTo(); - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.IsNotEqualTo)) { - searchFilter = new IsNotEqualTo(); - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.IsGreaterThan)) { - searchFilter = new IsGreaterThan(); - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.IsGreaterThanOrEqualTo)) { - searchFilter = new IsGreaterThanOrEqualTo(); - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.IsLessThan)) { - searchFilter = new IsLessThan(); - } else if (reader.getLocalName().equalsIgnoreCase( - XmlElementNames.IsLessThanOrEqualTo)) { - searchFilter = new IsLessThanOrEqualTo(); - } else { - searchFilter = null; - } - - if (searchFilter != null) { - searchFilter.loadFromXml(reader, reader.getLocalName()); - } - - return searchFilter; - } - - /** - * Gets the name of the XML element. - * - * @return the xml element name - */ - protected abstract String getXmlElementName(); - - /** - * Writes to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - public void writeToXml(EwsServiceXmlWriter writer) throws Exception { - super.writeToXml(writer, this.getXmlElementName()); - } - - /** - * Represents a search filter that checks for the presence of a substring - * inside a text property. Applications can use ContainsSubstring to define - * conditions such as "Field CONTAINS Value" or - * "Field IS PREFIXED WITH Value". - */ - public static final class ContainsSubstring extends PropertyBasedFilter { - - /** - * The containment mode. - */ - private ContainmentMode containmentMode = ContainmentMode.Substring; - - /** - * The comparison mode. - */ - private ComparisonMode comparisonMode = ComparisonMode.IgnoreCase; - - /** - * The value. - */ - private String value; - - /** - * Initializes a new instance of the class. - */ - public ContainsSubstring() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param value The value to compare with. - */ - public ContainsSubstring(PropertyDefinitionBase propertyDefinition, - String value) { - super(propertyDefinition); - this.value = value; - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param value The value to compare with. - * @param containmentMode The containment mode. - * @param comparisonMode The comparison mode. - */ - public ContainsSubstring(PropertyDefinitionBase propertyDefinition, - String value, ContainmentMode containmentMode, - ComparisonMode comparisonMode) { - this(propertyDefinition, value); - this.containmentMode = containmentMode; - this.comparisonMode = comparisonMode; - } - - /** - * validates instance. - * - * @throws ServiceValidationException the service validation exception - */ - @Override - protected void internalValidate() throws ServiceValidationException { - super.internalValidate(); - if ((this.value == null) || this.value.isEmpty()) { - throw new ServiceValidationException("The Value property must be set."); - } - } - - /** - * Gets the name of the XML element. - * - * @return the xml element name - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.Contains; - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return True if element was read. - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - boolean result = super.tryReadElementFromXml(reader); - - if (!result) { - if (reader.getLocalName().equals(XmlElementNames.Constant)) { - this.value = reader - .readAttributeValue(XmlAttributeNames.Value); - result = true; - } - } - return result; - } - - /** - * Reads the attribute of Xml. - * - * @param reader the reader - * @throws Exception the exception - */ - @Override - public void readAttributesFromXml(EwsServiceXmlReader reader) - throws Exception { - - super.readAttributesFromXml(reader); - this.containmentMode = reader.readAttributeValue( - ContainmentMode.class, XmlAttributeNames.ContainmentMode); - try { - this.comparisonMode = reader.readAttributeValue( - ComparisonMode.class, - XmlAttributeNames.ContainmentComparison); - } catch (IllegalArgumentException ile) { - // This will happen if we receive a value that is defined in the - // EWS - // schema but that is not defined - // in the API. We map that - // value to IgnoreCaseAndNonSpacingCharacters. - this.comparisonMode = ComparisonMode. - IgnoreCaseAndNonSpacingCharacters; - } - } - - /** - * Writes the attribute to XML. - * - * @param writer the writer - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeAttributesToXml(EwsServiceXmlWriter writer) - throws ServiceXmlSerializationException { - super.writeAttributesToXml(writer); - - writer.writeAttributeValue(XmlAttributeNames.ContainmentMode, - this.containmentMode); - writer.writeAttributeValue(XmlAttributeNames.ContainmentComparison, - this.comparisonMode); - } - - /** - * Writes the elements to Xml. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - super.writeElementsToXml(writer); - - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.Constant); - writer.writeAttributeValue(XmlAttributeNames.Value, this.value); - writer.writeEndElement(); // Constant - } - - /** - * Gets the containment mode. - * - * @return ContainmentMode - */ - public ContainmentMode getContainmentMode() { - return containmentMode; - } - - /** - * sets the ContainmentMode. - * - * @param containmentMode the new containment mode - */ - public void setContainmentMode(ContainmentMode containmentMode) { - this.containmentMode = containmentMode; - } - - /** - * Gets the comparison mode. - * - * @return ComparisonMode - */ - public ComparisonMode getComparisonMode() { - return comparisonMode; - } - - /** - * sets the comparison mode. - * - * @param comparisonMode the new comparison mode - */ - public void setComparisonMode(ComparisonMode comparisonMode) { - this.comparisonMode = comparisonMode; - } - - /** - * gets the value to compare the specified property with. - * - * @return String - */ - public String getValue() { - return value; - } - - /** - * sets the value to compare the specified property with. - * - * @param value the new value - */ - public void setValue(String value) { - this.value = value; - } - } - - - /** - * Represents a bitmask exclusion search filter. Applications can use - * ExcludesBitExcludesBitmaskFilter to define conditions such as - * "(OrdinalField and 0x0010) != 0x0010" - */ - public static class ExcludesBitmask extends PropertyBasedFilter { - - /** - * The bitmask. - */ - private int bitmask; - - /** - * Initializes a new instance of the class. - */ - public ExcludesBitmask() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition the property definition - * @param bitmask the bitmask - */ - public ExcludesBitmask(PropertyDefinitionBase propertyDefinition, - int bitmask) { - super(propertyDefinition); - this.bitmask = bitmask; - } - - /** - * Gets the name of the XML element. - * - * @return XML element name - */ - @Override - public String getXmlElementName() { - return XmlElementNames.Excludes; - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return true if element was read - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - boolean result = super.tryReadElementFromXml(reader); - - if (!result) { - if (reader.getLocalName().equals(XmlElementNames.Bitmask)) { - // EWS always returns the Bitmask value in hexadecimal - this.bitmask = Integer.parseInt(reader - .readAttributeValue(XmlAttributeNames.Value)); - } - } - - return result; - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws javax.xml.stream.XMLStreamException , ServiceXmlSerializationException - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - super.writeElementsToXml(writer); - - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.Bitmask); - writer.writeAttributeValue(XmlAttributeNames.Value, this.bitmask); - writer.writeEndElement(); // Bitmask - } - - /** - * Gets the bitmask to compare the property with. - * - * @return bitmask - */ - public int getBitmask() { - return bitmask; - } - - /** - * Sets the bitmask to compare the property with. - * - * @param bitmask the new bitmask - */ - public void setBitmask(int bitmask) { - this.bitmask = bitmask; - } - - } - - - /** - * Represents a search filter checking if a field is set. Applications can - * use ExistsFilter to define conditions such as "Field IS SET". - */ - public static final class Exists extends PropertyBasedFilter { - - /** - * Initializes a new instance of the class. - */ - public Exists() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition the property definition - */ - public Exists(PropertyDefinitionBase propertyDefinition) { - super(propertyDefinition); - } - - /** - * Gets the name of the XML element. - * - * @return the xml element name - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.Exists; - } - } - - - /** - * Represents a search filter that checks if a property is equal to a given - * value or other property. - */ - public static class IsEqualTo extends RelationalFilter { - - /** - * Initializes a new instance of the class. - */ - public IsEqualTo() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param otherPropertyDefinition The definition of the property to compare with. - */ - public IsEqualTo(PropertyDefinitionBase propertyDefinition, - PropertyDefinitionBase otherPropertyDefinition) { - super(propertyDefinition, otherPropertyDefinition); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param value The value of the property to compare with. - */ - public IsEqualTo(PropertyDefinitionBase propertyDefinition, - Object value) { - super(propertyDefinition, value); - } - - /** - * Gets the name of the XML element. - * - * @return the xml element name - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.IsEqualTo; - } - - } - - - /** - * Represents a search filter that checks if a property is greater than a - * given value or other property. - */ - public static class IsGreaterThan extends RelationalFilter { - - /** - * Initializes a new instance of the class. - */ - public IsGreaterThan() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param otherPropertyDefinition The definition of the property to compare with. - */ - public IsGreaterThan(PropertyDefinitionBase propertyDefinition, - PropertyDefinitionBase otherPropertyDefinition) { - super(propertyDefinition, otherPropertyDefinition); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param value The value of the property to compare with. - */ - public IsGreaterThan(PropertyDefinitionBase propertyDefinition, - Object value) { - super(propertyDefinition, value); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.IsGreaterThan; - } - } - - - /** - * Represents a search filter that checks if a property is greater than or - * equal to a given value or other property. - */ - public static class IsGreaterThanOrEqualTo extends RelationalFilter { - - /** - * Initializes a new instance of the class. - */ - public IsGreaterThanOrEqualTo() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param otherPropertyDefinition The definition of the property to compare with. - */ - public IsGreaterThanOrEqualTo( - PropertyDefinitionBase propertyDefinition, - PropertyDefinitionBase otherPropertyDefinition) { - super(propertyDefinition, otherPropertyDefinition); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param value The value of the property to compare with. - */ - public IsGreaterThanOrEqualTo( - PropertyDefinitionBase propertyDefinition, Object value) { - super(propertyDefinition, value); - } - - /** - * Gets the name of the XML element. XML element name. - * - * @return the xml element name - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.IsGreaterThanOrEqualTo; - } - - } - - - /** - * Represents a search filter that checks if a property is less than a given - * value or other property. - */ - public static class IsLessThan extends RelationalFilter { - - /** - * Initializes a new instance of the class. - */ - public IsLessThan() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param otherPropertyDefinition The definition of the property to compare with. - */ - public IsLessThan(PropertyDefinitionBase propertyDefinition, - PropertyDefinitionBase otherPropertyDefinition) { - super(propertyDefinition, otherPropertyDefinition); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param value The value of the property to compare with. - */ - public IsLessThan(PropertyDefinitionBase propertyDefinition, - Object value) { - super(propertyDefinition, value); - } - - /** - * Gets the name of the XML element. XML element name. - * - * @return the xml element name - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.IsLessThan; - } - - } - - - /** - * Represents a search filter that checks if a property is less than or - * equal to a given value or other property. - */ - public static class IsLessThanOrEqualTo extends RelationalFilter { - - /** - * Initializes a new instance of the class. - */ - public IsLessThanOrEqualTo() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param otherPropertyDefinition The definition of the property to compare with. - */ - public IsLessThanOrEqualTo(PropertyDefinitionBase propertyDefinition, - PropertyDefinitionBase otherPropertyDefinition) { - super(propertyDefinition, otherPropertyDefinition); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param value The value of the property to compare with. - */ - public IsLessThanOrEqualTo(PropertyDefinitionBase propertyDefinition, - Object value) { - super(propertyDefinition, value); - } - - /** - * Gets the name of the XML element. XML element name. - * - * @return the xml element name - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.IsLessThanOrEqualTo; - } - - } - - - /** - * Represents a search filter that checks if a property is not equal to a - * given value or other property. - */ - public static class IsNotEqualTo extends RelationalFilter { - - /** - * Initializes a new instance of the class. - */ - public IsNotEqualTo() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param otherPropertyDefinition The definition of the property to compare with. - */ - public IsNotEqualTo(PropertyDefinitionBase propertyDefinition, - PropertyDefinitionBase otherPropertyDefinition) { - super(propertyDefinition, otherPropertyDefinition); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param value The value of the property to compare with. - */ - public IsNotEqualTo(PropertyDefinitionBase propertyDefinition, - Object value) { - super(propertyDefinition, value); - } - - /** - * Gets the name of the XML element. - * - * @return XML element name. - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.IsNotEqualTo; - } - - } - - - /** - * Represents a search filter that negates another. Applications can use - * NotFilter to define conditions such as "NOT(other filter)". - */ - public static class Not extends SearchFilter implements IComplexPropertyChangedDelegate { - - /** - * The search filter. - */ - private SearchFilter searchFilter; - - /** - * Initializes a new instance of the class. - */ - public Not() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param searchFilter the search filter - */ - public Not(SearchFilter searchFilter) { - super(); - this.searchFilter = searchFilter; - } - - /** - * Search filter changed. - * - * @param complexProperty the complex property - */ - private void searchFilterChanged(ComplexProperty complexProperty) { - this.changed(); - } - - /** - * validates the instance. - * - * @throws ServiceValidationException the service validation exception - */ - @Override - protected void internalValidate() throws ServiceValidationException { - if (this.searchFilter == null) { - throw new ServiceValidationException("The SearchFilter property must be set."); - } - } - - /** - * Gets the name of the XML element. - * - * @return the xml element name - */ - @Override - protected String getXmlElementName() { - return XmlElementNames.Not; - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return true if the element was read - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - this.searchFilter = SearchFilter.loadFromXml(reader); - return true; - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - this.searchFilter.writeToXml(writer); - } - - /** - * Gets the search filter to negate. Available search filter - * classes include SearchFilter.IsEqualTo, - * SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection. - * - * @return SearchFilter - */ - public SearchFilter getSearchFilter() { - return searchFilter; - } - - /** - * Sets the search filter to negate. Available search filter classes - * include SearchFilter.IsEqualTo, SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection. - * - * @param searchFilter the new search filter - */ - public void setSearchFilter(SearchFilter searchFilter) { - if (this.searchFilter != null) { - this.searchFilter.removeChangeEvent(this); - } - - if (this.canSetFieldValue(this.searchFilter, searchFilter)) { - this.searchFilter = searchFilter; - this.changed(); - - } - - if (this.searchFilter != null) { - this.searchFilter.addOnChangeEvent(this); - } - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices. - * ComplexPropertyChangedDelegateInterface# - * complexPropertyChanged(microsoft.exchange.webservices.ComplexProperty - * ) - */ - @Override - public void complexPropertyChanged(ComplexProperty complexProperty) { - searchFilterChanged(complexProperty); - - } - } - - - /** - * Represents a search filter where an item or folder property is involved. - */ - @EditorBrowsable(state = EditorBrowsableState.Never) - public static abstract class PropertyBasedFilter extends SearchFilter { - - /** - * The property definition. - */ - private PropertyDefinitionBase propertyDefinition; - - /** - * Initializes a new instance of the class. - */ - PropertyBasedFilter() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition the property definition - */ - PropertyBasedFilter(PropertyDefinitionBase propertyDefinition) { - super(); - this.propertyDefinition = propertyDefinition; - } - - /** - * validate instance. - * - * @throws ServiceValidationException the service validation exception - */ - @Override - protected void internalValidate() throws ServiceValidationException { - if (this.propertyDefinition == null) { - throw new ServiceValidationException("The PropertyDefinition property must be set."); - } - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return true if element was read - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - OutParam outParam = - new OutParam(); - outParam.setParam(this.propertyDefinition); - - return PropertyDefinitionBase.tryLoadFromXml(reader, outParam); - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - this.propertyDefinition.writeToXml(writer); - } - - /** - * Gets the definition of the property that is involved in the search - * filter. - * - * @return propertyDefinition - */ - public PropertyDefinitionBase getPropertyDefinition() { - return this.propertyDefinition; - } - - /** - * Sets the definition of the property that is involved in the search - * filter. - * - * @param propertyDefinition the new property definition - */ - public void setPropertyDefinition( - PropertyDefinitionBase propertyDefinition) { - this.propertyDefinition = propertyDefinition; - } - } - - - /** - * Represents the base class for relational filter (for example, IsEqualTo, - * IsGreaterThan or IsLessThanOrEqualTo). - */ - @EditorBrowsable(state = EditorBrowsableState.Never) - public abstract static class RelationalFilter extends PropertyBasedFilter { - - /** - * The other property definition. - */ - private PropertyDefinitionBase otherPropertyDefinition; - - /** - * The value. - */ - private Object value; - - /** - * Initializes a new instance of the class. - */ - RelationalFilter() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param otherPropertyDefinition The definition of the property to compare with - */ - RelationalFilter(PropertyDefinitionBase propertyDefinition, - PropertyDefinitionBase otherPropertyDefinition) { - super(propertyDefinition); - this.otherPropertyDefinition = otherPropertyDefinition; - } - - /** - * Initializes a new instance of the class. - * - * @param propertyDefinition The definition of the property that is being compared. - * @param value The value to compare with. - */ - RelationalFilter(PropertyDefinitionBase propertyDefinition, - Object value) { - super(propertyDefinition); - this.value = value; - } - - /** - * validates the instance. - * - * @throws ServiceValidationException the service validation exception - */ - @Override - protected void internalValidate() throws ServiceValidationException { - super.internalValidate(); - - if (this.otherPropertyDefinition == null && this.value == null) { - throw new ServiceValidationException( - "Either the OtherPropertyDefinition or the Value property must be set."); - } - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return true if element was read - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - boolean result = super.tryReadElementFromXml(reader); - - if (!result) { - if (reader.getLocalName().equals( - XmlElementNames.FieldURIOrConstant)) { - try { - reader.read(); - reader.ensureCurrentNodeIsStartElement(); - } catch (ServiceXmlDeserializationException e) { - LOG.error(e); - } catch (XMLStreamException e) { - LOG.error(e); - } - - if (reader.isStartElement(XmlNamespace.Types, - XmlElementNames.Constant)) { - this.value = reader - .readAttributeValue(XmlAttributeNames.Value); - result = true; - } else { - OutParam outParam = - new OutParam(); - outParam.setParam(this.otherPropertyDefinition); - - result = PropertyDefinitionBase.tryLoadFromXml(reader, - outParam); - } - } - } - - return result; - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws javax.xml.stream.XMLStreamException , ServiceXmlSerializationException - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws XMLStreamException, ServiceXmlSerializationException { - super.writeElementsToXml(writer); - - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.FieldURIOrConstant); - - if (this.value != null) { - writer.writeStartElement(XmlNamespace.Types, - XmlElementNames.Constant); - writer.writeAttributeValue(XmlAttributeNames.Value, - true /* alwaysWriteEmptyString */, this.value); - writer.writeEndElement(); // Constant - } else { - this.otherPropertyDefinition.writeToXml(writer); - } - - writer.writeEndElement(); // FieldURIOrConstant - } - - /** - * Gets the definition of the property to compare with. - * - * @return otherPropertyDefinition - */ - public PropertyDefinitionBase getOtherPropertyDefinition() { - return this.otherPropertyDefinition; - } - - /** - * Sets the definition of the property to compare with. - * - * @param OtherPropertyDefinition the new other property definition - */ - public void setOtherPropertyDefinition( - PropertyDefinitionBase OtherPropertyDefinition) { - this.otherPropertyDefinition = OtherPropertyDefinition; - this.value = null; - } - - /** - * Gets the value of the property to compare with. - * - * @return the value - */ - public Object getValue() { - return value; - } - - /** - * Sets the value of the property to compare with. - * - * @param value the new value - */ - public void setValue(Object value) { - this.value = value; - this.otherPropertyDefinition = null; - } - - /** - * gets Xml Element name. - * - * @return the xml element name - */ - @Override - protected String getXmlElementName() { - return null; - } - } - - - /** - * Represents a collection of search filter linked by a logical operator. - * Applications can use SearchFilterCollection to define complex search - * filter such as "Condition1 AND Condition2". - */ - public static class SearchFilterCollection extends SearchFilter implements - Iterable, IComplexPropertyChangedDelegate { - - /** - * The logical operator. - */ - private LogicalOperator logicalOperator = LogicalOperator.And; - - /** - * The search filter. - */ - private ArrayList searchFilters = - new ArrayList(); - - /** - * Initializes a new instance of the class. - */ - public SearchFilterCollection() { - super(); - } - - /** - * Initializes a new instance of the class. - * - * @param logicalOperator The logical operator used to initialize the collection. - */ - public SearchFilterCollection(LogicalOperator logicalOperator) { - this.logicalOperator = logicalOperator; - } - - /** - * Initializes a new instance of the class. - * - * @param logicalOperator The logical operator used to initialize the collection. - * @param searchFilters The search filter to add to the collection. - */ - public SearchFilterCollection(LogicalOperator logicalOperator, - SearchFilter... searchFilters) { - this(logicalOperator); - for (SearchFilter search : searchFilters) { - Iterable searchFil = java.util.Arrays - .asList(search); - this.addRange(searchFil); - } - } - - /** - * Initializes a new instance of the class. - * - * @param logicalOperator The logical operator used to initialize the collection. - * @param searchFilters The search filter to add to the collection. - */ - public SearchFilterCollection(LogicalOperator logicalOperator, - Iterable searchFilters) { - this(logicalOperator); - this.addRange(searchFilters); - } - - /** - * Validate instance. - * - * @throws Exception - */ - @Override - protected void internalValidate() throws Exception { - for (int i = 0; i < this.getCount(); i++) { - try { - this.searchFilters.get(i).internalValidate(); - } catch (ServiceValidationException e) { - throw new ServiceValidationException(String.format("The search filter at index %d is invalid.", i), - e); - } - } - } - - /** - * A search filter has changed. - * - * @param complexProperty The complex property - */ - private void searchFilterChanged(ComplexProperty complexProperty) { - this.changed(); - } - - /** - * Gets the name of the XML element. - * - * @return xml element name - */ - @Override - protected String getXmlElementName() { - return this.logicalOperator.toString(); - } - - /** - * Tries to read element from XML. - * - * @param reader the reader - * @return true, if successful - * @throws Exception the exception - */ - @Override - public boolean tryReadElementFromXml(EwsServiceXmlReader reader) - throws Exception { - - this.add(SearchFilter.loadFromXml(reader)); - return true; - } - - /** - * Writes the elements to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override - public void writeElementsToXml(EwsServiceXmlWriter writer) - throws Exception { - for (SearchFilter searchFilter : this.searchFilters) { - searchFilter.writeToXml(writer); - } - } - - /** - * Writes to XML. - * - * @param writer the writer - * @throws Exception the exception - */ - @Override public void writeToXml(EwsServiceXmlWriter writer) throws Exception { - // If there is only one filter in the collection, which developers - // tend - // to do, - // we need to not emit the collection and instead only emit the one - // filter within - // the collection. This is to work around the fact that EWS does not - // allow filter - // collections that have less than two elements. - if (this.getCount() == 1) { - this.searchFilters.get(0).writeToXml(writer); - } else { - super.writeToXml(writer); - } - } - - /** - * Adds a search filter of any type to the collection. - * - * @param searchFilter >The search filter to add. Available search filter classes - * include SearchFilter.IsEqualTo, - * SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection. - */ - public void add(SearchFilter searchFilter) { - if (searchFilter == null) { - throw new IllegalArgumentException("searchFilter"); - } - searchFilter.addOnChangeEvent(this); - this.searchFilters.add(searchFilter); - this.changed(); - } - - /** - * Adds multiple search filter to the collection. - * - * @param searchFilters The search filter to add. Available search filter classes - * include SearchFilter.IsEqualTo, - * SearchFilter.ContainsSubstring and - * SearchFilter.SearchFilterCollection - */ - public void addRange(Iterable searchFilters) { - if (searchFilters == null) { - throw new IllegalArgumentException("searchFilters"); - } - - for (SearchFilter searchFilter : searchFilters) { - searchFilter.addOnChangeEvent(this); - this.searchFilters.add(searchFilter); - } - this.changed(); - } - - /** - * Clears the collection. - */ - public void clear() { - if (this.getCount() > 0) { - for (SearchFilter searchFilter : this.searchFilters) { - searchFilter.removeChangeEvent(this); - } - this.searchFilters.clear(); - this.changed(); - } - } - - /** - * Determines whether a specific search filter is in the collection. - * - * @param searchFilter The search filter to locate in the collection. - * @return True is the search filter was found in the collection, false - * otherwise. - */ - public boolean contains(SearchFilter searchFilter) { - return this.searchFilters.contains(searchFilter); - } - - /** - * Removes a search filter from the collection. - * - * @param searchFilter The search filter to remove - */ - public void remove(SearchFilter searchFilter) { - if (searchFilter == null) { - throw new IllegalArgumentException("searchFilter"); - } - - if (this.contains(searchFilter)) { - searchFilter.removeChangeEvent(this); - this.searchFilters.remove(searchFilter); - this.changed(); - } - } - - /** - * Removes the search filter at the specified index from the collection. - * - * @param index The zero-based index of the search filter to remove. - */ - public void removeAt(int index) { - if (index < 0 || index >= this.getCount()) { - throw new IllegalArgumentException( - String.format("index %d is out of range [0..%d[.", index, this.getCount())); - } - - this.searchFilters.get(index).removeChangeEvent(this); - this.searchFilters.remove(index); - this.changed(); - } - - /** - * Gets the total number of search filter in the collection. - * - * @return the count - */ - public int getCount() { - - return this.searchFilters.size(); - } - - /** - * Gets the search filter at the specified index. - * - * @param index the index - * @return The search filter at the specified index. - */ - public SearchFilter getSearchFilter(int index) { - if (index < 0 || index >= this.getCount()) { - throw new IllegalArgumentException( - String.format("index %d is out of range [0..%d[.", index, this.getCount()) - ); - } - return this.searchFilters.get(index); - } - - /** - * Sets the search filter at the specified index. - * - * @param index the index - * @param searchFilter the search filter - */ - public void setSearchFilter(int index, SearchFilter searchFilter) { - if (index < 0 || index >= this.getCount()) { - throw new IllegalArgumentException( - String.format("index %d is out of range [0..%d[.", index, this.getCount()) - ); - } - this.searchFilters.add(index, searchFilter); - } - - /** - * Gets the logical operator that links the serach filter in this - * collection. - * - * @return LogicalOperator - */ - public LogicalOperator getLogicalOperator() { - return logicalOperator; - } - - /** - * Sets the logical operator that links the serach filter in this - * collection. - * - * @param logicalOperator the new logical operator - */ - public void setLogicalOperator(LogicalOperator logicalOperator) { - this.logicalOperator = logicalOperator; - } - - /* - * (non-Javadoc) - * - * @see - * microsoft.exchange.webservices. - * ComplexPropertyChangedDelegateInterface# - * complexPropertyChanged(microsoft.exchange.webservices.ComplexProperty - * ) - */ - @Override - public void complexPropertyChanged(ComplexProperty complexProperty) { - searchFilterChanged(complexProperty); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Iterable#iterator() - */ - @Override - public Iterator iterator() { - return this.searchFilters.iterator(); - } - - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/security/SafeXmlDocument.java b/src/main/java/microsoft/exchange/webservices/data/security/SafeXmlDocument.java deleted file mode 100644 index 4e64fa877..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/security/SafeXmlDocument.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.security; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.w3c.dom.DOMImplementation; -import org.w3c.dom.Document; -import org.xml.sax.EntityResolver; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; - -/** - * XmlDocument that does not allow DTD parsing. - */ -public class SafeXmlDocument extends DocumentBuilder { - - private static final Log LOG = LogFactory.getLog(SafeXmlDocument.class); - - /** - * Initializes a new instance of the SafeXmlDocument class. - */ - private final XMLInputFactory inputFactory; - - public SafeXmlDocument() { - super(); - inputFactory = XMLInputFactory.newInstance(); - } - - - /** - * Loads the XML document from the specified stream. - * - * @param inStream The stream containing the XML document to load. - * @throws javax.xml.stream.XMLStreamException - */ - public void load(InputStream inStream) throws XMLStreamException { - // not in a using block because - // the stream doesn't belong to us - if (inputFactory != null) { - XMLEventReader reader = inputFactory - .createXMLEventReader(inStream); - - this.load((InputStream) reader); - } - } - - /** - * Loads the XML document from the specified URL. - * - * @param filename URL for the file containing the XML document to load. The URL - * can be either a local file or an HTTP URL (a Web address). - */ - public void load(String filename) { - if (inputFactory != null) { - FileInputStream inp; - - XMLEventReader reader; - try { - inp = new FileInputStream(filename); - reader = inputFactory.createXMLEventReader(inp); - this.load((InputStream) reader); - } catch (XMLStreamException e) { - // TODO Auto-generated catch block - LOG.error(e); - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - LOG.error(e); - } - } - } - - /** - * Loads the XML document from the specified TextReader. - * - * @param txtReader The TextReader used to feed the XML data into the document. - */ - public void load(Reader txtReader) { - if (inputFactory != null) { - - XMLEventReader reader; - try { - reader = inputFactory - .createXMLEventReader(txtReader); - - this.load((InputStream) reader); - } catch (XMLStreamException e) { - // TODO Auto-generated catch block - LOG.error(e); - } - } - } - - /** - * Loads the XML document from the specified XMLReader. - * - * @param reader The XMLReader used to feed the XML data into the document. - * @throws java.io.IOException - * @throws org.xml.sax.SAXException - */ - public void load(XMLStreamReader reader) throws SAXException, IOException { - - super.parse((InputStream) reader); - } - - /** - * Loads the XML document from the specified string. - * - * @param xml String containing the XML document to load. - */ - public void loadXml(String xml) { - if (inputFactory != null) { - try { - XMLEventReader reader = inputFactory - .createXMLEventReader(new StringReader(xml)); - - this.load((InputStream) reader); - } catch (XMLStreamException e) { - // TODO Auto-generated catch block - LOG.error(e); - } - } - - } - - @Override - public DOMImplementation getDOMImplementation() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean isNamespaceAware() { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean isValidating() { - // TODO Auto-generated method stub - return false; - } - - @Override - public Document newDocument() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Document parse(InputSource is) throws SAXException, IOException { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setEntityResolver(EntityResolver er) { - // TODO Auto-generated method stub - - } - - @Override - public void setErrorHandler(ErrorHandler eh) { - // TODO Auto-generated method stub - - } - - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/security/SafeXmlFactory.java b/src/main/java/microsoft/exchange/webservices/data/security/SafeXmlFactory.java deleted file mode 100644 index c12009e9f..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/security/SafeXmlFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.security; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; - -import java.io.FileInputStream; -import java.io.InputStream; -import java.io.Reader; - -public class SafeXmlFactory { - public static XMLInputFactory factory = XMLInputFactory.newInstance(); - - - public static XMLStreamReader createSafeXmlTextReader(InputStream stream) throws Exception { - XMLStreamReader xsr = factory.createXMLStreamReader(stream); - return xsr; - - } - - - public static XMLStreamReader createSafeXmlTextReader(String url) throws Exception { - FileInputStream fis = new FileInputStream(url); - XMLStreamReader xtr = factory.createXMLStreamReader(url, fis); - return xtr; - } - - public static XMLStreamReader createSafeXmlTextReader(XMLStreamReader reader) throws Exception { - - XMLStreamReader xmlr = - factory.createXMLStreamReader((Reader) reader); - return xmlr; - - - } - - - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/security/SafeXmlSchema.java b/src/main/java/microsoft/exchange/webservices/data/security/SafeXmlSchema.java deleted file mode 100644 index eb4d80bdd..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/security/SafeXmlSchema.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.security; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.validation.Schema; -import javax.xml.validation.Validator; -import javax.xml.validation.ValidatorHandler; - -import java.io.InputStream; - -/** - * XmlSchema with protection against DTD parsing in read overloads - */ -public class SafeXmlSchema extends Schema { - - @Override - public Validator newValidator() { - // TODO Auto-generated method stub - return null; - } - - @Override - public ValidatorHandler newValidatorHandler() { - // TODO Auto-generated method stub - return null; - } - - /** - * Reads an XML Schema from the supplied stream. - * - * @param stream The supplied data stream. - * @return The XmlSchema object representing the XML Schema. - * @throws javax.xml.stream.XMLStreamException - */ - public static Schema read(final InputStream stream) throws XMLStreamException { - final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - return (Schema) inputFactory.createXMLEventReader(stream); - } - - /** - * Reads an XML Schema from the supplied TextReader. - * - * @param reader The TextReader containing the XML Schema to read - * @return The XmlSchema object representing the XML Schema. - * @throws javax.xml.stream.XMLStreamException - */ - - public static Schema read(XMLStreamReader reader) throws XMLStreamException { - final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - return (Schema) inputFactory.createXMLEventReader(reader); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/security/XmlNameTable.java b/src/main/java/microsoft/exchange/webservices/data/security/XmlNameTable.java deleted file mode 100644 index f4ee0d988..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/security/XmlNameTable.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.security; - -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentNullException; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentOutOfRangeException; - -/** - * Table of atomized String objects. - */ -public abstract class XmlNameTable { - - /** - * Initializes a new instance of the XmlNameTable class. - */ - protected XmlNameTable() { - } - - /** - * When overridden in a derived class, atomizes the specified String and - * adds it to the XmlNameTable. - * - * @param array : The name to add. - * @return The new atomized String or the existing one if it already exists. - * @throws ArgumentNullException array is null. - */ - public abstract String Add(String array); - - /** - * Reads an XML Schema from the supplied stream. - * - * @param array The character array containing the name to add. - * @param offset Zero-based index into the array specifying the first character - * of the name. - * @param length The number of characters in the name. - * @return The new atomized String or the existing one if it already exists. - * If length is zero, String.Empty is returned - * @throws ArgumentOutOfRangeException 0 > offset -or- offset >= array.Length -or- length > - * array.Length The above conditions do not cause an exception - * to be thrown if length =0. - * @throws ArgumentOutOfRangeException length < 0. - */ - public abstract String Add(char[] array, int offset, int length); - - /** - * When overridden in a derived class, gets the atomized String containing - * the same value as the specified String. - * - * @param array The name to look up. - * @return The atomized String or null if the String has not already been - * atomized. - * @throws ArgumentNullException : array is null. - */ - public abstract String Get(String array); - - /** - * When overridden in a derived class, gets the atomized String containing - * the same characters as the specified range of characters in the given - * array. - * - * @param array The character array containing the name to add. - * @param offset Zero-based index into the array specifying the first character - * of the name. - * @param length The number of characters in the name. - * @return The atomized String or null if the String has not already been - * atomized. If length is zero, String.Empty is returned - * @throws ArgumentOutOfRangeException 0 > offset -or- offset >= array.Length -or- length > - * array.Length The above conditions do not cause an exception - * to be thrown if length =0. - * @throws ArgumentOutOfRangeException length < 0. - */ - public abstract String Get(char[] array, int offset, int length); - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/security/XmlNodeType.java b/src/main/java/microsoft/exchange/webservices/data/security/XmlNodeType.java deleted file mode 100644 index 83b6179ee..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/security/XmlNodeType.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.security; - -import javax.xml.stream.XMLStreamConstants; - -/** - * The Class XmlNodeType. - */ -public class XmlNodeType implements XMLStreamConstants { - - /** - * The node type. - */ - public int nodeType; - - /** - * Instantiates a new Xml node type. - * - * @param nodeType The node type. - */ - public XmlNodeType(int nodeType) { - this.nodeType = nodeType; - } - - /** - * Returns a string representation of the object. In general, the - * toString method returns a string that "textually represents" - * this object. The result should be a concise but informative - * representation that is easy for a person to read. It is recommended that - * all subclasses override this method. - *

- * The toString method for class Object returns a - * string consisting of the name of the class of which the object is an - * instance, the at-sign character `@', and the unsigned - * hexadecimal representation of the hash code of the object. In other - * words, this method returns a string equal to the value of:

- *

- *

-   * getClass().getName() + '@' + Integer.toHexString(hashCode())
-   * 
- *

- *

- * - * @return a string representation of the object. - */ - @Override - public String toString() { - return getString(nodeType); - } - - /** - * Sets the node type. - * - * @param nodeType the new node type - */ - public void setNodeType(int nodeType) { - this.nodeType = nodeType; - } - - /** - * Gets the node type. - * - * @return the node type - */ - public int getNodeType() { - return nodeType; - } - - /** - * Gets the string. - * - * @param nodeType the node type - * @return the string - */ - public static String getString(int nodeType) { - switch (nodeType) { - case XMLStreamConstants.ATTRIBUTE: - return "ATTRIBUTE"; - case XMLStreamConstants.CDATA: - return "CDATA"; - case XMLStreamConstants.CHARACTERS: - return "CHARACTERS"; - case XMLStreamConstants.COMMENT: - return "COMMENT"; - case XMLStreamConstants.DTD: - return "DTD"; - case XMLStreamConstants.END_DOCUMENT: - return "END_DOCUMENT"; - case XMLStreamConstants.END_ELEMENT: - return "END_ELEMENT"; - case XMLStreamConstants.ENTITY_DECLARATION: - return "ENTITY_DECLARATION"; - case XMLStreamConstants.ENTITY_REFERENCE: - return "ENTITY_REFERENCE"; - case XMLStreamConstants.NAMESPACE: - return "NAMESPACE"; - case XMLStreamConstants.NOTATION_DECLARATION: - return "NOTATION_DECLARATION"; - case XMLStreamConstants.PROCESSING_INSTRUCTION: - return "PROCESSING_INSTRUCTION"; - case XMLStreamConstants.SPACE: - return "SPACE"; - case XMLStreamConstants.START_DOCUMENT: - return "START_DOCUMENT"; - case XMLStreamConstants.START_ELEMENT: - return "START_ELEMENT"; - case 0: - return "NONE"; - default: - return "UNKNOWN"; - } - } - - /** - * Indicates whether some other object is "equal to" this one. - *

- * The equals method implements an equivalence relation on - * non-null object references: - *

    - *
  • It is reflexive: for any non-null reference value - * x, x.equals(x) should return true. - *
  • It is symmetric: for any non-null reference values - * x and y, x.equals(y) should return - * true if and only if y.equals(x) returns - * true. - *
  • It is transitive: for any non-null reference values - * x, y, and z, if - * x.equals(y) returns true and - * y.equals(z) returns true, then - * x.equals(z) should return true. - *
  • It is consistent: for any non-null reference values - * x and y, multiple invocations of - * x.equals(y) consistently return true or - * consistently return false, provided no information used in - * equals comparisons on the objects is modified. - *
  • For any non-null reference value x, - * x.equals(null) should return false. - *
- *

- * The equals method for class Object implements the - * most discriminating possible equivalence relation on objects; that is, - * for any non-null reference values x and y, this - * method returns true if and only if x and - * y refer to the same object (x == y has the - * value true). - *

- * Note that it is generally necessary to override the hashCode - * method whenever this method is overridden, so as to maintain the general - * contract for the hashCode method, which states that equal - * objects must have equal hash codes. - * - * @param obj the reference object with which to compare. - * @return if this object is the same as the obj argument; otherwise. - * @see #hashCode() - * @see java.util.Hashtable - */ - @Override - public boolean equals(Object obj) { - - if (this == obj) { - return true; - } - if (obj instanceof XmlNodeType) { - XmlNodeType other = (XmlNodeType) obj; - return this.nodeType == other.nodeType; - } else { - return super.equals(obj); - } - } - - /** - * Returns a hash code value for the object. This method is supported for - * the benefit of hashtables such as those provided by - * java.util.Hashtable. - *

- * The general contract of hashCode is: - *

    - *
  • Whenever it is invoked on the same object more than once during an - * execution of a Java application, the hashCode method must - * consistently return the same integer, provided no information used in - * equals comparisons on the object is modified. This integer need - * not remain consistent from one execution of an application to another - * execution of the same application. - *
  • If two objects are equal according to the equals(Object) - * method, then calling the hashCode method on each of the two - * objects must produce the same integer result. - *
  • It is not required that if two objects are unequal according - * to the {@link Object#equals(Object)} method, then - * calling the hashCode method on each of the two objects must - * produce distinct integer results. However, the programmer should be aware - * that producing distinct integer results for unequal objects may improve - * the performance of hashtables. - *
- *

- * As much as is reasonably practical, the hashCode method defined by class - * Object does return distinct integers for distinct objects. (This - * is typically implemented by converting the internal address of the object - * into an integer, but this implementation technique is not required by the - * JavaTM programming language.) - * - * @return a hash code value for this object. - * @see Object#equals(Object) - * @see java.util.Hashtable - */ - @Override - public int hashCode() { - return this.nodeType; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/sync/Change.java b/src/main/java/microsoft/exchange/webservices/data/sync/Change.java deleted file mode 100644 index bbe0f4e24..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/sync/Change.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.sync; - -import microsoft.exchange.webservices.data.attribute.EditorBrowsable; -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.enumeration.sync.ChangeType; -import microsoft.exchange.webservices.data.core.enumeration.attribute.EditorBrowsableState; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.ServiceId; - -/** - * Represents a change as returned by a synchronization operation. - */ -@EditorBrowsable(state = EditorBrowsableState.Never) -public abstract class Change { - - /** - * The type of change. - */ - private ChangeType changeType; - - /** - * The service object the change applies to. - */ - private ServiceObject serviceObject; - - /** - * The Id of the service object the change applies to. - */ - private ServiceId id; - - /** - * Initializes a new instance of Change. - */ - protected Change() { - } - - /** - * Initializes a new instance of Change. - * - * @return the service id - */ - public abstract ServiceId createId(); - - /** - * Gets the type of the change. - * - * @return the change type - */ - public ChangeType getChangeType() { - return this.changeType; - } - - /** - * sets the type of the change. - * - * @param changeType the new change type - */ - public void setChangeType(ChangeType changeType) { - this.changeType = changeType; - } - - /** - * Gets the service object the change applies to. - * - * @return the service object - */ - public ServiceObject getServiceObject() { - return this.serviceObject; - } - - /** - * Sets the service object. - * - * @param serviceObject the new service object - */ - public void setServiceObject(ServiceObject serviceObject) { - this.serviceObject = serviceObject; - } - - /** - * Gets the Id of the service object the change applies to. - * - * @return the id - * @throws ServiceLocalException the service local exception - */ - public ServiceId getId() throws ServiceLocalException { - return this.getServiceObject() != null ? this.getServiceObject() - .getId() : this.id; - } - - /** - * Sets the id. - * - * @param id the new id - */ - public void setId(ServiceId id) { - this.id = id; - } -} diff --git a/src/main/java/microsoft/exchange/webservices/data/sync/ChangeCollection.java b/src/main/java/microsoft/exchange/webservices/data/sync/ChangeCollection.java deleted file mode 100644 index db23a0e5b..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/sync/ChangeCollection.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.sync; - -import microsoft.exchange.webservices.data.core.EwsUtilities; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Represents a collection of changes as returned by a synchronization - * operation. - * - * @param the generic type - */ -public final class ChangeCollection implements - Iterable { - - /** - * The changes. - */ - private List changes = new ArrayList(); - - /** - * The sync state. - */ - private String syncState; - - /** - * The more changes available. - */ - private boolean moreChangesAvailable; - - /** - * Initializes a new instance of the class. - */ - public ChangeCollection() { - } - - /** - * Adds the specified change. - * - * @param change the change - */ - public void add(TChange change) { - EwsUtilities.ewsAssert(change != null, "ChangeList.Add", "change is null"); - this.changes.add(change); - } - - /** - * Gets the number of changes in the collection. - * - * @return the count - */ - public int getCount() { - return this.changes.size(); - } - - /** - * Gets an individual change from the change collection. - * - * @param index the index - * @return An single change - */ - public TChange getChangeAtIndex(int index) { - if (index < 0 || index >= this.getCount()) { - throw new IndexOutOfBoundsException( - String.format("index %d is out of range [0..%d[.", index, this.getCount())); - } - return this.changes.get(index); - } - - /** - * Gets the SyncState blob returned by a synchronization operation. - * - * @return the sync state - */ - public String getSyncState() { - return this.syncState; - } - - /** - * Sets the sync state. - * - * @param syncState the new sync state - */ - public void setSyncState(String syncState) { - this.syncState = syncState; - } - - /** - * Gets the SyncState blob returned by a synchronization operation. - * - * @return the more changes available - */ - public boolean getMoreChangesAvailable() { - return this.moreChangesAvailable; - } - - /** - * Sets the more changes available. - * - * @param moreChangesAvailable the new more changes available - */ - public void setMoreChangesAvailable(boolean moreChangesAvailable) { - this.moreChangesAvailable = moreChangesAvailable; - } - - /** - * Returns an iterator over a set of elements of type T. - * - * @return an Iterator. - */ - @Override - public Iterator iterator() { - return this.changes.iterator(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/sync/FolderChange.java b/src/main/java/microsoft/exchange/webservices/data/sync/FolderChange.java deleted file mode 100644 index 689c559b0..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/sync/FolderChange.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.sync; - -import microsoft.exchange.webservices.data.core.service.folder.Folder; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.FolderId; -import microsoft.exchange.webservices.data.property.complex.ServiceId; - -/** - * Represents a change on a folder as returned by a synchronization operation. - */ -public final class FolderChange extends Change { - /** - * Initializes a new instance of FolderChange. - */ - public FolderChange() { - super(); - } - - /** - * Creates a FolderId instance. - * - * @return A FolderId. - */ - @Override public ServiceId createId() { - return new FolderId(); - } - - /** - * Gets the folder the change applies to. Folder is null when ChangeType - * is equal to ChangeType.Delete. In that case, use the FolderId property to - * retrieve the Id of the folder that was deleted. - * - * @return the folder - */ - public Folder getFolder() { - return (Folder) this.getServiceObject(); - } - - /** - * Gets the folder the change applies to. Folder is null when ChangeType - * is equal to ChangeType.Delete. In that case, use the FolderId property to - * retrieve the Id of the folder that was deleted. - * - * @return the folder id - * @throws ServiceLocalException the service local exception - */ - public FolderId getFolderId() throws ServiceLocalException { - return (FolderId) this.getId(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/sync/ItemChange.java b/src/main/java/microsoft/exchange/webservices/data/sync/ItemChange.java deleted file mode 100644 index f8866eb61..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/sync/ItemChange.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.sync; - -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceLocalException; -import microsoft.exchange.webservices.data.property.complex.ItemId; -import microsoft.exchange.webservices.data.property.complex.ServiceId; - -/** - * Represents a change on an item as returned by a synchronization operation. - */ -public final class ItemChange extends Change { - - /** - * The is read. - */ - private boolean isRead; - - /** - * Initializes a new instance of ItemChange. - */ - public ItemChange() { - super(); - } - - /** - * Creates an ItemId instance. - * - * @return A ItemId. - */ - @Override public ServiceId createId() { - return new ItemId(); - } - - /** - * Gets the item the change applies to. Item is null when ChangeType is - * equal to either ChangeType.Delete or ChangeType.ReadFlagChange. In those - * cases, use the ItemId property to retrieve the Id of the item that was - * deleted or whose IsRead property changed. - * - * @return the item - */ - public Item getItem() { - return (Item) this.getServiceObject(); - } - - /** - * Gets the IsRead property for the item that the change applies to. - * IsRead is only valid when ChangeType is equal to - * ChangeType.ReadFlagChange. - * - * @return the checks if is read - */ - public boolean getIsRead() { - return this.isRead; - } - - /** - * Sets the checks if is read. - * - * @param isRead the new checks if is read - */ - public void setIsRead(boolean isRead) { - this.isRead = isRead; - } - - /** - * Gets the Id of the item the change applies to. - * - * @return the item id - * @throws ServiceLocalException the service local exception - */ - public ItemId getItemId() throws ServiceLocalException { - return (ItemId) this.getId(); - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/util/DateTimeUtils.java b/src/main/java/microsoft/exchange/webservices/data/util/DateTimeUtils.java deleted file mode 100644 index 0a30a3f02..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/util/DateTimeUtils.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.util; - -import org.apache.commons.lang3.StringUtils; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; - -import java.util.Date; - -public final class DateTimeUtils { - - private static final DateTimeFormatter[] DATE_TIME_FORMATS = createDateTimeFormats(); - private static final DateTimeFormatter[] DATE_FORMATS = createDateFormats(); - - - private DateTimeUtils() { - throw new UnsupportedOperationException(); - } - - - /** - * Converts a date time string to local date time. - * - * Note: this method also allows dates without times, in which case the time will be 00:00:00 in the - * supplied timezone. UTC timezone will be assumed if no timezone is supplied. - * - * @param value The string value to parse. - * @return The parsed {@link Date}. - * - * @throws java.lang.IllegalArgumentException If string can not be parsed. - */ - public static Date convertDateTimeStringToDate(String value) { - return parseInternal(value, false); - } - - /** - * Converts a date string to local date time. - * - * UTC timezone will be assumed if no timezone is supplied. - * - * @param value The string value to parse. - * @return The parsed {@link Date}. - * - * @throws java.lang.IllegalArgumentException If string can not be parsed. - */ - public static Date convertDateStringToDate(String value) { - return parseInternal(value, true); - } - - - private static Date parseInternal(String value, boolean dateOnly) { - String originalValue = value; - - if (StringUtils.isEmpty(value)) { - return null; - } else { - if (value.endsWith("z")) { - // This seems to be an edge case. Let's uppercase the Z to be sure. - value = value.substring(0, value.length() - 1) + "Z"; - } - - final DateTimeFormatter[] formats = dateOnly ? DATE_FORMATS : DATE_TIME_FORMATS; - for (final DateTimeFormatter format : formats) { - try { - return format.parseDateTime(value).toDate(); - } catch (IllegalArgumentException e) { - // Ignore and try the next pattern. - } - } - } - - throw new IllegalArgumentException( - String.format("Date String %s not in valid UTC/local format", originalValue)); - } - - private static DateTimeFormatter[] createDateTimeFormats() { - return new DateTimeFormatter[] { - DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZ").withZoneUTC(), - DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ").withZoneUTC(), - DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSZ").withZoneUTC(), - DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss").withZoneUTC(), - DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS").withZoneUTC(), - DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSSSSS").withZoneUTC(), - DateTimeFormat.forPattern("yyyy-MM-ddZ").withZoneUTC(), - DateTimeFormat.forPattern("yyyy-MM-dd").withZoneUTC() - }; - } - - private static DateTimeFormatter[] createDateFormats() { - return new DateTimeFormatter[] { - DateTimeFormat.forPattern("yyyy-MM-ddZ").withZoneUTC(), - DateTimeFormat.forPattern("yyyy-MM-dd").withZoneUTC() - }; - } - -} diff --git a/src/main/java/microsoft/exchange/webservices/data/util/TimeZoneUtils.java b/src/main/java/microsoft/exchange/webservices/data/util/TimeZoneUtils.java deleted file mode 100644 index f0ab97d49..000000000 --- a/src/main/java/microsoft/exchange/webservices/data/util/TimeZoneUtils.java +++ /dev/null @@ -1,630 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.util; - -import java.util.HashMap; -import java.util.Map; -import java.util.TimeZone; - -/** - * Miscellany timezone functions - */ -public final class TimeZoneUtils { - - // A map of olson name > Microsoft Name. - private static final Map olsonTimeZoneToMs = createOlsonTimeZoneToMsMap(); - - - private TimeZoneUtils() { - throw new UnsupportedOperationException(); - } - - - /** - * Convert Olson TimeZone to Microsoft TimeZone Generated using Unicode CLDR project Example: - * https://gist.github.com/scottmac/655675e9b4d4913c539c - * - * @param timeZone java timezone (Olson) - * @return a microsoft timezone identifier (ala Eastern Standard Time) - */ - public static String getMicrosoftTimeZoneName(final TimeZone timeZone) { - if (timeZone == null) { - throw new IllegalArgumentException("Parameter \"timeZone\" must be defined"); - } - - final String id = timeZone.getID(); - return olsonTimeZoneToMs.get(id); - } - - - public static Map createOlsonTimeZoneToMsMap() { - final Map map = new HashMap(); - map.put("Africa/Abidjan", "Greenwich Standard Time"); - map.put("Africa/Accra", "Greenwich Standard Time"); - map.put("Africa/Addis_Ababa", "E. Africa Standard Time"); - map.put("Africa/Algiers", "W. Central Africa Standard Time"); - map.put("Africa/Asmara", "E. Africa Standard Time"); - map.put("Africa/Asmera", "E. Africa Standard Time"); - map.put("Africa/Bamako", "Greenwich Standard Time"); - map.put("Africa/Bangui", "W. Central Africa Standard Time"); - map.put("Africa/Banjul", "Greenwich Standard Time"); - map.put("Africa/Bissau", "Greenwich Standard Time"); - map.put("Africa/Blantyre", "South Africa Standard Time"); - map.put("Africa/Brazzaville", "W. Central Africa Standard Time"); - map.put("Africa/Bujumbura", "South Africa Standard Time"); - map.put("Africa/Cairo", "Egypt Standard Time"); - map.put("Africa/Casablanca", "Morocco Standard Time"); - map.put("Africa/Ceuta", "Romance Standard Time"); - map.put("Africa/Conakry", "Greenwich Standard Time"); - map.put("Africa/Dakar", "Greenwich Standard Time"); - map.put("Africa/Dar_es_Salaam", "E. Africa Standard Time"); - map.put("Africa/Djibouti", "E. Africa Standard Time"); - map.put("Africa/Douala", "W. Central Africa Standard Time"); - map.put("Africa/El_Aaiun", "Morocco Standard Time"); - map.put("Africa/Freetown", "Greenwich Standard Time"); - map.put("Africa/Gaborone", "South Africa Standard Time"); - map.put("Africa/Harare", "South Africa Standard Time"); - map.put("Africa/Johannesburg", "South Africa Standard Time"); - map.put("Africa/Juba", "E. Africa Standard Time"); - map.put("Africa/Kampala", "E. Africa Standard Time"); - map.put("Africa/Khartoum", "E. Africa Standard Time"); - map.put("Africa/Kigali", "South Africa Standard Time"); - map.put("Africa/Kinshasa", "W. Central Africa Standard Time"); - map.put("Africa/Lagos", "W. Central Africa Standard Time"); - map.put("Africa/Libreville", "W. Central Africa Standard Time"); - map.put("Africa/Lome", "Greenwich Standard Time"); - map.put("Africa/Luanda", "W. Central Africa Standard Time"); - map.put("Africa/Lubumbashi", "South Africa Standard Time"); - map.put("Africa/Lusaka", "South Africa Standard Time"); - map.put("Africa/Malabo", "W. Central Africa Standard Time"); - map.put("Africa/Maputo", "South Africa Standard Time"); - map.put("Africa/Maseru", "South Africa Standard Time"); - map.put("Africa/Mbabane", "South Africa Standard Time"); - map.put("Africa/Mogadishu", "E. Africa Standard Time"); - map.put("Africa/Monrovia", "Greenwich Standard Time"); - map.put("Africa/Nairobi", "E. Africa Standard Time"); - map.put("Africa/Ndjamena", "W. Central Africa Standard Time"); - map.put("Africa/Niamey", "W. Central Africa Standard Time"); - map.put("Africa/Nouakchott", "Greenwich Standard Time"); - map.put("Africa/Ouagadougou", "Greenwich Standard Time"); - map.put("Africa/Porto-Novo", "W. Central Africa Standard Time"); - map.put("Africa/Sao_Tome", "Greenwich Standard Time"); - map.put("Africa/Timbuktu", "Greenwich Standard Time"); - map.put("Africa/Tripoli", "Libya Standard Time"); - map.put("Africa/Tunis", "W. Central Africa Standard Time"); - map.put("Africa/Windhoek", "Namibia Standard Time"); - map.put("America/Anchorage", "Alaskan Standard Time"); - map.put("America/Anguilla", "SA Western Standard Time"); - map.put("America/Antigua", "SA Western Standard Time"); - map.put("America/Araguaina", "SA Eastern Standard Time"); - map.put("America/Argentina/Buenos_Aires", "Argentina Standard Time"); - map.put("America/Argentina/Catamarca", "Argentina Standard Time"); - map.put("America/Argentina/ComodRivadavia", "Argentina Standard Time"); - map.put("America/Argentina/Cordoba", "Argentina Standard Time"); - map.put("America/Argentina/Jujuy", "Argentina Standard Time"); - map.put("America/Argentina/La_Rioja", "Argentina Standard Time"); - map.put("America/Argentina/Mendoza", "Argentina Standard Time"); - map.put("America/Argentina/Rio_Gallegos", "Argentina Standard Time"); - map.put("America/Argentina/Salta", "Argentina Standard Time"); - map.put("America/Argentina/San_Juan", "Argentina Standard Time"); - map.put("America/Argentina/San_Luis", "Argentina Standard Time"); - map.put("America/Argentina/Tucuman", "Argentina Standard Time"); - map.put("America/Argentina/Ushuaia", "Argentina Standard Time"); - map.put("America/Aruba", "SA Western Standard Time"); - map.put("America/Asuncion", "Paraguay Standard Time"); - map.put("America/Atikokan", "SA Pacific Standard Time"); - map.put("America/Bahia", "Bahia Standard Time"); - map.put("America/Bahia_Banderas", "Central Standard Time (Mexico)"); - map.put("America/Barbados", "SA Western Standard Time"); - map.put("America/Belem", "SA Eastern Standard Time"); - map.put("America/Belize", "Central America Standard Time"); - map.put("America/Blanc-Sablon", "SA Western Standard Time"); - map.put("America/Boa_Vista", "SA Western Standard Time"); - map.put("America/Bogota", "SA Pacific Standard Time"); - map.put("America/Boise", "Mountain Standard Time"); - map.put("America/Buenos_Aires", "Argentina Standard Time"); - map.put("America/Cambridge_Bay", "Mountain Standard Time"); - map.put("America/Campo_Grande", "Central Brazilian Standard Time"); - map.put("America/Cancun", "Eastern Standard Time (Mexico)"); - map.put("America/Caracas", "Venezuela Standard Time"); - map.put("America/Catamarca", "Argentina Standard Time"); - map.put("America/Cayenne", "SA Eastern Standard Time"); - map.put("America/Cayman", "SA Pacific Standard Time"); - map.put("America/Chicago", "Central Standard Time"); - map.put("America/Chihuahua", "Mountain Standard Time (Mexico)"); - map.put("America/Coral_Harbour", "SA Pacific Standard Time"); - map.put("America/Cordoba", "Argentina Standard Time"); - map.put("America/Costa_Rica", "Central America Standard Time"); - map.put("America/Creston", "US Mountain Standard Time"); - map.put("America/Cuiaba", "Central Brazilian Standard Time"); - map.put("America/Curacao", "SA Western Standard Time"); - map.put("America/Danmarkshavn", "UTC"); - map.put("America/Dawson", "Pacific Standard Time"); - map.put("America/Dawson_Creek", "US Mountain Standard Time"); - map.put("America/Denver", "Mountain Standard Time"); - map.put("America/Detroit", "Eastern Standard Time"); - map.put("America/Dominica", "SA Western Standard Time"); - map.put("America/Edmonton", "Mountain Standard Time"); - map.put("America/Eirunepe", "SA Pacific Standard Time"); - map.put("America/El_Salvador", "Central America Standard Time"); - map.put("America/Ensenada", "Pacific Standard Time"); - map.put("America/Fort_Nelson", "Mountain Standard Time"); - map.put("America/Fort_Wayne", "US Eastern Standard Time"); - map.put("America/Fortaleza", "SA Eastern Standard Time"); - map.put("America/Glace_Bay", "Atlantic Standard Time"); - map.put("America/Godthab", "Greenland Standard Time"); - map.put("America/Goose_Bay", "Atlantic Standard Time"); - map.put("America/Grand_Turk", "SA Western Standard Time"); - map.put("America/Grenada", "SA Western Standard Time"); - map.put("America/Guadeloupe", "SA Western Standard Time"); - map.put("America/Guatemala", "Central America Standard Time"); - map.put("America/Guayaquil", "SA Pacific Standard Time"); - map.put("America/Guyana", "SA Western Standard Time"); - map.put("America/Halifax", "Atlantic Standard Time"); - map.put("America/Havana", "Eastern Standard Time"); - map.put("America/Hermosillo", "US Mountain Standard Time"); - map.put("America/Indiana/Indianapolis", "US Eastern Standard Time"); - map.put("America/Indiana/Knox", "Central Standard Time"); - map.put("America/Indiana/Marengo", "US Eastern Standard Time"); - map.put("America/Indiana/Petersburg", "Eastern Standard Time"); - map.put("America/Indiana/Tell_City", "Central Standard Time"); - map.put("America/Indiana/Vevay", "US Eastern Standard Time"); - map.put("America/Indiana/Vincennes", "Eastern Standard Time"); - map.put("America/Indiana/Winamac", "Eastern Standard Time"); - map.put("America/Indianapolis", "US Eastern Standard Time"); - map.put("America/Inuvik", "Mountain Standard Time"); - map.put("America/Iqaluit", "Eastern Standard Time"); - map.put("America/Jamaica", "SA Pacific Standard Time"); - map.put("America/Jujuy", "Argentina Standard Time"); - map.put("America/Juneau", "Alaskan Standard Time"); - map.put("America/Kentucky/Louisville", "Eastern Standard Time"); - map.put("America/Kentucky/Monticello", "Eastern Standard Time"); - map.put("America/Knox_IN", "Central Standard Time"); - map.put("America/Kralendijk", "SA Western Standard Time"); - map.put("America/La_Paz", "SA Western Standard Time"); - map.put("America/Lima", "SA Pacific Standard Time"); - map.put("America/Los_Angeles", "Pacific Standard Time"); - map.put("America/Louisville", "Eastern Standard Time"); - map.put("America/Lower_Princes", "SA Western Standard Time"); - map.put("America/Maceio", "SA Eastern Standard Time"); - map.put("America/Managua", "Central America Standard Time"); - map.put("America/Manaus", "SA Western Standard Time"); - map.put("America/Marigot", "SA Western Standard Time"); - map.put("America/Martinique", "SA Western Standard Time"); - map.put("America/Matamoros", "Central Standard Time"); - map.put("America/Mazatlan", "Mountain Standard Time (Mexico)"); - map.put("America/Mendoza", "Argentina Standard Time"); - map.put("America/Menominee", "Central Standard Time"); - map.put("America/Merida", "Central Standard Time (Mexico)"); - map.put("America/Mexico_City", "Central Standard Time (Mexico)"); - map.put("America/Moncton", "Atlantic Standard Time"); - map.put("America/Monterrey", "Central Standard Time (Mexico)"); - map.put("America/Montevideo", "Montevideo Standard Time"); - map.put("America/Montreal", "Eastern Standard Time"); - map.put("America/Montserrat", "SA Western Standard Time"); - map.put("America/Nassau", "Eastern Standard Time"); - map.put("America/New_York", "Eastern Standard Time"); - map.put("America/Nipigon", "Eastern Standard Time"); - map.put("America/Nome", "Alaskan Standard Time"); - map.put("America/Noronha", "UTC-02"); - map.put("America/North_Dakota/Beulah", "Central Standard Time"); - map.put("America/North_Dakota/Center", "Central Standard Time"); - map.put("America/North_Dakota/New_Salem", "Central Standard Time"); - map.put("America/Ojinaga", "Mountain Standard Time"); - map.put("America/Panama", "SA Pacific Standard Time"); - map.put("America/Pangnirtung", "Eastern Standard Time"); - map.put("America/Paramaribo", "SA Eastern Standard Time"); - map.put("America/Phoenix", "US Mountain Standard Time"); - map.put("America/Port-au-Prince", "Eastern Standard Time"); - map.put("America/Port_of_Spain", "SA Western Standard Time"); - map.put("America/Porto_Acre", "SA Pacific Standard Time"); - map.put("America/Porto_Velho", "SA Western Standard Time"); - map.put("America/Puerto_Rico", "SA Western Standard Time"); - map.put("America/Rainy_River", "Central Standard Time"); - map.put("America/Rankin_Inlet", "Central Standard Time"); - map.put("America/Recife", "SA Eastern Standard Time"); - map.put("America/Regina", "Canada Central Standard Time"); - map.put("America/Resolute", "Central Standard Time"); - map.put("America/Rio_Branco", "SA Pacific Standard Time"); - map.put("America/Rosario", "Argentina Standard Time"); - map.put("America/Santa_Isabel", "Pacific Standard Time (Mexico)"); - map.put("America/Santarem", "SA Eastern Standard Time"); - map.put("America/Santiago", "Pacific SA Standard Time"); - map.put("America/Santo_Domingo", "SA Western Standard Time"); - map.put("America/Sao_Paulo", "E. South America Standard Time"); - map.put("America/Scoresbysund", "Azores Standard Time"); - map.put("America/Shiprock", "Mountain Standard Time"); - map.put("America/Sitka", "Alaskan Standard Time"); - map.put("America/St_Barthelemy", "SA Western Standard Time"); - map.put("America/St_Johns", "Newfoundland Standard Time"); - map.put("America/St_Kitts", "SA Western Standard Time"); - map.put("America/St_Lucia", "SA Western Standard Time"); - map.put("America/St_Thomas", "SA Western Standard Time"); - map.put("America/St_Vincent", "SA Western Standard Time"); - map.put("America/Swift_Current", "Canada Central Standard Time"); - map.put("America/Tegucigalpa", "Central America Standard Time"); - map.put("America/Thule", "Atlantic Standard Time"); - map.put("America/Thunder_Bay", "Eastern Standard Time"); - map.put("America/Tijuana", "Pacific Standard Time"); - map.put("America/Toronto", "Eastern Standard Time"); - map.put("America/Tortola", "SA Western Standard Time"); - map.put("America/Vancouver", "Pacific Standard Time"); - map.put("America/Virgin", "SA Western Standard Time"); - map.put("America/Whitehorse", "Pacific Standard Time"); - map.put("America/Winnipeg", "Central Standard Time"); - map.put("America/Yakutat", "Alaskan Standard Time"); - map.put("America/Yellowknife", "Mountain Standard Time"); - map.put("Antarctica/Casey", "W. Australia Standard Time"); - map.put("Antarctica/Davis", "SE Asia Standard Time"); - map.put("Antarctica/DumontDUrville", "West Pacific Standard Time"); - map.put("Antarctica/Macquarie", "Central Pacific Standard Time"); - map.put("Antarctica/Mawson", "West Asia Standard Time"); - map.put("Antarctica/McMurdo", "New Zealand Standard Time"); - map.put("Antarctica/Palmer", "Pacific SA Standard Time"); - map.put("Antarctica/Rothera", "SA Eastern Standard Time"); - map.put("Antarctica/South_Pole", "New Zealand Standard Time"); - map.put("Antarctica/Syowa", "E. Africa Standard Time"); - map.put("Antarctica/Vostok", "Central Asia Standard Time"); - map.put("Arctic/Longyearbyen", "W. Europe Standard Time"); - map.put("Asia/Aden", "Arab Standard Time"); - map.put("Asia/Almaty", "Central Asia Standard Time"); - map.put("Asia/Amman", "Jordan Standard Time"); - map.put("Asia/Anadyr", "Russia Time Zone 11"); - map.put("Asia/Aqtau", "West Asia Standard Time"); - map.put("Asia/Aqtobe", "West Asia Standard Time"); - map.put("Asia/Ashgabat", "West Asia Standard Time"); - map.put("Asia/Ashkhabad", "West Asia Standard Time"); - map.put("Asia/Baghdad", "Arabic Standard Time"); - map.put("Asia/Bahrain", "Arab Standard Time"); - map.put("Asia/Baku", "Azerbaijan Standard Time"); - map.put("Asia/Bangkok", "SE Asia Standard Time"); - map.put("Asia/Beirut", "Middle East Standard Time"); - map.put("Asia/Bishkek", "Central Asia Standard Time"); - map.put("Asia/Brunei", "Singapore Standard Time"); - map.put("Asia/Calcutta", "India Standard Time"); - map.put("Asia/Chita", "North Asia East Standard Time"); - map.put("Asia/Choibalsan", "Ulaanbaatar Standard Time"); - map.put("Asia/Chongqing", "China Standard Time"); - map.put("Asia/Chungking", "China Standard Time"); - map.put("Asia/Colombo", "Sri Lanka Standard Time"); - map.put("Asia/Dacca", "Bangladesh Standard Time"); - map.put("Asia/Damascus", "Syria Standard Time"); - map.put("Asia/Dhaka", "Bangladesh Standard Time"); - map.put("Asia/Dili", "Tokyo Standard Time"); - map.put("Asia/Dubai", "Arabian Standard Time"); - map.put("Asia/Dushanbe", "West Asia Standard Time"); - map.put("Asia/Harbin", "China Standard Time"); - map.put("Asia/Ho_Chi_Minh", "SE Asia Standard Time"); - map.put("Asia/Hong_Kong", "China Standard Time"); - map.put("Asia/Hovd", "SE Asia Standard Time"); - map.put("Asia/Irkutsk", "North Asia East Standard Time"); - map.put("Asia/Istanbul", "Turkey Standard Time"); - map.put("Asia/Jakarta", "SE Asia Standard Time"); - map.put("Asia/Jayapura", "Tokyo Standard Time"); - map.put("Asia/Jerusalem", "Israel Standard Time"); - map.put("Asia/Kabul", "Afghanistan Standard Time"); - map.put("Asia/Kamchatka", "Russia Time Zone 11"); - map.put("Asia/Karachi", "Pakistan Standard Time"); - map.put("Asia/Kashgar", "Central Asia Standard Time"); - map.put("Asia/Kathmandu", "Nepal Standard Time"); - map.put("Asia/Katmandu", "Nepal Standard Time"); - map.put("Asia/Khandyga", "Yakutsk Standard Time"); - map.put("Asia/Kolkata", "India Standard Time"); - map.put("Asia/Krasnoyarsk", "North Asia Standard Time"); - map.put("Asia/Kuala_Lumpur", "Singapore Standard Time"); - map.put("Asia/Kuching", "Singapore Standard Time"); - map.put("Asia/Kuwait", "Arab Standard Time"); - map.put("Asia/Macao", "China Standard Time"); - map.put("Asia/Macau", "China Standard Time"); - map.put("Asia/Magadan", "Magadan Standard Time"); - map.put("Asia/Makassar", "Singapore Standard Time"); - map.put("Asia/Manila", "Singapore Standard Time"); - map.put("Asia/Muscat", "Arabian Standard Time"); - map.put("Asia/Nicosia", "GTB Standard Time"); - map.put("Asia/Novokuznetsk", "North Asia Standard Time"); - map.put("Asia/Novosibirsk", "N. Central Asia Standard Time"); - map.put("Asia/Omsk", "N. Central Asia Standard Time"); - map.put("Asia/Oral", "West Asia Standard Time"); - map.put("Asia/Phnom_Penh", "SE Asia Standard Time"); - map.put("Asia/Pontianak", "SE Asia Standard Time"); - map.put("Asia/Pyongyang", "Korea Standard Time"); - map.put("Asia/Qatar", "Arab Standard Time"); - map.put("Asia/Qyzylorda", "Central Asia Standard Time"); - map.put("Asia/Rangoon", "Myanmar Standard Time"); - map.put("Asia/Riyadh", "Arab Standard Time"); - map.put("Asia/Saigon", "SE Asia Standard Time"); - map.put("Asia/Sakhalin", "Vladivostok Standard Time"); - map.put("Asia/Samarkand", "West Asia Standard Time"); - map.put("Asia/Seoul", "Korea Standard Time"); - map.put("Asia/Shanghai", "China Standard Time"); - map.put("Asia/Singapore", "Singapore Standard Time"); - map.put("Asia/Srednekolymsk", "Russia Time Zone 10"); - map.put("Asia/Taipei", "Taipei Standard Time"); - map.put("Asia/Tashkent", "West Asia Standard Time"); - map.put("Asia/Tbilisi", "Georgian Standard Time"); - map.put("Asia/Tehran", "Iran Standard Time"); - map.put("Asia/Tel_Aviv", "Israel Standard Time"); - map.put("Asia/Thimbu", "Bangladesh Standard Time"); - map.put("Asia/Thimphu", "Bangladesh Standard Time"); - map.put("Asia/Tokyo", "Tokyo Standard Time"); - map.put("Asia/Ujung_Pandang", "Singapore Standard Time"); - map.put("Asia/Ulaanbaatar", "Ulaanbaatar Standard Time"); - map.put("Asia/Ulan_Bator", "Ulaanbaatar Standard Time"); - map.put("Asia/Urumqi", "Central Asia Standard Time"); - map.put("Asia/Ust-Nera", "Vladivostok Standard Time"); - map.put("Asia/Vientiane", "SE Asia Standard Time"); - map.put("Asia/Vladivostok", "Vladivostok Standard Time"); - map.put("Asia/Yakutsk", "Yakutsk Standard Time"); - map.put("Asia/Yekaterinburg", "Ekaterinburg Standard Time"); - map.put("Asia/Yerevan", "Caucasus Standard Time"); - map.put("Atlantic/Azores", "Azores Standard Time"); - map.put("Atlantic/Bermuda", "Atlantic Standard Time"); - map.put("Atlantic/Canary", "GMT Standard Time"); - map.put("Atlantic/Cape_Verde", "Cape Verde Standard Time"); - map.put("Atlantic/Faeroe", "GMT Standard Time"); - map.put("Atlantic/Faroe", "GMT Standard Time"); - map.put("Atlantic/Jan_Mayen", "W. Europe Standard Time"); - map.put("Atlantic/Madeira", "GMT Standard Time"); - map.put("Atlantic/Reykjavik", "Greenwich Standard Time"); - map.put("Atlantic/South_Georgia", "UTC-02"); - map.put("Atlantic/St_Helena", "Greenwich Standard Time"); - map.put("Atlantic/Stanley", "SA Eastern Standard Time"); - map.put("Australia/ACT", "AUS Eastern Standard Time"); - map.put("Australia/Adelaide", "Cen. Australia Standard Time"); - map.put("Australia/Brisbane", "E. Australia Standard Time"); - map.put("Australia/Broken_Hill", "Cen. Australia Standard Time"); - map.put("Australia/Canberra", "AUS Eastern Standard Time"); - map.put("Australia/Currie", "Tasmania Standard Time"); - map.put("Australia/Darwin", "AUS Central Standard Time"); - map.put("Australia/Hobart", "Tasmania Standard Time"); - map.put("Australia/Lindeman", "E. Australia Standard Time"); - map.put("Australia/Melbourne", "AUS Eastern Standard Time"); - map.put("Australia/NSW", "AUS Eastern Standard Time"); - map.put("Australia/North", "AUS Central Standard Time"); - map.put("Australia/Perth", "W. Australia Standard Time"); - map.put("Australia/Queensland", "E. Australia Standard Time"); - map.put("Australia/South", "Cen. Australia Standard Time"); - map.put("Australia/Sydney", "AUS Eastern Standard Time"); - map.put("Australia/Tasmania", "Tasmania Standard Time"); - map.put("Australia/Victoria", "AUS Eastern Standard Time"); - map.put("Australia/West", "W. Australia Standard Time"); - map.put("Australia/Yancowinna", "Cen. Australia Standard Time"); - map.put("Brazil/Acre", "SA Pacific Standard Time"); - map.put("Brazil/DeNoronha", "UTC-02"); - map.put("Brazil/East", "E. South America Standard Time"); - map.put("Brazil/West", "SA Western Standard Time"); - map.put("CST6CDT", "Central Standard Time"); - map.put("Canada/Atlantic", "Atlantic Standard Time"); - map.put("Canada/Central", "Central Standard Time"); - map.put("Canada/East-Saskatchewan", "Canada Central Standard Time"); - map.put("Canada/Eastern", "Eastern Standard Time"); - map.put("Canada/Mountain", "Mountain Standard Time"); - map.put("Canada/Newfoundland", "Newfoundland Standard Time"); - map.put("Canada/Pacific", "Pacific Standard Time"); - map.put("Canada/Saskatchewan", "Canada Central Standard Time"); - map.put("Canada/Yukon", "Pacific Standard Time"); - map.put("Chile/Continental", "Pacific SA Standard Time"); - map.put("Cuba", "Eastern Standard Time"); - map.put("EST", "SA Pacific Standard Time"); - map.put("EST5EDT", "Eastern Standard Time"); - map.put("Egypt", "Egypt Standard Time"); - map.put("Eire", "GMT Standard Time"); - map.put("Etc/GMT", "UTC"); - map.put("Etc/GMT+0", "UTC"); - map.put("Etc/GMT+1", "Cape Verde Standard Time"); - map.put("Etc/GMT+10", "Hawaiian Standard Time"); - map.put("Etc/GMT+11", "UTC-11"); - map.put("Etc/GMT+12", "Dateline Standard Time"); - map.put("Etc/GMT+2", "UTC-02"); - map.put("Etc/GMT+3", "SA Eastern Standard Time"); - map.put("Etc/GMT+4", "SA Western Standard Time"); - map.put("Etc/GMT+5", "SA Pacific Standard Time"); - map.put("Etc/GMT+6", "Central America Standard Time"); - map.put("Etc/GMT+7", "US Mountain Standard Time"); - map.put("Etc/GMT-0", "UTC"); - map.put("Etc/GMT-1", "W. Central Africa Standard Time"); - map.put("Etc/GMT-10", "West Pacific Standard Time"); - map.put("Etc/GMT-11", "Central Pacific Standard Time"); - map.put("Etc/GMT-12", "UTC+12"); - map.put("Etc/GMT-13", "Tonga Standard Time"); - map.put("Etc/GMT-14", "Line Islands Standard Time"); - map.put("Etc/GMT-2", "South Africa Standard Time"); - map.put("Etc/GMT-3", "E. Africa Standard Time"); - map.put("Etc/GMT-4", "Arabian Standard Time"); - map.put("Etc/GMT-5", "West Asia Standard Time"); - map.put("Etc/GMT-6", "Central Asia Standard Time"); - map.put("Etc/GMT-7", "SE Asia Standard Time"); - map.put("Etc/GMT-8", "Singapore Standard Time"); - map.put("Etc/GMT-9", "Tokyo Standard Time"); - map.put("Etc/GMT0", "UTC"); - map.put("Etc/Greenwich", "UTC"); - map.put("Etc/UCT", "UTC"); - map.put("Etc/UTC", "UTC"); - map.put("Etc/Universal", "UTC"); - map.put("Etc/Zulu", "UTC"); - map.put("Europe/Amsterdam", "W. Europe Standard Time"); - map.put("Europe/Andorra", "W. Europe Standard Time"); - map.put("Europe/Athens", "GTB Standard Time"); - map.put("Europe/Belfast", "GMT Standard Time"); - map.put("Europe/Belgrade", "Central Europe Standard Time"); - map.put("Europe/Berlin", "W. Europe Standard Time"); - map.put("Europe/Bratislava", "Central Europe Standard Time"); - map.put("Europe/Brussels", "Romance Standard Time"); - map.put("Europe/Bucharest", "GTB Standard Time"); - map.put("Europe/Budapest", "Central Europe Standard Time"); - map.put("Europe/Busingen", "W. Europe Standard Time"); - map.put("Europe/Chisinau", "GTB Standard Time"); - map.put("Europe/Copenhagen", "Romance Standard Time"); - map.put("Europe/Dublin", "GMT Standard Time"); - map.put("Europe/Gibraltar", "W. Europe Standard Time"); - map.put("Europe/Guernsey", "GMT Standard Time"); - map.put("Europe/Helsinki", "FLE Standard Time"); - map.put("Europe/Isle_of_Man", "GMT Standard Time"); - map.put("Europe/Istanbul", "Turkey Standard Time"); - map.put("Europe/Jersey", "GMT Standard Time"); - map.put("Europe/Kaliningrad", "Kaliningrad Standard Time"); - map.put("Europe/Kiev", "FLE Standard Time"); - map.put("Europe/Lisbon", "GMT Standard Time"); - map.put("Europe/Ljubljana", "Central Europe Standard Time"); - map.put("Europe/London", "GMT Standard Time"); - map.put("Europe/Luxembourg", "W. Europe Standard Time"); - map.put("Europe/Madrid", "Romance Standard Time"); - map.put("Europe/Malta", "W. Europe Standard Time"); - map.put("Europe/Mariehamn", "FLE Standard Time"); - map.put("Europe/Minsk", "Belarus Standard Time"); - map.put("Europe/Monaco", "W. Europe Standard Time"); - map.put("Europe/Moscow", "Russian Standard Time"); - map.put("Europe/Nicosia", "GTB Standard Time"); - map.put("Europe/Oslo", "W. Europe Standard Time"); - map.put("Europe/Paris", "Romance Standard Time"); - map.put("Europe/Podgorica", "Central Europe Standard Time"); - map.put("Europe/Prague", "Central Europe Standard Time"); - map.put("Europe/Riga", "FLE Standard Time"); - map.put("Europe/Rome", "W. Europe Standard Time"); - map.put("Europe/Samara", "Russia Time Zone 3"); - map.put("Europe/San_Marino", "W. Europe Standard Time"); - map.put("Europe/Sarajevo", "Central European Standard Time"); - map.put("Europe/Simferopol", "Russian Standard Time"); - map.put("Europe/Skopje", "Central European Standard Time"); - map.put("Europe/Sofia", "FLE Standard Time"); - map.put("Europe/Stockholm", "W. Europe Standard Time"); - map.put("Europe/Tallinn", "FLE Standard Time"); - map.put("Europe/Tirane", "Central Europe Standard Time"); - map.put("Europe/Tiraspol", "GTB Standard Time"); - map.put("Europe/Uzhgorod", "FLE Standard Time"); - map.put("Europe/Vaduz", "W. Europe Standard Time"); - map.put("Europe/Vatican", "W. Europe Standard Time"); - map.put("Europe/Vienna", "W. Europe Standard Time"); - map.put("Europe/Vilnius", "FLE Standard Time"); - map.put("Europe/Volgograd", "Russian Standard Time"); - map.put("Europe/Warsaw", "Central European Standard Time"); - map.put("Europe/Zagreb", "Central European Standard Time"); - map.put("Europe/Zaporozhye", "FLE Standard Time"); - map.put("Europe/Zurich", "W. Europe Standard Time"); - map.put("GB", "GMT Standard Time"); - map.put("GB-Eire", "GMT Standard Time"); - map.put("GMT", "UTC"); - map.put("GMT+0", "UTC"); - map.put("GMT-0", "UTC"); - map.put("GMT0", "UTC"); - map.put("Greenwich", "UTC"); - map.put("HST", "Hawaiian Standard Time"); - map.put("Hongkong", "China Standard Time"); - map.put("Iceland", "Greenwich Standard Time"); - map.put("Indian/Antananarivo", "E. Africa Standard Time"); - map.put("Indian/Chagos", "Central Asia Standard Time"); - map.put("Indian/Christmas", "SE Asia Standard Time"); - map.put("Indian/Cocos", "Myanmar Standard Time"); - map.put("Indian/Comoro", "E. Africa Standard Time"); - map.put("Indian/Kerguelen", "West Asia Standard Time"); - map.put("Indian/Mahe", "Mauritius Standard Time"); - map.put("Indian/Maldives", "West Asia Standard Time"); - map.put("Indian/Mauritius", "Mauritius Standard Time"); - map.put("Indian/Mayotte", "E. Africa Standard Time"); - map.put("Indian/Reunion", "Mauritius Standard Time"); - map.put("Iran", "Iran Standard Time"); - map.put("Israel", "Israel Standard Time"); - map.put("Jamaica", "SA Pacific Standard Time"); - map.put("Japan", "Tokyo Standard Time"); - map.put("Kwajalein", "UTC+12"); - map.put("Libya", "Libya Standard Time"); - map.put("MST", "US Mountain Standard Time"); - map.put("MST7MDT", "Mountain Standard Time"); - map.put("Mexico/BajaNorte", "Pacific Standard Time"); - map.put("Mexico/BajaSur", "Mountain Standard Time (Mexico)"); - map.put("Mexico/General", "Central Standard Time (Mexico)"); - map.put("NZ", "New Zealand Standard Time"); - map.put("Navajo", "Mountain Standard Time"); - map.put("PRC", "China Standard Time"); - map.put("PST8PDT", "Pacific Standard Time"); - map.put("Pacific/Apia", "Samoa Standard Time"); - map.put("Pacific/Auckland", "New Zealand Standard Time"); - map.put("Pacific/Bougainville", "Central Pacific Standard Time"); - map.put("Pacific/Chuuk", "West Pacific Standard Time"); - map.put("Pacific/Efate", "Central Pacific Standard Time"); - map.put("Pacific/Enderbury", "Tonga Standard Time"); - map.put("Pacific/Fakaofo", "Tonga Standard Time"); - map.put("Pacific/Fiji", "Fiji Standard Time"); - map.put("Pacific/Funafuti", "UTC+12"); - map.put("Pacific/Galapagos", "Central America Standard Time"); - map.put("Pacific/Guadalcanal", "Central Pacific Standard Time"); - map.put("Pacific/Guam", "West Pacific Standard Time"); - map.put("Pacific/Honolulu", "Hawaiian Standard Time"); - map.put("Pacific/Johnston", "Hawaiian Standard Time"); - map.put("Pacific/Kiritimati", "Line Islands Standard Time"); - map.put("Pacific/Kosrae", "Central Pacific Standard Time"); - map.put("Pacific/Kwajalein", "UTC+12"); - map.put("Pacific/Majuro", "UTC+12"); - map.put("Pacific/Midway", "UTC-11"); - map.put("Pacific/Nauru", "UTC+12"); - map.put("Pacific/Niue", "UTC-11"); - map.put("Pacific/Noumea", "Central Pacific Standard Time"); - map.put("Pacific/Pago_Pago", "UTC-11"); - map.put("Pacific/Palau", "Tokyo Standard Time"); - map.put("Pacific/Pohnpei", "Central Pacific Standard Time"); - map.put("Pacific/Ponape", "Central Pacific Standard Time"); - map.put("Pacific/Port_Moresby", "West Pacific Standard Time"); - map.put("Pacific/Rarotonga", "Hawaiian Standard Time"); - map.put("Pacific/Saipan", "West Pacific Standard Time"); - map.put("Pacific/Samoa", "UTC-11"); - map.put("Pacific/Tahiti", "Hawaiian Standard Time"); - map.put("Pacific/Tarawa", "UTC+12"); - map.put("Pacific/Tongatapu", "Tonga Standard Time"); - map.put("Pacific/Truk", "West Pacific Standard Time"); - map.put("Pacific/Wake", "UTC+12"); - map.put("Pacific/Wallis", "UTC+12"); - map.put("Pacific/Yap", "West Pacific Standard Time"); - map.put("Poland", "Central European Standard Time"); - map.put("Portugal", "GMT Standard Time"); - map.put("ROC", "Taipei Standard Time"); - map.put("ROK", "Korea Standard Time"); - map.put("Singapore", "Singapore Standard Time"); - map.put("Turkey", "Turkey Standard Time"); - map.put("UCT", "UTC"); - map.put("US/Alaska", "Alaskan Standard Time"); - map.put("US/Arizona", "US Mountain Standard Time"); - map.put("US/Central", "Central Standard Time"); - map.put("US/East-Indiana", "US Eastern Standard Time"); - map.put("US/Eastern", "Eastern Standard Time"); - map.put("US/Hawaii", "Hawaiian Standard Time"); - map.put("US/Indiana-Starke", "Central Standard Time"); - map.put("US/Michigan", "Eastern Standard Time"); - map.put("US/Mountain", "Mountain Standard Time"); - map.put("US/Pacific", "Pacific Standard Time"); - map.put("US/Pacific-New", "Pacific Standard Time"); - map.put("US/Samoa", "UTC-11"); - map.put("UTC", "UTC"); - map.put("Universal", "UTC"); - map.put("W-SU", "Russian Standard Time"); - map.put("Zulu", "UTC"); - //additions outside of Unicode list - map.put("America/Adak", "Hawaiian Standard Time,(UTC-10:00) Hawaii"); - map.put("America/Atka", "Hawaiian Standard Time,(UTC-10:00) Hawaii"); - map.put("America/Metlakatla", "Pacific Standard Time"); - map.put("America/Miquelon", "South America Standard Time"); - map.put("Asia/Gaza", "Middle East Standard Time"); - return map; - } - -} diff --git a/src/test/java/microsoft/exchange/webservices/base/BaseTest.java b/src/test/java/microsoft/exchange/webservices/base/BaseTest.java deleted file mode 100644 index 46b07d915..000000000 --- a/src/test/java/microsoft/exchange/webservices/base/BaseTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.base; - -import microsoft.exchange.webservices.data.core.ExchangeService; -import microsoft.exchange.webservices.data.core.ExchangeServiceBase; -import microsoft.exchange.webservices.data.core.request.HttpWebRequest; -import org.junit.BeforeClass; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** - * A base class with "Common-Services" - */ -@RunWith(JUnit4.class) -public abstract class BaseTest { - - /** - * Mock for the ExchangeServiceBase - */ - protected static ExchangeServiceBase exchangeServiceBaseMock; - - /** - * Mock for the ExchangeService - */ - protected static ExchangeService exchangeServiceMock; - - /** - * Setup Mocks - * - * @throws Exception - */ - @BeforeClass - public static final void setUpBaseClass() throws Exception { - // Mock up ExchangeServiceBase - exchangeServiceBaseMock = new ExchangeServiceBase() { - @Override - protected void processHttpErrorResponse(HttpWebRequest httpWebResponse, Exception webException) - throws Exception { - throw webException; - } - }; - exchangeServiceMock = new ExchangeService(); - } -} diff --git a/src/test/java/microsoft/exchange/webservices/base/util/TestUtils.java b/src/test/java/microsoft/exchange/webservices/base/util/TestUtils.java deleted file mode 100644 index 3358ca533..000000000 --- a/src/test/java/microsoft/exchange/webservices/base/util/TestUtils.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.base.util; - -import org.junit.Assert; -import org.junit.Ignore; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Modifier; - -@Ignore -public final class TestUtils { - - private TestUtils() { - throw new UnsupportedOperationException(); - } - - - /** - * Check that class has only one private constructor without parameters that throws exception during - * instantiation. It's necessary for util-classes. - * - * @param utilClass util-class - * @throws Throwable exception during instantiation - */ - public static void checkUtilClassConstructor(final Class utilClass) throws Throwable { - // Check count of available constructors. - final Constructor[] constructors = utilClass.getDeclaredConstructors(); - Assert.assertEquals(1, constructors.length); - - // Check accessibility. - final Constructor constructor = constructors[0]; - Assert.assertTrue(Modifier.isPrivate(constructor.getModifiers())); - - // Try to create instance. - constructor.setAccessible(true); - try { - constructor.newInstance(); - } catch (final InvocationTargetException ex) { - throw ex.getTargetException(); - } - - // We should never get this situation. - Assert.fail(); - } - -} diff --git a/src/test/java/microsoft/exchange/webservices/data/autodiscover/request/GetUserSettingsRequestTest.java b/src/test/java/microsoft/exchange/webservices/data/autodiscover/request/GetUserSettingsRequestTest.java deleted file mode 100644 index 717d88f79..000000000 --- a/src/test/java/microsoft/exchange/webservices/data/autodiscover/request/GetUserSettingsRequestTest.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.autodiscover.request; - - -import microsoft.exchange.webservices.base.BaseTest; -import microsoft.exchange.webservices.data.autodiscover.AutodiscoverService; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; -import org.hamcrest.core.IsNot; -import org.hamcrest.core.IsNull; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; - -import javax.xml.stream.XMLStreamException; - -import java.io.ByteArrayOutputStream; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -/** - * Testclass for methods of GetUserSettingsRequest - */ -@RunWith(Parameterized.class) -public class GetUserSettingsRequestTest extends BaseTest { - - /** - * The ExchangeVersion which is under test - */ - private final ExchangeVersion exchangeVersion; - - /** - * The AutodiscoverService which is under test - */ - private final AutodiscoverService autodiscoverService; - - /** - * A mocked URI via HTTPS - */ - private final URI uriMockHttps = URI.create("https://localhost"); - - /** - * A mocked URI via HTTP - */ - private final URI uriMockHttp = URI.create("http://localhost"); - - /** - * Returns the Parameters which where handled to the constructor - * - * @return the available Services - * @throws ArgumentException - */ - @Parameterized.Parameters - public static List getAutodiscoverServices() throws ArgumentException { - return new ArrayList() { - - /** - * Constant serialized ID used for compatibility. - */ - private static final long serialVersionUID = 1L; - - { - for (ExchangeVersion exchangeVersion : ExchangeVersion.values()) { - add(new Object[] {exchangeVersion, new AutodiscoverService(exchangeVersion)}); - } - } - }; - } - - /** - * Construct the Testobject with given Parameters - * - * @param exchangeVersion - * @param autodiscoverService - */ - public GetUserSettingsRequestTest(final ExchangeVersion exchangeVersion, - final AutodiscoverService autodiscoverService) { - this.exchangeVersion = exchangeVersion; - this.autodiscoverService = autodiscoverService; - } - - /** - * setup - */ - @Before - public void setup() { - Assert.assertThat(this.exchangeVersion, IsNull.notNullValue()); - Assert.assertThat(this.autodiscoverService, IsNull.notNullValue()); - Assert.assertThat(uriMockHttp, IsNull.notNullValue()); - Assert.assertThat(uriMockHttps, IsNull.notNullValue()); - } - - /** - * Nothing should be written to the OutputStream if expectPartnerToken is not set. - * - * @throws ServiceValidationException - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Test - public void testWriteExtraCustomSoapHeadersToXmlWithoutPartnertoken() - throws ServiceValidationException, XMLStreamException, ServiceXmlSerializationException { - // HTTPS - GetUserSettingsRequest getUserSettingsRequest = - new GetUserSettingsRequest(autodiscoverService, uriMockHttps); - - // Test without expected Partnertoken - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - getUserSettingsRequest.writeExtraCustomSoapHeadersToXml( - new EwsServiceXmlWriter(exchangeServiceBaseMock, byteArrayOutputStream)); - - // nothing should be writyen to the outputstream - Assert.assertArrayEquals(byteArrayOutputStream.toByteArray(), new ByteArrayOutputStream().toByteArray()); - - // HTTP - getUserSettingsRequest = new GetUserSettingsRequest(autodiscoverService, uriMockHttp); - - // Test without expected Partnertoken - byteArrayOutputStream = new ByteArrayOutputStream(); - getUserSettingsRequest.writeExtraCustomSoapHeadersToXml( - new EwsServiceXmlWriter(exchangeServiceBaseMock, byteArrayOutputStream)); - - // nothing should be written to the outputstream - Assert.assertArrayEquals(byteArrayOutputStream.toByteArray(), new ByteArrayOutputStream().toByteArray()); - } - - /** - * Test if content is added correctly if expectPartnerToken is set. - * - * @throws ServiceValidationException - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Test - public void testWriteExtraCustomSoapHeadersToXmlWithPartnertoken() - throws ServiceValidationException, XMLStreamException, ServiceXmlSerializationException { - GetUserSettingsRequest getUserSettingsRequest = - new GetUserSettingsRequest(autodiscoverService, uriMockHttps, Boolean.TRUE); - - // Test without expected Partnertoken - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - getUserSettingsRequest.writeExtraCustomSoapHeadersToXml( - new EwsServiceXmlWriter(exchangeServiceBaseMock, byteArrayOutputStream)); - - // data should be added the same way as mentioned - Assert.assertThat(byteArrayOutputStream.toByteArray(), - IsNot.not(new ByteArrayOutputStream().toByteArray())); - - //TODO Test if the output is really correct - } - - /** - * Initialising a GetUserSettingsRequest with Http should lead to an ServiceValidationException. - * - * @throws ServiceValidationException - * @throws XMLStreamException the XML stream exception - * @throws ServiceXmlSerializationException the service xml serialization exception - */ - @Test(expected = ServiceValidationException.class) - public void testWriteExtraCustomSoapHeadersToXmlWithPartnertoken2() - throws ServiceValidationException, XMLStreamException, ServiceXmlSerializationException { - GetUserSettingsRequest getUserSettingsRequest = - new GetUserSettingsRequest(autodiscoverService, uriMockHttp, Boolean.TRUE); - } -} diff --git a/src/test/java/microsoft/exchange/webservices/data/core/PropertyBagTest.java b/src/test/java/microsoft/exchange/webservices/data/core/PropertyBagTest.java deleted file mode 100644 index f811fb106..000000000 --- a/src/test/java/microsoft/exchange/webservices/data/core/PropertyBagTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.core; - -import microsoft.exchange.webservices.data.core.service.ServiceObject; -import microsoft.exchange.webservices.data.core.service.item.Item; -import microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion; -import microsoft.exchange.webservices.data.core.exception.misc.ArgumentException; -import microsoft.exchange.webservices.data.core.exception.service.local.ServiceObjectPropertyException; -import microsoft.exchange.webservices.data.misc.OutParam; -import microsoft.exchange.webservices.data.property.definition.IntPropertyDefinition; -import microsoft.exchange.webservices.data.property.definition.RecurrencePropertyDefinition; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class PropertyBagTest { - - /** - * Calling tryGetPropertyType with invalid data. - * Expecting exception - * - * @throws Exception - */ - @Test(expected=ArgumentException.class) - public void tryGetPropertyType() throws Exception{ - PropertyBag pb = createPropertyBag(); - pb.tryGetPropertyType(String.class, new RecurrencePropertyDefinition("test", "none", null, ExchangeVersion.Exchange2010_SP2), new OutParam()); - } - - @Test(expected = ServiceObjectPropertyException.class) - public void testGetObjectFromPropertyDefinition() throws Exception { - PropertyBag pb = createPropertyBag(); - pb.getObjectFromPropertyDefinition(new IntPropertyDefinition("", "none", ExchangeVersion.Exchange2007_SP1)); - } - - - private PropertyBag createPropertyBag() throws Exception { - ExchangeService es = new ExchangeService(); - ServiceObject owner = new Item(es); - return new PropertyBag(owner); - } - -} diff --git a/src/test/java/microsoft/exchange/webservices/data/misc/availability/TimeWindowTest.java b/src/test/java/microsoft/exchange/webservices/data/misc/availability/TimeWindowTest.java deleted file mode 100644 index d0c9cc93d..000000000 --- a/src/test/java/microsoft/exchange/webservices/data/misc/availability/TimeWindowTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.misc.availability; - -import microsoft.exchange.webservices.base.BaseTest; -import microsoft.exchange.webservices.data.core.EwsServiceXmlReader; -import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; -import microsoft.exchange.webservices.data.core.XmlElementNames; -import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace; -import microsoft.exchange.webservices.data.security.XmlNodeType; -import org.junit.Assert; -import org.junit.Test; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.util.Date; - -public class TimeWindowTest extends BaseTest { - - @Test - public void testWriteToXmlUnscopedDatesOnlyUsesUTC() { - // Thu, 01 Jan 2015 0:0:00 UTC - final Date midnight = new Date(1420070400000l); - // Thu, 01 Jan 2015 23:59:59 GMT - final Date just_before_midnight = new Date(1420156799000l); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - EwsServiceXmlWriter writer; - - try { - // build the test xml markup - writer = new EwsServiceXmlWriter(exchangeServiceMock, outputStream); - writer.writeStartDocument(); - writer.writeStartElement(XmlNamespace.NotSpecified, "test"); - writer.writeAttributeValue("xmlns:" + XmlNamespace.Types.getNameSpacePrefix(), XmlNamespace.Types.getNameSpaceUri()); - TimeWindow tw = new TimeWindow(); - tw.setStartTime(midnight); - tw.setEndTime(just_before_midnight); - tw.writeToXmlUnscopedDatesOnly(writer, XmlElementNames.Duration); - writer.writeEndElement(); - - // read the test markup - InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); - EwsServiceXmlReader reader = new EwsServiceXmlReader(inputStream, exchangeServiceMock); - reader.read(new XmlNodeType(XmlNodeType.START_DOCUMENT)); - reader.readStartElement(XmlNamespace.NotSpecified, "test"); - reader.readStartElement(XmlNamespace.Types, XmlElementNames.Duration); - TimeWindow checkTw = new TimeWindow(); - - checkTw.loadFromXml(reader); - - // Test that the dates have not shifted. - Assert.assertEquals(midnight, checkTw.getStartTime()); - Assert.assertEquals(midnight, checkTw.getEndTime()); - } catch (Exception e) { - Assert.fail(e.getMessage()); - } - } -} diff --git a/src/test/java/microsoft/exchange/webservices/data/property/complex/OlsonTimeZoneTest.java b/src/test/java/microsoft/exchange/webservices/data/property/complex/OlsonTimeZoneTest.java deleted file mode 100644 index 3278e4b7a..000000000 --- a/src/test/java/microsoft/exchange/webservices/data/property/complex/OlsonTimeZoneTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.property.complex; - -import microsoft.exchange.webservices.data.property.complex.time.OlsonTimeZoneDefinition; -import microsoft.exchange.webservices.data.util.TimeZoneUtils; -import org.apache.commons.lang3.StringUtils; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -import java.util.Map; -import java.util.TimeZone; - -@RunWith(JUnit4.class) -public class OlsonTimeZoneTest { - - @Test - public void testOlsonTimeZoneConversion() { - final Map olsonTimeZoneToMsMap = TimeZoneUtils.createOlsonTimeZoneToMsMap(); - final String[] timeZoneIds = TimeZone.getAvailableIDs(); - - for (final String timeZoneId : timeZoneIds) { - final boolean america = timeZoneId.startsWith("America"); - final boolean europe = timeZoneId.startsWith("Europe"); - final boolean africa = timeZoneId.startsWith("Africa"); - - if (america || europe || africa) { - // There are a few timezones that are out of date or don't have direct microsoft mappings - // according to the Unicode source we use so we will only test Americas, Europe and Africa. - final TimeZone timeZone = TimeZone.getTimeZone(timeZoneId); - final OlsonTimeZoneDefinition olsonTimeZone = new OlsonTimeZoneDefinition(timeZone); - final String olsonTimeZoneId = olsonTimeZone.getId(); - - Assert.assertFalse("olsonTimeZoneId for " + timeZoneId + " is blank", StringUtils.isBlank(olsonTimeZoneId)); - Assert.assertEquals(olsonTimeZoneToMsMap.get(timeZoneId), olsonTimeZoneId); - } - } - } - -} diff --git a/src/test/java/microsoft/exchange/webservices/data/property/complex/TimeChangeTest.java b/src/test/java/microsoft/exchange/webservices/data/property/complex/TimeChangeTest.java deleted file mode 100644 index 6346bacf6..000000000 --- a/src/test/java/microsoft/exchange/webservices/data/property/complex/TimeChangeTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * The MIT License Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and - * associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, - * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or - * substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT - * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -package microsoft.exchange.webservices.data.property.complex; - -import java.util.Calendar; -import java.util.TimeZone; - -import javax.xml.bind.DatatypeConverter; - -import microsoft.exchange.webservices.data.core.EwsUtilities; -import microsoft.exchange.webservices.data.misc.Time; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class TimeChangeTest { - - private static String time = "03:00:00"; - private static String time_fail1 = "21:32"; - private static String time_fail2 = "25:25:10"; - private static String time_fail3 = "-10:00:00"; - - private static String dateUTC = "2001-10-27Z"; - private static String date_fail1 = "2001-10-32"; - private static String date_fail2 = "2001-13-26+02:00"; - private static String date_fail3 = "01-10-26"; - - @Test - public void testDateUTC() { - Assert.assertEquals("2001-10-27Z", testDate(dateUTC)); - } - - private String testDate(String value) { - Calendar cal = DatatypeConverter.parseDate(value); - cal.setTimeZone(TimeZone.getTimeZone("UTC")); - String XSDate = EwsUtilities.dateTimeToXSDate(cal.getTime()); - return XSDate; - } - - @Test(expected = IllegalArgumentException.class) - public void testDateFail1() { - testDate(date_fail1); - } - - @Test(expected = IllegalArgumentException.class) - public void testDateFail2() { - testDate(date_fail2); - } - - @Test(expected = IllegalArgumentException.class) - public void testDateFail3() { - testDate(date_fail3); - } - - private String testTime(String value) { - Calendar cal = DatatypeConverter.parseTime(value); - Time time = new Time(cal.getTime()); - return time.toXSTime(); - } - - @Test(expected = IllegalArgumentException.class) - public void testTimeFail1() { - testTime(time_fail1); - } - - @Test(expected = IllegalArgumentException.class) - public void testTimeFail2() { - testTime(time_fail2); - } - - @Test(expected = IllegalArgumentException.class) - public void testTimeFail3() { - testTime(time_fail3); - } - - @Test - public void testTimeValues() { - Assert.assertEquals("{0:00}:{1:00}:{2:00},3,0,0", testTime(time)); - } - -} diff --git a/src/test/java/microsoft/exchange/webservices/data/sync/ChangeCollectionTest.java b/src/test/java/microsoft/exchange/webservices/data/sync/ChangeCollectionTest.java deleted file mode 100644 index 0c9e15eae..000000000 --- a/src/test/java/microsoft/exchange/webservices/data/sync/ChangeCollectionTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.sync; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.verify; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; - -import java.util.List; - -@RunWith(MockitoJUnitRunner.class) public class ChangeCollectionTest { - - private static final String STATE = "SOME_STATE"; - @Mock Change change0; - @Mock Change change1; - @Mock Change change2; - - ChangeCollection impl; - @InjectMocks ChangeCollection spiedImpl; - - @Mock(name = "changes") List innerList; - - - @Before public void setUp() throws Exception { - - impl = new ChangeCollection(); - } - - @Test public void testAdd() throws Exception { - - assertEquals(impl.getCount(), 0); - impl.add(change0); - assertEquals(1, impl.getCount()); - impl.add(change1); - assertEquals(2, impl.getCount()); - - } - - - @Test public void testGetChangeAtIndex() throws Exception { - assertEquals(impl.getCount(), 0); - impl.add(change0); - impl.add(change1); - impl.add(change2); - assertSame(change0, impl.getChangeAtIndex(0)); - assertSame(change1, impl.getChangeAtIndex(1)); - assertSame(change2, impl.getChangeAtIndex(2)); - - } - - @Test(expected = IndexOutOfBoundsException.class) - public void testGetChangeAtIndexThrowsIndexOutOfBoundException() throws Exception { - assertEquals(impl.getCount(), 0); - impl.add(change0); - impl.add(change1); - impl.add(change2); - - impl.getChangeAtIndex(99); - } - - @Test public void testGetSyncState() throws Exception { - - impl.setSyncState(STATE); - assertSame(STATE, impl.getSyncState()); - - } - - - @Test public void testGetMoreChangesAvailable() throws Exception { - impl.setMoreChangesAvailable(true); - assertTrue(impl.getMoreChangesAvailable()); - - impl.setMoreChangesAvailable(false); - assertFalse(impl.getMoreChangesAvailable()); - } - - @Test public void testIterator() throws Exception { - spiedImpl.iterator(); - - verify(innerList).iterator(); - } -} diff --git a/src/test/java/microsoft/exchange/webservices/data/util/DateTimeUtilsTest.java b/src/test/java/microsoft/exchange/webservices/data/util/DateTimeUtilsTest.java deleted file mode 100644 index da002e77c..000000000 --- a/src/test/java/microsoft/exchange/webservices/data/util/DateTimeUtilsTest.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import microsoft.exchange.webservices.base.util.TestUtils; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.TimeZone; - -@RunWith(JUnit4.class) -public class DateTimeUtilsTest { - - // Tests for DateTimeUtils.convertDateTimeStringToDate() - - @Test - public void testDateTimeEmpty() { - assertNull(DateTimeUtils.convertDateTimeStringToDate(null)); - assertNull(DateTimeUtils.convertDateTimeStringToDate("")); - } - - @Test - public void testDateTimeZulu() { - String dateString = "2015-01-08T10:11:12Z"; - Date parsed = DateTimeUtils.convertDateTimeStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(8, calendar.get(Calendar.DATE)); - assertEquals(10, calendar.get(Calendar.HOUR_OF_DAY)); - assertEquals(11, calendar.get(Calendar.MINUTE)); - assertEquals(12, calendar.get(Calendar.SECOND)); - } - - @Test - public void testDateTimeZuluLowerZ() { - String dateString = "2015-01-08T10:11:12z"; - Date parsed = DateTimeUtils.convertDateTimeStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(8, calendar.get(Calendar.DATE)); - assertEquals(10, calendar.get(Calendar.HOUR_OF_DAY)); - assertEquals(11, calendar.get(Calendar.MINUTE)); - assertEquals(12, calendar.get(Calendar.SECOND)); - } - - @Test - public void testDateTimeZuluWithPrecision() { - String dateString = "2015-01-08T10:11:12.123Z"; - Date parsed = DateTimeUtils.convertDateTimeStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(8, calendar.get(Calendar.DATE)); - assertEquals(10, calendar.get(Calendar.HOUR_OF_DAY)); - assertEquals(11, calendar.get(Calendar.MINUTE)); - assertEquals(12, calendar.get(Calendar.SECOND)); - } - - @Test - public void testDateTimeZuluWithMilliseconds() { - String dateString = "9999-12-30T23:59:59.9999999Z"; - Date parsed = DateTimeUtils.convertDateTimeStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(9999, calendar.get(Calendar.YEAR)); - assertEquals(11, calendar.get(Calendar.MONTH)); - assertEquals(30, calendar.get(Calendar.DATE)); - assertEquals(23, calendar.get(Calendar.HOUR_OF_DAY)); - assertEquals(59, calendar.get(Calendar.MINUTE)); - assertEquals(59, calendar.get(Calendar.SECOND)); - } - - @Test - public void testDateTimeWithTimeZone() { - String dateString = "2015-01-08T10:11:12+0200"; - Date parsed = DateTimeUtils.convertDateTimeStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(8, calendar.get(Calendar.DATE)); - assertEquals(8, calendar.get(Calendar.HOUR)); - assertEquals(11, calendar.get(Calendar.MINUTE)); - assertEquals(12, calendar.get(Calendar.SECOND)); - } - - @Test - public void testDateTimeWithTimeZoneWithColon() { - String dateString = "2015-01-08T10:11:12-02:00"; - Date parsed = DateTimeUtils.convertDateTimeStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(8, calendar.get(Calendar.DATE)); - assertEquals(12, calendar.get(Calendar.HOUR_OF_DAY)); - assertEquals(11, calendar.get(Calendar.MINUTE)); - assertEquals(12, calendar.get(Calendar.SECOND)); - } - - @Test - public void testDateTime() { - String dateString = "2015-01-08T10:11:12"; - Date parsed = DateTimeUtils.convertDateTimeStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(8, calendar.get(Calendar.DATE)); - assertEquals(10, calendar.get(Calendar.HOUR_OF_DAY)); - assertEquals(11, calendar.get(Calendar.MINUTE)); - assertEquals(12, calendar.get(Calendar.SECOND)); - } - - @Test - public void testDateZulu() { - String dateString = "2015-01-08Z"; - Date parsed = DateTimeUtils.convertDateTimeStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(8, calendar.get(Calendar.DATE)); - } - - @Test - public void testDateOnly() { - String dateString = "2015-01-08"; - Date parsed = DateTimeUtils.convertDateTimeStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(8, calendar.get(Calendar.DATE)); - } - - - // Tests for DateTimeUtils.convertDateStringToDate() - - @Test - public void testDateOnlyEmpty() { - assertNull(DateTimeUtils.convertDateStringToDate(null)); - assertNull(DateTimeUtils.convertDateStringToDate("")); - } - - @Test - public void testDateOnlyZulu() { - String dateString = "2015-01-08Z"; - Date parsed = DateTimeUtils.convertDateStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(8, calendar.get(Calendar.DATE)); - assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY)); - assertEquals(0, calendar.get(Calendar.MINUTE)); - assertEquals(0, calendar.get(Calendar.SECOND)); - } - - @Test - public void testDateOnlyZuluWithLowerZ() { - String dateString = "2015-01-08z"; - Date parsed = DateTimeUtils.convertDateStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(8, calendar.get(Calendar.DATE)); - assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY)); - assertEquals(0, calendar.get(Calendar.MINUTE)); - assertEquals(0, calendar.get(Calendar.SECOND)); - } - - @Test - public void testDateOnlyWithTimeZone() { - String dateString = "2015-01-08+0200"; - Date parsed = DateTimeUtils.convertDateStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(7, calendar.get(Calendar.DATE)); - assertEquals(22, calendar.get(Calendar.HOUR_OF_DAY)); - assertEquals(0, calendar.get(Calendar.MINUTE)); - assertEquals(0, calendar.get(Calendar.SECOND)); - } - - @Test - public void testDateOnlyWithTimeZoneWithColon() { - String dateString = "2015-01-08-02:00"; - Date parsed = DateTimeUtils.convertDateStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(8, calendar.get(Calendar.DATE)); - assertEquals(2, calendar.get(Calendar.HOUR_OF_DAY)); - assertEquals(0, calendar.get(Calendar.MINUTE)); - assertEquals(0, calendar.get(Calendar.SECOND)); - } - - @Test - public void testDateOnlyWithoutTimeZone() { - String dateString = "2015-01-08"; - Date parsed = DateTimeUtils.convertDateStringToDate(dateString); - Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - calendar.setTime(parsed); - assertEquals(2015, calendar.get(Calendar.YEAR)); - assertEquals(0, calendar.get(Calendar.MONTH)); - assertEquals(8, calendar.get(Calendar.DATE)); - assertEquals(0, calendar.get(Calendar.HOUR_OF_DAY)); - assertEquals(0, calendar.get(Calendar.MINUTE)); - assertEquals(0, calendar.get(Calendar.SECOND)); - } - - @Test(expected = IllegalArgumentException.class) - public void testConvertDateStringToDateBadFormat() { - DateTimeUtils.convertDateStringToDate("Monday, May, 1988"); - } - - @Test(expected = UnsupportedOperationException.class) - public void testDateTimeUtilsConstructor() throws Throwable { - TestUtils.checkUtilClassConstructor(DateTimeUtils.class); - } - -} diff --git a/src/test/java/microsoft/exchange/webservices/data/util/TimeZoneUtilsTest.java b/src/test/java/microsoft/exchange/webservices/data/util/TimeZoneUtilsTest.java deleted file mode 100644 index 92f8c1b91..000000000 --- a/src/test/java/microsoft/exchange/webservices/data/util/TimeZoneUtilsTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The MIT License - * Copyright (c) 2012 Microsoft Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package microsoft.exchange.webservices.data.util; - -import microsoft.exchange.webservices.base.util.TestUtils; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -import java.util.TimeZone; - -@RunWith(JUnit4.class) -public class TimeZoneUtilsTest { - - @Test(expected = UnsupportedOperationException.class) - public void testTimeZoneUtilsConstructor() throws Throwable { - TestUtils.checkUtilClassConstructor(TimeZoneUtils.class); - } - - @Test - public void testGetMicrosoftTimeZoneName() { - checkGetMicrosoftTimeZoneName("Africa/Abidjan", "Greenwich Standard Time"); - } - - @Test - public void testGetMicrosoftTimeZoneNameBad() { - // null-argument is not allowed. - try { - Assert.fail(TimeZoneUtils.getMicrosoftTimeZoneName(null)); - } catch (final IllegalArgumentException ignored) {} - - // TODO: fix this later - // Case-insensitive ID is not supported. - // checkGetMicrosoftTimeZoneName("africa/abidjan", "UTC"); - } - - - private void checkGetMicrosoftTimeZoneName(final String id, final String name) { - final TimeZone timeZone = TimeZone.getTimeZone(id); - final String zoneName = TimeZoneUtils.getMicrosoftTimeZoneName(timeZone); - Assert.assertEquals(name, zoneName); - } - -} diff --git a/todo.txt b/todo.txt new file mode 100644 index 000000000..bee8b2e3e --- /dev/null +++ b/todo.txt @@ -0,0 +1 @@ +TODO: add your TODOs here. \ No newline at end of file