Exemplo n.º 1
0
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) {
            $currentRecordCount++;
            $metadata = processRecord($record);
            if (!empty($metadata)) {
                fwrite($out, json_encode($metadata) . LN);
            }