Package org.ehrbase.rest
Class BaseController
java.lang.Object
org.ehrbase.rest.BaseController
- Direct Known Subclasses:
AdminCompositionController,AdminContributionController,AdminController,AdminDirectoryController,AdminEhrController,AdminQueryController,AdminTemplateController,ItemTagController,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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic 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 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) protected CompositionRepresentationextractCompositionRepresentation(String contentType, String format) Extracts theCompositionRepresentationfrom the REST request's inputMediaTypestyle content type header string and validates them against the given format asCompositionFormat.protected UUIDextractVersionedObjectUidFromVersionUid(String versionUid) Extracts the UUID base from a versioned UID.extractVersionFromVersionUid(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 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 UUIDHelper to parse an input UUID int string format.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, org.springframework.http.MediaType... supportedMediaTypes) Resolves the Content-Type based on Accept header using the supported predicate.
-
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_ACCEPT
- See Also:
-
RESP_CONTENT_TYPE_DESC
- See Also:
-
LOCATION
- See Also:
-
ETAG
- See Also:
-
LAST_MODIFIED
- See Also:
-
IF_MATCH
- See Also:
-
EHR
- See Also:
-
EHR_STATUS
- See Also:
-
VERSIONED_EHR_STATUS
- See Also:
-
VERSIONED_COMPOSITION
- See Also:
-
COMPOSITION
- See Also:
-
DIRECTORY
- See Also:
-
CONTRIBUTION
- See Also:
-
QUERY
- See Also:
-
DEFINITION
- See Also:
-
TEMPLATE
- See Also:
-
API_CONTEXT_PATH
- See Also:
-
API_CONTEXT_PATH_WITH_VERSION
- See Also:
-
ADMIN_API_CONTEXT_PATH
- See Also:
-
apiContextPathWithVersion
-
-
Constructor Details
-
BaseController
public BaseController()
-
-
Method Details
-
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
-
parseUUID
Helper to parse an input UUID int string format.- Parameters:
uuidString- to parseerror- to raise in case the given UUID string is invalid- Returns:
- uuid parse from the input
uuidString - Throws:
InvalidApiParameterException- when the givenuuidStringis invalid
-
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
-
extractCompositionRepresentation
protected CompositionRepresentation extractCompositionRepresentation(String contentType, String format) Extracts theCompositionRepresentationfrom the REST request's inputMediaTypestyle content type header string and validates them against the given format asCompositionFormat.- Parameters:
contentType- String representation of REST request's inputMediaTypestyle content type headerformat- String representation of the REST requestformatparameter that is interpreted as anCompositionFormat- Returns:
CompositionFormatexpressing the content type- Throws:
NotAcceptableException- when content type or composition format is not supported or the input is invalid
-
extractVersionedObjectUidFromVersionUid
Extracts the UUID base from a versioned UID. Or, if- Parameters:
versionUid- raw versionUid in format[UUID]::[VERSION]- Returns:
- uuid
[UUID]part
-
extractVersionFromVersionUid
-
resolveContentType
Resolves the Content-Type based on Accept header. Validates if the givenacceptHeaderin eitherapplication/jsonorapplication/xml. In caseacceptHeaderis givenapplication/jsonwill be selected as a default.- 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, org.springframework.http.MediaType... supportedMediaTypes) Resolves the Content-Type based on Accept header using the supported predicate.- Parameters:
acceptHeader- Accept header valuedefaultMediaType- Default Content-TypesupportedMediaTypes- supported Content-Types- Returns:
- Content-Type of the response
-
decodeVersionAtTime
-