/** * Reads the specified node type. * * @throws ServiceXmlDeserializationException the service xml deserialization exception * @throws XMLStreamException the XML stream exception */ public void read() throws ServiceXmlDeserializationException, XMLStreamException { read(false); }
/** * Reads the element value. * * @param xmlNamespace the xml namespace * @param localName the local name * @return String * @throws Exception the exception */ public String readElementValue(XmlNamespace xmlNamespace, String localName) throws Exception { if (!this.isStartElement(xmlNamespace, localName)) { this.readStartElement(xmlNamespace, localName); } String value = null; if (!this.isEmptyElement()) { value = this.readValue(); } else { this.read(); } return value; }
/** * Read SOAP header. * * @param reader EwsXmlReader. * @throws Exception the exception */ protected void readSoapHeaders(EwsXmlReader reader) throws Exception { reader.readStartElement(XmlNamespace.Soap, XmlElementNames.SOAPHeaderElementName); do { reader.read(); this.readSoapHeader(reader); } while (!reader.isEndElement(XmlNamespace.Soap, XmlElementNames.SOAPHeaderElementName)); }
/** * Loads from XML. * * @param reader The reader. * @throws Exception the exception */ public void loadFromXml(EwsXmlReader reader) throws Exception { do { reader.read(); if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { if (reader.getLocalName().equals(XmlElementNames.ErrorCode)) { this.errorCode = reader .readElementValue(AutodiscoverErrorCode.class); } else if (reader.getLocalName().equals( XmlElementNames.ErrorMessage)) { this.errorMessage = reader.readElementValue(); } else if (reader.getLocalName().equals( XmlElementNames.SettingName)) { this.settingName = reader.readElementValue(); } } } while (!reader.isEndElement(XmlNamespace.Autodiscover, XmlElementNames.DomainSettingError)); }
/** * Loads the settings from XML. * * @param reader the reader * @throws Exception the exception */ public void loadFromXml(EwsXmlReader reader) throws Exception { reader.readStartElement(XmlNamespace.NotSpecified, XmlElementNames.Autodiscover); reader.readStartElement(XmlNamespace.NotSpecified, XmlElementNames.Response); do { reader.read(); if (reader.isStartElement()) { if (!this.tryReadCurrentXmlElement(reader)) { reader.skipCurrentElement(); } } } while (!reader.isEndElement(XmlNamespace.NotSpecified, XmlElementNames.Response)); reader.readEndElement(XmlNamespace.NotSpecified, XmlElementNames.Autodiscover); }
/** * Loads web client urls from XML. * * @param reader The reader. * @param webClientUrls The web client urls. * @param elementName Name of the element. * @throws Exception */ private static void loadWebClientUrlsFromXml(EwsXmlReader reader, WebClientUrlCollection webClientUrls, String elementName) throws Exception { do { reader.read(); if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { if (reader.getLocalName().equals(XmlElementNames.OWAUrl)) { String authMethod = reader.readAttributeValue( XmlAttributeNames.AuthenticationMethod); String owaUrl = reader.readElementValue(); WebClientUrl webClientUrl = new WebClientUrl(authMethod, owaUrl); webClientUrls.getUrls().add(webClientUrl); } else { reader.skipCurrentElement(); } } } while (!reader.isEndElement(XmlNamespace.NotSpecified, elementName)); }
/** * Tries to read value. * * @param value the value * @return boolean * @throws XMLStreamException the XML stream exception * @throws ServiceXmlDeserializationException the service xml deserialization exception */ public boolean tryReadValue(OutParam<String> value) throws XMLStreamException, ServiceXmlDeserializationException { if (!this.isEmptyElement()) { this.read(); if (this.presentEvent.isCharacters()) { value.setParam(this.readValue()); return true; } else { return false; } } else { return false; } }
/** * Reads domain setting from XML. * * @param reader The reader. * @throws Exception the exception */ private void readSettingFromXml(EwsXmlReader reader) throws Exception { DomainSettingName name = null; Object value = null; do { reader.read(); if (reader.getNodeType().nodeType == XmlNodeType.START_ELEMENT) { if (reader.getLocalName().equals( XmlElementNames.DomainStringSetting)) { name = reader.readElementValue(DomainSettingName.class); } else if (reader.getLocalName().equals(XmlElementNames.Value)) { value = reader.readElementValue(); } } } while (!reader.isEndElement(XmlNamespace.Autodiscover, XmlElementNames.DomainSetting)); EwsUtilities.ewsAssert(name != null, "GetDomainSettingsResponse.ReadSettingFromXml", "Missing name element in domain setting"); this.settings.put(name, value); }
/** * Skips the element. * * @param xmlNamespace the xml namespace * @param localName the local name * @throws Exception the exception */ public void skipElement(XmlNamespace xmlNamespace, String localName) throws Exception { if (!this.isEndElement(xmlNamespace, localName)) { if (!this.isStartElement(xmlNamespace, localName)) { this.readStartElement(xmlNamespace, localName); } if (!this.isEmptyElement()) { do { this.read(); } while (!this.isEndElement(xmlNamespace, localName)); } } }
/** * Reads the specified node type. * * @param nodeType Type of the node. * @throws Exception the exception */ public void read(XmlNodeType nodeType) throws Exception { this.read(); if (!this.getNodeType().equals(nodeType)) { throw new ServiceXmlDeserializationException(String .format("The expected XML node type was %s, but the actual type is %s.", nodeType, this .getNodeType())); } }
/** * Load from XML. * * @param reader The reader. * @throws Exception the exception */ protected void loadFromXml(EwsXmlReader reader) throws Exception { do { reader.read(); if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { if (reader.getLocalName().equals(XmlElementNames.DisplayName)) { this.displayName = reader.readElementValue(); } else if (reader.getLocalName().equals( XmlElementNames.LegacyDN)) { this.legacyDN = reader.readElementValue(); } else if (reader.getLocalName().equals( XmlElementNames.DeploymentId)) { this.deploymentId = reader.readElementValue(); } else { reader.skipCurrentElement(); } } } while (!reader.isEndElement(XmlNamespace.NotSpecified, XmlElementNames.User)); }
/** * Skips the element. * * @param namespacePrefix the namespace prefix * @param localName the local name * @throws Exception the exception */ public void skipElement(String namespacePrefix, String localName) throws Exception { if (!this.isEndElement(namespacePrefix, localName)) { if (!this.isStartElement(namespacePrefix, localName)) { this.readStartElement(namespacePrefix, localName); } if (!this.isEmptyElement()) { do { this.read(); } while (!this.isEndElement(namespacePrefix, localName)); } } }
/** * Read XML element. * * @param namespacePrefix The namespace prefix * @param localName Name of the local * @param nodeType Type of the node * @throws Exception the exception */ private void internalReadElement(String namespacePrefix, String localName, XmlNodeType nodeType) throws Exception { read(nodeType); if ((!this.getLocalName().equals(localName)) || (!this.getNamespacePrefix().equals(namespacePrefix))) { throw new ServiceXmlDeserializationException(String.format( "An element node '%s:%s' of the type %s was expected, but node '%s' of type %s was found.", namespacePrefix, localName, nodeType.toString(), this.getName(), this.getNodeType() .toString())); } }
/** * Loads from XML. * * @param reader The reader. * @throws Exception the exception */ public void loadFromXml(EwsXmlReader reader) throws Exception { do { reader.read(); if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { if (reader.getLocalName().equals(XmlElementNames.ErrorCode)) { this.setErrorCode(reader .readElementValue(AutodiscoverErrorCode.class)); } else if (reader.getLocalName().equals( XmlElementNames.ErrorMessage)) { this.setErrorMessage(reader.readElementValue()); } else if (reader.getLocalName().equals( XmlElementNames.SettingName)) { this.setSettingName(reader.readElementValue()); } } } while (!reader.isEndElement(XmlNamespace.Autodiscover, XmlElementNames.UserSettingError)); }
/** * Loads response from XML. * * @param reader the reader * @throws Exception the exception */ private void loadResponseCollectionFromXml(EwsXmlReader reader) throws Exception { if (!reader.isEmptyElement()) { do { reader.read(); if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && (reader.getLocalName().equals(this .getResponseInstanceXmlElementName()))) { TResponse response = this.createResponseInstance(); response.loadFromXml(reader, this .getResponseInstanceXmlElementName()); this.responses.add(response); } } while (!reader.isEndElement(XmlNamespace.Autodiscover, this .getResponseCollectionXmlElementName())); } else { reader.read(); } }
/** * Loads WebClientUrl instance from XML. * * @param reader The reader. * @return WebClientUrl. * @throws Exception the exception */ protected static WebClientUrl loadFromXml(EwsXmlReader reader) throws Exception { WebClientUrl webClientUrl = new WebClientUrl(); do { reader.read(); if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { if (reader.getLocalName().equals( XmlElementNames.AuthenticationMethods)) { webClientUrl.setAuthenticationMethods(reader .readElementValue(String.class)); } else if (reader.getLocalName().equals(XmlElementNames.Url)) { webClientUrl.setUrl(reader.readElementValue(String.class)); } } } while (!reader.isEndElement(XmlNamespace.Autodiscover, XmlElementNames.WebClientUrl)); return webClientUrl; }
/** * Loads instance of WebClientUrlCollection from XML. * * @param reader The reader. * @return the web client url collection * @throws Exception the exception */ public static WebClientUrlCollection loadFromXml(EwsXmlReader reader) throws Exception { WebClientUrlCollection instance = new WebClientUrlCollection(); do { reader.read(); if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && (reader.getLocalName() .equals(XmlElementNames.WebClientUrl))) { instance.getUrls().add(WebClientUrl.loadFromXml(reader)); } } while (!reader.isEndElement(XmlNamespace.Autodiscover, XmlElementNames.WebClientUrls)); return instance; }
/** * Loads instance of AlternateMailboxCollection from XML. * * @param reader the reader * @return AlternateMailboxCollection * @throws Exception the exception */ public static AlternateMailboxCollection loadFromXml(EwsXmlReader reader) throws Exception { AlternateMailboxCollection instance = new AlternateMailboxCollection(); do { reader.read(); if ((reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) && (reader.getLocalName() .equals(XmlElementNames.AlternateMailbox))) { instance.getEntries().add( AlternateMailbox.loadFromXml(reader)); } } while (!reader.isEndElement(XmlNamespace.Autodiscover, XmlElementNames.AlternateMailboxes)); return instance; }
/** * Read user setting with ProtocolConnectionCollection value. * * @param reader EwsServiceXmlReader * @return the protocol connection collection * @throws Exception the exception */ public static ProtocolConnectionCollection loadFromXml(final EwsXmlReader reader) throws Exception { final ProtocolConnectionCollection value = new ProtocolConnectionCollection(); do { reader.read(); if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { if (reader.getLocalName().equals(XmlElementNames.ProtocolConnection)) { final ProtocolConnection connection = ProtocolConnection.loadFromXml(reader); if (connection != null) { value.getConnections().add(connection); } } } } while (!reader.isEndElement(XmlNamespace.Autodiscover, XmlElementNames.ProtocolConnections)); return value; }
/** * Loads response from XML. * * @param reader the reader * @param endElementName End element name. * @throws Exception the exception */ public void loadFromXml(EwsXmlReader reader, String endElementName) throws Exception { do { reader.read(); if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { if (reader.getLocalName().equals( this.getResponseCollectionXmlElementName())) { this.loadResponseCollectionFromXml(reader); } else { super.loadFromXml(reader, endElementName); } } } while (!reader .isEndElement(XmlNamespace.Autodiscover, endElementName)); }