MdsRestFacade¶
-
public interface
MdsRestFacade
<T>¶ Interface called by the REST controller REST operations. Should be exposed as an OSGi service for each MDS Entity. If rest is not supported, it throws a
org.motechproject.mds.exception.rest.RestNotSupportedException
.Parameters: - <T> – the entity class.
Methods¶
create¶
-
RestProjection
create
(InputStream instanceBody)¶ Creates an instance in MDS, reading it from the input stream. Only fields that are visible via REST will be set in the created instance. It will fail, if data read from input stream contains fields that do not exists or if field values do not match their type. It also throws
org.motechproject.mds.exception.rest.RestOperationNotSupportedException
if the entity settings do not permit CREATE access via REST.Parameters: - instanceBody – input stream, containing instance representation in JSON
Returns: created instance, in form of a map with field names and their respective values
delete¶
-
void
delete
(Long id)¶ Deletes an instance by id. This works exactly like deleting an instance in any other way, but will throw
org.motechproject.mds.exception.rest.RestOperationNotSupportedException
if the entity settings do not permit DELETE access via REST.Parameters: - id – id of the instance
executeLookup¶
-
Object
executeLookup
(String lookupName, Map<String, String> lookupMap, QueryParams queryParams, boolean includeBlob)¶ Executes a lookup for REST, given the lookup name, lookup parameters and query parameters. The result will only contain fields that are visible for REST. If requested lookup is not available via REST, this will throw
RestLookupExecutionForbiddenException
. If a lookup of given name does not exist, it throwsorg.motechproject.mds.exception.rest.RestLookupNotFoundException
.Parameters: - lookupName – name of the lookup
- lookupMap – map containing field names and their respective values
- queryParams – query parameters to use retrieving instances
- includeBlob – set to true, if you wish to retrieve value for binary object fields
Returns: lookup result, that can be either a single instance or a collection of instances. Response contains also metadata.
get¶
-
RestResponse
get
(QueryParams queryParams, boolean includeBlob)¶ Retrieves entity instances for REST. This will only include fields that are visible for REST. It throws
org.motechproject.mds.exception.rest.RestOperationNotSupportedException
if the entity settings do not permit READ access via REST.Parameters: - queryParams – query parameters to use retrieving instances
- includeBlob – set to true, if you wish to retrieve value for binary object fields
Returns: a response that contains metadata and list of instances, in form of a map with field names and their respective values
get¶
-
RestResponse
get
(Long id, boolean includeBlob)¶ Retrieves a single instance for REST. This will only include fields that are visible for REST. It throws
org.motechproject.mds.exception.rest.RestOperationNotSupportedException
if the entity settings do not permit READ access via REST.Parameters: - id – id of the instance
- includeBlob – set to true, if you wish to retrieve value for binary object fields
Returns: a response that contains metadata and instance
update¶
-
RestProjection
update
(InputStream instanceBody)¶ Updates an instance in MDS, reading it from the input stream. Only fields that are visible via REST will be set in the updated instance. It will fail, if data read from input stream contains fields that do not exists or if field values do not match their type. It also throws
org.motechproject.mds.exception.rest.RestOperationNotSupportedException
if the entity settings do not permit UPDATE access via REST.Parameters: - instanceBody – input stream, containing instance representation in JSON
Returns: updated instance, in form of a map with field names and their respective values