/** * Delete a Part and all its Parts. * * @param object Id $partId * * @throws object RepositoryException An exception with one of * the following messages defined in * org.osid.repository.RepositoryException may be thrown: {@link * org.osid.repository.RepositoryException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.repository.RepositoryException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.repository.RepositoryException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.repository.RepositoryException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.repository.RepositoryException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID} * * @access public */ function deletePart(Id $partId) { $string = $partId->getIdString(); if (preg_match("/(.*)-(" . implode("|", array_keys($this->_parts)) . ")/", $string, $r)) { $recordId = $r[1]; $field = $r[2]; if ($this->_isLastPart($field)) { $dbHandler = Services::getService("DatabaseManager"); // Delete the data $query = new DeleteQuery(); $query->setTable("dr_file_url"); $query->setWhere("fk_file = '" . $this->_id->getIdString() . "'"); $dbHandler->query($query, $this->_configuration->getProperty("database_index")); // Delete the thumbnail $query = new DeleteQuery(); $query->setTable("dr_thumbnail"); $query->setWhere("fk_file = '" . $this->_id->getIdString() . "'"); $dbHandler->query($query, $this->_configuration->getProperty("database_index")); // delete the file row. $query = new DeleteQuery(); $query->setTable("dr_file"); $query->setWhere("id = '" . $this->_id->getIdString() . "'"); $dbHandler->query($query, $this->_configuration->getProperty("database_index")); } else { $this->_parts[$field]->updateValue("NULL"); } } else { throwError(new Error(RepositoryException::UNKNOWN_ID() . ": {$string}", "FileRecord", true)); } $this->_asset->updateModificationDate(); }
/** * Get all the PartStructures in the RecordStructure. Iterators return a * set, one at a time. * * @return object PartStructureIterator * * @throws object RepositoryException An exception with one of * the following messages defined in * org.osid.repository.RepositoryException may be thrown: {@link * org.osid.repository.RepositoryException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.repository.RepositoryException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.repository.RepositoryException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.repository.RepositoryException#UNIMPLEMENTED * UNIMPLEMENTED} * * @access public */ function getPartStructure(Id $partStructureId) { if ($this->_partStructures[$partStructureId->getIdString()]) { return $this->_partStructures[$partStructureId->getIdString()]; } else { throwError(new Error(RepositoryException::UNKNOWN_ID(), "Repository :: FileRecordStructure", TRUE)); } }
/** * Get the Part for a Record for this Asset that matches this Part's unique * Id. * * @param object Id $partId * * @return object Part * * @throws object RepositoryException An exception with one of * the following messages defined in * org.osid.repository.RepositoryException may be thrown: {@link * org.osid.repository.RepositoryException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.repository.RepositoryException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.repository.RepositoryException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.repository.RepositoryException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.repository.RepositoryException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID} * * @access public */ function getPart(Id $partId) { $records = $this->getRecords(); while ($records->hasNext()) { $record = $records->next(); $parts = $record->getParts(); while ($parts->hasNext()) { $part = $parts->next(); if ($partId->isEqual($part->getId())) { return $part; } } } // Throw an error if we didn't find the part. throwError(new Error(RepositoryException::UNKNOWN_ID(), "Repository :: Asset", TRUE)); }
/** * Delete a Part and all its Parts. * * @param object Id $partId * * @throws object RepositoryException An exception with one of * the following messages defined in * org.osid.repository.RepositoryException may be thrown: {@link * org.osid.repository.RepositoryException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.repository.RepositoryException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.repository.RepositoryException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.repository.RepositoryException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.repository.RepositoryException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID} * * @access public */ function deletePart(Id $partId) { $string = $partId->getIdString(); if (preg_match("/(.+)::(.+)::([0-9]+)/", $string, $r)) { $recordId = $r[1]; $label = $r[2]; $index = $r[3]; if ($this->_record->getID() == $recordId) { $this->_record->deleteValue($label, $index); $this->_record->commit(TRUE); } } else { throwError(new Error(RepositoryException::UNKNOWN_ID() . ": {$string}", "HarmoniPart", true)); } $this->_asset->updateModificationDate(); }
/** * Delete a Part and all its Parts. * * @param object Id $partId * * @throws object RepositoryException An exception with one of * the following messages defined in * org.osid.repository.RepositoryException may be thrown: {@link * org.osid.repository.RepositoryException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.repository.RepositoryException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.repository.RepositoryException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.repository.RepositoryException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.repository.RepositoryException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID} * * @access public */ function deletePart(Id $partId) { $string = $partId->getIdString(); if (preg_match("/(.*)-(FILE_SIZE|FILE_NAME|FILE_DATA|MIME_TYPE|THUMBNAIL_DATA|THUMBNAIL_MIME_TYPE)/", $string, $r)) { $recordId = $r[1]; $field = $r[2]; if ($this->_isLastPart($field)) { $dbHandler = Services::getService("DatabaseManager"); // Delete the data $file = $this->_parts['FILE_DATA']->_getFilePath(); if (!unlink($file)) { throwError(new Error(RepositoryException::OPERATION_FAILED() . ": '{$file}' could not be deleted.", "FileSystemFileRecord", true)); } // Delete the thumbnail $query = new DeleteQuery(); $query->setTable("dr_thumbnail"); $query->setWhere("fk_file = '" . $this->_id->getIdString() . "'"); $dbHandler->query($query, $this->_configuration->getProperty("database_index")); // Delete the data row in case we were switching from another type // that used it. $query = new DeleteQuery(); $query->setTable("dr_file_data"); $query->setWhere("fk_file = '" . $this->_id->getIdString() . "'"); $dbHandler->query($query, $this->_configuration->getProperty("database_index")); // delete the file row. $query = new DeleteQuery(); $query->setTable("dr_file"); $query->setWhere("id = '" . $this->_id->getIdString() . "'"); $dbHandler->query($query, $this->_configuration->getProperty("database_index")); } else { if ($field != "FILE_SIZE") { $this->_parts[$field]->updateValue("NULL"); } } } else { throwError(new Error(RepositoryException::UNKNOWN_ID() . ": {$string}", "FileSystemFileRecord", true)); } }
/** * Get all the dates for the Asset with the specified unique Id. These * dates allows a Repository implementation to support Asset versioning. * * @param object Id $assetId * * @return object LongValueIterator * * @throws object RepositoryException An exception with one of * the following messages defined in * org.osid.repository.RepositoryException may be thrown: {@link * org.osid.repository.RepositoryException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.repository.RepositoryException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.repository.RepositoryException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.repository.RepositoryException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.repository.RepositoryException#NULL_ARGUMENT * NULL_ARGUMENT} * * @access public */ function getAssetDates(Id $assetId) { // figure out which Repository it is in. if (!($repositoryId = $this->_getAssetRepository($assetId))) { throwError(new Error(RepositoryException::UNKNOWN_ID(), "RepositoryManager", 1)); } $repository = $this->getRepository($repositoryId); //return the assetByDate return $repository->getAssetDates($assetId, $date); }