Class AbstractOperation
- java.lang.Object
-
- org.linuxforhealth.fhir.server.spi.operation.AbstractOperation
-
- All Implemented Interfaces:
FHIROperation
- Direct Known Subclasses:
AbstractCqlOperation
,AbstractDataRequirementsOperation
,AbstractMeasureOperation
,AbstractTermOperation
,ApplyOperation
,BadOperation
,BenchOperation
,ConvertOperation
,CrashingOperation
,DocumentOperation
,EraseOperation
,EverythingOperation
,ExportOperation
,HealthcheckOperation
,ImportOperation
,MeasureSubmitDataOperation
,MemberMatchOperation
,MyOperation
,ReindexOperation
,RetrieveIndexOperation
,StatusOperation
,ValidateOperation
,VersionsOperation
public abstract class AbstractOperation extends java.lang.Object implements FHIROperation
-
-
Field Summary
Fields Modifier and Type Field Description protected OperationDefinition
definition
-
Constructor Summary
Constructors Constructor Description AbstractOperation()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected FHIROperationException
buildExceptionWithIssue(java.lang.String msg, IssueType issueType)
protected FHIROperationException
buildExceptionWithIssue(java.lang.String msg, IssueType issueType, java.lang.Throwable cause)
protected abstract OperationDefinition
buildOperationDefinition()
protected int
countParameters(Parameters parameters, java.lang.String name)
protected abstract Parameters
doInvoke(FHIROperationContext operationContext, java.lang.Class<? extends Resource> resourceType, java.lang.String logicalId, java.lang.String versionId, Parameters parameters, FHIRResourceHelpers resourceHelper, SearchHelper searchHelper)
This is the method that concrete subclasses must implement to perform the operation logic.protected OperationDefinition.Parameter
findOpDefParameter(java.util.List<OperationDefinition.Parameter> parameters, java.lang.String name)
Find the operation definition parameter with the specified name.OperationDefinition
getDefinition()
java.lang.String
getName()
protected Parameters.Parameter
getParameter(Parameters parameters, java.lang.String name)
Get the first instance of a parameter by nameprotected java.util.List<OperationDefinition.Parameter>
getParameterDefinitions(OperationParameterUse use)
protected java.util.List<Parameters.Parameter>
getParameters(Parameters parameters, java.lang.String name)
Get all instances of a parameter by nameprotected java.util.List<java.lang.String>
getResourceTypeNames()
Parameters
invoke(FHIROperationContext operationContext, java.lang.Class<? extends Resource> resourceType, java.lang.String logicalId, java.lang.String versionId, Parameters parameters, FHIRResourceHelpers resourceHelper, SearchHelper searchHelper)
Invoke the operation.protected boolean
isAbstractResourceTypesDisallowed()
Determines if the operation disallows abstract resource types, Resource and DomainResource.protected boolean
isAdditionalMethodAllowed(java.lang.String method)
Determines if any methods (except GET and POST) are allowed for the operation.protected void
validateInputParameters(FHIROperationContext operationContext, java.lang.Class<? extends Resource> resourceType, java.lang.String logicalId, java.lang.String versionId, Parameters parameters)
protected void
validateOperationContext(FHIROperationContext operationContext, java.lang.Class<? extends Resource> resourceType, Parameters parameters)
protected void
validateOutputParameters(FHIROperationContext operationContext, Parameters result)
protected void
validateParameters(FHIROperationContext operationContext, Parameters parameters, OperationParameterUse use)
-
-
-
Field Detail
-
definition
protected final OperationDefinition definition
-
-
Method Detail
-
getDefinition
public OperationDefinition getDefinition()
- Specified by:
getDefinition
in interfaceFHIROperation
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceFHIROperation
-
invoke
public final Parameters invoke(FHIROperationContext operationContext, java.lang.Class<? extends Resource> resourceType, java.lang.String logicalId, java.lang.String versionId, Parameters parameters, FHIRResourceHelpers resourceHelper, SearchHelper searchHelper) throws FHIROperationException
Description copied from interface:FHIROperation
Invoke the operation.- Specified by:
invoke
in interfaceFHIROperation
- Throws:
FHIROperationException
- if input or output parameters fail validation or an exception occurs
-
buildOperationDefinition
protected abstract OperationDefinition buildOperationDefinition()
-
countParameters
protected int countParameters(Parameters parameters, java.lang.String name)
-
doInvoke
protected abstract Parameters doInvoke(FHIROperationContext operationContext, java.lang.Class<? extends Resource> resourceType, java.lang.String logicalId, java.lang.String versionId, Parameters parameters, FHIRResourceHelpers resourceHelper, SearchHelper searchHelper) throws FHIROperationException
This is the method that concrete subclasses must implement to perform the operation logic.- Returns:
- the Parameters object to return or null if there is no response Parameters object to return
- Throws:
FHIROperationException
-
getParameterDefinitions
protected java.util.List<OperationDefinition.Parameter> getParameterDefinitions(OperationParameterUse use)
-
getParameter
protected Parameters.Parameter getParameter(Parameters parameters, java.lang.String name)
Get the first instance of a parameter by name- Parameters:
parameters
-name
- non-null- Returns:
- the first parameter that matches the given name; or null if none exist
- Throws:
java.lang.NullPointerException
- if name is null
-
getParameters
protected java.util.List<Parameters.Parameter> getParameters(Parameters parameters, java.lang.String name)
Get all instances of a parameter by name- Parameters:
parameters
-name
- non-null- Returns:
- a list of parameters that match the given name; never null
- Throws:
java.lang.NullPointerException
- if name is null
-
getResourceTypeNames
protected java.util.List<java.lang.String> getResourceTypeNames()
-
validateInputParameters
protected void validateInputParameters(FHIROperationContext operationContext, java.lang.Class<? extends Resource> resourceType, java.lang.String logicalId, java.lang.String versionId, Parameters parameters) throws FHIROperationException
- Throws:
FHIROperationException
-
validateOperationContext
protected void validateOperationContext(FHIROperationContext operationContext, java.lang.Class<? extends Resource> resourceType, Parameters parameters) throws FHIROperationException
- Throws:
FHIROperationException
-
isAdditionalMethodAllowed
protected boolean isAdditionalMethodAllowed(java.lang.String method)
Determines if any methods (except GET and POST) are allowed for the operation. This can be overridden by an operation to allow additional methods.- Returns:
- true or false
-
isAbstractResourceTypesDisallowed
protected boolean isAbstractResourceTypesDisallowed()
Determines if the operation disallows abstract resource types, Resource and DomainResource. TODO: Remove this method when Issue #2526 is implemented, at which time, abstract resource types will be disallowed for any operation.- Returns:
- true or false
-
validateOutputParameters
protected void validateOutputParameters(FHIROperationContext operationContext, Parameters result) throws FHIROperationException
- Throws:
FHIROperationException
-
validateParameters
protected void validateParameters(FHIROperationContext operationContext, Parameters parameters, OperationParameterUse use) throws FHIROperationException
- Throws:
FHIROperationException
-
findOpDefParameter
protected OperationDefinition.Parameter findOpDefParameter(java.util.List<OperationDefinition.Parameter> parameters, java.lang.String name)
Find the operation definition parameter with the specified name.- Parameters:
parameters
- the list of parameters from the OperationDefinitionname
- the name of the parameter to find- Returns:
- the operation definition parameter with the specified name or null if not found
-
buildExceptionWithIssue
protected FHIROperationException buildExceptionWithIssue(java.lang.String msg, IssueType issueType) throws FHIROperationException
- Throws:
FHIROperationException
-
buildExceptionWithIssue
protected FHIROperationException buildExceptionWithIssue(java.lang.String msg, IssueType issueType, java.lang.Throwable cause) throws FHIROperationException
- Throws:
FHIROperationException
-
-