Package com.jk.services.server
Class JKAbstractRestController
java.lang.Object
com.jk.services.server.JKAbstractRestController
- Direct Known Subclasses:
JKCacheService
,JKConfigService
,JKHeadersService
,JKHiService
,JKInfoService
,JKLogCrossCuttingService
,JKLogService
,JKPingService
@Consumes("application/json")
@Produces("application/json")
public class JKAbstractRestController
extends Object
This class is a base class for REST controllers that provides common
functionality and utility methods.
This class includes methods for handling HTTP requests, accessing request headers, and returning HTTP responses with appropriate status codes.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.ws.rs.core.Response
This method generates an HTTP response with an accepted status code and includes the provided model as the response entity.protected jakarta.ws.rs.core.Response
badRequest
(Object entity) This method generates an HTTP response with a bad request status code (HTTP 400 Bad Request) and includes the provided entity as the response entity.protected jakarta.ws.rs.core.Response
This method generates an HTTP response with a forbidden status code (HTTP 403 Forbidden) and includes the provided entity as the response entity.This method gets the header.This method retrieves the remote IP address of the client making the request.This method retrieves the remote role associated with the request.This method retrieves the remote user associated with the request.This method gets the tenant identifier (ID).protected jakarta.ws.rs.core.Response
interalServerError
(Object entity) This method generates an HTTP response with an internal server error status code (HTTP 500 Internal Server Error) and includes the provided entity as the response entity.protected jakarta.ws.rs.core.Response
This method generates an HTTP response with a not found status code (HTTP 404 Not Found) and includes the provided entity as the response entity.protected jakarta.ws.rs.core.Response
This method generates an HTTP response with a status code and includes the provided model as the response entity.protected jakarta.ws.rs.core.Response
This method generates an HTTP response with the specified HTTP status code and includes the provided entity as the response entity.protected jakarta.ws.rs.core.Response
unauthorized
(Object entity) This method generates an HTTP response with an unauthorized status code (HTTP 401 Unauthorized) and includes the provided entity as the response entity.
-
Field Details
-
logger
Represents the class logger.
-
-
Constructor Details
-
JKAbstractRestController
public JKAbstractRestController()
-
-
Method Details
-
getRemoteIp
This method retrieves the remote IP address of the client making the request.- Returns:
- the remote IP address as a string.
-
getRemoteUser
This method retrieves the remote user associated with the request.- Returns:
- the remote user.
-
getRemoteRole
This method retrieves the remote role associated with the request.- Returns:
- the remote role.
-
ok
This method generates an HTTP response with a status code and includes the provided model as the response entity.- Parameters:
model
- Specifies the representation entity data.- Returns:
- the response with a status code and the provided model as the entity.
-
accepted
This method generates an HTTP response with an accepted status code and includes the provided model as the response entity.- Parameters:
model
- Specifies the representation entity data.- Returns:
- the response with an accepted status code and the provided model as the entity.
-
notFound
This method generates an HTTP response with a not found status code (HTTP 404 Not Found) and includes the provided entity as the response entity.- Parameters:
entity
- Specifies the representation entity data.- Returns:
- the response with a status code and the provided entity.
-
badRequest
This method generates an HTTP response with a bad request status code (HTTP 400 Bad Request) and includes the provided entity as the response entity.- Parameters:
entity
- Specifies the representation entity data.- Returns:
- the response with a status code and the provided entity.
-
unauthorized
This method generates an HTTP response with an unauthorized status code (HTTP 401 Unauthorized) and includes the provided entity as the response entity.- Parameters:
entity
- Specifies the representation entity data.- Returns:
- the response with a status code and the provided entity.
-
forbidden
This method generates an HTTP response with a forbidden status code (HTTP 403 Forbidden) and includes the provided entity as the response entity.- Parameters:
entity
- Specifies the representation entity data.- Returns:
- the response with a status code and the provided entity.
-
interalServerError
This method generates an HTTP response with an internal server error status code (HTTP 500 Internal Server Error) and includes the provided entity as the response entity.- Parameters:
entity
- Specifies the representation entity data.- Returns:
- the response with a status code and the provided entity.
-
status
protected jakarta.ws.rs.core.Response status(jakarta.ws.rs.core.Response.Status status, Object entity) This method generates an HTTP response with the specified HTTP status code and includes the provided entity as the response entity.- Parameters:
status
- Specifies the HTTP status code to set for the response.entity
- Specifies the representation entity data.- Returns:
- the response with the provided status code and entity.
-
getHeader
This method gets the header.- Parameters:
name
- Specifies the name.- Returns:
- the header.
-
getTenantId
This method gets the tenant identifier (ID).- Returns:
- the tenant identifier (ID).
-