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 Type
    Method
    Description
    @NotNull List<String>
    getFields(@NotNull String graphQLDocument)
    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.
    @NotNull String
    getFileId(@NotNull String graphQLDocument)
    Given the JSON document wrapping a GraphQL query string, this method extracts the query argument, which is a file ID.
  • Method Details

    • getFileId

      @NotNull @NotNull String getFileId(@NotNull @NotNull String graphQLDocument)
      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}"
       }
       
       
      then this method returns "2", which means the requested metadata is for a file whose file ID is 2.
      Parameters:
      graphQLDocument - The provided JSON document
      Returns:
      an ordered list of requested metadata fields
      Throws:
      NullPointerException - if graphQLDocument is null
    • getFields

      @NotNull @NotNull List<String> getFields(@NotNull @NotNull String graphQLDocument)
      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}",
       }
       
       
      then this method returns a list of ["fileName", "fileType"].

      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}",
       }
       
       
      then the returned list becomes ["fileType", "fileNAME"]

      If no fields are found, this method returns an empty list

      Parameters:
      graphQLDocument - The provided JSON document which cannot be null, otherwise the behavior of this method is undefined
      Returns:
      an ordered list of requested metadata fields
      Throws:
      NullPointerException - if graphQLDocument is null