Enum RESTRequestFormat
- All Implemented Interfaces:
ValueEnum
,Serializable
,Comparable<RESTRequestFormat>
,Constable
RestConnector DataSources
. Note for all of these
RESTRequestFormat
options, only simple key-value criteria are supported; to handle AdvancedCriteria
, you can use a requestTemplate
, or subclass
com.isomorphic.dataSource.RestConnector
and override the applyValuesOrCriteriaToRequest()
method.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionIndicates that context is provided to the target REST service by providing a block of JSON-encoded text in the body of the HTTP request sent to the REST server.Indicates that context is provided to the target REST service by setting parameter values in the URL.Indicates that context is provided to the target REST service by providing a block of XML text in the body of the HTTP request sent to the REST server. -
Method Summary
Modifier and TypeMethodDescriptiongetValue()
static RESTRequestFormat
Returns the enum constant of this type with the specified name.static RESTRequestFormat[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
PARAMS
Indicates that context is provided to the target REST service by setting parameter values in the URL. With this request format, theDSRequest
's values or criteria will be added to thetarget dataURL
as standard HTTP parameters values as follows:- For "add" and "update" requests the "values" will be added to the target URL (see
the server-side Javadoc for
DSRequest.getValues()
) - For "fetch" and "remove" requests, where the concept of "values" doesn't make sense,
the "criteria" will be added to the target URL (see the server-side Javadoc for
DSRequest.getCriteria()
)
{countryCode: "US", stateCode: "CA"}
and adataURL
like this:https://somerestservice.com/customer/fetch https://somerestservice.com/customer/fetch?countryCode=US&stateCode=CA
Also, note that any explicitly declaredparams
will also be added to the target URL as standard HTTP parameters, as well as the request values/criteria (if there are any name collisions, the request values/criteria take precedence).This format is often used to supply criteria to "fetch" operations, and primary-key values to "remove" operations. However, this is by no means a universal approach; different REST services adopt different approaches, there is no generally-accepted "right way" to handle things
It is possible to suppress this automatic mapping - see
DataSource.suppressAutoMappings
If this enumerated value is used in a
Component XML
file or server-side DataSource descriptor (.ds.xml file), use the value "params". - For "add" and "update" requests the "values" will be added to the target URL (see
the server-side Javadoc for
-
JSON
Indicates that context is provided to the target REST service by providing a block of JSON-encoded text in the body of the HTTP request sent to the REST server. With this request format,RestConnector
will render an incomingDSRequest
's values or criteria as a JSON object; for "add" and "update" requests, the "values" will be used, and for "fetch" and "remove" operations, the criteria will be used (see the server-side Javadoc forDSRequest.getCriteria()
).So if we had an add request with the following record:
{ customerId: 7023, customerName: "Bay Financials inc", city: "San Francisco", countryCode: "US", stateCode: "CA" }
those values would be included, in strict JSON form, in the body of the HTTP request thatRestConnector
sends to the REST webservice:{"customerId": 7023,"customerName": "Bay Financials inc", "city: "San Francisco","countryCode": "US", "stateCode": "CA"}
This format is most often used when you need to supply more extensive amounts of data, like entire records to "add" and "update" operations. However, as mentioned above, this is by no means a universal approach, and some REST services use URL parameters even when specifying entire records of data. Also, some REST services use XML rather than JSON
Note, if there is a
requestTemplate
in force, we use that to drive the content and format of the generated JSON blockIf this enumerated value is used in a
Component XML
file or server-side DataSource descriptor (.ds.xml file), use the value "json". -
XML
Indicates that context is provided to the target REST service by providing a block of XML text in the body of the HTTP request sent to the REST server. With this request format,RestConnector
will render an incomingDSRequest
's values or criteria as a snippet of XML text; for "add" and "update" requests, the "values" will be used, and for "fetch" and "remove" operations, the criteria will be used (see the server-side Javadoc forDSRequest.getCriteria()
). The name of the enclosing tag is specified inDataSource.xmlTag
.So if we had an add request with the following record:
{ customerId: 7023, customerName: "Bay Financials inc", city: "San Francisco", countryCode: "US", stateCode: "CA" }
those values would be included in the body of the HTTP request thatRestConnector
sends to the REST webservice (assuming thexmlTag
is "customer"):<customer> <customerId>7023</customerId> <customerName>Bay Financials inc"</customerName> <city>San Francisco</city> <countryCode>US</countryCode> <stateCode>CA"</stateCode> </customer>
Note, if there is a
requestTemplate
in force, we use that to drive the content and format of the generated XMLIf this enumerated value is used in a
Component XML
file or server-side DataSource descriptor (.ds.xml file), use the value "xml".
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
getValue
-