public abstract class BigdataServlet extends javax.servlet.http.HttpServlet implements IMimeTypes
Modifier and Type | Field and Description |
---|---|
static String |
ATTRIBUTE_RDF_CONTEXT
The name of the
ServletContext attribute whose value is the
BigdataRDFContext . |
protected static String |
charset
The character set used for the response (not negotiated).
|
protected static String |
DELETE |
protected static String |
GET |
static int |
HTTP_BADREQUEST
Some HTTP response status codes
|
static String |
HTTP_HEADER_BIGDATA_READ_ONLY
HTTP header may be used to specify that the request is for read only.
|
static int |
HTTP_INTERNALERROR
Some HTTP response status codes
|
static int |
HTTP_METHOD_NOT_ALLOWED
Some HTTP response status codes
|
static int |
HTTP_NOTFOUND
Some HTTP response status codes
|
static int |
HTTP_NOTIMPLEMENTED
Some HTTP response status codes
|
static int |
HTTP_OK
Some HTTP response status codes
|
protected static String |
POST |
protected static String |
PUT |
MIME_APPLICATION_JSON, MIME_APPLICATION_URL_ENCODED, MIME_APPLICATION_XML, MIME_DEFAULT_BINARY, MIME_GRAPH_ML, MIME_PROPERTIES_XML, MIME_TEXT_HTML, MIME_TEXT_JAVASCRIPT, MIME_TEXT_PLAIN
Constructor and Description |
---|
BigdataServlet() |
Modifier and Type | Method and Description |
---|---|
static void |
buildAndCommitResponse(javax.servlet.http.HttpServletResponse resp,
int status,
String mimeType,
String content,
NV... headers)
Generate and commit a response having the indicated http status code, mime
type, and content.
|
protected static org.openrdf.model.Resource[] |
decodeContexts(javax.servlet.http.HttpServletRequest req,
String name)
Decode an array of named graph contexts from a request.
|
protected BigdataRDFContext |
getBigdataRDFContext() |
protected boolean |
getBooleanValue(javax.servlet.http.HttpServletRequest req,
String name,
boolean defaultValue)
Return the effective boolean value of a request parameter.
|
protected IIndexManager |
getIndexManager()
The backing
IIndexManager . |
static IIndexManager |
getIndexManager(javax.servlet.ServletContext servletContext)
The backing
IIndexManager . |
static String[] |
getServiceURIs(javax.servlet.ServletContext servletContext,
javax.servlet.http.HttpServletRequest req)
Return the serviceURI(s) for this service (one or more).
|
protected static String |
readFully(Reader reader) |
protected <T> FutureTask<T> |
submitApiTask(AbstractRestApiTask<T> task)
|
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
public static final transient String ATTRIBUTE_RDF_CONTEXT
ServletContext
attribute whose value is the
BigdataRDFContext
.protected static final String charset
protected static final transient String GET
protected static final transient String POST
protected static final transient String PUT
protected static final transient String DELETE
public static final String HTTP_HEADER_BIGDATA_READ_ONLY
public static final transient int HTTP_OK
public static final transient int HTTP_NOTFOUND
public static final transient int HTTP_BADREQUEST
public static final transient int HTTP_METHOD_NOT_ALLOWED
public static final transient int HTTP_INTERNALERROR
public static final transient int HTTP_NOTIMPLEMENTED
protected final BigdataRDFContext getBigdataRDFContext()
protected IIndexManager getIndexManager()
IIndexManager
.public static IIndexManager getIndexManager(javax.servlet.ServletContext servletContext)
IIndexManager
.protected <T> FutureTask<T> submitApiTask(AbstractRestApiTask<T> task) throws DatasetNotFoundException, InterruptedException, ExecutionException, IOException, TimeoutException
Future
, flush and commit the servlet
resdponse, and then a completed Future
for that
task. The task will be run on the appropriate executor service depending
on the nature of the backing database and the view required by the task.
The servlet API MUST NOT close the output stream from within the a submitted mutation task. Closing the output stream within the mutation task permits the client to conclude that the operation was finished before the group commit actually occurs which breaks the visibility guarantee of an ACID commit (the change is not yet visible).
This arises because the AbstractApiTask
implementation has invoked
conn.commit() and hence believes that it was successful, but the
AbstractTask
itself has not yet been through a checkpoint and the
write set for the commit group has not yet been melded into a stable
commit point. Instead, the caller MUST allow the servlet container to
close the output stream once the submitted task has completed successfully
(at which point the group commit will be stable). This provides the
necessary and correct visibility barrier for the updates.
CAUTION: Non-success outcomes MUST throw exceptions! Once
the flow of control enters an AbstractRestApiTask
the task MUST
throw out a typed exception that conveys the necessary information to the
launderThrowable() code which can then turn it into an appropriate HTTP
response. If the task does not throw an exception then it is presumed to
be successful and it will join the next group commit. Failure to follow
this caution can cause partial write sets to be made durable, thus
breaking the ACID semantics of the API.
task
- The task.Future
for that task.DatasetNotFoundException
ExecutionException
InterruptedException
IOException
TimeoutException
public static String[] getServiceURIs(javax.servlet.ServletContext servletContext, javax.servlet.http.HttpServletRequest req)
req
- The request.public static void buildAndCommitResponse(javax.servlet.http.HttpServletResponse resp, int status, String mimeType, String content, NV... headers) throws IOException
This flushes the response to the client immediately. Therefore this method
MUST NOT be invoked before the group commit point! All code paths in the
REST API that have actually performed a mutation (vs simply reporting a
client or server error before entering into their mutation code path) MUST
use submitApiTask(AbstractRestApiTask)
.
Note: It is NOT safe to invoke this method once you are inside an
AbstractRestApiTask
EVEN if the purpose is to report a client or
server error. The task MUST throw out a typed exception that conveys the
necessary information to the launderThrowable() code which can then turn
it into an appropriate HTTP response. If the task does not throw an
exception then it is presumed to be successful and it will join the next
group commit!
resp
- status
- The http status code.mimeType
- The MIME type of the response.content
- The content (optional).headers
- Zero or more headers.IOException
protected boolean getBooleanValue(javax.servlet.http.HttpServletRequest req, String name, boolean defaultValue)
"true"
is recognized. All other values are interpreted as
false
.req
- The request.name
- The name of the request parameter.defaultValue
- The default value.protected static org.openrdf.model.Resource[] decodeContexts(javax.servlet.http.HttpServletRequest req, String name)
req
- The request.name
- The name of the request parameter to be decoded.null
. If the
request parameter does not appear in the request then this method
returns Resource[0]
.BD.NULL_GRAPH
,
EncodeDecodeValue.decodeContexts(String[])
,
Resource... contexts
not encoded/decoded according to openrdf semantics (REST API) protected static String readFully(Reader reader) throws IOException
IOException
Copyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.