|
|
@ -963,6 +963,50 @@ function islandora_add_object(AbstractObject &$object) { |
|
|
|
return $object->repository->ingestObject($object); |
|
|
|
return $object->repository->ingestObject($object); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Creates a new object with the same properties as the old. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @todo Make Tuque objects support cloneing. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param AbstractObject $object |
|
|
|
|
|
|
|
* An existing or new Fedora Object. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return AbstractObject |
|
|
|
|
|
|
|
* The new Fedora Object with properties identical to the object given. This |
|
|
|
|
|
|
|
* returned object is not automatically ingested. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
function islandora_copy_object(AbstractObject $object) { |
|
|
|
|
|
|
|
$clone = $object->repository->constructObject($object->id); |
|
|
|
|
|
|
|
$object_properties = array( |
|
|
|
|
|
|
|
'state', |
|
|
|
|
|
|
|
'createdDate', |
|
|
|
|
|
|
|
'lastModifiedDate', |
|
|
|
|
|
|
|
'label', |
|
|
|
|
|
|
|
'owner', |
|
|
|
|
|
|
|
'logMessage', |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
// Copy Properties. |
|
|
|
|
|
|
|
foreach ($object_properties as $property) { |
|
|
|
|
|
|
|
if (isset($object->$property)) { |
|
|
|
|
|
|
|
$clone->$property = $object->$property; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Copy Datastreams. |
|
|
|
|
|
|
|
foreach ($object as $dsid => $datastream) { |
|
|
|
|
|
|
|
if (empty($clone[$dsid])) { |
|
|
|
|
|
|
|
$clone->ingestDatastream($datastream); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
// Get the content into a file, and add the file. |
|
|
|
|
|
|
|
$temp_file = drupal_tempnam('temporary://', 'datastream'); |
|
|
|
|
|
|
|
$datastream->getContent($temp_file); |
|
|
|
|
|
|
|
$clone[$dsid]->setContentFromFile($temp_file); |
|
|
|
|
|
|
|
drupal_unlink($temp_file); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return $clone; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Delete's or purges the given object. |
|
|
|
* Delete's or purges the given object. |
|
|
|
* |
|
|
|
* |
|
|
|