Java Code Examples for microsoft.exchange.webservices.data.property.complex.ItemAttachment

The following examples show how to use microsoft.exchange.webservices.data.property.complex.ItemAttachment. 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: CreateAttachmentRequest.java    License: MIT License 6 votes vote down vote up
/**
 * Gets a value indicating whether the TimeZoneContext SOAP header should be
 * emitted.
 */
protected boolean emitTimeZoneHeader() throws ServiceLocalException, Exception {
  {

    ListIterator<Attachment> items = this.getAttachments()
        .listIterator();

    while (items.hasNext())

    {

      ItemAttachment itemAttachment = (ItemAttachment) items.next();

      if ((itemAttachment.getItem() != null)
          && itemAttachment
          .getItem()
          .getIsTimeZoneHeaderRequired(false /* isUpdateOperation */)) {
        return true;
      }
    }

    return false;
  }
}
 
Example 2
Source Project: ews-java-api   Source File: EwsUtilities.java    License: MIT License 6 votes vote down vote up
/**
 * Creates the item from item class.
 *
 * @param itemAttachment the item attachment
 * @param itemClass      the item class
 * @param isNew          the is new
 * @return the item
 * @throws Exception the exception
 */
public static Item createItemFromItemClass(
    ItemAttachment itemAttachment, Class<?> itemClass, boolean isNew)
    throws Exception {
  final ServiceObjectInfo member = EwsUtilities.SERVICE_OBJECT_INFO.getMember();
  final Map<Class<?>, ICreateServiceObjectWithAttachmentParam>
    dataMap = member.getServiceObjectConstructorsWithAttachmentParam();
  final ICreateServiceObjectWithAttachmentParam creationDelegate =
    dataMap.get(itemClass);

  if (creationDelegate != null) {
    return (Item) creationDelegate
        .createServiceObjectWithAttachmentParam(itemAttachment, isNew);
  }
  throw new IllegalArgumentException("No appropriate constructor could be found for this item class.");
}
 
Example 3
Source Project: iaf   Source File: ExchangeFileSystem.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public InputStream readAttachment(Attachment a) throws FileSystemException, IOException {
	try {
		a.load();
	} catch (Exception e) {
		throw new FileSystemException("Cannot load attachment",e);
	}
	byte[] content = null;
	if (a instanceof FileAttachment) {
		content=((FileAttachment)a).getContent(); // TODO: should do streaming, instead of via byte array
	}
	if (a instanceof ItemAttachment) {
		ItemAttachment itemAttachment=(ItemAttachment)a;
		Item attachmentItem = itemAttachment.getItem();
		return readFile(attachmentItem);
	}
	if (content==null) {
		log.warn("content of attachment is null");
		content = new byte[0];
	}
	InputStream binaryInputStream = new ByteArrayInputStream(content);
	return binaryInputStream;
}
 
Example 4
Source Project: ews-java-api   Source File: Item.java    License: MIT License 5 votes vote down vote up
/**
 * Gets a value indicating whether a time zone SOAP header should be emitted
 * in a CreateItem or UpdateItem request so this item can be property saved
 * or updated.
 *
 * @param isUpdateOperation Indicates whether the operation being petrformed is an update
 *                          operation.
 * @return true if a time zone SOAP header should be emitted;
 * otherwise,false
 */
public boolean getIsTimeZoneHeaderRequired(boolean isUpdateOperation)
    throws Exception {
  // Starting E14SP2, attachment will be sent along with CreateItem
  // request.
  // if the attachment used to require the Timezone header, CreateItem
  // request should do so too.
  //

  if (!isUpdateOperation
      && (this.getService().getRequestedServerVersion().ordinal() >= ExchangeVersion.Exchange2010_SP2
      .ordinal())) {

    ListIterator<Attachment> items = this.getAttachments().getItems()
        .listIterator();

    while (items.hasNext()) {

      ItemAttachment itemAttachment = (ItemAttachment) items.next();

      if ((itemAttachment.getItem() != null)
          && itemAttachment
          .getItem()
          .getIsTimeZoneHeaderRequired(false /* isUpdateOperation */)) {
        return true;
      }
    }
  }

/*
               * for (ItemAttachment itemAttachment :
 * this.getAttachments().OfType<ItemAttachment>().getc) { if
 * ((itemAttachment.Item != null) &&
 * itemAttachment.Item.GetIsTimeZoneHeaderRequired(false /* //
 * isUpdateOperation )) { return true; } }
 */

  return super.getIsTimeZoneHeaderRequired(isUpdateOperation);
}
 
Example 5
Source Project: ews-java-api   Source File: Appointment.java    License: MIT License 5 votes vote down vote up
/**
 * Initializes a new instance of Appointment.
 *
 * @param parentAttachment the parent attachment
 * @param isNew            If true, attachment is new.
 * @throws Exception the exception
 */
public Appointment(ItemAttachment parentAttachment, boolean isNew)
    throws Exception {
  // If we're running against Exchange 2007, we need to explicitly preset
  // the StartTimeZone property since Exchange 2007 will otherwise scope
  // start and end to UTC.
  super(parentAttachment);
}
 
Example 6
Source Project: ews-java-api   Source File: EwsUtilities.java    License: MIT License 5 votes vote down vote up
/**
 * Creates the item from xml element name.
 *
 * @param itemAttachment the item attachment
 * @param xmlElementName the xml element name
 * @return the item
 * @throws Exception the exception
 */
