/**
  * Runs on production when an import request is received.
  *
  * @param array $args
  *
  * @return string
  */
 public function import(array $args)
 {
     $this->xmlrpc_client->handle_request($args);
     $result = $this->xmlrpc_client->get_request_data();
     // Get batch.
     $batch = isset($result['batch']) ? $result['batch'] : null;
     // Check if a batch has been provided.
     if (!$batch instanceof Batch) {
         $message = new Message();
         $message->set_level('error');
         $message->set_message('No batch has been sent from content stage to production.');
         $response = array('status' => 2, 'messages' => array($message));
         return $this->xmlrpc_client->prepare_response($response);
     }
     // Get production batch ID (if this is an existing batch).
     $batch_id = $this->batch_dao->get_id_by_guid($batch->get_guid());
     $batch->set_id($batch_id);
     if ($batch_id !== null) {
         $this->batch_dao->update_batch($batch);
     } else {
         $this->batch_dao->insert($batch);
     }
     // If auto import is set to true, then start the batch import immediately.
     if (!isset($result['auto_import']) || $result['auto_import']) {
         $this->api->import($batch);
     }
     $response = array('status' => $this->api->get_deploy_status($batch->get_id()), 'messages' => $this->api->get_deploy_messages($batch->get_id()));
     // Prepare and return the XML-RPC response data.
     return $this->xmlrpc_client->prepare_response($response);
 }