Example #1
0
 /**
  * sendData - 
  */
 function sendData($data, $pidName, $pidNum)
 {
     $pid = $pidName . ':' . $pidNum;
     //$curlCmd = 'curl --user fedoraAdmin:fedoraAdmin -i -s -H "Content-type: text/xml" -XPOST "' . $this->hostServer . 'objects/'.$pidName.':'.$pidNum.'" --data-binary @fedoraFoxXmlFile.xml -k';
     $curlCmd = 'curl --user ' . $this->fedoraUser . ':' . $this->fedoraPass . ' -i -s -H "Content-type: text/xml" -XPOST "' . $this->hostServer . 'objects/' . $pidName . ':' . $pidNum . '" --data-binary @fedoraFoxXmlFile.xml -k';
     if ($this->loggingFlag) {
         fedora_watchmen('curlCmd: ' . $curlCmd);
     }
     $resp = exec($curlCmd);
     return $resp;
 }
 /**
  * writeFedora - 
  */
 function writeFedora($nodeId, $node)
 {
     $flag = false;
     $namespace = $this->namespace;
     $nextPid = $nodeId;
     $pidName = $namespace;
     $pidNum = $nextPid;
     $ext = 'pdf';
     $authors = array();
     $contributorsList = $this->makeAuthorsArray($nodeId);
     // list out authors
     if (count($contributorsList)) {
         foreach ($contributorsList as $contributor) {
             $authors[] = $this->xmlifyDataFilter($contributor);
         }
     } else {
         $authors = null;
     }
     // build list of keywords for subject
     $keywordsList = $this->getKeywordsList($nodeId);
     $publishers[] = $node['biblio_publisher'];
     $publishers[] = $node['biblio_remote_db_provider'];
     $type = $this->getPublicationType($node['biblio_type']);
     // translate number into human word
     $host = $_SERVER['SERVER_NAME'];
     // if year is 9999 make it blank, we don't want to store the biblio centric "no year" marker
     $year = $node['biblio_year'] == 9999 ? '' : $node['biblio_year'];
     $this->fedoraFoxXml->clearData();
     $this->fedoraFoxXml->subjectName = $pidName;
     $this->fedoraFoxXml->state = 'A';
     // active
     $this->fedoraFoxXml->controlGrp = 'X';
     // xml
     $this->fedoraFoxXml->baseUrl = htmlentities($node['biblio_url'], ENT_QUOTES, 'UTF-8');
     // make friendly to the xml parser in Fedora
     // package up the data
     $this->fedoraFoxXml->title = $this->xmlifyDataFilter($node['title']);
     $this->fedoraFoxXml->creator = $authors;
     $this->fedoraFoxXml->subject = $keywordsList;
     // grab any keywords and put in the subject field
     $this->fedoraFoxXml->description = $this->xmlifyDataFilter($node['biblio_abst_e']);
     $this->fedoraFoxXml->publisher = $publishers;
     $this->fedoraFoxXml->identifier = 'http://' . $host . '/node/' . $nodeId;
     $this->fedoraFoxXml->contributor = '';
     // empty
     $this->fedoraFoxXml->date = $year;
     $this->fedoraFoxXml->type = $type;
     // translated to words from code number
     $this->fedoraFoxXml->format = '';
     $this->fedoraFoxXml->source = htmlentities($node['biblio_url'], ENT_QUOTES, 'UTF-8');
     $this->fedoraFoxXml->language = $node['biblio_lang'];
     $this->fedoraFoxXml->relation = '';
     $this->fedoraFoxXml->coverage = '';
     $rights = new RightsModel();
     $rights->setFromNode($node);
     $this->fedoraFoxXml->rights = '' . $rights;
     // sets the rights, listed pipe delimited values, for: status, statement, license name, license url
     $this->fedoraFoxXml->pidName = $pidName;
     $this->fedoraFoxXml->pid = $pidNum;
     $xml = $this->fedoraFoxXml->buildFoxXml($ext);
     $this->fedoraClient->pid = $pidName . ':' . $pidNum;
     $this->fedoraClient->pidName = $pidName;
     $this->fedoraClient->pidNum = $pidNum;
     if ($this->loggingFlag) {
         fedora_watchmen('fox xml author name ' . $this->fedoraFoxXml->contributor);
     }
     // create the fox xml file
     $this->fedoraClient->saveFoxFiles($xml);
     // feed fedora the data
     $this->fedoraClient->httpcode = 200;
     // clear it to good so we don't have confusion with setting elsewhere in isExists.
     $resp = $this->fedoraClient->sendData($xml, $pidName, $pidNum);
     // an error has something like "Fedora: 401"
     // success has basically like  "citebank:12345"
     if ($this->loggingFlag) {
         if ($this->fedoraClient->httpcode != 200) {
             fedora_watchmen('sendData resp ' . $this->fedoraClient->httpcode);
         }
     }
     if (strstr($resp, $pidName . ':' . $pidNum)) {
         $flag = true;
     }
     // done
     return $flag;
 }