Interface JsonDocumentParser
- All Known Implementing Classes:
JacksonParser
public interface JsonDocumentParser
JsonDocumentParser
is used exclusively by MetaServlet
and is
responsible for extracting metadata request info from POST request body, such as file ID and metadata fields that
client is asking for.
The request body must be JSON and have the following
format in order to be parsable by
JsonDocumentParser
:
{
"query":"{\n metaData(fileId:\"...\") {\n fileName\nfileType }\n}"
}
Note that the selection fileName\nfileType
can be any combination of file metadata object attributes-
Method Summary
Modifier and TypeMethodDescriptionGiven the JSON document wrapping a GraphQL query string, this method extracts the query field and then the requested metadata field(s) in an ordered list.@NotNull String
Given the JSON document wrapping a GraphQL query string, this method extracts the query argument, which is a file ID.
-
Method Details
-
getFileId
Given the JSON document wrapping a GraphQL query string, this method extracts the query argument, which is a file ID.For example, if the document is
{ "query":"{\n metaData(fileId:\"2\") {\n fileName\nfileType }\n}" }
- Parameters:
graphQLDocument
- The provided JSON document- Returns:
- an ordered list of requested metadata fields
- Throws:
NullPointerException
- ifgraphQLDocument
isnull
-
getFields
Given the JSON document wrapping a GraphQL query string, this method extracts the query field and then the requested metadata field(s) in an ordered list.For example, if the document is
{ "query":"{\n metaData(fileId:\"2\") {\n fileName\nfileType }\n}", }
The order of the metadata fields also influences the element order in the returned list. For instance, if the document above changes to
{ "query":"{\n metaData(fileId:\"2\") {\n fileType\nfileName }\n}", }
If no fields are found, this method returns an
empty list
- Parameters:
graphQLDocument
- The provided JSON document which cannot benull
, otherwise the behavior of this method is undefined- Returns:
- an ordered list of requested metadata fields
- Throws:
NullPointerException
- ifgraphQLDocument
isnull
-