Esempio n. 1
0
 /**
  * Extend 
  * @see Form::validate()
  */
 function validate()
 {
     // Check that all required fields are filled.
     if (!parent::validate()) {
         return false;
     }
     // Verify that the credentials work.
     $dcc = new DuraCloudConnection($this->getData('duracloudUrl'), $this->getData('duracloudUsername'), $this->getData('duracloudPassword'));
     $ds = new DuraStore($dcc);
     if ($ds->getSpaces($storeId) === false) {
         // Could not get a list of spaces.
         $this->addError('duracloudUrl', __('plugins.importexport.duracloud.configuration.credentialsInvalid'));
         return false;
     }
     // Success.
     return true;
 }
Esempio n. 2
0
if (!isset($argv)) {
    echo "This is a command line example. You must use the PHP CLI tool to execute.\n";
    exit(-1);
}
if (count($argv) < 5 || count($argv) > 9) {
    echo "Usage:\n";
    echo array_shift($argv) . " [DuraCloud base URL] [username] [password] [spaceID] [(storeID)]\n";
    exit(-2);
}
// Get arguments.
$exampleName = array_shift($argv);
$baseUrl = array_shift($argv);
$username = array_shift($argv);
$password = array_shift($argv);
$spaceId = array_shift($argv);
$storeId = array_shift($argv);
// Optional
// Try a connection.
$dcc = new DuraCloudConnection($baseUrl, $username, $password);
$ds = new DuraStore($dcc);
$metadata = $ds->getSpaceMetadata($spaceId, $storeId);
if ($metadata !== false) {
    echo "\nMetadata:\n";
    foreach ($metadata as $key => $value) {
        echo " {$key}: {$value}\n";
    }
    echo "\n";
} else {
    echo "The list of space metadata could not be fetched. Check your credentials and space ID.\n";
    exit(-3);
}
Esempio n. 3
0
    exit(-1);
}
if (count($argv) != 5) {
    echo "Usage:\n";
    echo array_shift($argv) . " [DuraCloud base URL] [username] [password] [spaceID]\n";
    exit(-2);
}
// Get arguments.
$exampleName = array_shift($argv);
$baseUrl = array_shift($argv);
$username = array_shift($argv);
$password = array_shift($argv);
$spaceId = array_shift($argv);
// Try a connection.
$dcc = new DuraCloudConnection($baseUrl, $username, $password);
$ds = new DuraStore($dcc);
// Create a space.
$location = $ds->createSpace($spaceId, array(DURACLOUD_SPACE_ACCESS => DURACLOUD_SPACE_ACCESS_OPEN));
if (!$location) {
    die("Could not create a space!\n");
}
// Check its metadata.
$metadata = $ds->getSpaceMetadata($spaceId);
if (!$metadata) {
    die("Could not read space metadata part 1!\n");
}
if ($metadata[DURACLOUD_SPACE_ACCESS] != DURACLOUD_SPACE_ACCESS_OPEN) {
    die("Incorrect metadata part 1!\n");
}
// Reset its metadata.
$result = $ds->setSpaceMetadata($spaceId, array(DURACLOUD_SPACE_ACCESS => DURACLOUD_SPACE_ACCESS_CLOSED));
Esempio n. 4
0
    echo "This is a command line example. You must use the PHP CLI tool to execute.\n";
    exit(-1);
}
if (count($argv) != 4) {
    echo "Usage:\n";
    echo array_shift($argv) . " [DuraCloud base URL] [username] [password]\n";
    exit(-2);
}
// Get arguments.
$exampleName = array_shift($argv);
$baseUrl = array_shift($argv);
$username = array_shift($argv);
$password = array_shift($argv);
// Try a connection.
$dcc = new DuraCloudConnection($baseUrl, $username, $password);
$ds = new DuraStore($dcc);
$stores = $ds->getStores();
if ($stores !== false) {
    echo "The list of stores is:\n";
    foreach ($stores as $store) {
        echo " {$store['id']}: {$store['storageProviderType']}";
        if ($store['primary']) {
            echo ' (Primary)';
        }
        echo "\n";
    }
    echo "\n";
} else {
    echo "The list of stores could not be fetched. Check your credentials.\n";
    exit(-3);
}
 /**
  * Get a list of importable issues from the DuraSpace instance.
  * @return array(contentId => issueIdentification)
  */
 function getImportableIssues()
 {
     $dcc =& $this->getDuraCloudConnection();
     $duraStore = new DuraStore($dcc);
     $spaceId = $this->getDuraCloudSpace();
     $contents = $duraStore->getSpace($spaceId, $metadata, null, 'issue-');
     if (!$contents) {
         return $contents;
     }
     $returner = array();
     foreach ($contents as $contentId) {
         $content = $duraStore->getContent($spaceId, $contentId);
         if (!$content) {
             continue;
         }
         // Could not fetch content
         $descriptor =& $content->getDescriptor();
         if (!$descriptor) {
             continue;
         }
         // Could not get descriptor
         $metadata = $descriptor->getMetadata();
         if (!$metadata) {
             continue;
         }
         // Could not get metadata
         if (!isset($metadata['creator']) || $metadata['creator'] != $this->getName()) {
             continue;
         }
         // Not created by this plugin
         if (!isset($metadata['identification'])) {
             continue;
         }
         // Could not get identification
         $returner[$contentId] = $metadata;
         unset($metadata);
     }
     return $returner;
 }
