Class CommandResponse
- Direct Known Subclasses:
AssayListResponse
,BaseTransformResponse
,CreateContainerResponse
,CreateGroupResponse
,CreateUserResponse
,DeleteContainerResponse
,DomainDetailsResponse
,DomainResponse
,FileNotificationResponse
,GetAssayRunResponse
,GetContainersResponse
,GetGroupPermsResponse
,GetQueriesResponse
,GetQueryDetailsResponse
,GetSchemasResponse
,GetUsersResponse
,ImportDataResponse
,ImportRunResponse
,LineageResponse
,ListDomainsResponse
,LoadAssayBatchResponse
,NAbRunsResponse
,ProtocolResponse
,RenameContainerResponse
,RenameGroupResponse
,SaveAssayBatchResponse
,SaveAssayRunsResponse
,SaveRowsResponse
,SelectRowsResponse
,StartSearchResponse
,StorageCommandResponse
,TruncateTableResponse
,UpdateParticipantGroupResponse
,WhoAmIResponse
Client code will typically use a class derived from this class that is returned from the particular command used (e.g. SelectRowsCommand returns SelectRowsResponse). However, if you are using the Command class directly to call an HTTP API that does not yet have a specialized command class, you would use this object to obtain the response details.
-
Constructor Summary
ConstructorsConstructorDescriptionCommandResponse
(String text, int statusCode, String contentType, org.json.JSONObject json) Constructs a new CommandResponse, initialized with the provided response text and status code. -
Method Summary
Modifier and TypeMethodDescriptionFinds, in a List of Maps, the first Map containing an entry that matchespropertyName
andvalue
matches thevalue
supplied.Returns the Content-Type header value from the response.Attempts to parse the response text and return a property Map.<T> T
getProperty
(String path) Returns the value of a specific property in the parsed data given a path to that property.protected <T> T
getProperty
(String[] path, int pathIndex, Map<String, Object> parent) Called bygetProperty(String)
after splitting the path into a String[], and recursively by itself as it descends the property hierarchy.int
Returns the HTTP status code (typically 200).getText()
Returns the raw response text.
-
Constructor Details
-
CommandResponse
Constructs a new CommandResponse, initialized with the provided response text and status code.- Parameters:
text
- The response textstatusCode
- The HTTP status codecontentType
- The response content typejson
- The parsed JSONObject (or null if JSON was not returned)
-
-
Method Details
-
getText
Returns the raw response text.Use this if your command returns something other than JSON, or if you want to use a different JSON parser.
This may return null if no response body was sent by the server.
- Returns:
- The raw response text.
-
getStatusCode
public int getStatusCode()Returns the HTTP status code (typically 200).- Returns:
- The HTTP status code
-
getContentType
Returns the Content-Type header value from the response. Note that this may return null if no content type header was supplied by the server (unlikely but possible).- Returns:
- The content type of the response.
-
getParsedData
Attempts to parse the response text and return a property Map.If the response text cannot be parsed, a runtime error will be thrown.
Note that the values in the Map may be simple values, Lists, or Maps.
- Returns:
- The parsed data as a property map.
-
getProperty
Returns the value of a specific property in the parsed data given a path to that property.The path is a period-delimited list of property names. For example, to obtain the 'bar' property from the Map associated with the 'foo' property, the path would be 'foo.bar'. Property names may include an array index. For example, 'foos[2].bar' will return the 'bar' property for the third item of the 'foos' array
- Type Parameters:
T
- the type of the property.- Parameters:
path
- The property path.- Returns:
- The property value, or null if the property was not found.
-
getProperty
Called bygetProperty(String)
after splitting the path into a String[], and recursively by itself as it descends the property hierarchy.- Type Parameters:
T
- The type of the property.- Parameters:
path
- The path split into a String[].pathIndex
- The current index into the path array.parent
- The current parent map.- Returns:
- The property value, or null if not found.
-
findObject
protected Map<String,Object> findObject(List<Map<String, Object>> objects, String propertyName, String value) Finds, in a List of Maps, the first Map containing an entry that matchespropertyName
andvalue
matches thevalue
supplied. Returns null if not found.- Parameters:
objects
- The list of Maps to search.propertyName
- The property name to examine in each Map.value
- The value to compare against.- Returns:
- The Map where the value of propertyName equals value, or null if not found.
-