+import org.argeo.util.http.HttpResponseStatus;
+import org.argeo.util.http.HttpServerUtils;
+
+import com.sun.net.httpserver.HttpExchange;
+
+public class CmsAcrHttpHandler extends DavServerHandler {
+ private ProvidedRepository contentRepository;
+
+ @Override
+ protected void handleGET(HttpExchange exchange) {
+ ContentSession session = RemoteAuthUtils.doAs(() -> contentRepository.get(),
+ new RemoteAuthHttpExchange(exchange));
+ String relativePath = HttpServerUtils.relativize(exchange);
+ Content content = session.get(ContentUtils.ROOT_SLASH + relativePath);
+ Optional<Long> size = content.get(CrName.size, Long.class);
+ try (InputStream in = content.open(InputStream.class)) {
+ exchange.sendResponseHeaders(HttpResponseStatus.OK.getStatusCode(), size.orElse(0l));
+ StreamUtils.copy(in, exchange.getResponseBody());
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot process " + relativePath, e);
+ }
+ }