Пример #1
0
 function handle()
 {
     $output = array();
     // Get and handle a comma-seperated list of valid params which we will forward to the indexer
     $permitted_forwarding_params = explode(',', $this->options['valid_solr_params']);
     $forwarded_params = array_intersect_key(array_flip($permitted_forwarding_params), $this->params);
     $fields = array();
     foreach ($forwarded_params as $param_name => $_) {
         $fields[$param_name] = $this->params[$param_name];
     }
     $fields = array_merge($this->default_params, $fields);
     $CI =& get_instance();
     $CI->load->library('solr');
     foreach ($fields as $key => $field) {
         $CI->solr->setOpt($key, $field);
     }
     // Get back a list of IDs for matching registry objects
     $solr_result = $CI->solr->executeSearch(true);
     $rifcsOutput = array();
     $CI->load->helper('crosswalks');
     $crosswalks = getCrossWalks();
     if (isset($solr_result['response']['docs']) && is_array($solr_result['response']['docs'])) {
         foreach ($solr_result['response']['docs'] as $result) {
             $CI->load->model('registry_object/registry_objects', 'ro');
             $registryObject = $CI->ro->getByID((int) $result['id']);
             if ($registryObject) {
                 $nativeFormat = $registryObject->getNativeFormat();
                 // Try and get the native version?
                 if (in_array($nativeFormat, array(RIFCS_SCHEME, EXTRIF_SCHEME))) {
                     $registryObjects[] = array("slug" => $registryObject->slug, "scheme" => $nativeFormat, "data" => wrapRegistryObjects($registryObject->getRif()));
                 } else {
                     // Check for a matching scheme from a crosswalk
                     $matched = false;
                     foreach ($crosswalks as $cw) {
                         if ($cw->metadataFormat() == $nativeFormat) {
                             $matched = true;
                             $registryObjects[] = array("slug" => $registryObject->slug, "scheme" => $nativeFormat, "data" => $cw->wrapNativeFormat($registryObject->getNativeFormatData()));
                         }
                     }
                     // If no matching crosswalk wraped, then just spit out whatever we've got...
                     if (!$matched) {
                         $registryObjects[] = array("slug" => $registryObject->slug, "scheme" => $nativeFormat, "data" => $registryObject->getNativeFormatData());
                     }
                 }
             }
         }
     }
     $rifcsOutput = array("numFound" => $solr_result['response']['numFound'], "start" => $solr_result['response']['start'], "docs" => &$registryObjects);
     // Bubble back the output status
     return $this->formatter->display($rifcsOutput);
 }
Пример #2
0
 function extractRIFCSfromQueue($pullback_queue)
 {
     $fragments = '';
     if (is_array($pullback_queue)) {
         foreach ($pullback_queue as $identifier) {
             $fragment = $this->pullbackRIFCSfromNLA(trim($identifier));
             if ($fragment) {
                 $fragments .= unWrapRegistryObjects($fragment);
             }
         }
         $fragments = wrapRegistryObjects($fragments);
     }
     return $fragments;
 }
Пример #3
0
 function transformForHtml($revision = '', $data_source_key = null)
 {
     try {
         $xslt_processor = Transforms::get_extrif_to_html_transformer();
         $dom = new DOMDocument();
         $dataSource = $this->ro->data_source_key;
         if ($revision == '') {
             $dom->loadXML(wrapRegistryObjects($this->ro->getRif()));
         } else {
             $dom->loadXML(wrapRegistryObjects($this->ro->getRif($revision)));
         }
         $xslt_processor->setParameter('', 'dataSource', $data_source_key ?: $this->ro->data_source_key);
         return html_entity_decode($xslt_processor->transformToXML($dom));
     } catch (Exception $e) {
         echo "UNABLE TO TRANSFORM" . BR;
         echo "<pre>" . nl2br($e->getMessage()) . "</pre>" . BR;
     }
 }
