function add_Datastream($pid, $datastream, $dsLabel, $mimetype, $xml_url) { module_load_include('php', 'Fedora_Repository', 'ObjectHelper'); module_load_include('php', 'Fedora_Repository', 'ConnectionHelper'); global $user; if (!fedora_repository_access(OBJECTHELPER::$ADD_FEDORA_STREAMS, $pid, $user)) { drupal_set_message('You do not have permission to add datastreams to this object!'); return false; } global $base_url; module_load_include('php', 'Fedora_Repository', 'ConnectionHelper'); $controlGroup = "M"; $params = array('pid' => $pid, 'dsID' => $datastream, 'altIDs' => "", 'dsLabel' => $dsLabel, 'versionable' => "true", 'MIMEType' => $mimetype, 'formatURI' => "URL", 'dsLocation' => $xml_url, 'controlGroup' => "{$controlGroup}", 'dsState' => "A", 'checksumType' => "DISABLED", 'checksum' => "none", 'logMessage' => "datastream added"); try { $soapHelper = new ConnectionHelper(); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); if ($client == null) { drupal_set_message(t('Error Getting Soap Client.'), 'error'); return false; } $object = $client->__soapCall('addDatastream', array('parameters' => $params)); return true; } catch (exception $e) { try { $params['force'] = 'true'; $object = $client->__soapCall('ModifyDatastreamByReference', array($params)); return true; } catch (exception $e1) { drupal_set_message(t($e1->getMessage()), 'error'); return false; } } }
function getEpistemetecData($pid) { global $base_url; $path = drupal_get_path('module', 'Fedora_Repository'); module_load_include('php', 'Fedora_Repository', 'ConnectionHelper'); $soapHelper = new ConnectionHelper(); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_url', 'http://localhost:8080/fedora/services/access?wsdl')); $dsId = 'MAG'; $params = array('pid' => "{$pid}", 'dsID' => "{$dsId}", 'asOfDateTime' => ""); try { $object = $client->__soapCAll('getDatastreamDissemination', array('parameters' => $params)); } catch (Exception $e2) { try { //probably no QDC so we will try for the DC stream. $dsId = 'MAG'; $params = array('pid' => "{$pid}", 'dsID' => "{$dsId}", 'asOfDateTime' => ""); $object = $client->__soapCAll('getDatastreamDissemination', array('parameters' => $params)); } catch (exception $e2) { drupal_set_message($e2->getMessage(), 'error'); return; } } $xmlstr = $object->dissemination->stream; try { $proc = new XsltProcessor(); } catch (Exception $e) { drupal_set_message($e->getMessage(), 'error'); return; } $proc->setParameter('', 'baseUrl', $base_url); $proc->setParameter('', 'path', $base_url . '/' . $path); $input = null; $xsl = new DomDocument(); try { $xsl->load($path . '/epistemetec/xsl/epistemetecData.xsl'); $input = new DomDocument(); $input->loadXML(trim($xmlstr)); } catch (exception $e) { watchdog("Fedora_Repository", "Problem loading xsl file!"); } $xsl = $proc->importStylesheet($xsl); $newdom = $proc->transformToDoc($input); $output = $newdom->saveXML(); $baseUrl = base_path(); $baseUrl = substr($baseUrl, 0, strpos($baseUrl, "/") - 1); // if (user_access(ObjectHelper :: $EDIT_FEDORA_METADATA)) { // $output .= '<br /><a title = "' . t('Edit Meta Data') . '" href="' . $base_url . '/fedora/repository/' . 'editmetadata/' . $pid . '/' . $dsId . '"><img src="' . $base_url . '/' . $path . '/images/edit.gif" alt="' . t('Edit Meta Data') . '" /></a>'; // } return $output; }
function handleQDCForm($form_values) { $dom = new DomDocument("1.0", "UTF-8"); $dom->formatOutput = true; $pid = $form_values['pid']; $rootElement = $dom->createElement("foxml:digitalObject"); $rootElement->setAttribute('PID', "{$pid}"); $rootElement->setAttribute('xmlns:foxml', "info:fedora/fedora-system:def/foxml#"); $rootElement->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"); $rootElement->setAttribute('xsi:schemaLocation', "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-0.xsd"); $dom->appendChild($rootElement); //create standard fedora stuff $this->createStandardFedoraStuff($form_values, $dom, $rootElement); //create relationships $this->createRelationShips($form_values, $dom, $rootElement); //create dublin core $this->createQDCStream($form_values, $dom, $rootElement); $this->createFedoraDataStreams($form_values, $dom, $rootElement); $params = array('objectXML' => $dom->saveXML(), 'format' => "foxml1.0", 'logMessage' => "Fedora Object Ingested"); try { $soapHelper = new ConnectionHelper(); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); if ($client == null) { drupal_set_message(t('Error Getting Soap Client.'), 'error'); return; } $object = $client->__soapCall('ingest', array($params)); $deleteFiles = $form_values['delete_file']; //remove files from drupal file system if ($deleteFiles > 0) { foreach ($_SESSION['fedora_ingest_files'] as $dsid => $createdFile) { unlink($createdFile); } unlink($form_values['fullpath']); } } catch (exception $e) { drupal_set_message(t('Error Ingesting Object! ' . $e->getMessage()), 'error'); return; } }
function handleFractionEditForm($form_id, $form_values, $soap_client) { // ====================================== // = begin creation of foxml dom object = // ====================================== $dom = new DomDocument("1.0", "UTF-8"); $dom->formatOutput = true; ///begin writing fraction datastream $frac = $dom->createElement("fractions:sample"); $frac->setAttribute('xmlns:fractions', "http://vre.upei.ca/fractions/"); //fraction elements $ident = $dom->createElement("fractions:identifier", $form_values['identifier']); $plate = $dom->createElement("fractions:plate", $form_values['plate']); $weight = $dom->createElement("fractions:weight", $form_values['weight']); $pt = $dom->createElement("fractions:ptp1b", $form_values['pt']); $pt_com = $dom->createElement("fractions:ptp1b_com", $form_values['pt_com']); $hct = $dom->createElement("fractions:hct116", $form_values['hct']); $hct_com = $dom->createElement("fractions:hct116_com", $form_values['hct_com']); $hela = $dom->createElement("fractions:hela", $form_values['hela']); $hela_com = $dom->createElement("fractions:hela_com", $form_values['hela_com']); $pc3 = $dom->createElement("fractions:pc3", $form_values['pc3']); $pc3_com = $dom->createElement("fractions:pc3_com", $form_values['pc3_com']); $are = $dom->createElement("fractions:are", $form_values['are']); $are_com = $dom->createElement("fractions:are_com", $form_values['are_com']); $antipro = $dom->createElement("fractions:antiproliferative", $form_values['antiproliferative']); $antipro_com = $dom->createElement("fractions:antiproliferative_com", $form_values['antiproliferative_com']); $location = $dom->createElement("fractions:location", $form_values['location']); $notes = $dom->createElement("fractions:notes", $form_values['notes']); // append elements $frac->appendChild($ident); $frac->appendChild($plate); $frac->appendChild($weight); $frac->appendChild($pt); $frac->appendChild($pt_com); $frac->appendChild($hct); $frac->appendChild($hct_com); $frac->appendChild($hela); $frac->appendChild($hela_com); $frac->appendChild($pc3); $frac->appendChild($pc3_com); $frac->appendChild($are); $frac->appendChild($are_com); $frac->appendChild($antipro); $frac->appendChild($antipro_com); $frac->appendChild($location); $frac->appendChild($notes); $dom->appendChild($frac); // form values $pid = $form_values['pid']; $dsId = 'FRACTION'; $params = array("pid" => $pid, "dsID" => $dsId, "altIDs" => "", "dsLabel" => "FRACTION", "MIMEType" => "text/xml", "formatURI" => "URL", "dsContent" => $dom->saveXML(), "checksumType" => "DISABLED", "checksum" => "none", "logMessage" => "datastream_modified", "force" => "true"); try { $soapHelper = new ConnectionHelper(); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); if ($client == null) { drupal_set_message(t('Error Getting Soap Client.'), 'error'); return; } $object = $client->__soapCall('ModifyDatastreamByValue', array($params)); return true; } catch (exception $e) { drupal_set_message(t('Error Editing Fraction Object! ') . $e->getMessage(), 'error'); watchdog(t("Fedora_Repository"), t("Error Editing Fraction Object!") . $e->getMessage(), WATCHDOG_ERROR); return; } }
function handleCompoundForm($form_values) { $dom = new DomDocument("1.0", "UTF-8"); $dom->formatOutput = true; $rootElement = $dom->createElement("foxml:digitalObject"); $rootElement->setAttribute('VERSION', '1.1'); $rootElement->setAttribute('PID', $this->setPid($form_values)); $rootElement->setAttribute('xmlns:foxml', "info:fedora/fedora-system:def/foxml#"); $rootElement->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"); $rootElement->setAttribute('xsi:schemaLocation', "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-0.xsd"); $dom->appendChild($rootElement); //create standard fedora stuff $this->createStandardFedoraStuff($form_values, $dom, $rootElement); //create relationships $this->createRelationShips($form_values, $dom, $rootElement); //create compound $this->createCompoundStream($form_values, $dom, $rootElement); $this->createReference($dom, $rootElement); $parent = $form_values['collection_pid']; $this->createPolicy($parent, $dom, $rootElement); // test output // $test = $dom->saveXML(); // var_dump($test);exit(0); $params = array('objectXML' => $dom->saveXML(), 'format' => "info:fedora/fedora-system:FOXML-1.1", 'logMessage' => "Fedora Object Ingested"); try { $soapHelper = new ConnectionHelper(); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); if ($client == null) { drupal_set_message(t('Error Getting Soap Client.'), 'error'); return; } $object = $client->__soapCall('ingest', array($params)); // $deleteFiles= $form_values['delete_file'];//remove files from drupal file system // // if($deleteFiles>0&&isset($_SESSION['fedora_ingest_files'][0])){ // foreach($_SESSION['fedora_ingest_files'] as $dsid => $createdFile){ // unlink($createdFile); // } // unlink($form_values['fullpath']); // } } catch (exception $e) { drupal_set_message(t('Error Ingesting Compound Object! ') . $e->getMessage(), 'error'); watchdog(t("Fedora_Repository"), t("Error Ingesting Compound Object!") . $e->getMessage(), WATCHDOG_ERROR); return; } }
function createUserCollection(&$user) { if (isset($user->fedora_personal_pid)) { return; } $username = array('name' => variable_get('fedora_admin_user', 'fedoraAdmin')); $admin_user = user_load($username); module_load_include('php', 'Fedora_Repository', 'ConnectionHelper'); $connectionHelper = new ConnectionHelper(); try { $soapClient = $connectionHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); $pidNameSpace = variable_get('fedora_repository_pid', 'vre:'); $pidNameSpace = substr($pidNameSpace, 0, strpos($pidNameSpace, ":")); $params = array('numPIDs' => '', 'pidNamespace' => $pidNameSpace); $object = $soapClient->__soapCall('getNextPID', array($params)); } catch (exception $e) { drupal_set_message(t('Error getting Next Pid! ') . $e->getMessage(), 'error'); return false; } $pid = implode(get_object_vars($object)); $pidNumber = strstr($pid, ":"); $pid = $pidNameSpace . ':' . 'USER-' . $user->name . '-' . substr($pidNumber, 1); $personal_collection_pid = array('fedora_personal_pid' => $pid); module_load_include('php', 'Fedora_Repository', 'plugins/PersonalCollectionClass'); $personalCollectionClass = new PersonalCollectionClass(); if (!$personalCollectionClass->createCollection($user, $pid, $soapClient)) { drupal_set_message("Did not create a personal collection object for " . $user->name); return false; //creation failed don't save the collection pid in drupal db } user_save($user, $personal_collection_pid); return true; }
function handleForm(&$form_values) { $errorMessage = NULL; module_load_include('php', 'Fedora_Repository', 'CollectionClass'); module_load_include('php', 'Fedora_Repository', 'ContentModel'); module_load_include('php', 'fedora_repository', 'api/fedora_item'); $content_model_pid = ContentModel::getPidFromIdentifier($form_values['models']); $content_model_dsid = ContentModel::getDSIDFromIdentifier($form_values['models']); $collectionHelper = new CollectionClass(); $startTime = time(); $collection_pid = $form_values['collection_pid']; $this->parse_refworks_item($form_values); $this->security_helper = new SecurityClass(); $collection_item = new Fedora_Item($collection_pid); $this->collection_policy_stream = $collection_item->get_datastream_dissemination('CHILD_SECURITY'); if (empty($this->collection_policy_stream)) { $this->collection_policy_stream = file_get_contents(drupal_get_path('module', 'fedora_repository') . '/policies/noObjectEditPolicy.xml'); } $success = 0; $errors = 0; foreach ($this->referencelist as $reference) { $dom = new DomDocument("1.0", "UTF-8"); $dom->substituteEntities = FALSE; $dom->formatOutput = true; $pid = $collectionHelper->getNextPid($collection_pid, $content_model_dsid); $rootElement = $dom->createElement("foxml:digitalObject"); $rootElement->setAttribute('VERSION', '1.1'); $rootElement->setAttribute('PID', "{$pid}"); $rootElement->setAttribute('xmlns:foxml', "info:fedora/fedora-system:def/foxml#"); $rootElement->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance"); $rootElement->setAttribute('xsi:schemaLocation', "info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd"); $dom->appendChild($rootElement); //create standard fedora stuff $qdc_element = $this->createQDCStream($dom, $rootElement, $reference); if (!$qdc_element) { drupal_set_message(t('Error Create DC for Refworks'), 'error'); continue; } $item_title = ''; foreach ($reference->t1 as $value) { $item_title .= ' --- ' . $value; } $this->createStandardFedoraStuff($form_values, $dom, $rootElement, $reference); $rootElement->appendChild($qdc_element); //create relationships $this->createRelationShips($form_values, $dom, $rootElement, $pid); //create dublin core $this->createFedoraDataStreams($form_values, $dom, $rootElement, $reference); if (!empty($this->collection_policy_stream)) { $this->create_security_policies($dom, $rootElement, $reference); } $params = array('objectXML' => $dom->saveXML(), 'format' => 'info:fedora/fedora-system:FOXML-1.1', 'logMessage' => "Fedora Object Ingested"); try { $soapHelper = new ConnectionHelper(); $client = $soapHelper->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); if ($client == null) { drupal_set_message(t('Error Getting Soap Client.'), 'error'); watchdog(t("FEDORA_REPOSITORY"), t("Error Getting SOAP client") . $e, null, WATCHDOG_ERROR); return; } $object = $client->__soapCall('ingest', array($params)); watchdog(t("FEDORA_REPOSITORY"), t("Successfully added repository item ") . $pid . ' - ' . $item_title, null, WATCHDOG_INFO); $deleteFiles = $form_values['delete_file']; //remove files from drupal file system if ($deleteFiles > 0) { unlink($form_values['fullpath']); } } catch (exception $e) { $errors++; $errorMessage = 'yes'; //drupal_set_message(t('Error Ingesting Object! Check Drupal watchdog logs for more info' . $e->getMessage()), 'error'); watchdog(t("FEDORA_REPOSITORY"), t("Error during ingest") . $item_title . ' ' . $e, null, WATCHDOG_ERROR); //return ' '; } $success++; } if (isset($errorMessage)) { drupal_set_message(t('Error Ingesting one or more records! Check Drupal watchdog logs for more info'), 'error'); } $endTime = time(); drupal_set_message(t('Successfull ingest of %success records. %errors records failed. Ingest took %seconds seconds', array('%success' => $success - $errors, '%errors' => $errors, '%seconds' => $endTime - $startTime)), 'info'); //drupal_set_message(t('ingest took %seconds ',array('%seconds'=>$endTime-$startTime)),'info'); }
function modifyDatastreamByValue($params) { module_load_include('php', 'Fedora_Repository', 'ConnectionHelper'); $connection = new ConnectionHelper(); $client = $connection->getSoapClient(variable_get('fedora_soap_manage_url', 'http://localhost:8080/fedora/services/management?wsdl')); try { $object = $client->__soapCall('ModifyDatastreamByValue', array($params)); } catch (exception $e) { drupal_set_message(t("Error modifying datastream data ") . $e->getMessage(), 'error'); return false; } return true; }