public static Principal createFromXml(Element principalElement) throws DavException { if (!DomUtil.matches(principalElement, XML_PRINCIPAL, NAMESPACE)) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:principal element expected."); } if (DomUtil.hasChildElement(principalElement, XML_ALL, NAMESPACE)) { return ALL_PRINCIPAL; } else if (DomUtil.hasChildElement(principalElement, XML_SELF, NAMESPACE)) { return SELF_PRINCIPAL; } else if (DomUtil.hasChildElement(principalElement, XML_AUTHENTICATED, NAMESPACE)) { return AUTHENTICATED_PRINCIPAL; } else if (DomUtil.hasChildElement(principalElement, XML_UNAUTHENTICATED, NAMESPACE)) { return UNAUTHENTICATED_PRINCIPAL; } else if (DomUtil.hasChildElement(principalElement, DavConstants.XML_HREF, DavConstants.NAMESPACE)) { String href = DomUtil.getChildText(principalElement, DavConstants.XML_HREF, DavConstants.NAMESPACE); return getHrefPrincipal(href); } else if (DomUtil.hasChildElement(principalElement, XML_PROPERTY, NAMESPACE)) { Element propEl = DomUtil.getChildElement(principalElement, XML_PROPERTY, NAMESPACE); DavPropertyName pn = DavPropertyName.createFromXml(DomUtil.getFirstChildElement(propEl)); return getPropertyPrincipal(pn); } else { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Invalid structure inside DAV:principal element."); } } }
public static Principal createFromXml(Element principalElement) throws DavException { if (!DomUtil.matches(principalElement, XML_PRINCIPAL, NAMESPACE)) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:principal element expected."); } if (DomUtil.hasChildElement(principalElement, XML_ALL, NAMESPACE)) { return ALL_PRINCIPAL; } else if (DomUtil.hasChildElement(principalElement, XML_SELF, NAMESPACE)) { return SELF_PRINCIPAL; } else if (DomUtil.hasChildElement(principalElement, XML_AUTHENTICATED, NAMESPACE)) { return AUTHENTICATED_PRINCIPAL; } else if (DomUtil.hasChildElement(principalElement, XML_UNAUTHENTICATED, NAMESPACE)) { return UNAUTHENTICATED_PRINCIPAL; } else if (DomUtil.hasChildElement(principalElement, DavConstants.XML_HREF, DavConstants.NAMESPACE)) { String href = DomUtil.getChildText(principalElement, DavConstants.XML_HREF, DavConstants.NAMESPACE); return getHrefPrincipal(href); } else if (DomUtil.hasChildElement(principalElement, XML_PROPERTY, NAMESPACE)) { Element propEl = DomUtil.getChildElement(principalElement, XML_PROPERTY, NAMESPACE); DavPropertyName pn = DavPropertyName.createFromXml(DomUtil.getFirstChildElement(propEl)); return getPropertyPrincipal(pn); } else { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Invalid structure inside DAV:principal element."); } } }
public static Principal createFromXml(Element principalElement) throws DavException { if (!DomUtil.matches(principalElement, XML_PRINCIPAL, NAMESPACE)) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:principal element expected."); } if (DomUtil.hasChildElement(principalElement, XML_ALL, NAMESPACE)) { return ALL_PRINCIPAL; } else if (DomUtil.hasChildElement(principalElement, XML_SELF, NAMESPACE)) { return SELF_PRINCIPAL; } else if (DomUtil.hasChildElement(principalElement, XML_AUTHENTICATED, NAMESPACE)) { return AUTHENTICATED_PRINCIPAL; } else if (DomUtil.hasChildElement(principalElement, XML_UNAUTHENTICATED, NAMESPACE)) { return UNAUTHENTICATED_PRINCIPAL; } else if (DomUtil.hasChildElement(principalElement, DavConstants.XML_HREF, DavConstants.NAMESPACE)) { String href = DomUtil.getChildText(principalElement, DavConstants.XML_HREF, DavConstants.NAMESPACE); return getHrefPrincipal(href); } else if (DomUtil.hasChildElement(principalElement, XML_PROPERTY, NAMESPACE)) { Element propEl = DomUtil.getChildElement(principalElement, XML_PROPERTY, NAMESPACE); DavPropertyName pn = DavPropertyName.createFromXml(DomUtil.getFirstChildElement(propEl)); return getPropertyPrincipal(pn); } else { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "Invalid structure inside DAV:principal element."); } } }