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

The following examples show how to use microsoft.exchange.webservices.data.core.PropertySet. These examples are extracted from open source projects. 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 Project: ews-java-api   Source File: NameResolution.java    License: 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 Project: ews-java-api   Source File: ViewBase.java    License: 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 Project: ews-java-api   Source File: GetAttachmentRequest.java    License: 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 4
Source Project: ews-java-api   Source File: ResolveNamesRequest.java    License: 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 5
Source Project: ews-java-api   Source File: GetFolderResponse.java    License: 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 6
Source Project: ews-java-api   Source File: GetItemResponse.java    License: 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 7
Source Project: ews-java-api   Source File: FindFolderResponse.java    License: 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 8
Source Project: ews-java-api   Source File: FindItemResponse.java    License: 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 9
Source Project: ews-java-api   Source File: FindItemResponse.java    License: 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 10
Source Project: ews-java-api   Source File: Item.java    License: 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 Project: ews-java-api   Source File: Folder.java    License: 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 12
Source Project: localization_nifi   Source File: ConsumeEWS.java    License: 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 Project: ews-java-api   Source File: SyncResponse.java    License: 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 Project: nifi   Source File: ConsumeEWS.java    License: 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 Project: ews-java-api   Source File: ServiceObject.java    License: 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 16
Source Project: ews-java-api   Source File: MeetingResponse.java    License: 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 Project: ews-java-api   Source File: Appointment.java    License: 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 18
Source Project: ews-java-api   Source File: Appointment.java    License: 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 Project: ews-java-api   Source File: MeetingCancellation.java    License: 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 20
Source Project: ews-java-api   Source File: MeetingRequest.java    License: 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 21
Source Project: ews-java-api   Source File: ViewBase.java    License: MIT License 2 votes vote down vote up
/**
 * 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;
}
 
Example 22
Source Project: ews-java-api   Source File: ViewBase.java    License: MIT License 2 votes vote down vote up
/**
 * 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;
}
 
Example 23
Source Project: ews-java-api   Source File: GetRequest.java    License: MIT License 2 votes vote down vote up
/**
 * Gets  the property set.
 *
 * @return the property set
 */
public PropertySet getPropertySet() {
  return this.propertySet;
}
 
Example 24
Source Project: ews-java-api   Source File: GetRequest.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the property set.
 *
 * @param propertySet the new property set
 */
public void setPropertySet(PropertySet propertySet) {
  this.propertySet = propertySet;
}
 
Example 25
Source Project: ews-java-api   Source File: SyncFolderHierarchyRequest.java    License: MIT License 2 votes vote down vote up
/**
 * Gets or sets the property set. <value>The property set.</value>
 *
 * @return the property set
 */
public PropertySet getPropertySet() {
  return this.propertySet;
}
 
Example 26
Source Project: ews-java-api   Source File: SyncFolderHierarchyRequest.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the property set.
 *
 * @param value the new property set
 */
public void setPropertySet(PropertySet value) {
  this.propertySet = value;
}
 
Example 27
Source Project: ews-java-api   Source File: SyncFolderItemsRequest.java    License: MIT License 2 votes vote down vote up
/**
 * Gets or sets the property set. <value>The property set.</value>
 *
 * @return the property set
 */
public PropertySet getPropertySet() {
  return this.propertySet;
}
 
Example 28
Source Project: ews-java-api   Source File: SyncFolderItemsRequest.java    License: MIT License 2 votes vote down vote up
/**
 * Sets the property set.
 *
 * @param propertySet the new property set
 */
public void setPropertySet(PropertySet propertySet) {
  this.propertySet = propertySet;
}
 
Example 29
Source Project: ews-java-api   Source File: ResolveNamesRequest.java    License: MIT License 2 votes vote down vote up
/**
 * Gets or sets the PropertySet for Contact Data
 * <p/>
 * The PropertySet
 */
public void setContactDataPropertySet(PropertySet propertySet) {


  this.contactDataPropertySet = propertySet;
}
 
Example 30
Source Project: ews-java-api   Source File: ResolveNamesRequest.java    License: MIT License 2 votes vote down vote up
/**
 * Gets or sets the PropertySet for Contact Data
 *
 * @return The PropertySet
 */
public PropertySet getContactDataPropertySet() {
  return this.contactDataPropertySet;
}