Пример #4
0
 public function metadata($format, $nestlvl = 0)
 {
     $lprefix = "";
     if ($nestlvl > 0) {
         foreach (range(0, $nestlvl) as $nest) {
             $lprefix .= "\t";
         }
     }
     $output = "";
     $data = false;
     switch ($format) {
         case 'dci':
             require_once REGISTRY_APP_PATH . '/services/method_handlers/dci.php';
             $dci_handler = new DCIMethod();
             $dci_handler->ro = $this->_rec;
             $dci_handler->populate_resource($this->id);
             $data = $dci_handler->ro_handle('dci');
             break;
         case 'oai_dc':
             $data = $this->_rec->transformToDC(false);
             break;
         case 'rif':
             $data = removeXMLDeclaration(wrapRegistryObjects($this->_rec->getRif()));
             break;
         case 'extRif':
             $data = removeXMLDeclaration($this->_rec->getExtRif());
             break;
         default:
             $data = removeXMLDeclaration($this->_rec->getRecordDataInScheme(null, $format));
     }
     if ($data) {
         foreach (explode("\n", $data) as $line) {
             if (empty($line)) {
                 continue;
             }
             $output .= $lprefix . $line . "\n";
         }
     }
     return $output;
 }
Пример #5
0
 public function payloadToRIFCS($payload)
 {
     $this->parsed_array = parse_ini_string($payload, TRUE);
     $rifcs_elts = array();
     foreach ($this->parsed_array as $key => $attrs) {
         $registryObject = '<registryObject group="' . $attrs['group'] . '">' . NL;
         $registryObject .= '<key>' . $key . '</key>' . NL;
         $registryObject .= '<originatingSource>Ben\'s INI Crosswalk Demo</originatingSource>' . NL;
         $registryObject .= '<' . $attrs['class'] . ' type="' . $attrs['type'] . '">' . NL;
         $registryObject .= '<name type="primary"><namePart>' . $attrs['name'] . '</namePart></name>' . NL;
         $registryObject .= '<description type="full">' . $attrs['description'] . '</description>' . NL;
         $registryObject .= '<relatedInfo type="' . NATIVE_HARVEST_FORMAT_TYPE . '">' . NL;
         $registryObject .= '<identifier type="internal">' . $this->metadataFormat() . '</identifier>' . NL;
         $registryObject .= '<notes><![CDATA[' . NL;
         $registryObject .= $this->wrapNativeFormat(php2ini(array($key => $attrs))) . NL;
         $registryObject .= ']]></notes>' . NL;
         $registryObject .= '</relatedInfo>' . NL;
         $registryObject .= '</' . $attrs['class'] . '>' . NL;
         $registryObject .= '</registryObject>' . NL;
         $rifcs_elts[] = $registryObject;
     }
     return trim(wrapRegistryObjects(implode("", $rifcs_elts)));
 }
