Search in sources :

Example 36 with ElementIterator

use of org.apache.jackrabbit.webdav.xml.ElementIterator in project jackrabbit by apache.

the class LockDiscovery method createFromXml.

// ---------------------------------------------------< factory from xml >---
/**
 * Builds a new <code>LockDiscovery</code> object from the given xml element.
 *
 * @param lockDiscoveryElement
 * @return
 * @throws IllegalArgumentException if the given xml element is not a
 * DAV:lockdiscovery element.
 */
public static LockDiscovery createFromXml(Element lockDiscoveryElement) {
    if (!DomUtil.matches(lockDiscoveryElement, PROPERTY_LOCKDISCOVERY, NAMESPACE)) {
        throw new IllegalArgumentException("DAV:lockdiscovery element expected.");
    }
    List<ActiveLock> activeLocks = new ArrayList<ActiveLock>();
    ElementIterator it = DomUtil.getChildren(lockDiscoveryElement, XML_ACTIVELOCK, NAMESPACE);
    while (it.hasNext()) {
        Element al = it.nextElement();
        activeLocks.add(new ALockImpl(al));
    }
    return new LockDiscovery(activeLocks.toArray(new ActiveLock[activeLocks.size()]));
}
Also used : ElementIterator(org.apache.jackrabbit.webdav.xml.ElementIterator) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList)

Aggregations

ElementIterator (org.apache.jackrabbit.webdav.xml.ElementIterator)36 Element (org.w3c.dom.Element)34 ArrayList (java.util.ArrayList)17 DavException (org.apache.jackrabbit.webdav.DavException)13 RepositoryException (javax.jcr.RepositoryException)9 Document (org.w3c.dom.Document)7 IOException (java.io.IOException)6 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)5 HttpResponse (org.apache.http.HttpResponse)4 SAXException (org.xml.sax.SAXException)4 Name (org.apache.jackrabbit.spi.Name)3 QValue (org.apache.jackrabbit.spi.QValue)3 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)3 HashMap (java.util.HashMap)2 Event (org.apache.jackrabbit.spi.Event)2 EventBundleImpl (org.apache.jackrabbit.spi.commons.EventBundleImpl)2 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1 URISyntaxException (java.net.URISyntaxException)1 KeyManagementException (java.security.KeyManagementException)1