public abstract class RestService<T> extends java.lang.Object implements Service<T>
Constructor and Description |
---|
RestService() |
Modifier and Type | Method and Description |
---|---|
boolean |
authorize(Request<T> request)
Determine whether access to this service is authorized for the authenticated user,
if any.
|
Response<T> |
delete(Request<T> request)
Delete an existing entity or relationship.
|
Response<T> |
get(Request<T> request)
Retrieve an existing entity or relationship.
|
abstract T |
getBody(java.lang.String text) |
java.util.List<java.lang.String> |
getRolesAllowedAccess(Request<T> request)
If the request user belongs to any of these roles, access is granted.
|
abstract java.lang.String |
getText(T body,
int prettyIndent) |
void |
initialize(Request<T> request,
java.security.Principal principal,
java.util.function.Predicate<java.lang.String> roleChecker)
Mechanism for setting up request for authorization
|
boolean |
isAuthenticationRequired(Request<T> request)
Return true if authentication is required.
|
Response<T> |
patch(Request<T> request)
Patch an existing entity with delta values.
|
Response<T> |
post(Request<T> request)
Create a new entity or relationship.
|
Response<T> |
put(Request<T> request)
Update an existing entity with different values.
|
Response<T> |
service(Request<T> request)
Service a request.
|
public abstract T getBody(java.lang.String text) throws ServiceException
ServiceException
public abstract java.lang.String getText(T body, int prettyIndent) throws ServiceException
body
- prettyIndent
- zero means no pretty printServiceException
public void initialize(Request<T> request, java.security.Principal principal, java.util.function.Predicate<java.lang.String> roleChecker) throws ServiceException
Service
initialize
in interface Service<T>
ServiceException
public boolean isAuthenticationRequired(Request<T> request) throws ServiceException
isAuthenticationRequired
in interface Service<T>
ServiceException
public boolean authorize(Request<T> request) throws ServiceException
Service
authorize
in interface Service<T>
ServiceException
public java.util.List<java.lang.String> getRolesAllowedAccess(Request<T> request) throws ServiceException
isAuthenticationRequired(Request)
must return true for this
to work with Java container authentication.ServiceException
public Response<T> service(Request<T> request) throws ServiceException
Service
service
in interface Service<T>
ServiceException
@GET public Response<T> get(Request<T> request) throws ServiceException
ServiceException
@POST public Response<T> post(Request<T> request) throws ServiceException
ServiceException
@PUT public Response<T> put(Request<T> request) throws ServiceException
ServiceException
@PUT public Response<T> patch(Request<T> request) throws ServiceException
ServiceException
@DELETE public Response<T> delete(Request<T> request) throws ServiceException
ServiceException
Copyright © 2018