Package org.mycore.frontend.jersey
Class MCRJerseyUtil
java.lang.Object
org.mycore.frontend.jersey.MCRJerseyUtil
Contains some jersey utility methods.
- Author:
- Matthias Eichner
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Checks if the current user has the read permission on the given derivate content.static void
checkPermission
(String permission) Checks if the current user has the given permission.static void
checkPermission
(String id, String permission) Checks if the current user has the given permission.static void
checkPermission
(MCRObjectID id, String permission) Checks if the current user has the given permission.static String
fromStatusCode
(int statusCode) Returns a human readable message of a http status code.static String
getBaseURL
(jakarta.ws.rs.core.UriInfo info, jakarta.ws.rs.core.Application app) Returns the base URL of the mycore system.static MCRObjectID
Returns the mycore id.static void
throwException
(jakarta.ws.rs.core.Response.Status status, String message) Throws aWebApplicationException
with status and message.static MCRContent
Transforms a jdom document to aMCRContent
via theMCRLayoutService
.
-
Field Details
-
APPLICATION_JSON_UTF8
- See Also:
-
APPLICATION_XML_UTF8
- See Also:
-
-
Constructor Details
-
MCRJerseyUtil
public MCRJerseyUtil()
-
-
Method Details
-
transform
public static MCRContent transform(Document document, jakarta.servlet.http.HttpServletRequest request) throws Exception Transforms a jdom document to aMCRContent
via theMCRLayoutService
.- Parameters:
document
- the document to transformrequest
- the http request- Throws:
Exception
-
getID
Returns the mycore id. Throws a web application exception if the id is invalid or not found.- Parameters:
id
- id as string- Returns:
- mycore object id
-
checkPermission
Checks if the current user has the given permission. Throws an unauthorized exception otherwise.- Parameters:
id
- mycore object idpermission
- permission to check
-
checkDerivateReadPermission
Checks if the current user has the read permission on the given derivate content. Throws an unauthorized exception otherwise.- Parameters:
id
- mycore object id- See Also:
-
checkPermission
Checks if the current user has the given permission. Throws an unauthorized exception otherwise.- Parameters:
id
- mycore object idpermission
- permission to check
-
checkPermission
Checks if the current user has the given permission. Throws an unauthorized exception otherwise.- Parameters:
permission
- permission to check
-
throwException
Throws aWebApplicationException
with status and message. This exception will be handled by theMCRJerseyExceptionMapper
. See stackoverflow.- Parameters:
status
- the http return statusmessage
- the message to print
-
fromStatusCode
Returns a human readable message of a http status code.- Parameters:
statusCode
- http status code- Returns:
- human readable string
-
getBaseURL
public static String getBaseURL(jakarta.ws.rs.core.UriInfo info, jakarta.ws.rs.core.Application app) Returns the base URL of the mycore system.- Parameters:
info
- the UriInfo- Returns:
- base URL of the mycore system as string
-