Author: fortim
Date: Mon Sep 21 13:12:09 2009
New Revision: 3460
Log:
Remove cURL call from oai harvest
Modified:
trunk/apps/qubit/modules/oai/actions/harvesterHarvestAction.class.php
trunk/apps/qubit/modules/oai/actions/harvesterListAction.class.php
Modified: trunk/apps/qubit/modules/oai/actions/harvesterHarvestAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/oai/actions/harvesterHarvestAction.class.php
Mon Sep 21 07:40:41 2009 (r3459)
+++ trunk/apps/qubit/modules/oai/actions/harvesterHarvestAction.class.php
Mon Sep 21 13:12:09 2009 (r3460)
@@ -39,7 +39,7 @@
//Set no records match to false to start with
$this->noRecordsMatch = false;
-
+
//Keep track of number of records harvested
$this->recordCount = 0;
@@ -67,7 +67,7 @@
$oaiSimpleRes = array();
$from = date('Y-m-d\TH:i:s\Z', strtotime($harvestInfo->getLastHarvest()));
$until = gmdate('Y-m-d\TH:i:s\Z');
-
+
//Create the base request
$verb = 'verb=ListRecords';
if ($harvestInfo->getLastHarvest() != null)
@@ -85,21 +85,10 @@
while ($resumptionToken)
{
- //Open a socket to the specified repository, with correct parameters
- $socket = new QubitSocket($rep->getUri().'?'.$verb);
- $oaiResponse = $socket->get_data();
-
- //If communication failed 404
- if ($oaiResponse == false)
- {
- // Add mail to admin if can't connect.
- //QubitOai::mailErrors('Unable to connect to repository :
'.$this->repositoryName);
- print_r("Can't connect to repository");
- $this->forward404();
- }
+ //Load XML through simplexml http
+ $oaiSimple = simplexml_load_file($rep->getUri().'?'.$verb);
//Strip oai header, construct array of records
- $oaiSimple = simplexml_load_string($oaiResponse);
$oaiSimple->registerXPathNamespace('c',
'http://www.openarchives.org/OAI/2.0/');
if ($oaiSimple->xpath('//c:error'))
{
@@ -117,14 +106,14 @@
if (!$this->noRecordsMatch)
{
-
+
//Container for xml import errors
$this->errorsFound = array();
$this->errorsXML = array();
-
+
//Create header and footer for XML record for it to validate
$oaiHeader = '<?xml version="1.0" encoding="UTF-8" ?>';
-
+
$oaiFooter = '';
$oaiRecords = $oaiSimple->xpath('//c:ListRecords/c:record');
foreach ($oaiRecords as $oaiRec)
@@ -141,7 +130,6 @@
}
}
-
// Increment record count to keep track of number of records harvested
$this->recordCount += count($oaiRecords);
@@ -159,21 +147,19 @@
//Check for resumption token which will also be the while loop indicator
$oaiResumptionToken =
$oaiSimple->xpath('//c:ListRecords/c:resumptionToken');
- if($oaiResumptionToken == false || count($oaiResumptionToken) > 1)
+ if ($oaiResumptionToken == false || count($oaiResumptionToken) > 1)
{
$resumptionToken = false;
- } else {
+ } else
+ {
$resumptionToken = $oaiResumptionToken[0];
$verb = 'verb=ListRecords&resumptionToken='.$resumptionToken;
}
-
}
// Update last harvest date
$harvestInfo->setLastHarvest($until);
$harvestInfo->save();
-
-
}
}
\ No newline at end of file
Modified: trunk/apps/qubit/modules/oai/actions/harvesterListAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/oai/actions/harvesterListAction.class.php Mon Sep
21 07:40:41 2009 (r3459)
+++ trunk/apps/qubit/modules/oai/actions/harvesterListAction.class.php Mon Sep
21 13:12:09 2009 (r3460)
@@ -52,22 +52,10 @@
}
$URI = $harvesterArr['uri'];
$URI .= '?verb=Identify';
- $newHarvesterParam = array('uri' => $URI);
-
- $socket = new QubitSocket($newHarvesterParam['uri']);
-
- if ($socket)
+ $oaiSimple = simplexml_load_file($URI);
+ libxml_use_internal_errors(true);
+ if ($oaiSimple)
{
- $oaiResponse = $socket->get_data();
- libxml_use_internal_errors(true);
- $oaiSimple = simplexml_load_string($oaiResponse);
-
- if (!$oaiSimple)
- {
- $this->request->setAttribute('parsingErrors', true);
- $this->forward('oai', 'harvesterNewRepository');
- }
-
$repository = new QubitOaiRepository();
$Identify = $oaiSimple->Identify;
@@ -82,6 +70,10 @@
$harvest->setMetadataPrefix('oai_dc');
$harvest->save();
$this->redirect('oai/harvesterNewRepository');
+ } else
+ {
+ $this->request->setAttribute('parsingErrors', true);
+ $this->forward('oai', 'harvesterNewRepository');
}
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---