/** * Tries to read the current XML element. * * @param reader the reader * @return True is the current element was read, false otherwise. * @throws Exception the exception */ public boolean tryReadCurrentXmlElement(EwsXmlReader reader) throws Exception { if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Error)) { this.error = AutodiscoverError.parse(reader); return true; } else { return false; } }
/** * Initializes a new instance of the AutodiscoverResponse class. * * @param reader the reader * @param endElementName the end element name * @throws Exception the exception */ public void loadFromXml(EwsXmlReader reader, String endElementName) throws Exception { if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.ErrorCode)) { this.errorCode = reader .readElementValue(AutodiscoverErrorCode.class); } else if (reader.getLocalName().equalsIgnoreCase( XmlElementNames.ErrorMessage)) { this.errorMessage = reader.readElementValue(); } }
/** * Skips the current element. * * @throws Exception the exception */ public void skipCurrentElement() throws Exception { this.skipElement(this.getNamespacePrefix(), this.getLocalName()); }
/** * Tries to read the current XML element. * * @param reader the reader * @return true is the current element was read, false otherwise * @throws Exception the exception */ @Override public boolean tryReadCurrentXmlElement(EwsXmlReader reader) throws Exception { if (!super.tryReadCurrentXmlElement(reader)) { if (reader.getLocalName().equals(XmlElementNames.User)) { this.user.loadFromXml(reader); return true; } else if (reader.getLocalName().equals(XmlElementNames.Account)) { this.account.loadFromXml(reader); return true; } else { reader.skipCurrentElement(); return false; } } else { return true; } }
/** * 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)); }
/** * Determines whether current element is a start element. * * @param xmlNamespace the xml namespace * @param localName the local name * @return true for matching start element; false otherwise. */ public boolean isStartElement(XmlNamespace xmlNamespace, String localName) { return this.isStartElement() && StringUtils.equals(getLocalName(), localName) && ( StringUtils.equals(getNamespacePrefix(), EwsUtilities.getNamespacePrefix(xmlNamespace)) || StringUtils.equals(getNamespaceUri(), EwsUtilities.getNamespaceUri(xmlNamespace))); }
/** * Read element value. * * @return String * @throws Exception the exception */ public String readElementValue() throws Exception { this.ensureCurrentNodeIsStartElement(); return this.readElementValue(this.getNamespacePrefix(), this .getLocalName()); }
/** * 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)); }
/** * 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); }
/** * Loads response from XML. * * @param reader The reader. * @param endElementName End element name. * @throws Exception the exception */ @Override public void loadFromXml(EwsXmlReader reader, String endElementName) throws Exception { do { reader.read(); if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { if (reader.getLocalName() .equals(XmlElementNames.RedirectTarget)) { this.setRedirectTarget(reader.readElementValue()); } else if (reader.getLocalName().equals( XmlElementNames.UserSettingErrors)) { this.loadUserSettingErrorsFromXml(reader); } else if (reader.getLocalName().equals( XmlElementNames.UserSettings)) { this.loadUserSettingsFromXml(reader); } else { super.loadFromXml(reader, endElementName); } } } while (!reader .isEndElement(XmlNamespace.Autodiscover, endElementName)); }
/** * 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)); }
/** * Read user setting with ProtocolConnection value. * * @param reader EwsServiceXmlReader * @return the protocol connection * @throws Exception the exception */ protected static ProtocolConnection loadFromXml(EwsXmlReader reader) throws Exception { ProtocolConnection connection = new ProtocolConnection(); do { reader.read(); if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) { if (reader.getLocalName().equals( XmlElementNames.EncryptionMethod)) { connection.setEncryptionMethod(reader .readElementValue(String.class)); } else if (reader.getLocalName().equals( XmlElementNames.Hostname)) { connection.setHostname(reader .readElementValue(String.class)); } else if (reader.getLocalName().equals(XmlElementNames.Port)) { connection.setPort(reader.readElementValue(int.class)); } } } while (!reader.isEndElement(XmlNamespace.Autodiscover, XmlElementNames.ProtocolConnection)); return connection; }
/** * 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 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)); }
/** * 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)); }
/** * 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(); } }