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 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​(HttpServletRequest req,
                                  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​(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