Package com.jms.socialmedia.handlers
Class RequestHandler
- java.lang.Object
-
- com.jms.socialmedia.handlers.RequestHandler
-
- Direct Known Subclasses:
CommentRequestHandler
,FollowRequestHandler
,LikeRequestHandler
,MetricsRequestHandler
,PostRequestHandler
,UserRequestHandler
public abstract class RequestHandler extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected DataService
dataService
protected TokenService
tokenService
-
Constructor Summary
Constructors Constructor Description RequestHandler(DataService dataService, TokenService tokenService, com.google.gson.Gson gson)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
authorizeRequest(spark.Request request)
protected void
authorizeRequest(spark.Request request, Integer userIdFromRequest, Permission permission)
protected void
checkParameter(boolean check, String errorMessage, StringBuilder stringBuilder)
protected void
checkParameter(Object parameter, String errorMessage, StringBuilder stringBuilder)
protected void
checkParameter(String parameter, String errorMessage, StringBuilder stringBuilder)
protected <T> T
extractBodyContent(spark.Request request, Class<T> aClass)
void
handleAuthorizeRequest(spark.Request request, spark.Response response)
Check Bearer Token for Admin Rightsprotected void
throwBadRequestExceptionIf(boolean check, String errorMessage)
protected void
throwExceptionIfNecessary(StringBuilder stringBuilder)
-
-
-
Field Detail
-
dataService
protected final DataService dataService
-
tokenService
protected final TokenService tokenService
-
-
Constructor Detail
-
RequestHandler
public RequestHandler(DataService dataService, TokenService tokenService, com.google.gson.Gson gson)
-
-
Method Detail
-
handleAuthorizeRequest
public void handleAuthorizeRequest(spark.Request request, spark.Response response) throws IOException
Check Bearer Token for Admin Rights- Parameters:
request
-response
-- Throws:
IOException
-
authorizeRequest
protected void authorizeRequest(spark.Request request, Integer userIdFromRequest, Permission permission) throws IOException
- Parameters:
request
-userIdFromRequest
-permission
-- Throws:
NoBearerTokenException
ForbiddenException
io.jsonwebtoken.ExpiredJwtException
io.jsonwebtoken.UnsupportedJwtException
io.jsonwebtoken.MalformedJwtException
io.jsonwebtoken.SignatureException
IllegalArgumentException
IOException
-
authorizeRequest
protected void authorizeRequest(spark.Request request) throws IOException
- Parameters:
request
-- Throws:
NoBearerTokenException
ForbiddenException
io.jsonwebtoken.ExpiredJwtException
io.jsonwebtoken.UnsupportedJwtException
io.jsonwebtoken.MalformedJwtException
io.jsonwebtoken.SignatureException
IllegalArgumentException
IOException
-
extractBodyContent
protected <T> T extractBodyContent(spark.Request request, Class<T> aClass)
-
checkParameter
protected void checkParameter(boolean check, String errorMessage, StringBuilder stringBuilder)
-
checkParameter
protected void checkParameter(String parameter, String errorMessage, StringBuilder stringBuilder)
-
checkParameter
protected void checkParameter(Object parameter, String errorMessage, StringBuilder stringBuilder)
-
throwExceptionIfNecessary
protected void throwExceptionIfNecessary(StringBuilder stringBuilder)
-
throwBadRequestExceptionIf
protected void throwBadRequestExceptionIf(boolean check, String errorMessage)
-
-