protected void showLockDiscoveryInfo(NodeLock token)
throws WebdavException {
// Generating XML response
XMLPrinter generatedXML = new XMLPrinter();
generatedXML.writeXMLHeader();
generatedXML.writeElement("d", "DAV:", "prop", XMLPrinter.OPENING);
generatedXML.writeElement("d", null, "lockdiscovery",
XMLPrinter.OPENING);
generatedXML.writeElement("d", null, "activelock", XMLPrinter.OPENING);
generatedXML.writeElement("d", null, "locktype", XMLPrinter.OPENING);
generatedXML.writeElement("d", null, "write", XMLPrinter.NO_CONTENT);
generatedXML.writeElement("d", null, "locktype", XMLPrinter.CLOSING);
generatedXML.writeElement("d", null, "lockscope", XMLPrinter.OPENING);
if (token.isExclusive()) {
generatedXML.writeElement("d", null, "exclusive",
XMLPrinter.NO_CONTENT);
} else {
generatedXML.writeElement("d", null, "shared",
XMLPrinter.NO_CONTENT);
}
generatedXML.writeElement("d", null, "lockscope", XMLPrinter.CLOSING);
generatedXML.writeElement("d", null, "depth", XMLPrinter.OPENING);
if (token.isInheritable()) {
generatedXML.writeText("Infinity");
} else {
generatedXML.writeText("0");
}
generatedXML.writeElement("d", null, "depth", XMLPrinter.CLOSING);
generatedXML.writeElement("d", null, "owner", XMLPrinter.OPENING);
//generatedXML.writeText(lockInfo_lockOwner);
generatedXML.writeText(req.getServletPath() + token.getSubjectUri());
generatedXML.writeElement("d", null, "owner", XMLPrinter.CLOSING);
generatedXML.writeElement("d", null, "timeout", XMLPrinter.OPENING);
generatedXML.writeText("Second-"
+ (new Long((token.getExpirationDate().getTime()
- (new Date()).getTime())/1000))
.toString());
generatedXML.writeElement("d", null, "timeout", XMLPrinter.CLOSING);
generatedXML.writeElement("d", null, "locktoken", XMLPrinter.OPENING);
generatedXML.writeElement("d", null, "href", XMLPrinter.OPENING);
// Put here the token Id
generatedXML.writeText("opaquelocktoken:" + token.getLockId());
generatedXML.writeElement("d", null, "href", XMLPrinter.CLOSING);
generatedXML.writeElement("d", null, "locktoken", XMLPrinter.CLOSING);
generatedXML.writeElement("d", null, "activelock", XMLPrinter.CLOSING);
generatedXML.writeElement("d", null, "lockdiscovery",
XMLPrinter.CLOSING);
generatedXML.writeElement("d", null, "prop", XMLPrinter.CLOSING);
try {
//System.out.println("Query result");
//System.out.println(generatedXML.toString());
Writer writer = resp.getWriter();
writer.write(generatedXML.toString());
writer.flush();
} catch (Exception e) {
e.printStackTrace();
throw new WebdavException(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
}