public abstract class AbstractResource<RESOURCE> extends java.lang.Object implements RestResource<RESOURCE>, CrudActionNotifable<RESOURCE>
| Modifier and Type | Field and Description |
|---|---|
protected HttpHeaders |
httpHeaders
The HTTP header information.
|
protected Providers |
providers |
protected Request |
request |
protected ResourceContext |
resourceCtx
The resource context is used for obtaining a new instance of a sub- resource.
|
protected SecurityContext |
securityCtx
The SecurityContext.
|
protected ServiceLocator |
serviceLocator
serviceLocator: a locator for available services
|
protected UriInfo |
uriInfo
The URI request context.
|
| Constructor and Description |
|---|
AbstractResource() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterDelete(RESOURCE deadEntity) |
protected void |
afterPost(java.lang.Object reqEntity,
java.lang.Object resrcEntity,
boolean isNewlyCreated)
HTTP-POST-listener which gets invoked after POST processing is finished.
|
protected void |
afterPut(java.lang.Object reqEntity,
RESOURCE resrcEntity,
boolean isNewlyCreated) |
protected void |
beforeDelete(RESOURCE respEntity) |
protected void |
beforePost(java.lang.Object reqEntity,
java.lang.Object resrcEntity)
HTTP-POST-listener which gets invoked before POST processing starts.
|
protected void |
beforePut(java.lang.Object reqEntity,
RESOURCE resrcEntity) |
protected YResponseBuilder |
createDeleteResponse()
Creates and returns a default
YResponseBuilder for a HTTP DELETE. |
protected YResponseBuilder |
createGetResponse()
Creates and returns a default
YResponseBuilder for a HTTP GET. |
protected void |
createOrUpdatePostResource(java.lang.Object reqEntity,
java.lang.Object resrcEntity,
boolean mustBeCreated)
HTTP-POST-hook method for updating (create/update) the POST resource value
Invoked by
HttpPostResponseBuilder.createOrUpdateResource(Object, Object, boolean). |
protected void |
createOrUpdateResource(java.lang.Object reqEntity,
RESOURCE resrcEntity,
boolean mustBeCreated) |
protected <T> T |
createPostResource(java.lang.Object reqEntity)
HTTP-POST-hook method for creating the POST resource value.
|
protected YResponseBuilder |
createPostResponse(java.lang.Object dto)
Creates and returns a default
YResponseBuilder for a HTTP POST. |
protected YResponseBuilder |
createPutResponse(java.lang.Object dto) |
protected YResponseBuilder |
createPutResponse(java.lang.Object dto,
boolean strict)
Generic PUT.
|
protected RESOURCE |
createResource(java.lang.Object reqEntity) |
protected void |
deleteResource(RESOURCE respEntity) |
protected EventActionFactory |
getEventActionFactory() |
PagingStrategy |
getPagingStrategy() |
AbstractResource |
getParentResource()
Returns the
RestResource which was executed as parent of current resource. |
CommandHandler |
getPostCommandHandler() |
CommandHandler |
getPutCommandHandler() |
Request |
getRequest() |
java.lang.String |
getResourceId() |
RESOURCE |
getResourceValue() |
protected ResponseBuilder |
getResponse() |
SecurityContext |
getSecurityContext() |
SecurityStrategy |
getSecurityStrategy() |
ServiceLocator |
getServiceLocator()
Returns a
ServiceLocator for all available services. |
UriInfo |
getUriInfo()
Returns the
UriInfo for current http-request. |
protected boolean |
isAccessGranted()
Security check for requested resource.
|
boolean |
isAccessGrantedExternal() |
void |
notifyAfterDelete()
Deprecated.
since ages - Configure
NotificationRequestProcessor instead. |
void |
notifyAfterGet()
Deprecated.
since ages - Configure
NotificationRequestProcessor instead. |
void |
notifyAfterPost()
Deprecated.
since ages - Configure
NotificationRequestProcessorinstead. |
void |
notifyAfterPut()
Deprecated.
since ages - Configure
NotificationRequestProcessor instead. |
void |
notifyBeforeDelete()
Deprecated.
since ages - Configure
NotificationRequestProcessor instead. |
void |
notifyBeforeGet()
Deprecated.
since ages - Configure
NotificationRequestProcessor instead. |
void |
notifyBeforePost()
Deprecated.
since ages - Configure
NotificationRequestProcessor instead. |
void |
notifyBeforePut()
Deprecated.
since ages - Configure
NotificationRequestProcessor instead. |
protected boolean |
processDtoId(java.lang.Object dto,
java.lang.String expPropValueLiteral,
boolean strict)
Internal helper method.
|
protected void |
processException(java.lang.String msg,
java.lang.Exception exception)
Throws a
WebApplicationException which interrupts any current processing and gives full control to jersey. |
protected <T> T |
readPostResource(java.lang.Object reqEntity)
HTTP-POST-hook method for reading the POST resource value.
|
protected abstract RESOURCE |
readResource(java.lang.String resourceId) |
void |
setCachingStrategy(AbstractCachingStrategy<RESOURCE> cachingStrategy)
Deprecated.
since 4.2.2, configure
RequestProcessor instead |
void |
setDeleteMethod(java.lang.String className) |
void |
setEventActionFactory(EventActionFactory eventActionFactory) |
void |
setGetMethod(java.lang.String className) |
void |
setPagingStrategy(PagingStrategy pagingStrategy) |
void |
setParentResource(AbstractResource parentResource) |
void |
setPostCommandHandler(CommandHandler postCommandHandler) |
void |
setPostMethod(java.lang.String className) |
void |
setPutCommandHandler(CommandHandler putCommandHandler) |
void |
setPutMethod(java.lang.String className) |
void |
setRequestProcessChain(ConfigurableRequestProcessChain<RESOURCE> requestProcessChain) |
void |
setResourceId(java.lang.String resourceId)
Sets the ID for this resource.
|
void |
setResourceValue(RESOURCE resourceValue)
Sets the value/entity for this resource.
|
void |
setSecurityStrategy(SecurityStrategy securityStrategy) |
void |
setServiceLocator(ServiceLocator serviceLocator) |
protected ResourceContext resourceCtx
protected SecurityContext securityCtx
protected UriInfo uriInfo
protected HttpHeaders httpHeaders
protected Providers providers
protected Request request
protected ServiceLocator serviceLocator
public SecurityContext getSecurityContext()
getSecurityContext in interface RestResource<RESOURCE>public Request getRequest()
getRequest in interface RestResource<RESOURCE>public AbstractResource getParentResource()
RestResource which was executed as parent of current resource.public void setParentResource(AbstractResource parentResource)
parentResource - the parentResource to setpublic void setPostCommandHandler(CommandHandler postCommandHandler)
postCommandHandler - the postCommandHandler to setpublic CommandHandler getPostCommandHandler()
public void setPutCommandHandler(CommandHandler putCommandHandler)
putCommandHandler - the putCommandHandler to setpublic CommandHandler getPutCommandHandler()
getPutCommandHandler in interface RestResource<RESOURCE>@Deprecated public void setCachingStrategy(AbstractCachingStrategy<RESOURCE> cachingStrategy)
RequestProcessor insteadpublic SecurityStrategy getSecurityStrategy()
public void setSecurityStrategy(SecurityStrategy securityStrategy)
public void setPagingStrategy(PagingStrategy pagingStrategy)
pagingStrategy - the pagingStrategy to setpublic PagingStrategy getPagingStrategy()
public void setResourceId(java.lang.String resourceId)
resourceId - the resourceId to setpublic java.lang.String getResourceId()
public ServiceLocator getServiceLocator()
RestResourceServiceLocator for all available services.getServiceLocator in interface RestResource<RESOURCE>ServiceLocatorpublic void setServiceLocator(ServiceLocator serviceLocator)
public void setEventActionFactory(EventActionFactory eventActionFactory)
protected EventActionFactory getEventActionFactory()
protected ResponseBuilder getResponse()
protected boolean isAccessGranted()
public boolean isAccessGrantedExternal()
public void setGetMethod(java.lang.String className)
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundExceptionpublic void setPutMethod(java.lang.String className)
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundExceptionpublic void setPostMethod(java.lang.String className)
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundExceptionpublic void setDeleteMethod(java.lang.String className)
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundExceptionprotected final YResponseBuilder createGetResponse()
YResponseBuilder for a HTTP GET. In addition, method checks whether the
requested user can perform the HTTP GET operation.YResponseBuilderprotected YResponseBuilder createDeleteResponse()
YResponseBuilder for a HTTP DELETE. In addition, method checks whether the
requested user can perform the HTTP DELETE operation.YResponseBuilderprotected YResponseBuilder createPostResponse(java.lang.Object dto)
YResponseBuilder for a HTTP POST. In addition, method checks whether the
requested user can perform the HTTP POST operation.YResponseBuilderprotected YResponseBuilder createPutResponse(java.lang.Object dto)
protected YResponseBuilder createPutResponse(java.lang.Object dto, boolean strict)
dto - strict - Responsepublic UriInfo getUriInfo()
RestResourceUriInfo for current http-request.getUriInfo in interface RestResource<RESOURCE>UriInfoprotected boolean processDtoId(java.lang.Object dto,
java.lang.String expPropValueLiteral,
boolean strict)
dto - dto to validatepublic void setResourceValue(RESOURCE resourceValue)
resourceValue - public RESOURCE getResourceValue()
getResourceValue in interface RestResource<RESOURCE>protected abstract RESOURCE readResource(java.lang.String resourceId) throws java.lang.Exception
java.lang.Exceptionprotected void beforeDelete(RESOURCE respEntity)
protected void deleteResource(RESOURCE respEntity)
protected void afterDelete(RESOURCE deadEntity)
protected void beforePut(java.lang.Object reqEntity,
RESOURCE resrcEntity)
protected RESOURCE createResource(java.lang.Object reqEntity)
protected void createOrUpdateResource(java.lang.Object reqEntity,
RESOURCE resrcEntity,
boolean mustBeCreated)
throws java.lang.Exception
java.lang.Exceptionprotected void afterPut(java.lang.Object reqEntity,
RESOURCE resrcEntity,
boolean isNewlyCreated)
protected <T> T readPostResource(java.lang.Object reqEntity)
HttpPostResponseBuilder.readResource(Object).T - type of response entityreqEntity - the passed request entityprotected void beforePost(java.lang.Object reqEntity,
java.lang.Object resrcEntity)
HttpPostResponseBuilder.beforeProcessing(Object, Object)reqEntity - request entity (dto)resrcEntity - response entity (model)protected <T> T createPostResource(java.lang.Object reqEntity)
HttpPostResponseBuilder.createResource(Object). Method gets called before request entity is
merged into response entity.T - type of response entityreqEntity - request entity (dto)protected void createOrUpdatePostResource(java.lang.Object reqEntity,
java.lang.Object resrcEntity,
boolean mustBeCreated)
throws java.lang.Exception
HttpPostResponseBuilder.createOrUpdateResource(Object, Object, boolean). Method gets called
after request entity is merged into response entity.reqEntity - request entity (dto)resrcEntity - resource entity (model)mustBeCreated - true when response entity must be newly created (updated only otherwise)java.lang.Exception - is allowed to throw any kind of exceptionprotected void afterPost(java.lang.Object reqEntity,
java.lang.Object resrcEntity,
boolean isNewlyCreated)
reqEntity - request entity (dto)resrcEntity - resource entity (model)isNewlyCreated - true when response entity was newly created (false when only updated)protected void processException(java.lang.String msg,
java.lang.Exception exception)
throws WebApplicationException
WebApplicationException which interrupts any current processing and gives full control to jersey.
But before passed Exception gets evaluated and used to produce nice client output and notify loggers.msg - a message which shall be given to client as headlineexception - the exception which is taken to produce a short client error messageWebApplicationException@Deprecated public void notifyAfterGet()
NotificationRequestProcessor instead.notifyAfterGet in interface CrudActionNotifable<RESOURCE>@Deprecated public void notifyAfterPut()
NotificationRequestProcessor instead.notifyAfterPut in interface CrudActionNotifable<RESOURCE>@Deprecated public void notifyAfterPost()
NotificationRequestProcessorinstead.notifyAfterPost in interface CrudActionNotifable<RESOURCE>@Deprecated public void notifyAfterDelete()
NotificationRequestProcessor instead.notifyAfterDelete in interface CrudActionNotifable<RESOURCE>@Deprecated public void notifyBeforeGet()
NotificationRequestProcessor instead.notifyBeforeGet in interface CrudActionNotifable<RESOURCE>@Deprecated public void notifyBeforeDelete()
NotificationRequestProcessor instead.notifyBeforeDelete in interface CrudActionNotifable<RESOURCE>@Deprecated public void notifyBeforePost()
NotificationRequestProcessor instead.notifyBeforePost in interface CrudActionNotifable<RESOURCE>@Deprecated public void notifyBeforePut()
NotificationRequestProcessor instead.notifyBeforePut in interface CrudActionNotifable<RESOURCE>public void setRequestProcessChain(ConfigurableRequestProcessChain<RESOURCE> requestProcessChain)
Copyright © 2018 SAP SE. All Rights Reserved.