Пример #6
0
 function setContributorPages($value, $inputvalues, $notifyChange = true)
 {
     $data_source_id = $this->id;
     $data_source_title = $this->title;
     $this->_CI->load->model("registry_object/registry_objects", "ro");
     $this->_CI->load->model("registry_object/rifcs_generator", "rifcs");
     $groups = $this->get_groups();
     $fixgroups = array();
     foreach ($groups as $group) {
         $fixgroups[] = $group;
     }
     $groups = $fixgroups;
     $pages = array();
     switch ($value) {
         case "0":
             //remove any reference to a contibutor page for this datasource from the institutional_pages db table
             $delete = $this->db->delete('institutional_pages', array('authorative_data_source_id' => $data_source_id));
             break;
         case "1":
             // for each group for this datasource that is not already managed by another datasource
             foreach ($groups as $group) {
                 $manageGroup = array();
                 $query = '';
                 $manageGroup[$group] = true;
                 //check that another ds is not the authoritive ds
                 $query = $this->db->get_where('institutional_pages', array('group' => $group));
                 $this->_CI->load->library('importer');
                 if ($query->num_rows > 0) {
                     foreach ($query->result_array() as $foundPage) {
                         if ($foundPage['authorative_data_source_id'] == $data_source_id) {
                             //we want to delete this record and reinsert it
                             $this->db->delete('institutional_pages', array('group' => $group));
                         } else {
                             //we want to leave this group alone if the group belongs to another ds
                             $manageGroup[$group] = false;
                         }
                     }
                 }
                 if ($manageGroup[$group]) {
                     $registry_object_key = 'Contributor:' . $group;
                     $data_source_key = $this->key;
                     $title = $group;
                     $contributorPage = $this->_CI->ro->getAllByKey('Contributor:' . $group);
                     if (!$contributorPage) {
                         //we need to automatically create the group party record if it dosn't exist
                         $xml = wrapRegistryObjects($this->_CI->rifcs->xml($data_source_key, $registry_object_key, $title, $group));
                         $this->_CI->importer->forceDraft();
                         $this->_CI->importer->setXML($xml);
                         $this->_CI->importer->setDatasource($this);
                         $the_key = $this->_CI->importer->commit();
                         $contributorPage = $this->_CI->ro->getAllByKey($registry_object_key);
                         $contributorPage[0]->sync();
                         //we need to email services that we have created this page
                         if ($notifyChange && $this->_CI->config->item('site_admin_email')) {
                             $subject = $title . " contributor page has been generated under datasource " . $this->title;
                             $message = '<a href="' . base_url() . 'registry_object/view/' . $contributorPage[0]->id . '">' . $registry_object_key . '</a>';
                             $to = $this->_CI->config->item('site_admin_email');
                             $headers = 'MIME-Version: 1.0' . "\r\n";
                             $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
                             mail($to, $subject, $message, $headers);
                         }
                     }
                     $registry_object_id = $contributorPage[0]->id;
                     //we need to add the  group , registry_object_id and autoritive datasource to the institutional_pages table
                     $data = array("id" => null, "group" => (string) $group, "registry_object_id" => $registry_object_id, "authorative_data_source_id" => $data_source_id);
                     $insert = $this->db->insert('institutional_pages', $data);
                 }
             }
             break;
         case "2":
             // for each group for this datasource that is not already managed by another datasource
             foreach ($groups as $group_index => $group) {
                 $manageGroup = true;
                 $query = '';
                 //check that another ds is not the authoritive ds
                 $query = $this->db->get_where('institutional_pages', array('group' => $group));
                 if ($query->num_rows > 0) {
                     foreach ($query->result_array() as $foundPage) {
                         if ($foundPage['authorative_data_source_id'] == $data_source_id) {
                             //we want to delete this record and reinsert it
                             $this->db->delete('institutional_pages', array('group' => $group));
                         } else {
                             //we want to leave this group alone if the group belongs to another ds
                             $manageGroup = false;
                         }
                     }
                 }
                 if ($manageGroup && isset($inputvalues['contributor_pages'])) {
                     // Turn the indexed input array back into associative values
                     foreach ($inputvalues['contributor_pages'] as $page_idx => $contributor_value) {
                         if (isset($groups[$page_idx])) {
                             $inputvalues[$groups[$page_idx]] = $contributor_value;
                         }
                     }
                     $registry_object_key = isset($inputvalues[$group]) ? $inputvalues[$group] : '';
                     $registry_object_key = isset($inputvalues['contributor_pages'][$group_index]) ? $inputvalues['contributor_pages'][$group_index] : '';
                     if ($registry_object_key != '') {
                         $contributorPage = $this->_CI->ro->getAllByKey($registry_object_key);
                         if (isset($contributorPage[0]->id) && $contributorPage[0]->class == "party") {
                             $registry_object_id = $contributorPage[0]->id;
                             //we need to add the  group , registry_object_id and autoritive datasource to the institutional_pages table
                             $data = array("id" => null, "group" => (string) $group, "registry_object_id" => $registry_object_id, "authorative_data_source_id" => $data_source_id);
                             $insert = $this->db->insert('institutional_pages', $data);
                             // $contributorPage[0]->sync();
                             if ($notifyChange && $this->_CI->config->item('site_admin_email')) {
                                 $subject = $contributorPage[0]->title . " has been mapped as a contributor page for group " . $group . " under datasource " . $data_source_title;
                                 $message = '<a href="' . base_url() . 'registry_object/view/' . $contributorPage[0]->id . '">' . $contributorPage[0]->key . '</a>';
                                 $to = $this->_CI->config->item('site_admin_email');
                                 $headers = 'MIME-Version: 1.0' . "\r\n";
                                 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
                                 mail($to, $subject, $message, $headers);
                             }
                         } else {
                             //how do we deal with the fact that its not a valid key?
                             throw new Exception("Could not save contributor for \"{$group}\"." . NL . "Record \"{$registry_object_key}\" does not seem to be a valid Party record?");
                         }
                     }
                 }
             }
             break;
     }
 }