public static Item createItemFromXmlElementName(
    ItemAttachment itemAttachment, String xmlElementName)
    throws Exception {
  final ServiceObjectInfo member = EwsUtilities.SERVICE_OBJECT_INFO.getMember();
  final Map<String, Class<?>> map =
    member.getXmlElementNameToServiceObjectClassMap();

  final Class<?> itemClass = map.get(xmlElementName);
  if (itemClass != null) {
    return createItemFromItemClass(itemAttachment, itemClass, false);
  }
  return null;
}
 
Example 7
Source Project: iaf   Source File: ExchangeFileSystem.java    License: Apache License 2.0 5 votes vote down vote up
public Item extractNestedItem(Item item) throws Exception {
	Iterator<Attachment> attachments = listAttachments(item);
	if (attachments!=null) {
		while (attachments.hasNext()) {
			Attachment attachment=attachments.next();
			if (attachment instanceof ItemAttachment) {
				ItemAttachment itemAttachment = (ItemAttachment)attachment;
				itemAttachment.load();
				return itemAttachment.getItem();
			}
		}
	}
	return null;
}
 
Example 8
Source Project: ews-java-api   Source File: MeetingMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Initializes a new instance of the "MeetingMessage" class.
 *
 * @param parentAttachment the parent attachment
 * @throws Exception the exception
 */
public MeetingMessage(ItemAttachment parentAttachment) throws Exception {
  super(parentAttachment);
}
 
Example 9
Source Project: ews-java-api   Source File: PostItem.java    License: MIT License 2 votes vote down vote up
/**
 * Initializes a new instance of the class.
 *
 * @param parentAttachment the parent attachment
 * @throws Exception the exception
 */
public PostItem(ItemAttachment parentAttachment) throws Exception {
  super(parentAttachment);
}
 
Example 10
Source Project: ews-java-api   Source File: Item.java    License: MIT License 2 votes vote down vote up
/**
 * Initializes a new instance of the item class.
 *
 * @param parentAttachment The parent attachment.
 * @throws Exception the exception
 */
public Item(final ItemAttachment parentAttachment) throws Exception {
  this(parentAttachment.getOwner().getService());
  this.parentAttachment = parentAttachment;
}
 
Example 11
Source Project: ews-java-api   Source File: Item.java    License: MIT License 2 votes vote down vote up
/**
 * Gets the parent attachment of this item.
 *
 * @return the parent attachment
 */
public ItemAttachment getParentAttachment() {
  return this.parentAttachment;
}
 
Example 12
Source Project: ews-java-api   Source File: Task.java    License: MIT License 2 votes vote down vote up
/**
 * Initializes a new instance of the class.
 *
 * @param parentAttachment the parent attachment
 * @throws Exception the exception
 */
public Task(ItemAttachment parentAttachment) throws Exception {
  super(parentAttachment);
}
 
Example 13
Source Project: ews-java-api   Source File: Contact.java    License: MIT License 2 votes vote down vote up
/**
 * Initializes a new instance of the {@link Contact} class.
 *
 * @param parentAttachment the parent attachment
 * @throws Exception the exception
 */
public Contact(ItemAttachment parentAttachment) throws Exception {
  super(parentAttachment);
}
 
Example 14
Source Project: ews-java-api   Source File: EmailMessage.java    License: MIT License 2 votes vote down vote up
/**
 * Initializes a new instance of the "EmailMessage" class.
 *
 * @param parentAttachment The parent attachment.
 * @throws Exception the exception
 */
public EmailMessage(ItemAttachment parentAttachment) throws Exception {
  super(parentAttachment);
}
 
Example 15
Source Project: ews-java-api   Source File: MeetingResponse.java    License: MIT License 2 votes vote down vote up
/**
 * Initializes a new instance of the class.
 *
 * @param parentAttachment The parentAttachment
 * @throws Exception the exception
 */
public MeetingResponse(ItemAttachment parentAttachment)
    throws Exception {
  super(parentAttachment);
}
 
Example 16
Source Project: ews-java-api   Source File: ContactGroup.java    License: MIT License 2 votes vote down vote up
/**
 * Initializes an new instance of the class.
 *
 * @param parentAttachment the parent attachment
 * @throws Exception the exception
 */
public ContactGroup(ItemAttachment parentAttachment) throws Exception {
  super(parentAttachment);
}
 
Example 17
Source Project: ews-java-api   Source File: MeetingCancellation.java    License: MIT License 2 votes vote down vote up
/**
 * Initializes a new instance of the class.
 *
 * @param parentAttachment The parent attachment.
 * @throws Exception the exception
 */
public MeetingCancellation(ItemAttachment parentAttachment)
    throws Exception {
  super(parentAttachment);
}
 
Example 18
Source Project: ews-java-api   Source File: MeetingRequest.java    License: MIT License 2 votes vote down vote up
/**
 * Initializes a new instance of the class.
 *
 * @param parentAttachment The parent attachment
 * @throws Exception throws Exception
 */
public MeetingRequest(ItemAttachment parentAttachment) throws Exception {
  super(parentAttachment);
}
 
Example 19
/**
 * Creates the service object with attachment param.
 *
 * @param itemAttachment the item attachment
 * @param isNew          the is new
 * @return the object
 * @throws Exception the exception
 */
Object createServiceObjectWithAttachmentParam(
    ItemAttachment itemAttachment, boolean isNew) throws Exception;