microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion Java Examples

The following examples show how to use microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Recurrence.java    From ews-java-api with MIT License 7 votes vote down vote up
/**
 * 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);
  }

}
 
Example #2
Source File: ExchangeService.java    From ews-java-api with MIT License 6 votes vote down vote up
/**
 * 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<Conversation> 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();
}
 
Example #3
Source File: ImpersonatedUserId.java    From ews-java-api with MIT License 6 votes vote down vote up
/**
 * 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
}
 
Example #4
Source File: StartTimeZonePropertyDefinition.java    From ews-java-api with MIT License 6 votes vote down vote up
/**
 * 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);
    }
  }
}
 
Example #5
Source File: EwsUtilities.java    From ews-java-api with MIT License 6 votes vote down vote up
/**
 * Builds the enum dict.
 *
 * @param <E> the element type
 * @param c   the c
 * @return the map
 */
private static <E extends Enum<E>> Map<String, ExchangeVersion>
buildEnumDict(Class<E> c) {
  Map<String, ExchangeVersion> dict =
      new HashMap<String, ExchangeVersion>();
  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;
}
 
Example #6
Source File: EwsUtilities.java    From ews-java-api with MIT License 6 votes vote down vote up
@Override
public Map<Class<?>, Map<String, ExchangeVersion>>
createInstance() {
  Map<Class<?>, Map<String, ExchangeVersion>> enumDicts =
      new HashMap<Class<?>, Map<String,
          ExchangeVersion>>();
  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;
}
 
Example #7
Source File: SyncFolderItemsRequest.java    From ews-java-api with MIT License 6 votes vote down vote up
/**
 * 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 */);
}
 
Example #8
Source File: ExchangeService.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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<FolderId> 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();
}
 
Example #9
Source File: EwsUtilities.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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));
  }
}
 
Example #10
Source File: PropertySet.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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
}
 
Example #11
Source File: PropertyDefinition.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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;
}
 
Example #12
Source File: PropertyDefinition.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * Initializes a new instance.
 *
 * @param xmlElementName Name of the XML element.
 * @param flags          The flags.
 * @param version        The version.
 */
protected PropertyDefinition(String xmlElementName,
    EnumSet<PropertyDefinitionFlags> flags, ExchangeVersion version) {
  super();
  this.xmlElementName = xmlElementName;
  this.flags = flags;
  this.version = version;
}
 
Example #13
Source File: ExchangeService.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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());
  }
}
 
Example #14
Source File: AttachmentCollection.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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);
      }
    }
  }
}
 
Example #15
Source File: ExchangeService.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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<ServiceResponse> applyConversationAction(
    ConversationActionType actionType,
    Iterable<ConversationId> 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();
}
 
Example #16
Source File: ExchangeService.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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<FolderId> folderIds,
    EventType... eventTypes) throws Exception {
  EwsUtilities.validateMethodVersion(this,
      ExchangeVersion.Exchange2010_SP1,
      "BeginSubscribeToStreamingNotifications");

  EwsUtilities.validateParamCollection(folderIds.iterator(), "folderIds");

  return this.buildSubscribeToStreamingNotificationsRequest(folderIds,
      eventTypes).beginExecute(callback);
}
 
Example #17
Source File: ExchangeServiceBase.java    From ews-java-api with MIT License 5 votes vote down vote up
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();
}
 
Example #18
Source File: ExchangeService.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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<FolderId> 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();
}
 
Example #19
Source File: FileAttachment.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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;
}
 
Example #20
Source File: AutodiscoverService.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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<String> domains, List<DomainSettingName> 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();
}
 
Example #21
Source File: Contact.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example #22
Source File: ExchangeServiceBase.java    From ews-java-api with MIT License 4 votes vote down vote up
protected ExchangeServiceBase(ExchangeVersion requestedServerVersion) {
  this();
  this.requestedServerVersion = requestedServerVersion;
}
 
Example #23
Source File: GetPasswordExpirationDateRequest.java    From ews-java-api with MIT License 4 votes vote down vote up
@Override
protected ExchangeVersion getMinimumRequiredServerVersion() {
  // TODO Auto-generated method stub
  return ExchangeVersion.Exchange2010_SP1;
}
 
Example #24
Source File: Appointment.java    From ews-java-api with MIT License 4 votes vote down vote up
/**
 * 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());
    }
  }
}
 
Example #25
Source File: ContainedPropertyDefinition.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * 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<TComplexProperty> cls, String xmlElementName, String uri,
    String containedXmlElementName, EnumSet<PropertyDefinitionFlags> flags, ExchangeVersion version,
    ICreateComplexPropertyDelegate<TComplexProperty> propertyCreationDelegate) {
  super(cls, xmlElementName, uri, flags, version,
      propertyCreationDelegate);
  this.containedXmlElementName = containedXmlElementName;
}
 
Example #26
Source File: ExchangeService.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * 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<MoveCopyItemResponse> moveItems(
    Iterable<ItemId> itemIds, FolderId destinationFolderId,
    boolean returnNewItemIds) throws Exception {
  EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010_SP1, "MoveItems");

  return this.internalMoveItems(itemIds, destinationFolderId, returnNewItemIds,
                                ServiceErrorHandling.ReturnErrors);
}
 
Example #27
Source File: ExchangeService.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * 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<MoveCopyItemResponse> copyItems(
    Iterable<ItemId> itemIds, FolderId destinationFolderId,
    boolean returnNewItemIds) throws Exception {
  EwsUtilities.validateMethodVersion(this, ExchangeVersion.Exchange2010_SP1, "CopyItems");

  return this.internalCopyItems(itemIds, destinationFolderId, returnNewItemIds,
                                ServiceErrorHandling.ReturnErrors);
}
 
Example #28
Source File: ExchangeService.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * 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);
}
 
Example #29
Source File: ResolveNamesRequest.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the request version.
 *
 * @return Earliest Exchange version in which this request is supported.
 */
@Override
protected ExchangeVersion getMinimumRequiredServerVersion() {
  return ExchangeVersion.Exchange2007_SP1;
}
 
Example #30
Source File: GetDelegateRequest.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the request version.
 *
 * @return Earliest Exchange version in which this request is supported
 */
@Override
protected ExchangeVersion getMinimumRequiredServerVersion() {
  return ExchangeVersion.Exchange2007_SP1;
}