ServerResource
class instead.@Deprecated public class Resource extends Handler
acceptRepresentation(Representation)
for POST
processing, storeRepresentation(Representation)
for PUT processing
or removeRepresentations()
for DELETE processing.represent(Variant)
method. This allows an easy and cheap
declaration of the available variants, in the constructor for example. Then
the creation of costly representations is delegated to the
represent(Variant)
method when actually needed.Representation
,
Finder
Constructor and Description |
---|
Resource()
Deprecated.
Special constructor used by IoC frameworks.
|
Resource(Context context,
Request request,
Response response)
Deprecated.
Normal constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
acceptRepresentation(Representation entity)
Deprecated.
Accepts and processes a representation posted to the resource.
|
boolean |
allowDelete()
Deprecated.
Indicates if DELETE calls are allowed by checking the "modifiable"
property.
|
boolean |
allowGet()
Deprecated.
Indicates if GET calls are allowed by checking the "readable" property.
|
boolean |
allowPost()
Deprecated.
Indicates if POST calls are allowed by checking the "modifiable"
property.
|
boolean |
allowPut()
Deprecated.
Indicates if PUT calls are allowed by checking the "modifiable" property.
|
Variant |
getPreferredVariant()
Deprecated.
Returns the preferred variant according to the client preferences
specified in the request.
|
List<Variant> |
getVariants()
Deprecated.
Returns the modifiable list of variants.
|
void |
handleDelete()
Deprecated.
Handles a DELETE call by invoking the
removeRepresentations()
method. |
void |
handleGet()
Deprecated.
Handles a GET call by automatically returning the best representation
available.
|
void |
handlePost()
Deprecated.
Handles a POST call by invoking the
acceptRepresentation(Representation) method. |
void |
handlePut()
Deprecated.
Handles a PUT call by invoking the
storeRepresentation(Representation) method. |
void |
init(Context context,
Request request,
Response response)
Deprecated.
Initialize the resource with its context.
|
boolean |
isAvailable()
Deprecated.
Indicates if the resource is actually available.
|
boolean |
isModifiable()
Deprecated.
Indicates if the representations can be modified via the
handlePost() , the handlePut() or the
handleDelete() methods. |
boolean |
isNegotiateContent()
Deprecated.
Indicates if the best content is automatically negotiated.
|
boolean |
isReadable()
Deprecated.
Indicates if the representations can be read via the
handleGet()
method. |
void |
removeRepresentations()
Deprecated.
Removes all the representations of the resource and effectively the
resource itself.
|
Representation |
represent()
Deprecated.
Returns the preferred representation according to the client preferences
specified in the request.
|
Representation |
represent(Variant variant)
Deprecated.
Returns a full representation for a given variant previously returned via
the getVariants() method.
|
void |
setAvailable(boolean available)
Deprecated.
Indicates if the resource is actually available.
|
void |
setModifiable(boolean modifiable)
Deprecated.
Indicates if the representations can be modified via the
handlePost() , the handlePut() or the
handleDelete() methods. |
void |
setNegotiateContent(boolean negotiateContent)
Deprecated.
Indicates if the returned representation is automatically negotiated.
|
void |
setReadable(boolean readable)
Deprecated.
Indicates if the representations can be read via the
handleGet()
method. |
void |
setVariants(List<Variant> variants)
Deprecated.
Sets the modifiable list of variants.
|
void |
storeRepresentation(Representation entity)
Deprecated.
Stores a representation put to the resource and replaces all existing
representations of the resource.
|
allowHead, allowOptions, generateRef, getAllowedMethods, getApplication, getContext, getLogger, getMatrix, getQuery, getRequest, getResponse, handleHead, handleOptions, setContext, setRequest, setResponse, updateAllowedMethods
public Resource()
public void acceptRepresentation(Representation entity) throws ResourceException
Status.SERVER_ERROR_INTERNAL
.entity
- The posted entity.ResourceException
public boolean allowDelete()
allowDelete
in class Handler
public boolean allowGet()
public boolean allowPost()
public boolean allowPut()
public Variant getPreferredVariant()
public List<Variant> getVariants()
represent(Variant)
public void handleDelete()
removeRepresentations()
method. It also automatically support conditional DELETEs.handleDelete
in class Handler
public void handleGet()
Status.CLIENT_ERROR_NOT_FOUND
status.getPreferredVariant()
. If a variant is successfully selected,
then the represent(Variant)
method is called to get the actual
representation corresponding to the metadata in the variant.Status.CLIENT_ERROR_NOT_ACCEPTABLE
and the list
of available representations is returned in the response entity as a
textual list of URIs (only if the variants have an identifier properly
set).represent(Variant)
method. If several variants are
available, then the list of available representations is returned in the
response entity as a textual list of URIs (only if the variants have an
identifier properly set).Status.CLIENT_ERROR_NOT_FOUND
. public void handlePost()
acceptRepresentation(Representation)
method. It also logs a
trace if there is no entity posted.handlePost
in class Handler
public void handlePut()
storeRepresentation(Representation)
method. It also handles
conditional PUTs and forbids partial PUTs as they are not supported yet.
Finally, it prevents PUT with no entity by setting the response status to
Status.CLIENT_ERROR_BAD_REQUEST
following the HTTP
specifications.public void init(Context context, Request request, Response response)
public boolean isAvailable()
handleGet()
method will set the response's status to
Status.CLIENT_ERROR_NOT_FOUND
if this property is false.public boolean isModifiable()
handlePost()
, the handlePut()
or the
handleDelete()
methods.public boolean isNegotiateContent()
public boolean isReadable()
handleGet()
method.public void removeRepresentations() throws ResourceException
Status.SERVER_ERROR_INTERNAL
.ResourceException
public Representation represent() throws ResourceException
represent(Variant)
method with the preferred variant returned by
getPreferredVariant()
.ResourceException
getPreferredVariant()
public Representation represent(Variant variant) throws ResourceException
variant
- The variant whose full representation must be returned.ResourceException
getVariants()
public void setAvailable(boolean available)
handleGet()
method will set the response's status to
Status.CLIENT_ERROR_NOT_FOUND
if this property is false.available
- True if the resource is actually available.public void setModifiable(boolean modifiable)
handlePost()
, the handlePut()
or the
handleDelete()
methods.modifiable
- Indicates if the representations can be modified.public void setNegotiateContent(boolean negotiateContent)
negotiateContent
- True if content negotiation is enabled.public void setReadable(boolean readable)
handleGet()
method.readable
- Indicates if the representations can be read.public void setVariants(List<Variant> variants)
variants
- The modifiable list of variants.public void storeRepresentation(Representation entity) throws ResourceException
Status.SERVER_ERROR_INTERNAL
.entity
- ResourceException
Copyright © 2005–2016. All rights reserved.