/** * 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)); } }
/** * 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)); } }
/** * 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 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); } }
/** * Initializes a new instance of <see cref="UserConfiguration"/> 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<UserConfigurationProperties> 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); }
/** * 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())); } }
/** * 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."); } }
/** * 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()); } }
/** * 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()); } } }
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.",
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.",
/** * 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 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)); } }
/** * Initializes a new instance of <see cref="UserConfiguration"/> 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<UserConfigurationProperties> 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); }
/** * 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())); } }