/**
  * Writes elements to XML.
  *
  * @param reader the reader
  * @return true, if successful
  * @throws Exception the exception
  */
 @Override
 protected boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception {
   if (PhysicalAddressSchema.getXmlElementNames().contains(reader.getLocalName())) {
     this.propertyBag.setSimplePropertyBag(reader.getLocalName(), reader.readElementValue());
     return true;
   } else {
     return false;
   }
 }
예제 #2
0
  /**
   * Read items from XML.
   *
   * @param reader The reader
   * @param propertySet The property set
   * @param destinationList The list in which to add the read items.
   * @throws javax.xml.stream.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();
    }
  }
예제 #3
0
  /**
   * * Tries to read element from XML.
   *
   * @param reader the reader
   * @return True if element was read.
   * @throws Exception the exception
   */
  @Override
  protected boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception {
    boolean result = super.tryReadElementFromXml(reader);

    if (!result) {
      if (reader.getLocalName().equals(XmlElementNames.IsContactPhoto)) {
        this.isContactPhoto = reader.readElementValue(Boolean.class);
      } else if (reader.getLocalName().equals(XmlElementNames.Content)) {
        if (this.loadToStream != null) {
          reader.readBase64ElementValue(this.loadToStream);
        } else {
          // If there's a file attachment content handler, use it.
          // Otherwise
          // load the content into a byte array.
          // TODO: Should we mark the attachment to indicate that
          // content is stored elsewhere?
          if (reader.getService().getFileAttachmentContentHandler() != null) {
            OutputStream outputStream =
                reader.getService().getFileAttachmentContentHandler().getOutputStream(getId());
            if (outputStream != null) {
              reader.readBase64ElementValue(outputStream);
            } else {
              this.content = reader.readBase64ElementValue();
            }
          } else {
            this.content = reader.readBase64ElementValue();
          }
        }

        result = true;
      }
    }

    return result;
  }
  /**
   * Tries to read element from XML.
   *
   * @param reader the reader
   * @return Returns true if element was read.
   * @throws Exception the exception
   */
  protected boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception {
    DelegateFolderPermission delegateFolderPermission = null;

    if (this.delegateFolderPermissions.containsKey(reader.getLocalName())) {
      delegateFolderPermission = this.delegateFolderPermissions.get(reader.getLocalName());
      delegateFolderPermission.initialize(
          reader.readElementValue(DelegateFolderPermissionLevel.class));
    }

    return delegateFolderPermission != null;
  }
 /**
  * Tries to read element from XML.
  *
  * @param reader the reader
  * @return True if element was read
  * @throws Exception the exception
  */
 protected boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception {
   if (super.tryReadElementFromXml(reader)) {
     return true;
   } else {
     if (reader.getLocalName().equals(XmlElementNames.NumberOfOccurrences)) {
       this.numberOfOccurrences = reader.readElementValue(Integer.class);
       return true;
     } else {
       return false;
     }
   }
 }
 /**
  * Tries to read element from XML.
  *
  * @return true
  * @throws Exception
  */
 @Override
 protected boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception {
   if (reader.getLocalName().equals(XmlElementNames.OperationIndex)) {
     this.operationIndex = reader.readElementValue(Integer.class);
     return true;
   } else if (reader.getLocalName().equals(XmlElementNames.ValidationErrors)) {
     this.ruleErrors = new RuleErrorCollection();
     this.ruleErrors.loadFromXml(reader, reader.getLocalName());
     return true;
   } else {
     return false;
   }
 }
 /**
  * Tries to read element from XML.
  *
  * @param reader accepts EwsServiceXmlReader
  * @return True if element was read.
  * @throws Exception throws Exception
  */
 @Override
 protected boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception {
   if (super.tryReadElementFromXml(reader)) {
     return true;
   } else {
     if (reader.getLocalName().equals(XmlElementNames.DayOfWeek)) {
       this.dayOfTheWeek = reader.readElementValue(DayOfTheWeek.class);
       return true;
     } else if (reader.getLocalName().equals(XmlElementNames.Occurrence)) {
       this.weekIndex = reader.readElementValue(Integer.class);
       return true;
     } else {
       return false;
     }
   }
 }
  /**
   * * Loads from XML.
   *
   * @param reader the reader
   * @param localElementName the local element name
   * @throws Exception the exception
   */
  @Override
  protected void loadFromXml(EwsServiceXmlReader reader, String localElementName) throws Exception {
    reader.ensureCurrentNodeIsStartElement(XmlNamespace.Types, localElementName);

    reader.readStartElement(XmlNamespace.Types, this.getInnerCollectionXmlElementName());
    super.loadFromXml(reader, this.getInnerCollectionXmlElementName());
    reader.readEndElementIfNecessary(XmlNamespace.Types, this.getInnerCollectionXmlElementName());

    reader.read();

    if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.UnknownEntries)) {
      do {
        reader.read();

        if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.UnknownEntry)) {
          this.unknownEntries.add(reader.readElementValue());
        }
      } while (!reader.isEndElement(XmlNamespace.Types, XmlElementNames.UnknownEntries));
    }
  }
