-
Notifications
You must be signed in to change notification settings - Fork 0
/
seadl_delete_jp2_book.php
51 lines (45 loc) · 1.38 KB
/
seadl_delete_jp2_book.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
#!/usr/bin/env drush
/*
Script to delete jp2s from the book model. Only need jp2 for pages.
1/7/2021
*/
<?php
$tuquePath = libraries_get_path('tuque') . '/*.php'; foreach ( glob($tuquePath) as $filename) {
require_once($filename);
}
$serializer = new FedoraApiSerializer();
$cache = new SimpleCache();
$connection = new RepositoryConnection('fedora_url', 'user', 'password');
$api = new FedoraApi($connection, $serializer);
$repository = new FedoraRepository($api, $cache);
$count = 1;
$csv = array_map('str_getcsv', file('/file/path/seadl_book_models_3.csv'));
foreach ($csv as $row) {
$id = $row[0];
$object = $repository->getObject($id);
if (!$object) {
drupal_set_message("Fedora Object isn't in the repo!");
} else {
$models = $object->models;
$bookcm = $models[0];
if ($bookcm == 'islandora:bookCModel') {
print "Using model " . $bookcm . "\n";
foreach ($object as $datastream) {
if ($datastream->id == 'JP2') {
print $count . "\n";
$count += 1;
print "PID: " . $id;
print "\nModel: " . $models[0];
print "\nDSID: " . $datastream->id;
print "\nLabel: " . $datastream->label;
print "\nMimetype: " . $datastream->mimetype;
print "\n\n";
print "Deleting " . $id . " JP2 file\n\n";
$dsid = $datastream->id;
$object->purgeDatastream($dsid);
}
}
}
}
}
?>