Extension:GWToolset/Technical Implementation/Handlers/MetadataDetectHandler

Step 1: Metadata Detection
This handler is used between step 1: metadata detection, and step 2: metadata mapping, in the upload process.


 * 1) Validates the  ’ed edit token
 * 2) if invalid, a user error message is displayed.
 * 3) if valid, calls

The expected outcome of ’ing the metadata detection form is that the extension will receive four items from the form:
 * 1) A record element name that identifies the root element in the metadatafile that contains the mediafile’s metadata.
 * 2) A MediaWiki template selection that will be used to map the metadata found in the metadatafile to the MediaWiki template.
 * 3) A wiki Title to a previously saved metadata mapping ( optional ).
 * 4) A metadata file to be uploaded and used during the MediaWiki template mapping, creation and upload of the mediafile.

The following describes what happens within the  method:
 * 1)   attempts to save the metadata file provided and return  the resulting stash key.
 * 2) * if an exception is thrown a user message is displayed.
 * 3)   retrieves an UploadStashFile instance based on the stash key provided in step 1.
 * 4) * if an exception is thrown a user message is displayed.
 * 5)   is sent:
 * 6) * the ’ed form variables as
 * 7) * the FS path to the uploaded stash file
 * 8)   is sent:
 * 9) * the ’ed form variables as
 * 10) * the FS path to the uploaded stash file
 * 11) * a callback method in the XmlDetecHandler
 * 12)    starts a read process that will:
 * 13) * use the callback method provided to process the metadata records found during the read process.
 * 14) * continue to the end of the metadata file or stop reading if  is set to true.
 * , the callback passed to  will:
 * 1) * use  to create an example metadata record, the first record found in the metadata file, to display to the user for reference while they map the metadata to the MediaWiki template in step 2.
 * 2) * use  to find additional XML nodes that may not exist in the example metadata record and add them to it. e.g., the second record contains a node, dc:spatial, which does not exist in the first record; this node is added to the example record.
 * 3)   attempts to retrieve the MediaWiki template schema via TemplateData. If no TemplateData schema exists it falls back to a hard coded version stored in.
 * 4)   attempts to retrieve a metadata mapping schema provided as a wiki title in step 1. The expected schema format is a valid JSON.
 * 5) * If no wiki title was provided none is used.
 * 6) * if a wiki title was provided, but does not exist, a user error message is displayed.
 * 7) * if a wiki title was provided, exists, but the schema is invalid, a user error message is displayed.
 * 8)   sets up the HTML form and returns it to   to be displayed.