public abstract class AbstractResource extends Object implements TxCheckedResource
Modifier and Type | Field and Description |
---|---|
static String |
ACCESSOR_PARAM |
static String |
ALL_PARAM |
static String |
AUTH_HEADER_NAME |
static String |
COMMIT_PARAM |
static String |
CSV_MEDIA_TYPE |
static int |
DEFAULT_LIST_LIMIT |
static String |
FILTER_PARAM |
protected com.tinkerpop.frames.FramedGraph<? extends TxGraph> |
graph |
static String |
GROUP_PARAM |
static String |
ID_PARAM |
static String |
INCLUDE_PROPS_PARAM
Serialization config parameters.
|
static int |
ITEM_CACHE_TIME |
protected static com.fasterxml.jackson.core.JsonFactory |
jsonFactory |
protected static com.fasterxml.jackson.databind.ObjectMapper |
jsonMapper |
static String |
LIMIT_PARAM |
static String |
LOG_MESSAGE_HEADER_NAME |
static String |
LOG_PARAM |
protected static org.slf4j.Logger |
logger |
protected GraphManager |
manager |
static String |
N3_MIMETYPE |
static String |
OFFSET_PARAM |
static String |
PATCH_HEADER_NAME |
static String |
RANGE_HEADER_NAME
Header names
|
protected com.google.common.collect.BiMap<String,String> |
RDF_MIMETYPE_FORMATS |
static String |
RDF_XML_MIMETYPE |
protected javax.ws.rs.core.Request |
request |
protected javax.ws.rs.core.HttpHeaders |
requestHeaders
With each request the headers of that request are injected into the
requestHeaders parameter.
|
static String |
RESOURCE_ENDPOINT_PREFIX |
static String |
SCOPE_PARAM |
static String |
SORT_PARAM
Query arguments.
|
static String |
STREAM_HEADER_NAME |
static String |
TOLERANT_PARAM |
static String |
TURTLE_MIMETYPE
RDF Mimetypes and formatting mappings
|
protected javax.ws.rs.core.UriInfo |
uriInfo
With each request URI info is injected into the uriInfo parameter.
|
static String |
VERSION_PARAM |
Constructor and Description |
---|
AbstractResource(org.neo4j.graphdb.GraphDatabaseService database)
Constructer.
|
Modifier and Type | Method and Description |
---|---|
protected Api |
anonymousApi()
Fetch an instance of the API for anonymous access.
|
protected Api |
api()
Fetch an instance of the API with the current user.
|
protected Tx |
beginTx()
Open a transaction on the graph.
|
protected javax.ws.rs.core.Response |
creationResponse(Entity frame)
Return a response from a new item with a 201 CREATED status.
|
protected <T extends Entity> |
getCacheControl(T item)
Get a cache control header based on the access restrictions
set on the item.
|
protected Actioner |
getCurrentActioner()
Retrieve the current actioner, which may be a user or
a group, throwing a bad request if it's invalid.
|
protected UserProfile |
getCurrentUser()
Retrieve the profile of the current user, throwing a
BadRequest if it's invalid or not a user.
|
com.tinkerpop.frames.FramedGraph<? extends TxGraph> |
getGraph()
Fetch the graph associated with the resource.
|
protected int |
getIntQueryParam(String key,
int defaultValue)
Get an integer value for a given query parameter, falling back
on a default.
|
protected URI |
getItemUri(Entity item)
Get the URI for a given item.
|
protected Optional<String> |
getLogMessage()
Retrieve an action log message from the request header.
|
protected QueryApi |
getQuery()
Get a query object configured according to incoming parameters.
|
protected String |
getRdfFormat(String format,
String defaultFormat)
Get an RDF format for content-negotiation form
|
protected Accessor |
getRequesterUserProfile()
Retrieve the account of the current user, who may be
anonymous.
|
protected Serializer |
getSerializer()
Get a serializer according to passed-in serialization config.
|
protected List<String> |
getStringListQueryParam(String key)
Get a list of values for a given query parameter key.
|
protected Boolean |
isPatch()
Determine if a PATCH header is present.
|
protected boolean |
isStreaming()
Determine if the X-Stream header is present.
|
protected <T extends Entity> |
single(T item)
Return a default response from a single frame item.
|
protected <T extends Entity> |
streamingList(Supplier<Iterable<T>> list)
Return a streaming response from an iterable.
|
protected <T extends Entity> |
streamingList(Supplier<Iterable<T>> list,
Serializer serializer)
Return a streaming response from an iterable, using the given
entity converter.
|
protected <T extends Entity> |
streamingListOfLists(Supplier<Iterable<? extends Collection<T>>> lists)
Return a streaming response from an iterable of item lists.
|
protected <T extends Entity> |
streamingPage(Supplier<QueryApi.Page<T>> page)
Stream a single page with total, limit, and offset info.
|
protected <T extends Entity> |
streamingPage(Supplier<QueryApi.Page<T>> page,
Serializer serializer)
Stream a single page with total, limit, and offset info, using
the given entity converter.
|
protected javax.ws.rs.core.Response |
streamingVertexList(Supplier<Iterable<com.tinkerpop.blueprints.Vertex>> vertices)
Stream an iterable of vertices.
|
protected javax.ws.rs.core.Response |
streamingVertexList(Supplier<Iterable<com.tinkerpop.blueprints.Vertex>> vertices,
Serializer serializer)
Stream an iterable of vertices.
|
public static final int DEFAULT_LIST_LIMIT
public static final int ITEM_CACHE_TIME
public static final String RESOURCE_ENDPOINT_PREFIX
protected static final com.fasterxml.jackson.databind.ObjectMapper jsonMapper
protected static final com.fasterxml.jackson.core.JsonFactory jsonFactory
protected static final org.slf4j.Logger logger
public static final String CSV_MEDIA_TYPE
public static final String TURTLE_MIMETYPE
public static final String RDF_XML_MIMETYPE
public static final String N3_MIMETYPE
protected final com.google.common.collect.BiMap<String,String> RDF_MIMETYPE_FORMATS
public static final String SORT_PARAM
public static final String FILTER_PARAM
public static final String LIMIT_PARAM
public static final String OFFSET_PARAM
public static final String ACCESSOR_PARAM
public static final String GROUP_PARAM
public static final String ALL_PARAM
public static final String ID_PARAM
public static final String LOG_PARAM
public static final String VERSION_PARAM
public static final String SCOPE_PARAM
public static final String TOLERANT_PARAM
public static final String COMMIT_PARAM
public static final String INCLUDE_PROPS_PARAM
public static final String RANGE_HEADER_NAME
public static final String PATCH_HEADER_NAME
public static final String AUTH_HEADER_NAME
public static final String LOG_MESSAGE_HEADER_NAME
public static final String STREAM_HEADER_NAME
@Context protected javax.ws.rs.core.HttpHeaders requestHeaders
@Context protected javax.ws.rs.core.Request request
@Context protected javax.ws.rs.core.UriInfo uriInfo
protected final com.tinkerpop.frames.FramedGraph<? extends TxGraph> graph
protected final GraphManager manager
public AbstractResource(@Context org.neo4j.graphdb.GraphDatabaseService database)
database
- A Neo4j graph databasepublic com.tinkerpop.frames.FramedGraph<? extends TxGraph> getGraph()
TxCheckedResource
getGraph
in interface TxCheckedResource
protected Tx beginTx()
protected Serializer getSerializer()
Currently the only parameter is _ip=[propertyName]
which
ensures a given property is always included in the output.
protected List<String> getStringListQueryParam(String key)
key
- the parameter nameprotected int getIntQueryParam(String key, int defaultValue)
key
- the parameter namedefaultValue
- the default valueprotected QueryApi getQuery()
protected Accessor getRequesterUserProfile()
protected Api api()
protected Api anonymousApi()
protected UserProfile getCurrentUser()
protected Actioner getCurrentActioner()
protected Optional<String> getLogMessage()
protected Boolean isPatch()
protected boolean isStreaming()
protected <T extends Entity> javax.ws.rs.core.Response single(T item)
T
- the item's generic typeitem
- the itemprotected <T extends Entity> javax.ws.rs.core.Response streamingPage(Supplier<QueryApi.Page<T>> page)
page
- A page of dataprotected <T extends Entity> javax.ws.rs.core.Response streamingPage(Supplier<QueryApi.Page<T>> page, Serializer serializer)
page
- a page of dataserializer
- a custom serializer instanceprotected javax.ws.rs.core.Response streamingVertexList(Supplier<Iterable<com.tinkerpop.blueprints.Vertex>> vertices)
vertices
- an iterable of verticesprotected javax.ws.rs.core.Response streamingVertexList(Supplier<Iterable<com.tinkerpop.blueprints.Vertex>> vertices, Serializer serializer)
vertices
- an iterable of verticesserializer
- a serializer instanceprotected <T extends Entity> javax.ws.rs.core.Response streamingList(Supplier<Iterable<T>> list)
list
- A list of framed itemsprotected <T extends Entity> javax.ws.rs.core.Response streamingListOfLists(Supplier<Iterable<? extends Collection<T>>> lists)
lists
- an iterable of item groupsprotected <T extends Entity> javax.ws.rs.core.Response streamingList(Supplier<Iterable<T>> list, Serializer serializer)
list
- A list of framed itemsprotected URI getItemUri(Entity item)
item
- The itemprotected javax.ws.rs.core.Response creationResponse(Entity frame)
frame
- A newly-created itemprotected <T extends Entity> javax.ws.rs.core.CacheControl getCacheControl(T item)
item
- The itemCopyright © 2018 The European Holocaust Research Infrastructure (EHRI). All rights reserved.