예제 #1
0
 /**
  * @see DOIExportPlugin::registerDoi()
  */
 function registerDoi($request, $journal, &$objects, $file)
 {
     // Use a different endpoint for testing and
     // production.
     $this->import('classes.MedraWebservice');
     $endpoint = $this->isTestMode($request) ? MEDRA_WS_ENDPOINT_DEV : MEDRA_WS_ENDPOINT;
     // Get credentials.
     $username = $this->getSetting($journal->getId(), 'username');
     $password = $this->getSetting($journal->getId(), 'password');
     // Retrieve the XML.
     assert(is_readable($file));
     $xml = file_get_contents($file);
     assert($xml !== false && !empty($xml));
     // Instantiate the mEDRA web service wrapper.
     $ws = new MedraWebservice($endpoint, $username, $password);
     // Register the XML with mEDRA.
     $result = $ws->upload($xml);
     if ($result === true) {
         // Mark all objects as registered.
         foreach ($objects as $object) {
             $this->markRegistered($request, $object, MEDRA_WS_TESTPREFIX);
         }
     } else {
         // Handle errors.
         if (is_string($result)) {
             $result = array(array('plugins.importexport.common.register.error.mdsError', $result));
         } else {
             $result = false;
         }
     }
     return $result;
 }
예제 #2
0
 /**
  * @copydoc DOIPubIdExportPlugin::depositXML()
  */
 function depositXML($objects, $context, $filename)
 {
     // Use a different endpoint for testing and
     // production.
     $this->import('classes.MedraWebservice');
     $endpoint = $this->isTestMode($context) ? MEDRA_WS_ENDPOINT_DEV : MEDRA_WS_ENDPOINT;
     // Get credentials.
     $username = $this->getSetting($context->getId(), 'username');
     $password = $this->getSetting($context->getId(), 'password');
     // Retrieve the XML.
     assert(is_readable($filename));
     $xml = file_get_contents($filename);
     assert($xml !== false && !empty($xml));
     // Instantiate the mEDRA web service wrapper.
     $ws = new MedraWebservice($endpoint, $username, $password);
     // Register the XML with mEDRA.
     $result = $ws->upload($xml);
     if ($result === true) {
         // Mark all objects as registered.
         foreach ($objects as $object) {
             $object->setData($this->getDepositStatusSettingName(), DOI_EXPORT_STATUS_REGISTERED);
             $this->saveRegisteredDoi($context, $object);
         }
     } else {
         // Handle errors.
         if (is_string($result)) {
             $result = array(array('plugins.importexport.common.register.error.mdsError', $result));
         } else {
             $result = false;
         }
     }
     return $result;
 }