Пример #7
0
 /**
  * Straightforward import from url or XML
  * @param  string $type url|xml
  * @param  data_source_id $id   
  * @param  POST_DATA $data from the switchboard
  * @return json       
  */
 private function simple_import($type, $id, $data)
 {
     $this->load->library('importer');
     $ds = $this->ds->getByID($id);
     if ($type == 'url') {
         $url = trim($data['url']);
         if (!$url) {
             throw new Exception('URL must be provided');
         }
         if (!preg_match("/^https?:\\/\\/.*/", $url)) {
             throw new Exception('URL must be valid http:// or https:// resource. Please try again');
             return;
         }
         try {
             $ds->append_log('Import from URL: ' . $data['url'] . ' started at ' . date('Y-m-d H:i:s', time()));
             $xml = @file_get_contents($url);
         } catch (Exception $e) {
             $ds->append_log('Import from URL (' . $data['url'] . ') failed' . NL . $e->getMessage(), 'error');
             throw new Exception($e->getMessage());
             return;
         }
     }
     if ($type == 'xml') {
         $xml = $data['xml'];
     }
     if ($xml || $type == 'xml') {
         if ($type == 'xml') {
             $ds->append_log('Import from Pasted XML started at ' . date('Y-m-d H:i:s', time()));
         }
         //check the xml
         if (strlen($xml) == 0) {
             if ($type == 'xml') {
                 $ds->append_log('Import from Pasted XML failed: Pasted content is empty', 'error');
             }
             throw new Exception('Unable to retrieve any content. Make sure the content is not empty');
             return;
         }
         // if(!isValidXML($xml)){
         // 	if($type=='xml') $ds->append_log('Import from Pasted XML failed: Pasted content is not valid XML', 'error');
         // 	throw new Exception('Import failed, Input is not valid XML');
         // 	return;
         // }
         $xml = stripXMLHeader($xml);
         if (strpos($xml, '<registryObjects') === FALSE) {
             $xml = wrapRegistryObjects($xml);
         }
         try {
             $this->importer->runBenchMark = true;
             $this->importer->setXML($xml);
             // $this->importer->maintainStatus(); //records which already exists are harvested into their same status
             $this->importer->setCrosswalk($ds->provider_type);
             $this->importer->setDatasource($ds);
             $this->importer->commit();
         } catch (Exception $e) {
             if ($type == 'xml') {
                 $ds->append_log('Import from Pasted XML failed ' . $e->getMessage(), 'error');
             }
             if ($type == 'url') {
                 $ds->append_log('Import from URL failed ' . NL . 'URL: ' . $url . NL . $e->getMessage(), 'error');
             }
             throw new Exception($e->getMessage());
             return;
         }
         $error_log = $this->importer->getErrors();
         if ($error_log && $error_log != '') {
             if ($type == 'xml') {
                 $ds->append_log('Import from Pasted XML failed due to errors' . $error_log, 'error');
             }
             if ($type == 'url') {
                 $ds->append_log('Import from URL failed due to errors ' . NL . 'URL: ' . $url . NL . $error_log, 'error');
             }
             throw new Exception($error_log);
         }
     } elseif ($type == 'url') {
         throw new Exception('URL not contain any XML');
     } else {
         throw new Exception('Bad XML');
     }
     $import_msg = '';
     if ($type == 'xml') {
         $import_msg .= 'Import from Pasted XML Completed!' . NL;
     }
     if ($type == 'url') {
         $import_msg .= 'Import from URL Completed!' . NL . 'URL:' . $url . NL;
     }
     $import_msg .= trim($this->importer->getMessages());
     $ds->append_log($import_msg);
     //all goes well
     echo json_encode(array('status' => 'OK', 'message' => $import_msg));
 }
