/** * 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)); } }
/** * 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(); }
/** * @param string $model */ public function __construct($model) { $message = sprintf(self::MESSAGE, $model); parent::__construct($message, 0, null); }
/** * Get all the Parts in this Part. Iterators return a set, one at a time. * * @return object PartIterator * * @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 getParts() { throwError(new Error(RepositoryException::UNIMPLEMENTED(), "HarmoniPart", true)); }
/** * @param string $criteriaClassName */ public function __construct($criteriaClassName) { $message = sprintf(self::MESSAGE, $criteriaClassName); parent::__construct($message, 0, null); }
/** * 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)); }
/** * Create a new validation error with an associative array of errors. * @param array $errors */ public function __construct(array $errors) { $this->errors = $errors; parent::__construct("Validation error", 0, null); }
/** * Update the value for this Part. * * @param object mixed $value (original type: java.io.Serializable) * * @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 updateValue($value) { throwError(new Error(RepositoryException::PERMISSION_DENIED(), "FileSizePart", 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("/(.*)-(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)); } }
/** * 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(); }
/** * Build the file path where we will store our data * * @return string * @access public * @since 2/16/05 */ function _getFilePath() { if (!$this->_configuration->getProperty('file_data_path')) { throwError(new Error(RepositoryException::CONFIGURATION_ERROR() . ": 'file_data_path' was not specified.", "FileSystemFileDataPart", true)); } $path = $this->_configuration->getProperty('file_data_path'); if (!file_exists($path)) { throwError(new Error(RepositoryException::CONFIGURATION_ERROR() . ": The 'file_data_path' specified, '{$path}', was does not exist.", "FileSystemFileDataPart", true)); } if (!is_readable($path)) { throwError(new Error(RepositoryException::CONFIGURATION_ERROR() . ": The 'file_data_path' specified, '{$path}', is not readable.", "FileSystemFileDataPart", true)); } if (!is_writable($path)) { throwError(new Error(RepositoryException::CONFIGURATION_ERROR() . ": The 'file_data_path' specified, '{$path}', is not writable.", "FileSystemFileDataPart", true)); } return $this->_configuration->getProperty('file_data_path') . "/" . $this->_recordId->getIdString(); }
/** * 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); }
/** * Delete a RecordStructure all Records in the repository that use it. * * WARNING: NOT IN OSID * * @param object Id $recordStructureId * @return void * @access public * @since 6/6/06 */ function deleteRecordStructure(Id $recordStructureId, $statusStars = null) { // Delete the Records that use this RecordStructure $assets = $this->getAssets(); if (!is_null($statusStars)) { $statusStars->initializeStatistics($assets->count()); } while ($assets->hasNext()) { $asset = $assets->next(); $records = $asset->getRecordsByRecordStructure($recordStructureId); while ($records->hasNext()) { $record = $records->next(); $asset->deleteRecord($record->getId()); } if (!is_null($statusStars)) { $statusStars->updateStatistics(); } } // Delete the Structure $schemaMgr = Services::getService("SchemaManager"); $recordMgr = Services::getService("RecordManager"); $recordIdsForSchema = $recordMgr->getRecordIDsByType($recordStructureId->getIdString()); if (count($recordIdsForSchema)) { throwError(new Error(RepositoryException::OPERATION_FAILED() . " when deleting RecordStructure: '" . $recordStructureId->getIdString() . "', Records exist for this RecordStructure.", "Repository", 1)); } $schema = $schemaMgr->deleteSchema($recordStructureId->getIdString()); }
/** * Delete a PartStucture * * @param object Id $partStructureId * @return void * @access public * @since 6/8/06 */ function deletePartStructure(Id $partStructureId) { // Delete the Structure $schemaMgr = Services::getService("SchemaManager"); $recordMgr = Services::getService("RecordManager"); $partStructure = $this->getPartStructure($partStructureId); $dummyValues = array(String::withValue('4000-02-05')); $recordIdsWithValues = $recordMgr->getRecordSetIDsBySearch(new FieldValueSearch($this->_schema->getID(), $this->_schema->getFieldLabelFromID($partStructureId->getIdString()), new HarmoniIterator($dummyValues), SEARCH_TYPE_NOT_IN_LIST)); if (count($recordIdsWithValues)) { throwError(new Error(RepositoryException::OPERATION_FAILED() . " when deleting RecordStructure: '" . $recordStructureId->getIdString() . "', Records exist for this RecordStructure.", "Repository", 1)); } $sm = Services::getService("SchemaManager"); $this->_schema->deleteField($partStructureId->getIdString()); $sm->synchronize($this->_schema); $partStructure = null; }
/** * Same as the default exception constructor except it takes another * parameter errors, this is the error returned by the xml parser. */ function __construct($message, $code, $errors, $previous = NULL) { parent::__construct($message, $code, $previous); $this->errors = $errors; }