예제 #9
0
  /**
   * * Tries to read element from XML.
   *
   * @param reader accepts EwsServiceXmlReader
   * @return True if element was read
   * @throws Exception throws Exception
   */
  @Override
  protected boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception {

    if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Offset)) {
      this.offset = EwsUtilities.getXSDurationToTimeSpan(reader.readElementValue());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.RelativeYearlyRecurrence)) {
      this.recurrence = new TimeChangeRecurrence();
      this.recurrence.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.AbsoluteDate)) {
      SimpleDateFormat sdfin = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
      Date tempDate = sdfin.parse(reader.readElementValue());
      this.absoluteDate = tempDate;
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Time)) {
      SimpleDateFormat sdfin = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
      Date tempDate = sdfin.parse(reader.readElementValue());
      this.time = new Time(tempDate);
      return true;
    } else {
      return false;
    }
  }
예제 #10
0
  /**
   * Reads response elements from XML.
   *
   * @param reader ,The reader
   * @throws Exception the exception
   */
  @Override
  protected void readElementsFromXml(EwsServiceXmlReader reader) throws Exception {
    reader.readStartElement(XmlNamespace.Messages, XmlElementNames.RootFolder);

    int totalItemsInView =
        reader.readAttributeValue(Integer.class, XmlAttributeNames.TotalItemsInView);
    boolean moreItemsAvailable =
        !reader.readAttributeValue(Boolean.class, XmlAttributeNames.IncludesLastItemInRange);

    // Ignore IndexedPagingOffset attribute if moreItemsAvailable is false.
    Integer nextPageOffset =
        moreItemsAvailable
            ? reader.readNullableAttributeValue(
                Integer.class, XmlAttributeNames.IndexedPagingOffset)
            : null;

    if (!this.isGrouped) {
      this.results = new FindItemsResults<TItem>();
      this.results.setTotalCount(totalItemsInView);
      this.results.setNextPageOffset(nextPageOffset);
      this.results.setMoreAvailable(moreItemsAvailable);
      internalReadItemsFromXml(reader, this.propertySet, this.results.getItems());
    } else {
      this.groupedFindResults = new GroupedFindItemsResults<TItem>();
      this.groupedFindResults.setTotalCount(totalItemsInView);
      this.groupedFindResults.setNextPageOffset(nextPageOffset);
      this.groupedFindResults.setMoreAvailable(moreItemsAvailable);

      reader.readStartElement(XmlNamespace.Types, XmlElementNames.Groups);

      if (!reader.isEmptyElement()) {
        do {
          reader.read();

          if (reader.isStartElement(XmlNamespace.Types, XmlElementNames.GroupedItems)) {
            String groupIndex =
                reader.readElementValue(XmlNamespace.Types, XmlElementNames.GroupIndex);

            ArrayList<TItem> itemList = new ArrayList<TItem>();
            internalReadItemsFromXml(reader, this.propertySet, itemList);

            reader.readEndElement(XmlNamespace.Types, XmlElementNames.GroupedItems);

            this.groupedFindResults.getItemGroups().add(new ItemGroup<TItem>(groupIndex, itemList));
          }
        } while (!reader.isEndElement(XmlNamespace.Types, XmlElementNames.Groups));
      } else {
        reader.read();
      }
    }

    reader.readEndElement(XmlNamespace.Messages, XmlElementNames.RootFolder);
  }
 /**
  * Loads from XML.
  *
  * @param reader the reader
  * @param propertyBag the property bag
  * @throws Exception the exception
  */
 protected void loadPropertyValueFromXml(EwsServiceXmlReader reader, PropertyBag propertyBag)
     throws Exception {
   String value = reader.readElementValue(XmlNamespace.Types, getXmlElement());
   propertyBag.setObjectFromPropertyDefinition(
       this, reader.getService().convertUniversalDateTimeStringToDate(value));
 }