Пример #8
0
 public function init()
 {
     acl_enforce('REGISTRY_STAFF');
     $this->load->library('importer');
     $slogTitle = 'Import from URL completed successfully' . NL;
     $elogTitle = 'An error occurred whilst importing from the specified URL' . NL;
     $log = 'IMPORT LOG' . NL;
     //$log .= 'URI: ' . $this->input->post('url') . NL;
     $log .= 'Harvest Method: Direct import from URL' . NL;
     $this->load->model('data_source/data_sources', 'ds');
     $data_source = $this->ds->getByKey($this->config->item('example_ds_key'));
     if (!$this->config->item('example_ds_key')) {
         echo "Example DataSource Key is required to complete the task" . NL;
         return;
     }
     if (!$data_source) {
         $data_source = $this->ds->create($this->config->item('example_ds_key'), url_title($this->config->item('example_ds_title')));
         $data_source->setAttribute('title', $this->config->item('example_ds_title'));
         $data_source->setAttribute('record_owner', 'superuser');
         $data_source->save();
         $data_source->updateStats();
         $data_source = $this->ds->getByKey($this->config->item('example_ds_key'));
     }
     $sampleRecordUrls = array('http://services.ands.org.au/documentation/rifcs/1.6/examples/eg-collection-1.xml', 'http://services.ands.org.au/documentation/rifcs/1.6/examples/eg-party-1.xml', 'http://services.ands.org.au/documentation/rifcs/1.6/examples/eg-service-1.xml', 'http://services.ands.org.au/documentation/rifcs/1.6/examples/eg-activity-1.xml');
     $xml = '';
     foreach ($sampleRecordUrls as $recUrl) {
         $xml .= unWrapRegistryObjects(file_get_contents($recUrl));
     }
     $this->importer->setXML(wrapRegistryObjects($xml));
     $this->importer->setDatasource($data_source);
     $this->importer->commit(false);
     $this->importer->finishImportTasks();
     $data_source->updateStats();
     if ($error_log = $this->importer->getErrors()) {
         $log .= $elogTitle . $log . $error_log;
         $data_source->append_log($log, HARVEST_ERROR, "HARVEST_ERROR");
     }
     //else{
     $log .= $slogTitle . $log . $this->importer->getMessages();
     $data_source->append_log($log, HARVEST_INFO, "HARVEST_INFO");
     header('Location: ' . registry_url('data_source/manage_records/' . $data_source->id));
     exit;
 }
 /**
  * XXX: 
  */
 function cloneToDraft($registry_object)
 {
     if (!$registry_object instanceof _registry_object) {
         // Then this is a registry object ID
         $registry_object = $this->getByID($registry_object);
     }
     if (!$registry_object) {
         throw new Exception("Could not load registry object to create draft.");
     }
     // Add the XML content of this draft to the published record (and follow enrichment process, etc.)
     $this->load->model('data_source/data_sources', 'ds');
     $this->importer->_reset();
     $this->importer->setXML(wrapRegistryObjects(html_entity_decode($registry_object->getRif())));
     //echo $registry_object->getRif();
     $this->importer->setDatasource($this->ds->getByID($registry_object->data_source_id));
     $this->importer->forceDraft();
     $this->importer->commit();
     if ($error_log = $this->importer->getErrors()) {
         throw new Exception("Errors occured whilst cloning the record to DRAFT status: " . NL . $error_log);
     }
     return $this->getDraftByKey($registry_object->key);
 }
