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

The following examples show how to use microsoft.exchange.webservices.data.property.complex.ItemAttachment. 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: ExchangeFileSystem.java    From iaf with 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 #2
Source File: EwsUtilities.java    From ews-java-api with 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 File: CreateAttachmentRequest.java    From ews-java-api with 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 #4
Source File: ExchangeFileSystem.java    From iaf with 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 #5
Source File: EwsUtilities.java    From ews-java-api with 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 #6
Source File: Item.java    From ews-java-api with 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 #7
Source File: Appointment.java    From ews-java-api with 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 #8
Source File: MeetingResponse.java    From ews-java-api with 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 #9
Source File: ICreateServiceObjectWithAttachmentParam.java    From ews-java-api with MIT License 2 votes vote down vote up
/**
 * 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;
 
Example #10
Source File: MeetingRequest.java    From ews-java-api with 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 #11
Source File: MeetingCancellation.java    From ews-java-api with 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 #12
Source File: ContactGroup.java    From ews-java-api with 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 #13
Source File: EmailMessage.java    From ews-java-api with 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 #14
Source File: Contact.java    From ews-java-api with 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 #15
Source File: Task.java    From ews-java-api with 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 #16
Source File: Item.java    From ews-java-api with 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 #17
Source File: Item.java    From ews-java-api with 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 #18
Source File: PostItem.java    From ews-java-api with 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 #19
Source File: MeetingMessage.java    From ews-java-api with 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);
}