예제 #12
0
 /**
  * * Reads the attributes from XML.
  *
  * @param reader accepts EwsServiceXmlReader
  * @throws Exception throws Exception
  */
 @Override
 protected void readAttributesFromXml(EwsServiceXmlReader reader) throws Exception {
   this.timeZoneName = reader.readAttributeValue(XmlAttributeNames.TimeZoneName);
 }
  /**
   * Tries to read element from XML.
   *
   * @param reader The reader
   * @throws Exception
   * @return True if element was read.
   */
  @Override
  protected boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception {

    if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Categories)) {
      this.categories.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsBodyStrings)) {
      this.containsBodyStrings.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsHeaderStrings)) {
      this.containsHeaderStrings.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsRecipientStrings)) {
      this.containsRecipientStrings.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsSenderStrings)) {
      this.containsSenderStrings.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader
        .getLocalName()
        .equalsIgnoreCase(XmlElementNames.ContainsSubjectOrBodyStrings)) {
      this.containsSubjectOrBodyStrings.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ContainsSubjectStrings)) {
      this.containsSubjectStrings.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.FlaggedForAction)) {
      this.flaggedForAction = reader.readElementValue(FlaggedForAction.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.FromAddresses)) {
      this.fromAddresses.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.FromConnectedAccounts)) {
      this.fromConnectedAccounts.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.HasAttachments)) {
      this.hasAttachments = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Importance)) {
      this.importance = reader.readElementValue(Importance.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsApprovalRequest)) {
      this.isApprovalRequest = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsAutomaticForward)) {
      this.isAutomaticForward = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsAutomaticReply)) {
      this.isAutomaticReply = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsEncrypted)) {
      this.isEncrypted = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsMeetingRequest)) {
      this.isMeetingRequest = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsMeetingResponse)) {
      this.isMeetingResponse = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsNDR)) {
      this.isNonDeliveryReport = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsPermissionControlled)) {
      this.isPermissionControlled = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsSigned)) {
      this.isSigned = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsVoicemail)) {
      this.isVoicemail = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.IsReadReceipt)) {
      this.isReadReceipt = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ItemClasses)) {
      this.itemClasses.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.MessageClassifications)) {
      this.messageClassifications.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.NotSentToMe)) {
      this.notSentToMe = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentCcMe)) {
      this.sentCcMe = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentOnlyToMe)) {
      this.sentOnlyToMe = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentToAddresses)) {
      this.sentToAddresses.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentToMe)) {
      this.sentToMe = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.SentToOrCcMe)) {
      this.sentToOrCcMe = reader.readElementValue(Boolean.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Sensitivity)) {
      this.sensitivity = reader.readElementValue(Sensitivity.class);
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.WithinDateRange)) {
      this.withinDateRange.loadFromXml(reader, reader.getLocalName());
      return true;
    } else if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.WithinSizeRange)) {
      this.withinSizeRange.loadFromXml(reader, reader.getLocalName());
      return true;
    } else {
      return false;
    }
  }
예제 #14
0
 /**
  * Loads the attributes from XML.
  *
  * @param reader the reader
  * @throws Exception the exception
  */
 protected void loadAttributesFromXml(EwsServiceXmlReader reader) throws Exception {
   this.setFormat(reader.readAttributeValue(IdFormat.class, XmlAttributeNames.Format));
 }