-
Notifications
You must be signed in to change notification settings - Fork 1
/
printDSInfo.php
67 lines (54 loc) · 1.76 KB
/
printDSInfo.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env drush
#<?php
/**
* This script simply prints out the datastream information of a single object
* and single datastream label
*
* @author Paul Church
* @date July 2014
*
*
* Usage: drush scr printDSInfo.php objectPID datastreamLabel
*
* Example: drush scr printDSInfo.php islandora:3 TECHMD
*
*/
// grab the first user supplied parameter as the PID
$PID = drush_shift();
if (! $PID) {
drush_print("***Error: please provide the PID as the first argument");
drush_print("Example: drush php-script printDSInfo.php RULA:193");
return;
}
// grab the second user supplied parameter as the DS name
$dslabel = drush_shift();
if (! $dslabel) {
drush_print("***Error: please provide the DS name as the second argument");
drush_print("Example: drush php-script printDSInfo.php RULA:193 OBJ.0");
return;
}
# include all Tuque php files
$tuquePath = libraries_get_path('tuque') . '/*.php';
foreach ( glob($tuquePath) as $filename) {
require_once($filename);
}
// repository connection parameters
$url = 'localhost:8080/fedora';
$username = 'fedoraAdmin';
$password = 'fedoraAdmin';
// set up connection and repository variables
$connection = new RepositoryConnection($url, $username, $password);
$api = new FedoraApi($connection);
$repository = new FedoraRepository($api, new SimpleCache());
$api_m = $repository->api->m;
$api_a = $repository->api->a;
drush_print("Datastream history for the $dslabel datastream:");
$info = array_reverse($api_m->getDatastreamHistory($PID, $dslabel));
print_r($info);
$history = $api_a->getObjectHistory($PID);
$profile = $api_a->getObjectProfile($PID, new DateTime());
drush_print("Object History:");
print_r($history);
drush_print("Object Profile:");
print_r($profile);
echo "\n\nAll operations complete\n";