Search in sources :

Example 1 with LockInfoSaxHandler

use of io.milton.http.LockInfoSaxHandler in project lobcder by skoulouzis.

the class LockHandler method parseLockInfo.

private LockInfo parseLockInfo(Request request) throws IOException, SAXException {
    InputStream in = request.getInputStream();
    XMLReader reader = XMLReaderFactory.createXMLReader();
    LockInfoSaxHandler handler = new LockInfoSaxHandler();
    reader.setContentHandler(handler);
    reader.parse(new InputSource(in));
    LockInfo info = handler.getInfo();
    // todo
    info.depth = LockDepth.INFINITY;
    info.lockedByUser = null;
    if (request.getAuthorization() != null) {
        info.lockedByUser = request.getAuthorization().getUser();
    }
    if (info.lockedByUser == null) {
    }
    return info;
}
Also used : InputSource(org.xml.sax.InputSource) InputStream(java.io.InputStream) LockInfoSaxHandler(io.milton.http.LockInfoSaxHandler) LockInfo(io.milton.http.LockInfo) XMLReader(org.xml.sax.XMLReader)

Example 2 with LockInfoSaxHandler

use of io.milton.http.LockInfoSaxHandler in project lobcder by skoulouzis.

the class TestSaxHandler method testLockInfo.

public void testLockInfo() throws Exception {
    XMLReader reader = XMLReaderFactory.createXMLReader();
    LockInfoSaxHandler handler = new LockInfoSaxHandler();
    reader.setContentHandler(handler);
    reader.parse(new InputSource(LockInfoSaxHandler.class.getResourceAsStream("/sample_lockinfo.xml")));
    LockInfo result = handler.getInfo();
    assertEquals(result.scope, LockScope.EXCLUSIVE);
    assertEquals(result.type, LockType.WRITE);
}
Also used : InputSource(org.xml.sax.InputSource) LockInfoSaxHandler(io.milton.http.LockInfoSaxHandler) XMLReader(org.xml.sax.XMLReader)

Aggregations

LockInfoSaxHandler (io.milton.http.LockInfoSaxHandler)2 InputSource (org.xml.sax.InputSource)2 XMLReader (org.xml.sax.XMLReader)2 LockInfo (io.milton.http.LockInfo)1 InputStream (java.io.InputStream)1