Interface EntityRequestHandler


  • public interface EntityRequestHandler
    Handles the URL/request processing for an entity in a central location
    Author:
    Aaron Zeckoski (aaron@caret.cam.ac.uk)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String BATCH
      The reserved word used to trigger batch operations
      static String COMPENSATE_METHOD
      This is the special indicator used to denote that POST should be translated to a PUT or DELETE in order to compensate for browser limitations, Example: /people/1?
      static String DESCRIBE
      The reserved word used to trigger entity descriptions
      static String FAKE_ID
      The id used in generated URLs
      static String HEADER_ENTITY_ID
      This is the name of the header which will contain the id of newly created entities
      static String HEADER_ENTITY_REFERENCE
      This is the name of the header which will contain the reference of created/updated entities
      static String HEADER_ENTITY_URL
      This is the name of the header that will contain created/updated entities SHOW URL
      static String SLASH_BATCH  
      static String SLASH_DESCRIBE  
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      String handleEntityAccess​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, String path)
      Handles the servlet request response cycle for all direct servlet accesses, logically, we only want to let this request continue on if the entity exists AND there is an http access provider to handle it AND the user can access it (there is some auth completed already or no auth is required)
      String handleEntityError​(javax.servlet.http.HttpServletRequest req, Throwable error)
      Handles an error which occurs by sending an email and logging extra info about the failure
    • Field Detail

      • HEADER_ENTITY_ID

        static final String HEADER_ENTITY_ID
        This is the name of the header which will contain the id of newly created entities
        See Also:
        Constant Field Values
      • HEADER_ENTITY_REFERENCE

        static final String HEADER_ENTITY_REFERENCE
        This is the name of the header which will contain the reference of created/updated entities
        See Also:
        Constant Field Values
      • HEADER_ENTITY_URL

        static final String HEADER_ENTITY_URL
        This is the name of the header that will contain created/updated entities SHOW URL
        See Also:
        Constant Field Values
      • COMPENSATE_METHOD

        static final String COMPENSATE_METHOD
        This is the special indicator used to denote that POST should be translated to a PUT or DELETE in order to compensate for browser limitations, Example: /people/1?_method=PUT
        See Also:
        Constant Field Values
    • Method Detail

      • handleEntityAccess

        String handleEntityAccess​(javax.servlet.http.HttpServletRequest req,
                                  javax.servlet.http.HttpServletResponse res,
                                  String path)
        Handles the servlet request response cycle for all direct servlet accesses, logically, we only want to let this request continue on if the entity exists AND there is an http access provider to handle it AND the user can access it (there is some auth completed already or no auth is required)
        Parameters:
        req - the servlet request
        res - the servlet response
        path - the path from the request (if null it will be generated from the req)
        Returns:
        the entity reference that was handled as part of this request
        Throws:
        EntityException - if entity could not be found or failure parsing
      • handleEntityError

        String handleEntityError​(javax.servlet.http.HttpServletRequest req,
                                 Throwable error)
        Handles an error which occurs by sending an email and logging extra info about the failure
        Parameters:
        req - the current request
        error - the current error that occurred
        Returns:
        the comprehensive error message