Пример #10
0
 function returnChunks()
 {
     $ro_xml = '';
     foreach ($this->registryObjectChunks as $chunk) {
         $ro_xml .= implode(NL, $chunk);
     }
     return wrapRegistryObjects($ro_xml);
 }
Пример #11
0
 public function add_new()
 {
     header('Cache-Control: no-cache, must-revalidate');
     header('Content-type: application/json');
     set_exception_handler('json_exception_handler');
     $this->load->library('importer');
     $data = $this->input->post('data');
     acl_enforce('REGISTRY_USER');
     ds_acl_enforce($data['data_source_id']);
     $this->load->model('registry_objects', 'ro');
     $record_owner = $this->user->identifier();
     $this->load->model('data_source/data_sources', 'ds');
     $ds = $this->ds->getByID($data['data_source_id']);
     $jsondata = array();
     $jsondata['success'] = false;
     $jsondata['message'] = '';
     $jsondata['ro_id'] = null;
     if (!$ds) {
         $jsondata['message'] = 'do datasource';
     } else {
         $ro = $this->ro->getDraftByKey($data['registry_object_key']);
         if ($ro) {
             throw new Exception("A registry object with this key already exists. Registry Object keys must be unique!");
         }
         $this->importer->setDatasource($ds);
         $xml = "<registryObject group='" . $data['group'] . "'>" . NL;
         $xml .= "<key>" . $data['registry_object_key'] . "</key>" . NL;
         $xml .= "<originatingSource type=''>" . $data['originating_source'] . "</originatingSource>" . NL;
         $xml .= "<" . $data['ro_class'] . " type='" . $data['type'] . "'>" . NL;
         $xml .= "<name type='primary'><namePart>No Name/Title</namePart></name>";
         $xml .= "<description type=''></description>";
         $xml .= "<identifier type=''></identifier>";
         if ($data['ro_class'] == 'collection') {
             $xml .= "<dates type=''></dates>";
         }
         $xml .= "<location></location>";
         $xml .= "<relatedObject><key></key><relation type=''></relation></relatedObject>";
         $xml .= "<subject type=''></subject>";
         $xml .= "<relatedInfo></relatedInfo>";
         $xml .= "</" . $data['ro_class'] . ">" . NL;
         $xml .= "</registryObject>";
         $this->importer->forceDraft();
         $this->importer->setXML(wrapRegistryObjects($xml));
         $this->importer->commit();
         $error_log = $this->importer->getErrors();
         if ($error_log) {
             throw new Exception($error_log);
         } else {
             $jsondata['success'] = true;
             $ro = $this->ro->getDraftByKey($data['registry_object_key']);
             $jsondata['ro_id'] = $ro->id;
             $jsondata['message'] = 'new Registry Object with id ' . $ro->id . ' was created';
         }
     }
     echo json_encode($jsondata);
 }
Пример #12
0
 function cleanRIFCSofEmptyTags($rifcs, $removeFormAttributes = 'true')
 {
     if (strlen($rifcs) > 50000) {
         $rifcs = preg_replace('/<relatedObject.*?<\\/relatedObject>|\\s{2,}/ms', '', $rifcs);
     }
     $xslt_processor = Transforms::get_form_to_cleanrif_transformer();
     $dom = new DOMDocument();
     //$dom->loadXML($this->ro->getXML());
     $dom->loadXML(wrapRegistryObjects(unWrapRegistryObjects($rifcs)));
     //$dom->loadXML($rifcs);
     $xslt_processor->setParameter('', 'removeFormAttributes', $removeFormAttributes);
     return $xslt_processor->transformToXML($dom);
 }
 function returnChunks()
 {
     $ro_xml = '';
     echo "registryObjectChunks: " . count($this->registryObjectChunks) . NL;
     foreach ($this->registryObjectChunks as $chunk) {
         echo "Chunks: " . count($chunk);
         $ro_xml .= implode(NL, $chunk);
     }
     //echo wrapRegistryObjects($ro_xml);
     return wrapRegistryObjects($ro_xml);
 }
