if (strlen($person) == 0) { continue; } if ($numPeopleLoaded < $maxPeopleToLoad || $maxPeopleToLoad == -1) { //Check to see if the entity exists already $new = false; $existingPID = doesEntityExist($person); if ($existingPID != false) { if (!$updateModsForExistingEntities) { continue; } //Load the object $entity = $repository->getObject($existingPID); } else { //Create an entity within Islandora $entity = $repository->constructObject('person'); $entity->models = array('islandora:personCModel'); $entity->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', 'marmot:people'); $entity->relationships->add(FEDORA_RELS_EXT_URI, 'isMemberOfCollection', 'islandora:entity_collection'); $new = true; } echo "{$i}) Processing Person {$person} <br/>"; $entity->label = $person; //Add MADS data if ($entity->getDatastream('MODS') == null) { $modsDatastream = $entity->constructDatastream('MODS'); } else { $modsDatastream = $entity->getDatastream('MODS'); } $modsDatastream->label = 'MODS Record'; $modsDatastream->mimetype = 'text/xml';
/** * @param FedoraRepository $repository * @param string $identifier * @return array */ function getObjectForIdentifier($identifier, $repository) { global $fedoraPassword, $fedoraUser, $solrUrl; //Check Solr to see if we have created the compound object yet $escapedIdentifer = str_replace(':', '\\:', $identifier); $solrQuery = "?q=mods_identifier_ms:\"{$escapedIdentifer}\"&fl=PID,dc.title"; $context = stream_context_create(array('http' => array('header' => "Authorization: Basic " . base64_encode("{$fedoraUser}:{$fedoraPassword}")))); //echo("checking solr ".$solrUrl . $solrQuery."<br/>"); $ch = curl_init(); $connectTimeout = 5; $timeout = 20; curl_setopt($ch, CURLOPT_URL, $solrUrl . $solrQuery); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connectTimeout); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $curTry = 0; $maxTries = 3; while ($curTry < $maxTries) { $solrResponse = curl_exec($ch); if ($solrResponse !== false) { //We got a good response, stop looking. break; } $curTry++; } curl_close($ch); if (!$solrResponse) { die("Solr is currently down"); } else { $solrResponse = json_decode($solrResponse); if ($solrResponse->response->numFound == 0) { $newObject = true; $existingPID = false; } else { $newObject = false; $existingPID = $solrResponse->response->docs[0]->PID; } } //Basic settings for this content type $namespace = 'fortlewis'; //Create an object (this will create a new PID) /** @var AbstractFedoraObject $object */ if ($newObject) { $object = $repository->constructObject($namespace); } else { $object = $repository->getObject($existingPID); } return array($object, $newObject); }
$existingPID = false; } else { $newObject = false; $existingPID = $solrResponse->response->docs[0]->PID; } if ($processAllFiles == false) { continue; } } } //Basic settings for this content type $namespace = 'evld'; //Create an object (this will create a new PID) /** @var AbstractFedoraObject $newPhoto */ if ($newObject) { $newPhoto = $repository->constructObject($namespace); } else { $newPhoto = $repository->getObject($existingPID); } if (strtolower(substr($imageFilename, -3)) == 'jpg') { fwrite($basicImageNames, "{$imageFilename} \r\n"); $isLargeImage = false; //Copy basic image to another location for derivative creation } else { $isLargeImage = true; } if ($newObject) { //$newPhoto->relationships->add() //TODO: if we get a tiff this can be a large image, otherwise it should be a basic image if (strtolower(substr($imageFilename, -3)) == 'jpg') { $newPhoto->models = array('islandora:sp_basic_image');