/**
  * Store an issue in DuraCloud.
  * @param $journal Journal
  * @param $issue Issue
  * @return string location iff success; false otherwise
  */
 function exportIssue(&$journal, &$issue)
 {
     // Export the native XML to a file.
     $nativeImportExportPlugin =& $this->getNativeImportExportPlugin();
     $filename = tempnam('duracloud', 'dcissue');
     $nativeImportExportPlugin->exportIssue($journal, $issue, $filename);
     // Store the file in DuraCloud.
     $dcc = $this->getDuraCloudConnection();
     $ds = new DuraStore($dcc);
     $descriptor = new DuraCloudContentDescriptor(array('creator' => $this->getName(), 'identification' => $issue->getIssueIdentification(), 'date_published' => $issue->getDatePublished(), 'num_articles' => $issue->getNumArticles()));
     $content = new DuraCloudFileContent($descriptor);
     $fp = fopen($filename, 'r');
     $content->setResource($fp);
     $location = $ds->storeContent($this->getDuraCloudSpace(), 'issue-' . $issue->getId(), $content);
     // Clean up temporary file
     unlink($filename);
     return $location;
 }
Esempio n. 2
0
$password = array_shift($argv);
$spaceId = array_shift($argv);
$contentId = array_shift($argv);
// Try a connection.
$dcc = new DuraCloudConnection($baseUrl, $username, $password);
$ds = new DuraStore($dcc);
// Create a content file.
$fp = tmpfile();
fwrite($fp, TEST_CONTENT_STRING);
// Create content.
$descriptor = new DuraCloudContentDescriptor(array('custommetadataname' => 'CustomMetadataValue'));
$content = new DuraCloudFileContent($descriptor);
$content->setResource($fp);
unset($fp);
// Store content.
$location = $ds->storeContent($spaceId, $contentId, $content);
if (!$location) {
    die("Could not create content!\n");
}
// Clean up
unset($content, $descriptor);
// Check its metadata.
$descriptor = $ds->getContentMetadata($spaceId, $contentId);
if ($descriptor) {
    $metadata = $descriptor->getMetadata();
} else {
    $metadata = null;
}
if (!$metadata) {
    die("Could not read content metadata part 1!\n");
}