microsoft.exchange.webservices.data.core.enumeration.property.BodyType Java Examples

The following examples show how to use microsoft.exchange.webservices.data.core.enumeration.property.BodyType. 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: ExchangeService.java    From ews-java-api with MIT License 6 votes vote down vote up
/**
 * Gets an attachment.
 *
 * @param attachments          the attachments
 * @param bodyType             the body type
 * @param additionalProperties the additional property
 * @param errorHandling        the error handling
 * @throws Exception the exception
 */
private ServiceResponseCollection<GetAttachmentResponse> internalGetAttachments(
    Iterable<Attachment> attachments, BodyType bodyType,
    Iterable<PropertyDefinitionBase> additionalProperties, ServiceErrorHandling errorHandling)
    throws Exception {
  GetAttachmentRequest request = new GetAttachmentRequest(this, errorHandling);

  Iterator<Attachment> it = attachments.iterator();
  while (it.hasNext()) {
    request.getAttachments().add(it.next());
  }
  request.setBodyType(bodyType);

  if (additionalProperties != null) {
    List<PropertyDefinitionBase> propsArray = new ArrayList<PropertyDefinitionBase>();
    for (PropertyDefinitionBase propertyDefinitionBase : additionalProperties) {
      propsArray.add(propertyDefinitionBase);
    }
    request.getAdditionalProperties().addAll(propsArray);
  }

  return request.execute();
}
 
Example #2
Source File: MessageBody.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * Reads text value from XML.
 *
 * @param reader the reader
 * @throws XMLStreamException the XML stream exception
 * @throws ServiceXmlDeserializationException the service xml deserialization exception
 */
@Override
public void readTextValueFromXml(EwsServiceXmlReader reader)
    throws XMLStreamException, ServiceXmlDeserializationException {
  if (log.isDebugEnabled()) {
     log.debug("Reading text value from XML. BodyType = " + this.getBodyType() +
        ", keepWhiteSpace = " +
        ((this.getBodyType() == BodyType.Text) ? "true." : "false."));
  }
  this.text = reader.readValue(this.getBodyType() == BodyType.Text);
  if (log.isDebugEnabled()) {
     log.debug("Text value read:\n---\n" + this.text + "\n---");
  }
}
 
Example #3
Source File: MessageBody.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * Writes attribute to XML.
 *
 * @param writer The writer.
 * @throws ServiceXmlSerializationException the service xml serialization exception
 */
@Override
public void writeAttributesToXml(EwsServiceXmlWriter writer)
    throws ServiceXmlSerializationException {
  writer.writeAttributeValue(XmlAttributeNames.BodyType, this
      .getBodyType());
}
 
Example #4
Source File: MessageBody.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * Sets the type of the message body's text.
 *
 * @param bodyType BodyType enum
 */
public void setBodyType(BodyType bodyType) {
  if (this.canSetFieldValue(this.bodyType, bodyType)) {
    this.bodyType = bodyType;
    this.changed();
  }
}
 
Example #5
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 #6
Source File: ExchangeService.java    From ews-java-api with MIT License 5 votes vote down vote up
/**
 * Gets the attachment.
 *
 * @param attachment           the attachment
 * @param bodyType             the body type
 * @param additionalProperties the additional property
 * @throws Exception the exception
 */
public void getAttachment(Attachment attachment, BodyType bodyType,
    Iterable<PropertyDefinitionBase> additionalProperties)
    throws Exception {

  List<Attachment> attachmentArray = new ArrayList<Attachment>();
  attachmentArray.add(attachment);

  this.internalGetAttachments(attachmentArray, bodyType, additionalProperties,
                              ServiceErrorHandling.ThrowOnError);

}
 
Example #7
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 #8
Source File: UniqueBodyTest.java    From ews-java-api with MIT License 4 votes vote down vote up
@Test public void testWriteAttributesToXml() throws Exception {
  impl.writeAttributesToXml(writer);
  verify(writer).writeAttributeValue(XmlAttributeNames.BodyType, impl.getBodyType());
}
 
Example #9
Source File: UniqueBodyTest.java    From ews-java-api with MIT License 4 votes vote down vote up
@Test public void testReadAttributesFromXml() throws Exception {
  doReturn(BodyType.Text).when(reader).readAttributeValue(BodyType.class, XmlAttributeNames.BodyType);
  impl.readAttributesFromXml(reader);
  assertEquals(BodyType.Text, impl.getBodyType());
}
 
Example #10
Source File: ExchangeService.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * Gets attachments.
 *
 * @param attachments          the attachments
 * @param bodyType             the body type
 * @param additionalProperties the additional property
 * @return service response collection
 * @throws Exception on error
 */
