/** * Get the metadata format. */ function getMetadataFormat($default = DUBLIN_CORE_METADATA_PREFIX) { if (isset($this->metadataFormat)) { return $this->metadataFormat; } $archive =& $this->getArchive(); $schemaPluginName = $archive->getSchemaPluginName(); if (empty($schemaPluginName)) { return $this->metadataFormat = $default; } $schemaDao = DAORegistry::getDAO('SchemaDAO'); $aliases = array_keys($schemaDao->getSchemaAliases($schemaPluginName)); $supportedFormats = OAIHarvester::getMetadataFormats($archive->getSetting('harvesterUrl'), $archive->getSetting('isStatic')); // Return the first common format between the aliases for this // plugin and the archive's supported formats. $this->metadataFormat = array_shift(array_intersect((array) $aliases, (array) $supportedFormats)); if (empty($this->metadataFormat)) { $this->metadataFormat = $default; } return $this->metadataFormat; }
/** * Get the harvest update parameters from the Request object. * @param $archive object * @return array */ function readUpdateParams(&$archive) { $this->import('OAIHarvester'); $returner = array(); $set = Request::getUserVar('set'); if (count($set) == 1 && $set[0] == '') { $set = null; } $returner['set'] = $set; $dateFrom = Request::getUserDateVar('from', 1, 1); $dateTo = Request::getUserDateVar('until', 32, 12, null, 23, 59, 59); if (!empty($dateFrom)) { $returner['from'] = OAIHarvester::UTCDate($dateFrom); } if (!empty($dateTo)) { $returner['until'] = OAIHarvester::UTCDate($dateTo); } return $returner; }
<?php if (!class_exists('DOMAttr')) { echo "Requires PHP 5 with the DOM module enabled.\n" . "\n" . "Although enabled by default in most PHP configurations, this module\n" . "is sometimes shipped in a separate package by Linux distributions.\n" . "\n" . "Fedora 6 users, please try:\n" . " yum install php-xml\n" . "\n"; exit(1); } $base = dirname(dirname(dirname(__FILE__))); require_once "{$base}/maintenance/commandLine.inc"; /** * Persistent data: * - Source repo URL * - Last seen update timestamp */ $harvester = new OAIHarvester($oaiSourceRepository); if (isset($options['from'])) { $lastUpdate = wfTimestamp(TS_MW, $options['from']); } else { $dbr = wfGetDB(DB_MASTER); $checkpoint = $dbr->selectField('oaiharvest', 'oh_last_timestamp', array('oh_repository' => $oaiSourceRepository)); $highest = $dbr->selectField('revision', 'MAX(rev_timestamp)'); if ($checkpoint) { $lastUpdate = wfTimestamp(TS_MW, $checkpoint); echo "Starting at last checkpoint: " . wfTimestamp(TS_DB, $lastUpdate) . "\n"; } elseif ($highest) { $lastUpdate = wfTimestamp(TS_MW, $highest); echo "No local update checkpoint; starting at last-updated page: " . wfTimestamp(TS_DB, $lastUpdate) . "\n"; } else { # Starting from an empty database! echo "Empty database; starting at epoch: 1970-01-01 00:00:00\n"; $lastUpdate = '19700101000000'; }
die('Failed to create directory: ' . $dir); } } } $verb = 'ListRecords'; if (isset($options['id'])) { $params['identifier'] = ID_PREFIX . $options['id']; unset($params['set']); define('ID_BASED_FILE_NAME_TEMPLATE', $options['set'] . '/individuals.json'); $out = fopen($configuration['OUTPUT_DIR'] . getOutputFileName($total), "a+"); $verb = 'GetRecord'; } else { $out = fopen($configuration['OUTPUT_DIR'] . getOutputFileName($total), "w"); } do { $harvester = new OAIHarvester($verb, 'http://oai.europeana.eu/oaicat/OAIHandler', $params); $harvester->setAuthentication($configuration['username'], $configuration['password']); $times['fetch'] = microtime(TRUE); $retry = 0; do { $harvester->fetchContent(); if ($retry > 0) { print "Needs retrying at {$total} ({$retry})\n"; } $fetchOk = checkFetchState($harvester, $total, $retry); } while ($fetchOk === FALSE && ++$retry <= MAX_RETRY); $times['fetch'] = microtime(TRUE) - $times['fetch']; $currentRecordCount = 0; if ($fetchOk) { $harvester->processContent(); while (($record = $harvester->getNextRecord()) != null) {