Class MCRJerseyUtil

java.lang.Object
org.mycore.frontend.jersey.MCRJerseyUtil

public abstract class MCRJerseyUtil extends Object
Contains some jersey utility methods.
Author:
Matthias Eichner
  • Field Details

  • 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 a MCRContent via the MCRLayoutService.
      Parameters:
      document - the document to transform
      request - the http request
      Throws:
      Exception
    • getID

      public static MCRObjectID getID(String id)
      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

      public static void checkPermission(MCRObjectID id, String permission)
      Checks if the current user has the given permission. Throws an unauthorized exception otherwise.
      Parameters:
      id - mycore object id
      permission - permission to check
    • checkDerivateReadPermission

      public static void checkDerivateReadPermission(MCRObjectID id)
      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

      public static void checkPermission(String id, String permission)
      Checks if the current user has the given permission. Throws an unauthorized exception otherwise.
      Parameters:
      id - mycore object id
      permission - permission to check
    • checkPermission

      public static void checkPermission(String permission)
      Checks if the current user has the given permission. Throws an unauthorized exception otherwise.
      Parameters:
      permission - permission to check
    • throwException

      public static void throwException(jakarta.ws.rs.core.Response.Status status, String message)
      Throws a WebApplicationException with status and message. This exception will be handled by the MCRJerseyExceptionMapper. See stackoverflow.
      Parameters:
      status - the http return status
      message - the message to print
    • fromStatusCode

      public static String fromStatusCode(int statusCode)
      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