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   that identifies the root element in the metadatafile, which contains the mediafile’s metadata.
 * 2) A   that will be used when mapping the metadata found in the metadatafile.
 * 3) A   to a wiki title previously saved as a metadata mapping ( optional ).
 * 4) A   that indicates the number of mediafiles that will be added to the job queue each time a batch upload job is run ( optional, default is 10 ).
 * 5) A , which is a reference to a local metadatafile that will be uploaded and used during the rest of the upload process.

The following describes what happens within the  method:
 * 1)   attempts to save the metadata file provided and returns the relative path to the stored file.
 * 2) * if an exception is thrown a user message is displayed.
 * 3)   retrieves a FileBackend file based on the relative path 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.