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
public abstract class BaseController extends Object
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
Fields Modifier and Type Field Description static StringACCEPTstatic StringCOMPOSITIONstatic StringCONTENT_TYPEstatic StringCONTRIBUTIONstatic StringDEFINITIONstatic StringDIRECTORYstatic StringEHRstatic StringEHR_STATUSstatic StringETAGstatic StringIF_MATCHstatic StringIF_NONE_MATCHstatic StringLAST_MODIFIEDstatic StringLOCATIONstatic StringOPENEHR_AUDIT_DETAILSstatic StringOPENEHR_VERSIONstatic StringPREFERstatic StringQUERYstatic StringREQ_ACCEPTstatic StringREQ_CONTENT_TYPEstatic StringREQ_CONTENT_TYPE_BODYstatic StringREQ_OPENEHR_AUDITstatic StringREQ_OPENEHR_VERSIONstatic StringREQ_PREFERstatic StringRESP_CONTENT_TYPE_DESCstatic StringRESP_ETAG_DESCstatic StringRESP_LAST_MODIFIED_DESCstatic StringRESP_LOCATION_DESCstatic StringRESP_NOT_ACCEPTABLE_DESCstatic StringRESP_UNSUPPORTED_MEDIA_DESCstatic StringREST_OPERATIONstatic StringRETURN_MINIMALstatic StringRETURN_REPRESENTATION
-
Constructor Summary
Constructors Constructor Description BaseController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Map<String,String>>add2MetaMap(Map<String,Map<String,String>> metaMap, String key, String value)StringencodePath(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 StringgetBaseEnvLinkURL()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 Optional<OffsetDateTime>getVersionAtTimeParam()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 Detail
-
OPENEHR_AUDIT_DETAILS
public static final String OPENEHR_AUDIT_DETAILS
- See Also:
- Constant Field Values
-
OPENEHR_VERSION
public static final String OPENEHR_VERSION
- See Also:
- Constant Field Values
-
PREFER
public static final String PREFER
- See Also:
- Constant Field Values
-
RETURN_MINIMAL
public static final String RETURN_MINIMAL
- See Also:
- Constant Field Values
-
RETURN_REPRESENTATION
public static final String RETURN_REPRESENTATION
- See Also:
- Constant Field Values
-
CONTENT_TYPE
public static final String CONTENT_TYPE
- See Also:
- Constant Field Values
-
ACCEPT
public static final String ACCEPT
- See Also:
- Constant Field Values
-
REQ_CONTENT_TYPE
public static final String REQ_CONTENT_TYPE
- See Also:
- Constant Field Values
-
REQ_CONTENT_TYPE_BODY
public static final String REQ_CONTENT_TYPE_BODY
- See Also:
- Constant Field Values
-
REQ_ACCEPT
public static final String REQ_ACCEPT
- See Also:
- Constant Field Values
-
RESP_CONTENT_TYPE_DESC
public static final String RESP_CONTENT_TYPE_DESC
- See Also:
- Constant Field Values
-
REST_OPERATION
public static final String REST_OPERATION
- See Also:
- Constant Field Values
-
LOCATION
public static final String LOCATION
- See Also:
- Constant Field Values
-
ETAG
public static final String ETAG
- See Also:
- Constant Field Values
-
LAST_MODIFIED
public static final String LAST_MODIFIED
- See Also:
- Constant Field Values
-
IF_MATCH
public static final String IF_MATCH
- See Also:
- Constant Field Values
-
IF_NONE_MATCH
public static final String IF_NONE_MATCH
- See Also:
- Constant Field Values
-
REQ_OPENEHR_VERSION
public static final String REQ_OPENEHR_VERSION
- See Also:
- Constant Field Values
-
REQ_OPENEHR_AUDIT
public static final String REQ_OPENEHR_AUDIT
- See Also:
- Constant Field Values
-
REQ_PREFER
public static final String REQ_PREFER
- See Also:
- Constant Field Values
-
RESP_LOCATION_DESC
public static final String RESP_LOCATION_DESC
- See Also:
- Constant Field Values
-
RESP_ETAG_DESC
public static final String RESP_ETAG_DESC
- See Also:
- Constant Field Values
-
RESP_LAST_MODIFIED_DESC
public static final String RESP_LAST_MODIFIED_DESC
- See Also:
- Constant Field Values
-
RESP_NOT_ACCEPTABLE_DESC
public static final String RESP_NOT_ACCEPTABLE_DESC
- See Also:
- Constant Field Values
-
RESP_UNSUPPORTED_MEDIA_DESC
public static final String RESP_UNSUPPORTED_MEDIA_DESC
- See Also:
- Constant Field Values
-
EHR
public static final String EHR
- See Also:
- Constant Field Values
-
EHR_STATUS
public static final String EHR_STATUS
- See Also:
- Constant Field Values
-
COMPOSITION
public static final String COMPOSITION
- See Also:
- Constant Field Values
-
DIRECTORY
public static final String DIRECTORY
- See Also:
- Constant Field Values
-
CONTRIBUTION
public static final String CONTRIBUTION
- See Also:
- Constant Field Values
-
QUERY
public static final String QUERY
- See Also:
- Constant Field Values
-
DEFINITION
public static final String DEFINITION
- See Also:
- Constant Field Values
-
-
Method Detail
-
add2MetaMap
public Map<String,Map<String,String>> add2MetaMap(Map<String,Map<String,String>> metaMap, String key, String value)
-
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 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
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
-
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)
-
enrichRequestAttribute
protected void enrichRequestAttribute(String attributeName, Object value)
Add attribute to the current request.- Parameters:
attributeName-value-
-
resolveContentType
protected org.springframework.http.MediaType resolveContentType(String acceptHeader)
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
-
getVersionAtTimeParam
protected Optional<OffsetDateTime> getVersionAtTimeParam()
-
-