Class BaseController

    • Constructor Detail

      • BaseController

        public BaseController()
    • Method Detail

      • getBaseEnvLinkURL

        protected String getBaseEnvLinkURL()
      • getEhrUuid

        protected UUID getEhrUuid​(String ehrIdString)
        Helper to allow string UUID input from controllers, which throws an ObjectNotFound exception when no UUID representation can be created. This case is equal to no matching object.
        Parameters:
        ehrIdString - Input String representation of the ehrId
        Returns:
        UUID representation of the ehrId
        Throws:
        ObjectNotFoundException - when no UUID can't be created from input
      • getCompositionVersionedObjectUidString

        protected UUID getCompositionVersionedObjectUidString​(String compositionVersionedObjectUidString)
        Helper to allow string UUID input from controllers, which throws an ObjectNotFound exception when no UUID representation can be created. This case is equal to no matching object.
        Parameters:
        compositionVersionedObjectUidString - Input String representation
        Returns:
        UUID representation
        Throws:
        ObjectNotFoundException - when no UUID can't be created from input
      • getContributionVersionedObjectUidString

        protected UUID getContributionVersionedObjectUidString​(String compositionVersionedObjectUidString)
        Helper to allow string UUID input from controllers, which throws an ObjectNotFound exception when no UUID representation can be created. This case is equal to no matching object.
        Parameters:
        compositionVersionedObjectUidString - Input String representation
        Returns:
        UUID representation
        Throws:
        ObjectNotFoundException - when no UUID can't be created from input
      • extractCompositionFormat

        protected CompositionFormat extractCompositionFormat​(String contentType)
        Extracts the CompositionFormat from the REST request's input MediaType style content type header string.
        Parameters:
        contentType - String representation of REST request's input MediaType style content type header
        Returns:
        CompositionFormat expressing the content type
        Throws:
        NotAcceptableException - when content type is not supported or input is invalid
      • extractMediaType

        protected org.springframework.http.MediaType extractMediaType​(String accept)
      • encodePath

        public String encodePath​(String path)
        Convenience helper to encode path strings to URI-safe strings
        Parameters:
        path - input
        Returns:
        URI-safe escaped string
        Throws:
        InternalServerException - when encoding failed
      • createErrorResponse

        protected org.springframework.http.ResponseEntity<Map<String,​String>> createErrorResponse​(String message,
                                                                                                        org.springframework.http.HttpStatus status)
      • extractVersionedObjectUidFromVersionUid

        protected UUID extractVersionedObjectUidFromVersionUid​(String versionUid)
        Extracts the UUID base from a versioned UID. Or, if
        Parameters:
        versionUid -
        Returns:
      • extractVersionFromVersionUid

        protected int extractVersionFromVersionUid​(String versionUid)
      • restErrorHandler

        @Deprecated
        @ExceptionHandler(java.lang.IllegalArgumentException.class)
        public org.springframework.http.ResponseEntity<Map<String,​String>> restErrorHandler​(IllegalArgumentException e)
        Deprecated.
        Throw a more specific exception.
        Handler for broad and general Java standard exception IllegalArgumentException. Shall be replaced with a more specific exception like InvalidApiParameterException in backend code with time.
        Returns:
        ResponseEntity> as BAD_REQUEST - 400
      • restErrorHandler

        @ExceptionHandler(org.springframework.web.bind.MissingServletRequestParameterException.class)
        public org.springframework.http.ResponseEntity<Map<String,​String>> restErrorHandler​(org.springframework.web.bind.MissingServletRequestParameterException e)
        This handler catches the exception automatically generated and thrown by the framework, when specified parameters are not present or matching.
        Returns:
        ResponseEntity> as BAD_REQUEST - 400
      • restErrorHandler

        @ExceptionHandler(org.springframework.http.converter.HttpMessageNotReadableException.class)
        public org.springframework.http.ResponseEntity<Map<String,​String>> restErrorHandler​(org.springframework.http.converter.HttpMessageNotReadableException e)
        This handler catches the exception automatically generated and thrown by the framework, when the request's message can't be read. For example, due to missing body, while required.
        Returns:
        ResponseEntity> as BAD_REQUEST - 400
      • restErrorHandler

        @ExceptionHandler(java.lang.Exception.class)
        public org.springframework.http.ResponseEntity<Map<String,​String>> restErrorHandler​(Exception e)
        Fallback error handler.
        Returns:
        ResponseEntity> as INTERNAL_SERVER_ERROR - 500