microsoft.exchange.webservices.data.core.PropertySet Java Examples

The following examples show how to use microsoft.exchange.webservices.data.core.PropertySet. 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: NameResolution.java    From ews-java-api with MIT License 6 votes vote down vote up
/**
 * 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);
  }
}
 
Example #2
Source File: ViewBase.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * Gets the property set or the default.
 *
 * @return PropertySet
 */
public PropertySet getPropertySetOrDefault() {
  if (this.getPropertySet() == null) {
    return PropertySet.getFirstClassProperties();
  } else {
    return this.getPropertySet();
  }
}
 
Example #3
Source File: FindFolderResponse.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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");
}
 
Example #4
Source File: GetItemResponse.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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");
}
 
Example #5
Source File: FindItemResponse.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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");
}
 
Example #6
Source File: GetFolderResponse.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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");
}
 
Example #7
Source File: FindItemResponse.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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<TItem> 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();
  }

}
 
Example #8
Source File: Folder.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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);
}
 
Example #9
Source File: ResolveNamesRequest.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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);
  }
}
 
Example #10
Source File: Item.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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<Item> itemArry = new ArrayList<Item>();
  itemArry.add(this);
  this.getService().internalLoadPropertiesForItems(itemArry, propertySet,
      ServiceErrorHandling.ThrowOnError);
}
 
Example #11
Source File: GetAttachmentRequest.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * 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();
}
 
Example #12
Source File: ConsumeEWS.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Fills the internal message queue if such queue is empty. This is due to
 * the fact that per single session there may be multiple messages retrieved
 * from the email server (see FETCH_SIZE).
 */
protected void fillMessageQueueIfNecessary(ProcessContext context) throws ProcessException {
    if (this.messageQueue.isEmpty()) {
        ExchangeService service = this.initializeIfNecessary(context);
        boolean deleteOnRead = context.getProperty(SHOULD_DELETE_MESSAGES).getValue().equals("true");
        boolean markAsRead = context.getProperty(SHOULD_MARK_READ).getValue().equals("true");

        try {
            //Get Folder
            Folder folder = getFolder(service);

            ItemView view = new ItemView(messageQueue.remainingCapacity());
            view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending);

            SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
            FindItemsResults<Item> findResults = service.findItems(folder.getId(), sf, view);

            if(findResults == null || findResults.getItems().size()== 0){
                return;
            }

            service.loadPropertiesForItems(findResults, PropertySet.FirstClassProperties);

            for (Item item : findResults) {
                EmailMessage ewsMessage = (EmailMessage) item;
                messageQueue.add(parseMessage(ewsMessage));

                if(deleteOnRead){
                    ewsMessage.delete(DeleteMode.HardDelete);
                } else if(markAsRead){
                    ewsMessage.setIsRead(true);
                    ewsMessage.update(ConflictResolutionMode.AlwaysOverwrite);
                }
            }

            service.close();
        } catch (Exception e) {
            throw new ProcessException("Failed retrieving new messages from EWS.", e);
        }
    }
}
 
Example #13
Source File: SyncResponse.java    From ews-java-api with MIT License 4 votes vote down vote up
/**
 * 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");
}
 
Example #14
Source File: ConsumeEWS.java    From nifi with Apache License 2.0 4 votes vote down vote up
/**
 * Fills the internal message queue if such queue is empty. This is due to
 * the fact that per single session there may be multiple messages retrieved
 * from the email server (see FETCH_SIZE).
 */
protected void fillMessageQueueIfNecessary(ProcessContext context) throws ProcessException {
    if (this.messageQueue.isEmpty()) {
        ExchangeService service = this.initializeIfNecessary(context);
        boolean deleteOnRead = context.getProperty(SHOULD_DELETE_MESSAGES).getValue().equals("true");
        boolean markAsRead = context.getProperty(SHOULD_MARK_READ).getValue().equals("true");
        String includeHeaders = context.getProperty(INCLUDE_EMAIL_HEADERS).getValue();
        String excludeHeaders = context.getProperty(EXCLUDE_EMAIL_HEADERS).getValue();

        List<String> includeHeadersList = null;
        List<String> excludeHeadersList = null;

        if (!StringUtils.isEmpty(includeHeaders)) {
            includeHeadersList = Arrays.asList(includeHeaders.split(","));
        }

        if (!StringUtils.isEmpty(excludeHeaders)) {
            excludeHeadersList = Arrays.asList(excludeHeaders.split(","));
        }

        try {
            //Get Folder
            Folder folder = getFolder(service);

            ItemView view = new ItemView(messageQueue.remainingCapacity());
            view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending);

            SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
            FindItemsResults<Item> findResults = service.findItems(folder.getId(), sf, view);

            if(findResults == null || findResults.getItems().size()== 0){
                return;
            }

            service.loadPropertiesForItems(findResults, PropertySet.FirstClassProperties);

            for (Item item : findResults) {
                EmailMessage ewsMessage = (EmailMessage) item;
                messageQueue.add(parseMessage(ewsMessage,includeHeadersList,excludeHeadersList));

                if(deleteOnRead){
                    ewsMessage.delete(DeleteMode.HardDelete);
                } else if(markAsRead){
                    ewsMessage.setIsRead(true);
                    ewsMessage.update(ConflictResolutionMode.AlwaysOverwrite);
                }
            }

            service.close();
        } catch (Exception e) {
            throw new ProcessException("Failed retrieving new messages from EWS.", e);
        }
    }
}
 
Example #15
Source File: MeetingRequest.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * 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;
  }
}
 
Example #16
Source File: MeetingResponse.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * 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;
  }
}
 
Example #17
Source File: MeetingCancellation.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * 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;
  }
}
 
Example #18
Source File: Appointment.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * 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);
}
 
Example #19
Source File: Appointment.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * 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);
}
 
Example #20
Source File: ServiceObject.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * 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);

}
 
Example #21
Source File: ContactsFolder.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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());
}
 
Example #22
Source File: Appointment.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example #23
Source File: ContactsFolder.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example #24
Source File: TasksFolder.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example #25
Source File: MeetingRequest.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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());
}
 
Example #26
Source File: TasksFolder.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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());
}
 
Example #27
Source File: SuppressReadReceipt.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Loads the specified set of property on the object.
 *
 * @param propertySet the property set
 */
@Override
protected void internalLoad(PropertySet propertySet) {
  throw new UnsupportedOperationException();
}
 
Example #28
Source File: PostReply.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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.");
}
 
Example #29
Source File: TasksFolder.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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);
}
 
Example #30
Source File: MeetingCancellation.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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());
}