Esempio n. 6
0
}
if (count($argv) != 6) {
    echo "Usage:\n";
    echo array_shift($argv) . " [DuraCloud base URL] [username] [password] [spaceID] [contentId]\n";
    exit(-2);
}
// Get arguments.
$exampleName = array_shift($argv);
$baseUrl = array_shift($argv);
$username = array_shift($argv);
$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);
Esempio n. 7
0
$exampleName = array_shift($argv);
$baseUrl = array_shift($argv);
$username = array_shift($argv);
$password = array_shift($argv);
$spaceId = array_shift($argv);
$storeId = array_shift($argv);
// Optional
$prefixId = array_shift($argv);
// Optional
$maxResults = array_shift($argv);
// Optional
$marker = array_shift($argv);
// Optional
// Try a connection.
$dcc = new DuraCloudConnection($baseUrl, $username, $password);
$ds = new DuraStore($dcc);
$contents = $ds->getSpace($spaceId, $metadata, $storeId, $prefixId, $maxResults, $marker);
if ($contents !== false) {
    echo "The list of contents is:\n";
    foreach ($contents as $item) {
        echo " - {$item}\n";
    }
    echo "\nMetadata:\n";
    foreach ($metadata as $key => $value) {
        echo " {$key}: {$value}\n";
    }
    echo "\n";
} else {
    echo "The list of space contents could not be fetched. Check your credentials and space ID.\n";
    exit(-3);
}
Esempio n. 8
0
ini_set('display_errors', E_ALL);
// Import DuraCloud PHP library
require_once '../DuraCloudPHP.inc.php';
// Check usage.
if (!isset($argv)) {
    echo "This is a command line example. You must use the PHP CLI tool to execute.\n";
    exit(-1);
}
if (count($argv) < 5 || count($argv) > 6) {
    echo "Usage:\n";
    echo array_shift($argv) . " [DuraCloud base URL] [username] [password] [spaceID] [(storeID)]\n";
    exit(-2);
}
// Get arguments.
$exampleName = array_shift($argv);
$baseUrl = array_shift($argv);
$username = array_shift($argv);
$password = array_shift($argv);
$spaceId = array_shift($argv);
$storeId = array_shift($argv);
// Optional
// Try a connection.
$dcc = new DuraCloudConnection($baseUrl, $username, $password);
$ds = new DuraStore($dcc);
$location = $ds->createSpace($spaceId, array(DURACLOUD_SPACE_ACCESS => DURACLOUD_SPACE_ACCESS_OPEN), $storeId);
if ($location !== false) {
    echo "\nThe new space was created as \"{$location}\".\n";
} else {
    echo "The new space could not be created. Check your credentials and space ID.\n";
    exit(-3);
}
Esempio n. 9
0
// Check usage.
if (!isset($argv)) {
    echo "This is a command line example. You must use the PHP CLI tool to execute.\n";
    exit(-1);
}
if (count($argv) < 4 || count($argv) > 5) {
    echo "Usage:\n";
    echo array_shift($argv) . " [DuraCloud base URL] [username] [password] [(storeID)]\n";
    exit(-2);
}
// Get arguments.
$exampleName = array_shift($argv);
$baseUrl = array_shift($argv);
$username = array_shift($argv);
$password = array_shift($argv);
$storeId = array_shift($argv);
// Optional
// Try a connection.
$dcc = new DuraCloudConnection($baseUrl, $username, $password);
$ds = new DuraStore($dcc);
$spaces = $ds->getSpaces($storeId);
if ($spaces !== false) {
    echo "The list of spaces is:\n";
    foreach ($spaces as $space) {
        echo " - {$space}\n";
    }
    echo "\n";
} else {
    echo "The list of spaces could not be fetched. Check your credentials.\n";
    exit(-3);
}