/** * <p> * Returns an instance of <code>StandardDavProperty</code> representing * the given element. The element itself is provided as the property value. * If either the element or its parent element has the attribute * <code>xml:lang</code>, that attribute's value is provided as the * property's language. The resulting property is not "protected" (i.e. * it will not appear in "allprop" <code>PROPFIND</code> responses). * </p> */ public static StandardDavProperty createFromXml(Element e) { DavPropertyName name = DavPropertyName.createFromXml(e); String lang = DomUtil.getAttribute(e, XML_LANG, NAMESPACE_XML); if (lang == null && e.getParentNode() != null && e.getParentNode().getNodeType() == Node.ELEMENT_NODE) { lang = DomUtil.getAttribute((Element)e.getParentNode(), XML_LANG, NAMESPACE_XML); } return new StandardDavProperty(name, e, lang); }
/** * <p> * Returns an instance of <code>StandardDavProperty</code> representing * the given element. The element itself is provided as the property value. * If either the element or its parent element has the attribute * <code>xml:lang</code>, that attribute's value is provided as the * property's language. The resulting property is not "protected" (i.e. * it will not appear in "allprop" <code>PROPFIND</code> responses). * </p> */ public static StandardDavProperty createFromXml(Element e) { DavPropertyName name = DavPropertyName.createFromXml(e); String lang = DomUtil.getAttribute(e, XML_LANG, NAMESPACE_XML); if (lang == null && e.getParentNode() != null && e.getParentNode().getNodeType() == Node.ELEMENT_NODE) { lang = DomUtil.getAttribute((Element)e.getParentNode(), XML_LANG, NAMESPACE_XML); } return new StandardDavProperty(name, e, lang); }
throw new IllegalArgumentException("Cannot create a new DavProperty from a 'null' element."); DavPropertyName name = DavPropertyName.createFromXml(propertyElement); Object value;
/** * Create a new <code>DavPropertyNameSet</code> from the given DAV:prop * element. * * @param propElement * @throws IllegalArgumentException if the specified element is <code>null</code> * or is not a DAV:prop element. */ public DavPropertyNameSet(Element propElement) { if (!DomUtil.matches(propElement, XML_PROP, NAMESPACE)) { throw new IllegalArgumentException("'DAV:prop' element expected."); } // fill the set ElementIterator it = DomUtil.getChildren(propElement); while (it.hasNext()) { add(DavPropertyName.createFromXml(it.nextElement())); } }
private static DavPropertyName findPrincipalProperty(ReportInfo info) throws CosmoDavException { Element pp = info.getContentElement(ELEMENT_ACL_PRINCIPAL_PROPERTY, NAMESPACE); if (pp == null) { return null; } ElementIterator ei = DomUtil.getChildren(pp); if (! ei.hasNext()) { return null; } return DavPropertyName.createFromXml(ei.nextElement()); } }
throw new IllegalArgumentException("Cannot create a new DavProperty from a 'null' element."); DavPropertyName name = DavPropertyName.createFromXml(propertyElement); DefaultDavProperty<?> prop;
/** * Create a new <code>DavPropertyNameSet</code> from the given DAV:prop * element. * * @param propElement * @throws IllegalArgumentException if the specified element is <code>null</code> * or is not a DAV:prop element. */ public DavPropertyNameSet(Element propElement) { if (!DomUtil.matches(propElement, XML_PROP, NAMESPACE)) { throw new IllegalArgumentException("'DAV:prop' element expected."); } // fill the set ElementIterator it = DomUtil.getChildren(propElement); while (it.hasNext()) { add(DavPropertyName.createFromXml(it.nextElement())); } }
private static DavPropertyName findPrincipalProperty(ReportInfo info) throws CosmoDavException { Element pp = info.getContentElement(ELEMENT_ACL_PRINCIPAL_PROPERTY, NAMESPACE); if (pp == null) { return null; } ElementIterator ei = DomUtil.getChildren(pp); if (! ei.hasNext()) { return null; } return DavPropertyName.createFromXml(ei.nextElement()); } }
/** * Create a new <code>DavPropertyNameSet</code> from the given DAV:prop * element. * * @param propElement * @throws IllegalArgumentException if the specified element is <code>null</code> * or is not a DAV:prop element. */ public DavPropertyNameSet(Element propElement) { if (!DomUtil.matches(propElement, XML_PROP, NAMESPACE)) { throw new IllegalArgumentException("'DAV:prop' element expected."); } // fill the set ElementIterator it = DomUtil.getChildren(propElement); while (it.hasNext()) { add(DavPropertyName.createFromXml(it.nextElement())); } }
throw new IllegalArgumentException("Cannot create a new DavProperty from a 'null' element."); DavPropertyName name = DavPropertyName.createFromXml(propertyElement); DefaultDavProperty<?> prop;
/** * @see Report#init(DavResource, ReportInfo) */ public void init(DavResource resource, ReportInfo info) throws DavException { super.init(resource, info); if (info.containsContentElement(XML_PRINCIPAL_PROPERTY, SecurityConstants.NAMESPACE)) { Element pp = info.getContentElement(XML_PRINCIPAL_PROPERTY, SecurityConstants.NAMESPACE); principalPropertyName = DavPropertyName.createFromXml(DomUtil.getFirstChildElement(pp)); } else if (info.containsContentElement(XML_SELF, SecurityConstants.NAMESPACE)) { principalPropertyName = SecurityConstants.PRINCIPAL_URL; } else { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:self or DAV:principal-property element required within report info."); } }
/** * @see Report#init(DavResource, ReportInfo) */ @Override public void init(DavResource resource, ReportInfo info) throws DavException { super.init(resource, info); if (info.containsContentElement(XML_PRINCIPAL_PROPERTY, SecurityConstants.NAMESPACE)) { Element pp = info.getContentElement(XML_PRINCIPAL_PROPERTY, SecurityConstants.NAMESPACE); principalPropertyName = DavPropertyName.createFromXml(DomUtil.getFirstChildElement(pp)); } else if (info.containsContentElement(XML_SELF, SecurityConstants.NAMESPACE)) { principalPropertyName = SecurityConstants.PRINCIPAL_URL; } else { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:self or DAV:principal-property element required within report info."); } }
/** * @see Report#init(DavResource, ReportInfo) */ @Override public void init(DavResource resource, ReportInfo info) throws DavException { super.init(resource, info); if (info.containsContentElement(XML_PRINCIPAL_PROPERTY, SecurityConstants.NAMESPACE)) { Element pp = info.getContentElement(XML_PRINCIPAL_PROPERTY, SecurityConstants.NAMESPACE); principalPropertyName = DavPropertyName.createFromXml(DomUtil.getFirstChildElement(pp)); } else if (info.containsContentElement(XML_SELF, SecurityConstants.NAMESPACE)) { principalPropertyName = SecurityConstants.PRINCIPAL_URL; } else { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "DAV:self or DAV:principal-property element required within report info."); } }
public static SearchSpec createFromXml(Element root) throws CosmoDavException { if (! DomUtil.matches(root, "property-search", NAMESPACE)) { throw new IllegalArgumentException("Expected root element DAV:property-search"); } Element p = DomUtil.getChildElement(root, "prop", NAMESPACE); if (p == null) { throw new BadRequestException("Expected DAV:prop child of DAV:property-search"); } ElementIterator pi = DomUtil.getChildren(p); if (! pi.hasNext()) { throw new BadRequestException("Expected at least one child of DAV:prop"); } HashSet<DavPropertyName> properties = new HashSet<DavPropertyName>(); while (pi.hasNext()) { DavPropertyName name = DavPropertyName.createFromXml(pi.nextElement()); properties.add(name); } Element m = DomUtil.getChildElement(root, "match", NAMESPACE); if (m == null) { throw new BadRequestException("Expected DAV:match child of DAV:property-search"); } String match = DomUtil.getText(m); return new SearchSpec(properties, match); } }
public static SearchSpec createFromXml(Element root) throws CosmoDavException { if (! DomUtil.matches(root, "property-search", NAMESPACE)) { throw new IllegalArgumentException("Expected root element DAV:property-search"); } Element p = DomUtil.getChildElement(root, "prop", NAMESPACE); if (p == null) { throw new BadRequestException("Expected DAV:prop child of DAV:property-search"); } ElementIterator pi = DomUtil.getChildren(p); if (! pi.hasNext()) { throw new BadRequestException("Expected at least one child of DAV:prop"); } HashSet<DavPropertyName> properties = new HashSet<DavPropertyName>(); while (pi.hasNext()) { DavPropertyName name = DavPropertyName.createFromXml(pi.nextElement()); properties.add(name); } Element m = DomUtil.getChildElement(root, "match", NAMESPACE); if (m == null) { throw new BadRequestException("Expected DAV:match child of DAV:property-search"); } String match = DomUtil.getText(m); return new SearchSpec(properties, match); } }
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."); } } }
while (included.hasNext()) { DavPropertyName name = DavPropertyName .createFromXml(included.nextElement()); propfindProps.add(name);
while (included.hasNext()) { DavPropertyName name = DavPropertyName .createFromXml(included.nextElement()); propfindProps.add(name);