protected ServiceResponseCollection<GetAttachmentResponse> getAttachments(
    Attachment[] attachments, BodyType bodyType,
    Iterable<PropertyDefinitionBase> additionalProperties)
    throws Exception {
  return this.internalGetAttachments(Arrays.asList(attachments), bodyType,
      additionalProperties, ServiceErrorHandling.ReturnErrors);
}
 
Example #11
Source File: Attachment.java    From ews-java-api with MIT License 3 votes vote down vote up
/**
 * Load the attachment.
 *
 * @param bodyType             Type of the body.
 * @param additionalProperties The additional property.
 * @throws Exception the exception
 */
protected void internalLoad(BodyType bodyType,
    Iterable<PropertyDefinitionBase> additionalProperties)
    throws Exception {
  this.getOwner().getService().getAttachment(this, bodyType,
      additionalProperties);
}
 
Example #12
Source File: UniqueBody.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the type of the unique body's text.
 *
 * @return bodytype
 */
public BodyType getBodyType() {
  return this.bodyType;
}
 
Example #13
Source File: GetAttachmentRequest.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Sets the body type.
 *
 * @param bodyType the new body type
 */
public void setBodyType(BodyType bodyType) {
  this.bodyType = bodyType;
}
 
Example #14
Source File: GetAttachmentRequest.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets  the type of the body.
 *
 * @return the body type
 */
public BodyType getBodyType() {

  return this.bodyType;

}
 
Example #15
Source File: PropertySet.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Sets type of body that should be loaded on item. If RequestedBodyType is
 * null, body is returned as HTML if available, plain text otherwise.
 *
 * @param requestedBodyType Type of body that should be loaded on item.
 */
public void setRequestedBodyType(BodyType requestedBodyType) {
  this.throwIfReadonly();
  this.requestedBodyType = requestedBodyType;
}
 
Example #16
Source File: PropertySet.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets type of body that should be loaded on item. If RequestedBodyType
 * is null, body is returned as HTML if available, plain text otherwise.
 *
 * @return the requested body type
 */
public BodyType getRequestedBodyType() {
  return this.requestedBodyType;
}
 
Example #17
Source File: MessageBody.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Initializes a new instance.
 *
 * @param bodyType The type of the message body's text.
 * @param text     The text of the message body.
 */
public MessageBody(BodyType bodyType, String text) {
  this();
  this.bodyType = bodyType;
  this.text = text;
}
 
Example #18
Source File: UniqueBody.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Writes attributes from XML.
 *
 * @param writer the writer
 * @throws ServiceXmlSerializationException the service xml serialization exception
 */
public void writeAttributesToXml(EwsServiceXmlWriter writer)
    throws ServiceXmlSerializationException {
  writer.writeAttributeValue(XmlAttributeNames.BodyType, this.bodyType);
}
 
Example #19
Source File: UniqueBody.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Reads attribute from XML.
 *
 * @param reader the reader
 * @throws Exception the exception
 */
public void readAttributesFromXml(EwsServiceXmlReader reader)
    throws Exception {
  this.bodyType = reader.readAttributeValue(BodyType.class,
      XmlAttributeNames.BodyType);
}
 
Example #20
Source File: ItemAttachment.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Loads this attachment.
 *
 * @param bodyType             the body type
 * @param additionalProperties the additional property
 * @throws Exception the exception
 */
public void load(BodyType bodyType,
    Iterable<PropertyDefinitionBase> additionalProperties)
    throws Exception {
  this.internalLoad(bodyType, additionalProperties);
}
 
Example #21
Source File: ItemAttachment.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Loads this attachment.
 *
 * @param bodyType             the body type
 * @param additionalProperties the additional property
 * @throws Exception the exception
 */
public void load(BodyType bodyType,
    PropertyDefinitionBase... additionalProperties) throws Exception {
  internalLoad(bodyType, Arrays.asList(additionalProperties));
}
 
Example #22
Source File: MessageBody.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Gets the type of the message body's text.
 *
 * @return BodyType enum
 */
public BodyType getBodyType() {
  return this.bodyType;
}
 
Example #23
Source File: MessageBody.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Reads attribute from XML.
 *
 * @param reader The reader.
 * @throws Exception the exception
 */
public void readAttributesFromXml(EwsServiceXmlReader reader)
    throws Exception {
  this.bodyType = reader.readAttributeValue(BodyType.class,
      XmlAttributeNames.BodyType);
}
 
Example #24
Source File: MessageBody.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Defines an implicit conversation between a string and MessageBody.
 *
 * @param textBody The string to convert to MessageBody, assumed to be HTML.
 * @return A MessageBody initialized with the specified string.
 */
public static MessageBody getMessageBodyFromText(String textBody) {
  return new MessageBody(BodyType.HTML, textBody);
}
 
Example #25
Source File: MessageBody.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * Initializes a new instance.
 *
 * @param text The text of the message body, assumed to be HTML.
 */
public MessageBody(String text) {
  this(BodyType.HTML, text);
}