/** * 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<Class<?>, Map<String, ExchangeVersion>> member = ENUM_VERSION_DICTIONARIES.getMember(); final Map<String, ExchangeVersion> 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 ) ); } } }
/** * 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<String> 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<String> smtpAddresses = new ArrayList<String>(); smtpAddresses.addAll((Collection<? extends String>) userSmtpAddresses); List<UserSettingName> settings = new ArrayList<UserSettingName>(); settings.addAll(Arrays.asList(userSettingNames)); return this.getUserSettings(smtpAddresses, settings); }
/** * 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); }
/** * Retrieves the specified settings for single SMTP address. * <p>This method will run the entire Autodiscover "discovery" * algorithm and will follow address and URL redirections.</p> * @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<UserSettingName> requestedSettings = new ArrayList<UserSettingName>(); 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); } }
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.", 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.",
if (this.getRequestedServerVersion().compareTo( MinimumRequestVersionForAutoDiscoverSoapService) < 0) { throw new ServiceVersionException(String.format(
compareTo(ExchangeVersion.Exchange2010_SP1) >= 0) { writer.writeElementValue( XmlNamespace.Types,
/** * 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); } }
/** * 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<Class<?>, Map<String, ExchangeVersion>> member = ENUM_VERSION_DICTIONARIES.getMember(); final Map<String, ExchangeVersion> 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 ) ); } } }
/** * 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<String> 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<String> smtpAddresses = new ArrayList<String>(); smtpAddresses.addAll((Collection<? extends String>) userSmtpAddresses); List<UserSettingName> settings = new ArrayList<UserSettingName>(); settings.addAll(Arrays.asList(userSettingNames)); return this.getUserSettings(smtpAddresses, settings); }
/** * 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); }
/** * Retrieves the specified settings for single SMTP address. * <p>This method will run the entire Autodiscover "discovery" * algorithm and will follow address and URL redirections.</p> * @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<UserSettingName> requestedSettings = new ArrayList<UserSettingName>(); 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); } }
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.", 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.",
if (this.getRequestedServerVersion().compareTo( MinimumRequestVersionForAutoDiscoverSoapService) < 0) { throw new ServiceVersionException(String.format(
compareTo(ExchangeVersion.Exchange2010_SP1) >= 0) { writer.writeElementValue( XmlNamespace.Types,
/** * 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); } }