private Message successMultiStatus(MULTISTATUS multiStatus) { final Document doc = new Document(XML_DECLARATION, multiStatus); return Response.build(SUCCESS_MULTI_STATUS) .header(CONTENT_TYPE) .set(APPLICATION_XML.toString()) .setBody(CHARSET_UTF_8.encode(XMLWriter.write(doc))); }
private Message handleRequestWithoutRange(Request request) { final Path path = Path.fromUri(request.uri()); final Resource resource = resolveResource(path); try { return Response.build(SUCCESS_OK) .header(CONTENT_TYPE) .set(APPLICATION_OCTET_STREAM.toString()) .setBody(resource.channel()); } catch (IOException e) { return serverErrorInternal(); } }
@LOCK public Message lock(@PathTranslated Path path, Depth depth) throws IOException { final Resource resource = resolveResource(path); if (resource.exists()) { final Lock lock = resource.lock(WRITE, EXCLUSIVE); final ACTIVE_LOCK activelock = activeLock(lock, depth, relativizeResource(resource)); final Element lockDiscovery = lockDiscovery(activelock); final Element prop = prop(lockDiscovery); final Document doc = new Document(XML_DECLARATION, prop); return Response.build(SUCCESS_OK) .header(LOCK_TOKEN) .set("<" + lock.token() + ">") .setBody(Charset.defaultCharset().encode(XMLWriter.write(doc))); } else { return clientErrorNotFound(); } }