Package org.ehrbase.rest
Class BaseController
java.lang.Object
org.ehrbase.rest.BaseController
- Direct Known Subclasses:
AdminCompositionController,AdminContributionController,AdminController,AdminDirectoryController,AdminEhrController,AdminTemplateController,OpenehrCompositionController,OpenehrContributionController,OpenehrDefinitionQueryController,OpenehrDirectoryController,OpenehrEhrController,OpenehrEhrStatusController,OpenehrQueryController,OpenehrTemplateController,OpenehrVersionedCompositionController,OpenehrVersionedEhrStatusController,StatusController
This base controller implements the basic functionality for all specific controllers. This
includes error handling and utils.
- Since:
- 1.0.0
- Author:
- Stefan Spiska, Jake Smolka
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringprotected Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected URIcreateLocationUri(String... pathSegments) Returns a URI for list of segments.protected static Optional<OffsetDateTime>decodeVersionAtTime(String versionAtTimeParam) encodePath(String path) Convenience helper to encode path strings to URI-safe stringsprotected voidenrichRequestAttribute(String attributeName, Object value) Add attribute to the current request.protected org.ehrbase.response.ehrscape.CompositionFormatextractCompositionFormat(String contentType) Extracts theCompositionFormatfrom the REST request's inputMediaTypestyle content type header string.protected UUIDextractVersionedObjectUidFromVersionUid(String versionUid) Extracts the UUID base from a versioned UID.protected intextractVersionFromVersionUid(String versionUid) protected UUIDgetCompositionVersionedObjectUidString(String compositionVersionedObjectUidString) Helper to allow string UUID input from controllers, which throws an ObjectNotFound exception when no UUID representation can be created.protected Stringprotected UUIDgetContributionVersionedObjectUidString(String compositionVersionedObjectUidString) Helper to allow string UUID input from controllers, which throws an ObjectNotFound exception when no UUID representation can be created.protected UUIDgetEhrUuid(String ehrIdString) Helper to allow string UUID input from controllers, which throws an ObjectNotFound exception when no UUID representation can be created.protected org.springframework.http.MediaTyperesolveContentType(String acceptHeader) Resolves the Content-Type based on Accept header.protected org.springframework.http.MediaTyperesolveContentType(String acceptHeader, org.springframework.http.MediaType defaultMediaType) Resolves the Content-Type based on Accept header.
-
Field Details
-
OPENEHR_AUDIT_DETAILS
- See Also:
-
OPENEHR_VERSION
- See Also:
-
PREFER
- See Also:
-
RETURN_MINIMAL
- See Also:
-
RETURN_REPRESENTATION
- See Also:
-
CONTENT_TYPE
- See Also:
-
ACCEPT
- See Also:
-
REQ_CONTENT_TYPE
- See Also:
-
REQ_CONTENT_TYPE_BODY
- See Also:
-
REQ_ACCEPT
- See Also:
-
RESP_CONTENT_TYPE_DESC
- See Also:
-
REST_OPERATION
- See Also:
-
LOCATION
- See Also:
-
ETAG
- See Also:
-
LAST_MODIFIED
- See Also:
-
IF_MATCH
- See Also:
-
IF_NONE_MATCH
- See Also:
-
REQ_OPENEHR_VERSION
- See Also:
-
REQ_OPENEHR_AUDIT
- See Also:
-
REQ_PREFER
- See Also:
-
RESP_LOCATION_DESC
- See Also:
-
RESP_ETAG_DESC
- See Also:
-
RESP_LAST_MODIFIED_DESC
- See Also:
-
RESP_NOT_ACCEPTABLE_DESC
- See Also:
-
RESP_UNSUPPORTED_MEDIA_DESC
- See Also:
-
EHR
- See Also:
-
EHR_STATUS
- See Also:
-
COMPOSITION
- See Also:
-
DIRECTORY
- See Also:
-
CONTRIBUTION
- See Also:
-
QUERY
- See Also:
-
DEFINITION
- See Also:
-
TEMPLATE
- See Also:
-
API_CONTEXT_PATH_WITH_VERSION
- See Also:
-
apiContextPathWithVersion
-
-
Constructor Details
-
BaseController
public BaseController()
-
-
Method Details
-
add2MetaMap
-
getContextPath
-
createLocationUri
Returns a URI for list of segments. The segments are appended to the base path and encoded to ensure safe usage in a URI.- Parameters:
pathSegments- List of segments to append to the base URL- Returns:
- URI for the given base URL and segments
-
getEhrUuid
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
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
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 org.ehrbase.response.ehrscape.CompositionFormat extractCompositionFormat(String contentType) Extracts theCompositionFormatfrom the REST request's inputMediaTypestyle content type header string.- Parameters:
contentType- String representation of REST request's inputMediaTypestyle content type header- Returns:
CompositionFormatexpressing the content type- Throws:
NotAcceptableException- when content type is not supported or input is invalid
-
encodePath
Convenience helper to encode path strings to URI-safe strings- Parameters:
path- input- Returns:
- URI-safe escaped string
- Throws:
InternalServerException- when encoding failed
-
extractVersionedObjectUidFromVersionUid
Extracts the UUID base from a versioned UID. Or, if- Parameters:
versionUid-- Returns:
-
extractVersionFromVersionUid
-
enrichRequestAttribute
Add attribute to the current request.- Parameters:
attributeName-value-
-
resolveContentType
Resolves the Content-Type based on Accept header.- Parameters:
acceptHeader- Accept header value- Returns:
- Content-Type of the response
-
resolveContentType
protected org.springframework.http.MediaType resolveContentType(String acceptHeader, org.springframework.http.MediaType defaultMediaType) Resolves the Content-Type based on Accept header.- Parameters:
acceptHeader- Accept header valuedefaultMediaType- Default Content-Type- Returns:
- Content-Type of the response
-
decodeVersionAtTime
-