@Override public Void call() throws Exception { final long begin = System.currentTimeMillis(); BigdataSailRepositoryConnection conn = null; try { conn = getQueryConnection(); // Note: We have to align Sail semantics for Resource... with the // REST API. final boolean found = conn.hasStatement(s, p, o, includeInferred, c == null ? new Resource[0] : c); final long elapsed = System.currentTimeMillis() - begin; buildAndCommitBooleanResponse(resp, found, elapsed); return null; } finally { if (conn != null) { conn.close(); } } }
/** * Report that a namespace is not found. The namespace is extracted from the * {@link HttpServletRequest}. */ protected void buildAndCommitNamespaceNotFoundResponse( final HttpServletRequest req, final HttpServletResponse resp) throws IOException { buildAndCommitResponse(resp, HttpServletResponse.SC_NOT_FOUND, MIME_TEXT_PLAIN, "Not found: namespace=" + getNamespace(req) // +", timestamp="+getTimestamp(req) ); }
/** * Return the timestamp which will be used to execute the query. The uri * query parameter <code>timestamp</code> may be used to communicate the * desired commit time against which the query will be issued. If that uri * query parameter is not given then the default configured commit time will * be used. Applications may create protocols for sharing interesting commit * times as reported by {@link IAtomicStore#commit()} or by a distributed * data loader (for scale-out). * * @see QueryServlet#ATTR_TIMESTAMP; */ protected long getTimestamp(final HttpServletRequest req) { final String timestamp = req.getParameter(QueryServlet.ATTR_TIMESTAMP); if (timestamp == null) { return getConfig(getServletContext()).timestamp; } return Long.valueOf(timestamp); }
/** * Post a GraphML file to the blueprints layer. */ @Override protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws IOException { final String contentType = req.getContentType(); if (log.isInfoEnabled()) log.info("Request body: " + contentType); final String mimeType = new MiniMime(contentType).getMimeType().toLowerCase(); if (!mimeTypes.contains(mimeType)) { buildAndCommitResponse(resp, HTTP_BADREQUEST, MIME_TEXT_PLAIN, "Content-Type not recognized as graph data: " + contentType); return; } try { submitApiTask( new BlueprintsPostTask(req, resp, getNamespace(req), ITx.UNISOLATED)).get(); } catch (Throwable t) { BigdataRDFServlet.launderThrowable(t, resp, ""); } }
/** * Overridden to create and initialize the delegate {@link Servlet} * instances. */ @Override public void init() throws ServletException { super.init(); m_restServlet = new RESTServlet(); m_restServlet.init(getServletConfig()); }
buildAndCommitResponse(resp, HTTP_BADREQUEST, MIME_TEXT_PLAIN, sb.toString()); return null;
@Override public Void call() throws Exception { final long begin = System.currentTimeMillis(); BigdataSailRepositoryConnection conn = null; try { conn = getQueryConnection(); // Range count all statements matching that access path. long rangeCount = 0; if (c != null && c.length > 0) { for (Resource r : c) { rangeCount += conn.getTripleStore().getAccessPath(s, p, o, r) .rangeCount(exact); } } else { rangeCount += conn.getTripleStore() .getAccessPath(s, p, o, (Resource) null) .rangeCount(exact); } final long elapsed = System.currentTimeMillis() - begin; buildAndCommitRangeCountResponse(resp, rangeCount, elapsed); return null; } finally { if (conn != null) { conn.close(); } } }
if (isAttachment(queryTask.mimeType)) {
BigdataRDFServlet.launderThrowable(t, resp, "DELETE-WITH-ACCESS-PATH: (s=" + s + ",p=" + p + ",o=" + o + ",c=" + Arrays.toString(c) + ")");
/** * Overridden to create and initialize the delegate {@link Servlet} * instances. */ @Override public void init() throws ServletException { super.init(); m_restServlet = new RESTServlet(); m_restServlet.init(getServletConfig()); }
buildAndCommitResponse(resp, HTTP_BADREQUEST, MIME_TEXT_PLAIN, sb.toString()); return null;
@Override public Void call() throws Exception { final long begin = System.currentTimeMillis(); BigdataSailRepositoryConnection conn = null; try { conn = getQueryConnection(); // Range count all statements matching that access path. long rangeCount = 0; if (c != null && c.length > 0) { for (Resource r : c) { rangeCount += conn.getTripleStore().getAccessPath(s, p, o, r) .rangeCount(exact); } } else { rangeCount += conn.getTripleStore() .getAccessPath(s, p, o, (Resource) null) .rangeCount(exact); } final long elapsed = System.currentTimeMillis() - begin; buildAndCommitRangeCountResponse(resp, rangeCount, elapsed); return null; } finally { if (conn != null) { conn.close(); } } }
super.destroy();
if (isAttachment(queryTask.mimeType)) {
BigdataRDFServlet.launderThrowable(t, resp, "DELETE-WITH-ACCESS-PATH: (s=" + s + ",p=" + p + ",o=" + o + ",c=" + Arrays.toString(c) + ")");
/** * Return the timestamp which will be used to execute the query. The uri * query parameter <code>timestamp</code> may be used to communicate the * desired commit time against which the query will be issued. If that uri * query parameter is not given then the default configured commit time will * be used. Applications may create protocols for sharing interesting commit * times as reported by {@link IAtomicStore#commit()} or by a distributed * data loader (for scale-out). * * @see QueryServlet#ATTR_TIMESTAMP; */ protected long getTimestamp(final HttpServletRequest req) { final String timestamp = req.getParameter(QueryServlet.ATTR_TIMESTAMP); if (timestamp == null) { return getConfig(getServletContext()).timestamp; } return Long.valueOf(timestamp); }
/** * Report that a namespace is not found. The namespace is extracted from the * {@link HttpServletRequest}. */ protected void buildAndCommitNamespaceNotFoundResponse( final HttpServletRequest req, final HttpServletResponse resp) throws IOException { buildAndCommitResponse(resp, HttpServletResponse.SC_NOT_FOUND, MIME_TEXT_PLAIN, "Not found: namespace=" + getNamespace(req) // +", timestamp="+getTimestamp(req) ); }
/** * Overridden to create and initialize the delegate {@link Servlet} * instances. */ @Override public void init() throws ServletException { super.init(); m_restServlet = new RESTServlet(); m_restServlet.init(getServletConfig()); }
/** * Report an access path range count and elapsed time back to the user agent. * * @param resp * The response. * @param rangeCount * The mutation count. * @param elapsed * The elapsed time (milliseconds). * * @throws IOException */ static protected void buildAndCommitRangeCountResponse( final HttpServletResponse resp, final long rangeCount, final long elapsed) throws IOException { final StringWriter w = new StringWriter(); final XMLBuilder t = new XMLBuilder(w); t.root("data").attr("rangeCount", rangeCount) .attr("milliseconds", elapsed).close(); buildAndCommitResponse(resp, HTTP_OK, MIME_APPLICATION_XML, w.toString()); }