Пример #14
0
 function exportDataSource($id)
 {
     parse_str($_SERVER['QUERY_STRING'], $_GET);
     $as = 'xml';
     $formatString = 'rif-cs';
     $statusString = '';
     $classString = '';
     $data = json_decode($this->input->get('data'));
     foreach ($data as $param) {
         if ($param->name == 'ro_class') {
             $classString .= $param->value;
         }
         if ($param->name == 'as') {
             $as = $param->value;
         }
         if ($param->name == 'ro_status') {
             $statusString .= $param->value;
         }
         if ($param->name == 'format') {
             $formatString = $param->value;
         }
     }
     $this->load->model("data_sources", "ds");
     $this->load->model("registry_object/registry_objects", "ro");
     $dataSource = $this->ds->getByID($id);
     $dsSlug = $dataSource->getAttribute('slug');
     $rifcs = '';
     $dciOutput = '';
     $ids = $this->ro->getIDsByDataSourceID($id, false, 'All');
     if ($ids) {
         $i = 0;
         foreach ($ids as $idx => $ro_id) {
             try {
                 $ro = $this->ro->getByID($ro_id);
                 if ($formatString == 'dci') {
                     $dciOutput .= $ro->transformToDCI(false);
                 } elseif ($ro && strpos($classString, $ro->class) !== false && strpos($statusString, $ro->status) !== false) {
                     $rifcs .= unWrapRegistryObjects($ro->getRif()) . NL;
                 }
             } catch (Exception $e) {
             }
             if ($idx % 100 == 0) {
                 unset($ro);
                 gc_collect_cycles();
             }
         }
     }
     if ($formatString == 'dci') {
         $result = '<?xml version="1.0"?>' . NL;
         $result .= '<DigitalContentData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DCI_schema_providers_V4.1.xsd">' . NL;
         $result .= $dciOutput;
         $result .= '</DigitalContentData>';
     } else {
         $result = wrapRegistryObjects($rifcs);
     }
     if ($as == 'file') {
         $this->load->helper('download');
         force_download($dsSlug . '-' . strtoupper($formatString) . '-Export.xml', $result);
     } else {
         header('Cache-Control: no-cache, must-revalidate');
         header('Content-type: application/xml');
         echo $result;
     }
 }
Пример #15
0
 /**
  * 
  */
 public function getRifcsFromFeed($oai_feed)
 {
     $result = '';
     try {
         //$sxml = simplexml_load_string($oai_feed);
         $sxml = $this->_getSimpleXMLFromString($oai_feed);
         if ($sxml) {
             @$sxml->registerXPathNamespace("oai", OAI_NAMESPACE);
             @$sxml->registerXPathNamespace("ro", RIFCS_NAMESPACE);
             $registryObjects = $sxml->xpath('//ro:registryObject');
             foreach ($registryObjects as $ro) {
                 $result .= $ro->asXML();
             }
             $result = wrapRegistryObjects($result);
         }
     } catch (Exception $e) {
         return $e;
     }
     return $result;
 }
Пример #16
0
 function error($message)
 {
     echo wrapRegistryObjects('');
 }
Пример #17
0
 function handleStatusChange($target_status)
 {
     $this->_CI->load->library('Solr');
     // Changing between draft statuses, nothing to worry about:
     $this->_CI->load->model('data_source/data_sources', 'ds');
     $data_source = $this->_CI->ds->getByID($this->getAttribute('data_source_id'));
     if (isDraftStatus($this->getAttribute('original_status')) && isDraftStatus($target_status)) {
         if ($this->getAttribute('original_status') == 'ASSESSMENT_IN_PROGRESS' && $target_status == 'APPROVED') {
             $this->setAttribute("manually_assessed", 'yes');
         }
         if ($target_status == 'DRAFT') {
             $this->setAttribute("manually_assessed", 'no');
         }
     } else {
         if (isDraftStatus($this->getAttribute('original_status')) && isPublishedStatus($target_status)) {
             $xml = html_entity_decode($this->ro->getRif());
             $existingRegistryObject = $this->_CI->ro->getPublishedByKey($this->ro->key);
             if ($existingRegistryObject && $existingRegistryObject->getAttribute('data_source_id') != $this->getAttribute('data_source_id')) {
                 $otherDs = $this->_CI->ds->getByID($existingRegistryObject->getAttribute('data_source_id'));
                 throw new Exception("Registry Object with key " . $this->ro->key . " already exists in the " . NL . $otherDs->title . " Data Source");
             } else {
                 if ($existingRegistryObject) {
                     // Delete this original draft and change this object to point to the PUBLISHED (seamless changeover)
                     $manuallyAssessed = $this->getAttribute('manually_assessed');
                     $this->ro = $this->_CI->ro->getPublishedByKey($this->getAttribute("key"));
                     if ($this->getAttribute('original_status') === 'ASSESSMENT_IN_PROGRESS' || $manuallyAssessed === 'yes') {
                         $this->ro->setAttribute("manually_assessed", 'yes');
                     }
                     if ($this->ro->getAttribute('gold_status_flag') === 't') {
                         $this->ro->setAttribute("gold_status_flag", 'f');
                     }
                     $this->ro->harvest_id = $this->getAttribute('harvest_id');
                     $this->ro->save();
                     $this->_CI->ro->deleteRegistryObject($this->id);
                     $this->id = $this->ro->id;
                     $this->init();
                 }
             }
             // If the importer is already running
             if ($this->_CI->importer->isImporting) {
                 // other actions will occur in the existing importer run...
             } else {
                 // Add the XML content of this draft to the published record (and follow enrichment process, etc.)
                 $this->_CI->importer->_reset();
                 $this->_CI->importer->setXML(wrapRegistryObjects($xml));
                 $this->_CI->importer->setDatasource($data_source);
                 $this->_CI->importer->forcePublish();
                 $this->_CI->importer->statusAlreadyChanged = true;
                 $this->_CI->importer->commit();
                 if ($this->getAttribute('original_status') == 'ASSESSMENT_IN_PROGRESS' || $this->getAttribute('manually_assessed') == 'yes') {
                     $this->ro = $this->_CI->ro->getPublishedByKey($this->getAttribute("key"));
                     $this->ro->setAttribute("manually_assessed", 'yes');
                 }
                 $this->ro->index_solr();
                 if ($error_log = $this->_CI->importer->getErrors()) {
                     throw new Exception("Errors occured whilst migrating to PUBLISHED status: " . NL . $error_log);
                 }
             }
         } else {
             $existingRegistryObject = $this->_CI->ro->getDraftByKey($this->ro->key);
             if ($existingRegistryObject) {
                 // Delete any existing drafts (effectively overwriting them)
                 $this->_CI->ro->deleteRegistryObject($existingRegistryObject->id);
             }
             // Reenrich related records (reindexes affected records)
             // XXX: REENRICH RECORDS RELATED TO ME WHEN I CHANGE STATUS
             /*
             $reenrich_queue = $target_ro->getRelatedKeys();
             $this->_CI->importer->_enrichRecords($reenrich_queue);
             $this->_CI->importer->_reindexRecords($reenrich_queue);
             */
             $this->ro->slug = DRAFT_RECORD_SLUG . $this->ro->id;
             //remove the record from the index
             $this->_CI->solr->deleteByQueryCondition('id:' . $this->ro->id);
         }
     }
     $this->_initAttribute("original_status", $target_status);
 }